Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Help

In most toolwindows we had a help button, created and initialised like this:

AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help22.png"), false);
helpButton.setToolTipText("Help."); /*I18N*/
helpButton.setName("helpButton");
...
if (getDescriptor().getHelpId() != null) {
    HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId());
    HelpSys.enableHelpKey(mainPane, getDescriptor().getHelpId());
}

This code can be replaced by within a <Name>TopComponent.initComponents() method as follows:

AbstractButton helpButton = ToolButtonFactory.createButton(new HelpAction(this), false);
helpButton.setName("helpButton");

We can use new HelpAction(this), because this is a TopComponent which is always HelpCtx.Provider. To provide context-sensitive help also add 

@Override
public HelpCtx getHelpCtx() {
    return new HelpCtx(HELP_ID);
}
  • No labels