Changeset 4666 in josm
- Timestamp:
- 2011-12-15T21:12:57+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java
r4609 r4666 61 61 ((Destroyable) action).destroy(); 62 62 } 63 action.removePropertyChangeListener(this); 63 if (action != null) { 64 action.removePropertyChangeListener(this); 65 } 64 66 } 65 67 66 68 @Override 67 69 public void applyButtonHiddenPreferences() { 68 String actionName = (String) getAction().getValue(AbstractAction.NAME); 69 boolean hiddenFlag = 70 Main.pref.getBoolean(actionName + ".itbutton_hidden", false); 71 setVisible(!hiddenFlag); 70 String actionName = (String) getSafeActionValue(AbstractAction.NAME); 71 boolean hiddenFlag = Main.pref.getBoolean(actionName + ".itbutton_hidden", false); 72 setVisible(!hiddenFlag); 72 73 } 73 74 74 75 @Override 75 76 public void setButtonHidden(boolean b) { 76 String actionName = (String) getAction().getValue(AbstractAction.NAME); 77 setVisible(!b); 78 if (listener!=null) { // if someone wants to know about changes of visibility 79 if (!b) listener.buttonShown(); else listener.buttonHidden(); 80 } 81 Main.pref.put(actionName + ".itbutton_hidden", b); 82 77 String actionName = (String) getSafeActionValue(AbstractAction.NAME); 78 setVisible(!b); 79 if (listener!=null) { // if someone wants to know about changes of visibility 80 if (!b) listener.buttonShown(); else listener.buttonHidden(); 81 } 82 Main.pref.put(actionName + ".itbutton_hidden", b); 83 83 } 84 84 85 @Override 85 86 public void showButton() { 86 87 setButtonHidden(false); 87 88 } 89 88 90 @Override 89 91 public void hideButton() { … … 93 95 @Override 94 96 public String getActionName() { 95 return (String) get Action().getValue(Action.NAME);97 return (String) getSafeActionValue(Action.NAME); 96 98 } 97 99 98 100 @Override 99 101 public Icon getIcon() { 100 return (Icon) get Action().getValue(Action.SMALL_ICON);102 return (Icon) getSafeActionValue(Action.SMALL_ICON); 101 103 } 102 104 … … 111 113 } 112 114 113 115 protected final Object getSafeActionValue(String key) { 116 // Mac OS X Aqua L&F can call accessors from constructor, so getAction() can be null in those cases 117 return getAction() != null ? getAction().getValue(key) : null; 118 } 114 119 }
Note:
See TracChangeset
for help on using the changeset viewer.