- Timestamp:
- 2021-07-18T17:13:27+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r18062 r18066 17 17 import java.awt.event.AWTEventListener; 18 18 import java.awt.event.ActionEvent; 19 import java.awt.event.ActionListener; 19 20 import java.awt.event.ComponentAdapter; 20 21 import java.awt.event.ComponentEvent; … … 55 56 import org.openstreetmap.josm.gui.SideButton; 56 57 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; 58 import org.openstreetmap.josm.gui.help.HelpBrowser; 57 59 import org.openstreetmap.josm.gui.help.HelpUtil; 58 60 import org.openstreetmap.josm.gui.help.Helpful; … … 566 568 buttonsHide = new JButton(ImageProvider.get("misc", buttonHiding != ButtonHidingType.ALWAYS_SHOWN 567 569 ? /* ICON(misc/)*/ "buttonhide" : /* ICON(misc/)*/ "buttonshow")); 568 buttonsHide.setToolTipText(tr("Toggle dynamic buttons")); 569 buttonsHide.setBorder(BorderFactory.createEmptyBorder()); 570 buttonsHide.addActionListener(e -> { 570 addButton(buttonsHide, tr("Toggle dynamic buttons"), e -> { 571 571 JRadioButtonMenuItem item = (buttonHiding == ButtonHidingType.DYNAMIC) ? alwaysShown : dynamic; 572 572 item.setSelected(true); 573 573 item.getAction().actionPerformed(null); 574 574 }); 575 add(buttonsHide);576 575 577 576 // show the pref button if applicable 578 577 if (preferenceClass != null) { 579 JButton pref = new JButton(ImageProvider.get("preference_small", ImageProvider.ImageSizes.SMALLICON)); 580 pref.setToolTipText(tr("Open preferences for this panel")); 581 pref.setBorder(BorderFactory.createEmptyBorder()); 582 pref.addActionListener(e -> { 578 addButton(new JButton(ImageProvider.get("preference_small", ImageProvider.ImageSizes.SMALLICON)), 579 tr("Open preferences for this panel"), e -> { 583 580 final PreferenceDialog p = new PreferenceDialog(MainApplication.getMainFrame()); 584 581 SwingUtilities.invokeLater(() -> { … … 591 588 p.setVisible(true); 592 589 }); 593 add(pref); 594 } 590 } 591 592 // show the help button 593 addButton(new JButton(ImageProvider.get("help", ImageProvider.ImageSizes.SMALLICON)), 594 tr("Open help for this panel"), e -> { 595 HelpBrowser.setUrlForHelpTopic(helpTopic()); 596 }); 595 597 596 598 // show the sticky button 597 JButton sticky = new JButton(ImageProvider.get("misc", "sticky")); 598 sticky.setToolTipText(tr("Undock the panel")); 599 sticky.setBorder(BorderFactory.createEmptyBorder()); 600 sticky.addActionListener(e -> { 599 addButton(new JButton(ImageProvider.get("misc", "sticky")), tr("Undock the panel"), e -> { 601 600 detach(); 602 601 if (dialogsPanel != null) { … … 604 603 } 605 604 }); 606 add(sticky);607 605 608 606 // show the close button 609 JButton close = new JButton(ImageProvider.get("misc", "close")); 610 close.setToolTipText(tr("Close this panel. You can reopen it with the buttons in the left toolbar.")); 611 close.setBorder(BorderFactory.createEmptyBorder()); 612 close.addActionListener(e -> { 607 addButton(new JButton(ImageProvider.get("misc", "close")), 608 tr("Close this panel. You can reopen it with the buttons in the left toolbar."), e -> { 613 609 hideDialog(); 614 610 if (dialogsPanel != null) { … … 617 613 hideNotify(); 618 614 }); 619 add(close); 615 620 616 setToolTipText(tr("Click to minimize/maximize the panel content")); 621 617 setTitle(toggleDialogName); 618 } 619 620 protected final Component addButton(JButton button, String tooltip, ActionListener actionListener) { 621 button.setBorder(BorderFactory.createEmptyBorder()); 622 button.addActionListener(actionListener); 623 button.setToolTipText(tooltip); 624 return add(button); 622 625 } 623 626
Note:
See TracChangeset
for help on using the changeset viewer.