Changeset 4033 in josm
- Timestamp:
- 2011-04-17T13:49:50+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r4032 r4033 75 75 private String name = ""; 76 76 private String icon = ""; 77 private ImageIcon ico = null; 77 78 private final Map<String, Object> parameters = new HashMap<String, Object>(); 78 79 … … 100 101 } 101 102 103 public String getDisplayName() { 104 return name.isEmpty() ? (String) action.getValue(Action.NAME) : name; 105 } 106 107 public String getDisplayTooltip() { 108 if(!name.isEmpty()) 109 return name; 110 111 Object tt = action.getValue(TaggingPreset.OPTIONAL_TOOLTIP_TEXT); 112 if (tt != null) 113 return (String) tt; 114 115 return (String) action.getValue(Action.SHORT_DESCRIPTION); 116 } 117 118 public Icon getDisplayIcon() { 119 return ico != null ? ico : (Icon) action.getValue(Action.SMALL_ICON); 120 } 121 102 122 public void setName(String name) { 103 123 this.name = name; 104 action.putValue(AbstractAction.SHORT_DESCRIPTION, Main.platform.makeTooltip(name, null));105 action.putValue(AbstractAction.NAME, name);106 124 } 107 125 … … 112 130 public void setIcon(String icon) { 113 131 this.icon = icon; 114 ImageIcon ico = ImageProvider.getIfAvailable("", icon); 115 if(ico != null) 116 action.putValue(AbstractAction.SMALL_ICON, ico); 132 ico = ImageProvider.getIfAvailable("", icon); 117 133 } 118 134 … … 279 295 280 296 public int getRowCount() { 297 int adaptable = ((currentAction.getAction() instanceof AdaptableAction) ? 2 : 0); 281 298 if (currentAction.isSeparator() || !(currentAction.getAction() instanceof ParameterizedAction)) 282 return 0;299 return adaptable; 283 300 ParameterizedAction pa = (ParameterizedAction)currentAction.getAction(); 284 return pa.getActionParameters().size() 285 + ((currentAction.getAction() instanceof ParameterizedAction) ? 2 : 0); 301 return pa.getActionParameters().size() + adaptable; 286 302 } 287 303 … … 293 309 294 310 public Object getValueAt(int rowIndex, int columnIndex) { 295 if(currentAction.getAction() instanceof ParameterizedAction)311 if(currentAction.getAction() instanceof AdaptableAction) 296 312 { 297 313 if (rowIndex < 2) { … … 325 341 @Override 326 342 public void setValueAt(Object aValue, int rowIndex, int columnIndex) { 327 if(currentAction.getAction() instanceof ParameterizedAction)343 if(currentAction.getAction() instanceof AdaptableAction) 328 344 { 329 345 if (rowIndex == 0) { … … 503 519 ActionDefinition action = (ActionDefinition)value; 504 520 if (!action.isSeparator()) { 505 s = (String) action.getAction().getValue(Action.NAME);506 i = (Icon) action.getAction().getValue(Action.SMALL_ICON);521 s = action.getDisplayName(); 522 i = action.getDisplayIcon(); 507 523 } else { 508 524 i = ImageProvider.get("preferences/separator"); … … 799 815 } 800 816 801 private static final String[] deftoolbar = {"open", "save", "download", "upload", "|", "undo", "redo", "|", "dialogs/search", "preference", "|", "splitway", "combineway", "wayflip", "|", "imagery-offset", "|", "tagginggroup_Highways/Streets", "tagginggroup_Highways/Ways", "tagginggroup_Highways/Waypoints", "tagginggroup_Highways/Barriers", "|", "tagginggroup_Transport/Car", "tagginggroup_Transport/Public Transport", "|", "tagginggroup_Travel/Tourism", "tagginggroup_Travel/Food+Drinks", "|", "tagginggroup_Travel/Historic Places", "|", "tagginggroup_Man-Made/Man Made"}; 817 private static final String[] deftoolbar = {"open", "save", "download", "upload", "|", 818 "undo", "redo", "|", "dialogs/search", "preference", "|", "splitway", "combineway", 819 "wayflip", "|", "imagery-offset", "|", "tagginggroup_Highways/Streets", 820 "tagginggroup_Highways/Ways", "tagginggroup_Highways/Waypoints", 821 "tagginggroup_Highways/Barriers", "|", "tagginggroup_Transport/Car", 822 "tagginggroup_Transport/Public Transport", "|", "tagginggroup_Facilities/Tourism", 823 "tagginggroup_Facilities/Food+Drinks", "|", "tagginggroup_Man Made/Historic Places", "|", 824 "tagginggroup_Man Made/Man Made"}; 802 825 803 826 private static Collection<String> getToolString() { … … 826 849 if(a != null) { 827 850 result.add(a); 851 } else { 852 System.out.println("Could not load tool definition "+s); 828 853 } 829 854 } … … 854 879 control.addSeparator(); 855 880 } else { 856 Action a = action.getParametrizedAction(); 857 JButton b = control.add(a); 858 Object tt = a.getValue(TaggingPreset.OPTIONAL_TOOLTIP_TEXT); 859 if (tt != null) { 860 b.setToolTipText((String)tt); 861 } 881 JButton b = control.add(action.getParametrizedAction()); 882 String tt = action.getDisplayTooltip(); 883 if (tt != null && !tt.isEmpty()) 884 b.setToolTipText(tt); 885 Icon i = action.getDisplayIcon(); 886 if (i != null) 887 b.setIcon(i); 862 888 } 863 889 }
Note:
See TracChangeset
for help on using the changeset viewer.