I was surprised how easy it was to create a Navigator. Actually, the Navigator displays a TopComponent, because that's what the getComponent() method returns. Here's the whole Navigator class:
public class SubjectNavigatorPanel implements NavigatorPanel {
public SubjectNavigatorPanel() {
}
public String getDisplayHint() {
return NbBundle.getMessage(SubjectNavigatorPanel.class, "HINT_SubjectNavigatorPanel");
}
public String getDisplayName() {
return NbBundle.getMessage(SubjectNavigatorPanel.class, "CTL_SubjectNavigatorPanel");
}
public JComponent getComponent() {
return SubjectLineTopComponent.getDefault();/
}
public void panelActivated(Lookup context) {
}
public void panelDeactivated() {
}
public Lookup getLookup() {
return null;
}
}
You also need a class that implements NavigatorLookupHint:
public class ShapeNavigatorHint implements NavigatorLookupHint {
public String getContentType () {
return "mail/client"; // NOI18N
}
}
Notice that a content type is set. This is matched in the layer.xml registration for the Navigator:
<folder name="Navigator">
<folder name="Panels">
<folder name="mail">
<folder name="client">
<file name="org-netbeans-modules-javamail-SubjectNavigatorPanel.instance"/>
</folder>
</folder>
</folder>
</folder>
So, notice that you don't even need a data object, or a MIME type. (Although, this is some kind of MIME type anyway.) Finally, I added the Navigator to the other TopComponent's Lookup, so that when the Mail Explorer opens, the Navigator opens as well. This Lookup is found in the Mail Explorer's constructor, and combines the Explorer Manager with the Navigator in my Lookup, thanks to a tip I picked up from the mailing list:
associateLookup(new ProxyLookup(new Lookup[]{
ExplorerUtils.createLookup(explorerManager, getActionMap()),Lookups.fixed( new Object[] {new SubjectNavigatorHint()} )
}));
And, that's it. I have a method in the TopComponent, the one returned in the getComponent() method, for adding subject lines to a JList. So, at the appropriate time, the subject lines are added to the JList in the TopComponent that is inserted in the Navigator. Really simple.
I have followed exactly the same steps to create my navigator. But it does not work for me. Here you can find the details of my problem.
http://www.nabble.com/navigator-panel-does-not-work-tf3475464.html
Any help would be highly appreciated.
Thanks.
Mamata