Changeset 16409 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-05-14T23:05:12+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
r14977 r16409 8 8 import java.awt.event.KeyEvent; 9 9 import java.beans.PropertyChangeListener; 10 import java.util.HashMap;11 import java.util.Map;12 10 13 11 import javax.swing.AbstractAction; … … 46 44 private static final String EDITABLE = "editable"; 47 45 48 private static final Map<String, ImageIcon> iconCache = new HashMap<>();49 50 private static ImageIcon loadIcon(String iconName) {51 return iconCache.computeIfAbsent(iconName,52 x -> new ImageProvider(x).setOptional(true).setSize(ImageProvider.ImageSizes.SMALLICON).get());53 }54 55 46 protected JTextComponent component; 56 47 protected boolean undoRedo; … … 132 123 if (component.isEditable()) { 133 124 if (undoRedo) { 134 add (new JMenuItem(undoAction));135 add (new JMenuItem(redoAction));125 addMenuEntry(new JMenuItem(undoAction), "undo"); 126 addMenuEntry(new JMenuItem(redoAction), "redo"); 136 127 addSeparator(); 137 128 } 138 addMenuEntry(component, tr("Cut"), DefaultEditorKit.cutAction, null);129 addMenuEntry(component, tr("Cut"), DefaultEditorKit.cutAction, "cut"); 139 130 } 140 131 addMenuEntry(component, tr("Copy"), DefaultEditorKit.copyAction, "copy"); 141 132 if (component.isEditable()) { 142 133 addMenuEntry(component, tr("Paste"), DefaultEditorKit.pasteAction, "paste"); 143 addMenuEntry(component, tr("Delete"), DefaultEditorKit.deleteNextCharAction, null);134 addMenuEntry(component, tr("Delete"), DefaultEditorKit.deleteNextCharAction, "dialogs/delete"); 144 135 } 145 136 addSeparator(); 146 addMenuEntry(component, tr("Select All"), DefaultEditorKit.selectAllAction, null);137 addMenuEntry(component, tr("Select All"), DefaultEditorKit.selectAllAction, "dialogs/select"); 147 138 } 148 139 … … 213 204 JMenuItem mi = new JMenuItem(action); 214 205 mi.setText(label); 215 if (iconName != null && Config.getPref().getBoolean("text.popupmenu.useicons", true)) { 216 ImageIcon icon = loadIcon(iconName); 217 if (icon != null) { 218 mi.setIcon(icon); 219 } 220 } 221 add(mi); 222 } 206 addMenuEntry(mi, iconName); 207 } 208 } 209 210 protected void addMenuEntry(JMenuItem mi, String iconName) { 211 if (iconName != null && Config.getPref().getBoolean("text.popupmenu.useicons", true)) { 212 ImageIcon icon = new ImageProvider(iconName).setSize(ImageProvider.ImageSizes.SMALLICON).get(); 213 mi.setIcon(icon); 214 } 215 add(mi); 223 216 } 224 217 … … 263 256 public RedoAction() { 264 257 super(tr("Redo")); 258 new ImageProvider("redo").getResource().attachImageIcon(this); 265 259 setEnabled(false); 266 260 }
Note:
See TracChangeset
for help on using the changeset viewer.