Ticket #6953: SidetoolbarLayerChange.patch
File SidetoolbarLayerChange.patch, 2.7 KB (added by , 14 years ago) |
---|
-
src/org/openstreetmap/josm/gui/IconToggleButton.java
65 65 } 66 66 } 67 67 68 String getPreferenceKey() { 69 String s = (String) getSafeActionValue("toolbar"); 70 if (s==null) { 71 if (getAction()!=null) s=getAction().getClass().getName(); 72 } 73 return "sidetoolbar.hidden."+s; 74 75 } 76 68 77 @Override 69 78 public void applyButtonHiddenPreferences() { 70 String actionName = (String) getSafeActionValue(AbstractAction.NAME); 71 boolean hiddenFlag = Main.pref.getBoolean(actionName + ".itbutton_hidden", false); 79 boolean hiddenFlag = Main.pref.getBoolean(getPreferenceKey(), false); 72 80 setVisible(!hiddenFlag); 73 81 } 74 82 75 83 @Override 76 84 public void setButtonHidden(boolean b) { 77 String actionName = (String) getSafeActionValue(AbstractAction.NAME);78 85 setVisible(!b); 79 86 if (listener!=null) { // if someone wants to know about changes of visibility 80 87 if (!b) listener.buttonShown(); else listener.buttonHidden(); 81 88 } 82 Main.pref.put( actionName + ".itbutton_hidden", b);89 Main.pref.put(getPreferenceKey(), b); 83 90 } 84 91 85 92 @Override -
src/org/openstreetmap/josm/gui/MapFrame.java
407 407 } 408 408 })); 409 409 } 410 410 411 411 class ListAllButtonsAction extends AbstractAction { 412 412 413 413 private JButton button; … … 453 453 } 454 454 toolBarToggle.repaint(); 455 455 for (IconToggleButton b : allMapModeButtons) { 456 b.applyButtonHiddenPreferences(); 456 Action a=b.getAction(); 457 boolean hideAnyway=false; 458 if (a instanceof MapMode) { 459 hideAnyway = !((MapMode)a).layerIsSupported(Main.main.getActiveLayer()); 460 } 461 if (hideAnyway) b.setVisible(false); else 462 b.applyButtonHiddenPreferences(); 457 463 } 458 464 toolBarActions.repaint(); 459 465 } 460 466 461 467 /** 462 468 * Replies the instance of a toggle dialog of type <code>type</code> managed by this 463 469 * map frame … … 532 538 mapMode.exitMode(); 533 539 mapMode.enterMode(); 534 540 } 541 validateToolBarsVisibility(); 535 542 // invalidate repaint cache 536 543 Main.map.mapView.preferenceChanged(null); 537 544 }