- Timestamp:
- 2011-12-20T21:33:34+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java
r4666 r4669 25 25 public boolean groupbutton; 26 26 private ShowHideButtonListener listener; 27 private boolean hideIfDisabled=false; 27 28 28 29 /** … … 66 67 } 67 68 69 String getPreferenceKey() { 70 String s = (String) getSafeActionValue("toolbar"); 71 if (s==null) { 72 if (getAction()!=null) s=getAction().getClass().getName(); 73 } 74 return "sidetoolbar.hidden."+s; 75 76 } 77 68 78 @Override 69 79 public void applyButtonHiddenPreferences() { 70 String actionName = (String) getSafeActionValue(AbstractAction.NAME); 71 boolean hiddenFlag = Main.pref.getBoolean(actionName + ".itbutton_hidden", false); 72 setVisible(!hiddenFlag); 80 boolean alwaysHideDisabled = Main.pref.getBoolean("sidetoolbar.hideDisabledButtons", false); 81 boolean hiddenFlag = Main.pref.getBoolean(getPreferenceKey(), false); 82 if (!isEnabled() && (hideIfDisabled || alwaysHideDisabled)) 83 setVisible(false); // hide because of disabled button 84 else 85 setVisible( !hiddenFlag ); // show or hide, do what preferences say 73 86 } 74 87 75 88 @Override 76 89 public void setButtonHidden(boolean b) { 77 String actionName = (String) getSafeActionValue(AbstractAction.NAME);78 90 setVisible(!b); 79 91 if (listener!=null) { // if someone wants to know about changes of visibility 80 92 if (!b) listener.buttonShown(); else listener.buttonHidden(); 81 93 } 82 Main.pref.put(actionName + ".itbutton_hidden", b); 94 Main.pref.put(getPreferenceKey(), b); 95 } 96 97 /* 98 * This fuction should be called for plugins that want to enable auto-hiding 99 * custom buttons when they are disabled (because of incorrect layer, for example) 100 */ 101 public void setAutoHideDisabledButton(boolean b) { 102 hideIfDisabled=b; 103 if (b && !isEnabled()) setVisible(false); 83 104 } 84 105 -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r4609 r4669 33 33 import javax.swing.JToolBar; 34 34 import javax.swing.KeyStroke; 35 import javax.swing.SwingUtilities; 35 36 import javax.swing.border.Border; 36 37 import javax.swing.plaf.basic.BasicSplitPaneDivider; … … 408 409 })); 409 410 } 410 411 411 412 class ListAllButtonsAction extends AbstractAction { 412 413 … … 454 455 toolBarToggle.repaint(); 455 456 for (IconToggleButton b : allMapModeButtons) { 456 b.applyButtonHiddenPreferences();457 b.applyButtonHiddenPreferences(); 457 458 } 458 459 toolBarActions.repaint(); 459 460 } 460 461 461 462 /** 462 463 * Replies the instance of a toggle dialog of type <code>type</code> managed by this … … 535 536 // invalidate repaint cache 536 537 Main.map.mapView.preferenceChanged(null); 537 } 538 539 // After all listeners notice new layer, some buttons will be disabled/enabled 540 // and possibly need to be hidden/shown. 541 SwingUtilities.invokeLater(new Runnable() { 542 public void run() { 543 validateToolBarsVisibility(); 544 } 545 }); 546 } 547 538 548 539 549 private MapMode getLastMapMode(Layer newLayer) {
Note:
See TracChangeset
for help on using the changeset viewer.