Changeset 2285 in josm for trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
- Timestamp:
- 2009-10-13T20:34:11+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2168 r2285 23 23 24 24 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.gui.help.HelpBrowserProxy; 26 import org.openstreetmap.josm.gui.help.HelpBuilder; 25 27 import org.openstreetmap.josm.tools.GBC; 26 28 import org.openstreetmap.josm.tools.ImageProvider; … … 41 43 private Component content; 42 44 private final String[] bTexts; 45 private String[] bToolTipTexts; 43 46 private String[] bIcons; 47 48 /** true, if the dialog should include a help button */ 49 private boolean showHelpButton; 50 /** the help topic */ 51 private String helpTopic; 52 44 53 /** 45 54 * set to true if the content of the extended dialog should … … 99 108 100 109 /** 110 * Allows decorating the buttons with tooltips. Expects an String[] with translated 111 * tooltip texts. 112 * 113 * @param toolTipTexts the tool tip texts. Ignored, if null. 114 */ 115 public void setToolTipTexts(String[] toolTipTexts) { 116 this.bToolTipTexts = toolTipTexts; 117 } 118 119 /** 101 120 * Sets the content that will be displayed in the message dialog. 102 121 * … … 187 206 button.setIcon(ImageProvider.get(bIcons[i])); 188 207 } 208 if (bToolTipTexts != null && i < bToolTipTexts.length && bToolTipTexts[i] != null) { 209 button.setToolTipText(bToolTipTexts[i]); 210 } 189 211 190 212 if(i == 0) { … … 193 215 buttonsPanel.add(button, GBC.std().insets(2,2,2,2)); 194 216 buttons.add(button); 217 } 218 if (showHelpButton) { 219 buttonsPanel.add(new JButton(new HelpAction()), GBC.std().insets(2,2,2,2)); 220 HelpBuilder.setHelpContext(getRootPane(),helpTopic); 195 221 } 196 222 … … 396 422 return lbl; 397 423 } 424 425 /** 426 * Configures how this dialog support for context sensitive help. 427 * <ul> 428 * <li>if helpTopic is null, the dialog doesn't provide context sensitive help</li> 429 * <li>if helpTopic != null, the dialog redirect user to the help page for this helpTopic when 430 * the user clicks F1 in the dialog</li> 431 * <li>if showHelpButton is true, the dialog displays "Help" button (rightmost button in 432 * the button row)</li> 433 * </ul> 434 * 435 * @param helpTopic the help topic 436 * @param showHelpButton true, if the dialog displays a help button 437 */ 438 public void configureContextsensitiveHelp(String helpTopic, boolean showHelpButton) { 439 this.helpTopic = helpTopic; 440 this.showHelpButton = showHelpButton; 441 } 442 443 444 class HelpAction extends AbstractAction { 445 public HelpAction() { 446 putValue(SHORT_DESCRIPTION, tr("Show help information")); 447 putValue(NAME, tr("Help")); 448 putValue(SMALL_ICON, ImageProvider.get("help")); 449 } 450 451 public void actionPerformed(ActionEvent e) { 452 HelpBrowserProxy.getInstance().setUrlForHelpTopic(helpTopic); 453 } 454 } 398 455 }
Note:
See TracChangeset
for help on using the changeset viewer.