- Timestamp:
- 2014-09-15T19:42:31+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r7005 r7539 24 24 25 25 import javax.swing.AbstractAction; 26 import javax.swing.Action;27 26 import javax.swing.DefaultCellEditor; 28 27 import javax.swing.DefaultListSelectionModel; … … 62 61 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 63 62 import org.openstreetmap.josm.gui.util.GuiHelper; 63 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; 64 64 import org.openstreetmap.josm.gui.widgets.JosmTextField; 65 65 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; … … 76 76 * change the ordering of the layers, to hide/show layers, to activate layers, 77 77 * and to delete layers. 78 * 78 * @since 17 79 79 */ 80 80 public class LayerListDialog extends ToggleDialog { … … 127 127 public void actionPerformed(ActionEvent e) { 128 128 final Layer l = model.getLayer(model.getRowCount() - layerIndex - 1); 129 if (l != null) {129 if (l != null) { 130 130 l.toggleVisible(); 131 131 } … … 135 135 private final Shortcut[] visibilityToggleShortcuts = new Shortcut[10]; 136 136 private final ToggleLayerIndexVisibility[] visibilityToggleActions = new ToggleLayerIndexVisibility[10]; 137 137 138 /** 138 139 * registers (shortcut to toggle right hand side toggle dialogs)+(number keys) shortcuts … … 153 154 154 155 /** 155 * Create anlayer list and attach it to the given mapView.156 * Creates a layer list and attach it to the given mapView. 156 157 */ 157 158 protected LayerListDialog(MapFrame mapFrame) { … … 189 190 layerList.getColumnModel().getColumn(1).setResizable(false); 190 191 layerList.getColumnModel().getColumn(2).setCellRenderer(new LayerNameCellRenderer()); 191 layerList.getColumnModel().getColumn(2).setCellEditor(new LayerNameCellEditor(new JosmTextField())); 192 layerList.getColumnModel().getColumn(2).setCellEditor(new LayerNameCellEditor(new DisableShortcutsOnFocusGainedTextField())); 193 // Disable some default JTable shortcuts to use JOSM ones (see #5678, #10458) 192 194 for (KeyStroke ks : new KeyStroke[] { 193 KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), 194 KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK), 195 KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.SHIFT_MASK), 196 KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK), 197 KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_MASK), 198 KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_MASK), 195 KeyStroke.getKeyStroke(KeyEvent.VK_A, GuiHelper.getMenuShortcutKeyMaskEx()), 196 KeyStroke.getKeyStroke(KeyEvent.VK_C, GuiHelper.getMenuShortcutKeyMaskEx()), 197 KeyStroke.getKeyStroke(KeyEvent.VK_V, GuiHelper.getMenuShortcutKeyMaskEx()), 198 KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.SHIFT_DOWN_MASK), 199 KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_DOWN_MASK), 200 KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_DOWN_MASK), 201 KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_DOWN_MASK), 202 KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK), 203 KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), 204 KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_DOWN_MASK), 205 KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_DOWN_MASK), 199 206 KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), 200 207 KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), 208 KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), 209 KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), 201 210 }) 202 211 { … … 246 255 adaptTo(showHideLayerAction, selectionModel); 247 256 248 // -- layer opacity action257 // -- layer opacity action 249 258 LayerOpacityAction layerOpacityAction = new LayerOpacityAction(); 250 259 adaptTo(layerOpacityAction, selectionModel); … … 261 270 adaptTo(duplicateLayerAction, selectionModel); 262 271 263 // -- delete layer action272 // -- delete layer action 264 273 DeleteLayerAction deleteLayerAction = new DeleteLayerAction(); 265 274 layerList.getActionMap().put("deleteLayer", deleteLayerAction); … … 309 318 } 310 319 320 /** 321 * Returns the layer list model. 322 * @return the layer list model 323 */ 311 324 public LayerListModel getModel() { 312 325 return model; … … 372 385 */ 373 386 public final class DeleteLayerAction extends AbstractAction implements IEnabledStateUpdating, LayerAction { 387 374 388 /** 375 389 * Creates a {@link DeleteLayerAction} which will delete the currently 376 390 * selected layers in the layer dialog. 377 *378 391 */ 379 392 public DeleteLayerAction() { … … 423 436 } 424 437 438 /** 439 * Action which will toggle the visibility of the currently selected layers. 440 */ 425 441 public final class ShowHideLayerAction extends AbstractAction implements IEnabledStateUpdating, LayerAction, MultikeyShortcutAction { 426 442 … … 431 447 * Creates a {@link ShowHideLayerAction} which will toggle the visibility of 432 448 * the currently selected layers 433 * 434 */ 435 public ShowHideLayerAction(boolean init) { 449 */ 450 public ShowHideLayerAction() { 436 451 putValue(NAME, tr("Show/hide")); 437 452 putValue(SMALL_ICON, ImageProvider.get("dialogs", "showhide")); … … 441 456 tr("Show/hide layer")), KeyEvent.VK_S, Shortcut.SHIFT); 442 457 multikeyShortcut.setAccelerator(this); 443 if (init) { 444 updateEnabledState(); 445 } 446 } 447 448 /** 449 * Constructs a new {@code ShowHideLayerAction}. 450 */ 451 public ShowHideLayerAction() { 452 this(true); 458 updateEnabledState(); 453 459 } 454 460 … … 517 523 } 518 524 525 /** 526 * Action which allows to change the opacity of one or more layers. 527 */ 519 528 public final class LayerOpacityAction extends AbstractAction implements IEnabledStateUpdating, LayerAction { 520 529 private Layer layer; … … 523 532 524 533 /** 525 * Creates a {@link LayerOpacityAction} which allows to ch enge the534 * Creates a {@link LayerOpacityAction} which allows to change the 526 535 * opacity of one or more layers. 527 536 * … … 632 641 private Shortcut multikeyShortcut; 633 642 643 /** 644 * Constructs a new {@code ActivateLayerAction}. 645 * @param layer the layer 646 */ 634 647 public ActivateLayerAction(Layer layer) { 635 648 this(); … … 670 683 671 684 private void execute(Layer layer) { 672 // model is going to be updated via LayerChangeListener 673 // and PropertyChangeEvents 685 // model is going to be updated via LayerChangeListener and PropertyChangeEvents 674 686 Main.map.mapView.setActiveLayer(layer); 675 687 layer.setVisible(true); … … 704 716 updateEnabledState(); 705 717 } 718 706 719 @Override 707 720 public void layerAdded(Layer newLayer) { 708 721 updateEnabledState(); 709 722 } 723 710 724 @Override 711 725 public void layerRemoved(Layer oldLayer) { … … 738 752 private Layer layer; 739 753 754 /** 755 * Constructs a new {@code MergeAction}. 756 * @param layer the layer 757 * @throws IllegalArgumentException if {@code layer} is null 758 */ 740 759 public MergeAction(Layer layer) throws IllegalArgumentException { 741 760 this(); … … 806 825 */ 807 826 public final class DuplicateAction extends AbstractAction implements IEnabledStateUpdating { 808 private Layer layer; 809 827 private Layer layer; 828 829 /** 830 * Constructs a new {@code DuplicateAction}. 831 * @param layer the layer 832 * @throws IllegalArgumentException if {@code layer} is null 833 */ 810 834 public DuplicateAction(Layer layer) throws IllegalArgumentException { 811 835 this(); … … 891 915 892 916 private static class LayerVisibleCheckBox extends JCheckBox { 893 private final ImageIcon icon _eye;894 private final ImageIcon icon _eye_translucent;917 private final ImageIcon iconEye; 918 private final ImageIcon iconEyeTranslucent; 895 919 private boolean isTranslucent; 896 920 public LayerVisibleCheckBox() { 897 921 setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); 898 icon _eye = ImageProvider.get("dialogs/layerlist", "eye");899 icon _eye_translucent = ImageProvider.get("dialogs/layerlist", "eye-translucent");922 iconEye = ImageProvider.get("dialogs/layerlist", "eye"); 923 iconEyeTranslucent = ImageProvider.get("dialogs/layerlist", "eye-translucent"); 900 924 setIcon(ImageProvider.get("dialogs/layerlist", "eye-off")); 901 925 setPressedIcon(ImageProvider.get("dialogs/layerlist", "eye-pressed")); 902 setSelectedIcon(icon _eye);926 setSelectedIcon(iconEye); 903 927 isTranslucent = false; 904 928 } … … 907 931 if (this.isTranslucent == isTranslucent) return; 908 932 if (isTranslucent) { 909 setSelectedIcon(icon _eye_translucent);933 setSelectedIcon(iconEyeTranslucent); 910 934 } else { 911 setSelectedIcon(icon _eye);935 setSelectedIcon(iconEye); 912 936 } 913 937 this.isTranslucent = isTranslucent; … … 923 947 924 948 private static class ActiveLayerCellRenderer implements TableCellRenderer { 925 JCheckBox cb;949 final JCheckBox cb; 926 950 public ActiveLayerCellRenderer() { 927 951 cb = new ActiveLayerCheckBox(); … … 938 962 939 963 private static class LayerVisibleCellRenderer implements TableCellRenderer { 940 LayerVisibleCheckBox cb;964 final LayerVisibleCheckBox cb; 941 965 public LayerVisibleCellRenderer() { 942 966 this.cb = new LayerVisibleCheckBox(); … … 953 977 954 978 private static class LayerVisibleCellEditor extends DefaultCellEditor { 955 LayerVisibleCheckBox cb;979 final LayerVisibleCheckBox cb; 956 980 public LayerVisibleCellEditor(LayerVisibleCheckBox cb) { 957 981 super(cb); … … 1014 1038 1015 1039 private static class LayerNameCellEditor extends DefaultCellEditor { 1016 public LayerNameCellEditor( JosmTextField tf) {1040 public LayerNameCellEditor(DisableShortcutsOnFocusGainedTextField tf) { 1017 1041 super(tf); 1018 1042 } … … 1027 1051 1028 1052 class PopupMenuHandler extends PopupMenuLauncher { 1029 @Override public void showMenu(MouseEvent evt) { 1053 @Override 1054 public void showMenu(MouseEvent evt) { 1030 1055 Layer layer = getModel().getLayer(layerList.getSelectedRow()); 1031 1056 menu = new LayerListPopup(getModel().getSelectedLayers(), layer); … … 1079 1104 1080 1105 /** 1081 * Observer interface to be implemented by views using {@link LayerListModel} 1082 * 1106 * Observer interface to be implemented by views using {@link LayerListModel}. 1083 1107 */ 1084 1108 public interface LayerListModelListener { 1109 1110 /** 1111 * Fired when a layer is made visible. 1112 * @param index the layer index 1113 * @param layer the layer 1114 */ 1085 1115 public void makeVisible(int index, Layer layer); 1116 1117 1118 /** 1119 * Fired when something has changed in the layer list model. 1120 */ 1086 1121 public void refresh(); 1087 1122 } … … 1161 1196 1162 1197 /** 1163 * Populates the model with the current layers managed by 1164 * {@link MapView}. 1165 * 1198 * Populates the model with the current layers managed by {@link MapView}. 1166 1199 */ 1167 1200 public void populate() { 1168 1201 for (Layer layer: getLayers()) { 1169 1202 // make sure the model is registered exactly once 1170 //1171 1203 layer.removePropertyChangeListener(this); 1172 1204 layer.addPropertyChangeListener(this); … … 1176 1208 1177 1209 /** 1178 * Marks <code>layer</code> as selected layer. Ignored, if 1179 * layer is null. 1210 * Marks <code>layer</code> as selected layer. Ignored, if layer is null. 1180 1211 * 1181 1212 * @param layer the layer. … … 1192 1223 1193 1224 /** 1194 * Replies the list of currently selected layers. Never null, but may 1195 * be empty. 1196 * 1197 * @return the list of currently selected layers. Never null, but may 1198 * be empty. 1225 * Replies the list of currently selected layers. Never null, but may be empty. 1226 * 1227 * @return the list of currently selected layers. Never null, but may be empty. 1199 1228 */ 1200 1229 public List<Layer> getSelectedLayers() { … … 1412 1441 final Layer activeLayer = getActiveLayer(); 1413 1442 if (activeLayer != null) { 1414 // there's an active layer - select it and make it 1415 // visible 1443 // there's an active layer - select it and make it visible 1416 1444 int idx = getLayers().indexOf(activeLayer); 1417 1445 selectionModel.setSelectionInterval(idx, idx); 1418 1446 ensureSelectedIsVisible(); 1419 1447 } else { 1420 // no active layer - select the first one and make 1421 // it visible 1448 // no active layer - select the first one and make it visible 1422 1449 selectionModel.setSelectionInterval(0, 0); 1423 1450 ensureSelectedIsVisible(); … … 1557 1584 1558 1585 /** 1559 * Creates a {@link ShowHideLayerAction} for <code>layer</code>in the1586 * Creates a {@link ShowHideLayerAction} in the 1560 1587 * context of this {@link LayerListDialog}. 1561 1588 * … … 1563 1590 */ 1564 1591 public ShowHideLayerAction createShowHideLayerAction() { 1565 ShowHideLayerAction act = new ShowHideLayerAction(true); 1566 act.putValue(Action.NAME, tr("Show/Hide")); 1567 return act; 1568 } 1569 1570 /** 1571 * Creates a {@link DeleteLayerAction} for <code>layer</code> in the 1592 return new ShowHideLayerAction(); 1593 } 1594 1595 /** 1596 * Creates a {@link DeleteLayerAction} in the 1572 1597 * context of this {@link LayerListDialog}. 1573 1598 * … … 1575 1600 */ 1576 1601 public DeleteLayerAction createDeleteLayerAction() { 1577 // the delete layer action doesn't depend on the current layer1578 1602 return new DeleteLayerAction(); 1579 1603 } … … 1601 1625 } 1602 1626 1627 /** 1628 * Returns the layer at given index, or {@code null}. 1629 * @param index the index 1630 * @return the layer at given index, or {@code null} if index out of range 1631 */ 1603 1632 public static Layer getLayerForIndex(int index) { 1604 1633 … … 1614 1643 } 1615 1644 1616 // This is not Class<? extends Layer> on purpose, to allow asking for layers implementing some interface 1645 /** 1646 * Returns a list of info on all layers of a given class. 1647 * @param layerClass The layer class. This is not {@code Class<? extends Layer>} on purpose, 1648 * to allow asking for layers implementing some interface 1649 * @return list of info on all layers assignable from {@code layerClass} 1650 */ 1617 1651 public static List<MultikeyInfo> getLayerInfoByClass(Class<?> layerClass) { 1618 1652 … … 1635 1669 } 1636 1670 1671 /** 1672 * Determines if a layer is valid (contained in layer list). 1673 * @param l the layer 1674 * @return {@code true} if layer {@code l} is contained in current layer list 1675 */ 1637 1676 public static boolean isLayerValid(Layer l) { 1638 if (l == null) 1677 1678 if (l == null || !Main.isDisplayingMapView()) 1639 1679 return false; 1640 1680 1641 if (!Main.isDisplayingMapView())1642 return false;1643 1644 1681 return Main.map.mapView.getAllLayersAsList().contains(l); 1645 1682 } 1646 1683 1684 /** 1685 * Returns info about layer. 1686 * @param l the layer 1687 * @return info about layer {@code l} 1688 */ 1647 1689 public static MultikeyInfo getLayerInfo(Layer l) { 1648 1690 1649 if (l == null) 1650 return null; 1651 1652 if (!Main.isDisplayingMapView()) 1691 if (l == null || !Main.isDisplayingMapView()) 1653 1692 return null; 1654 1693 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r7029 r7539 117 117 HighlightHelper highlightHelper = new HighlightHelper(); 118 118 private boolean highlightEnabled = Main.pref.getBoolean("draw.target-highlight", true); 119 119 120 /** 120 121 * Constructs <code>RelationListDialog</code> … … 197 198 } 198 199 199 @Override public void showNotify() { 200 @Override 201 public void showNotify() { 200 202 MapView.addLayerChangeListener(newAction); 201 203 newAction.updateEnabledState(); … … 205 207 } 206 208 207 @Override public void hideNotify() { 209 @Override 210 public void hideNotify() { 208 211 MapView.removeLayerChangeListener(newAction); 209 212 DatasetEventManager.getInstance().removeDatasetListener(this); … … 323 326 } 324 327 325 @Override public void mouseClicked(MouseEvent e) { 328 @Override 329 public void mouseClicked(MouseEvent e) { 326 330 if (!Main.main.hasEditLayer()) return; 327 331 if (isDoubleClick(e)) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r7158 r7539 80 80 81 81 /** 82 * Class that helps PropertiesDialog add and edit tag values 82 * Class that helps PropertiesDialog add and edit tag values. 83 * @since 5633 83 84 */ 84 85 class TagEditHelper { … … 139 140 140 141 /** 141 * Edit the value in the tags table row 142 * Edit the value in the tags table row. 142 143 * @param row The row of the table from which the value is edited. 143 144 * @param focusOnKey Determines if the initial focus should be set on key instead of value … … 187 188 188 189 /** 189 * Load recently used tags from preferences if needed 190 * Load recently used tags from preferences if needed. 190 191 */ 191 192 public void loadTagsIfNeeded() { … … 204 205 205 206 /** 206 * Store recently used tags in preferences if needed 207 * Store recently used tags in preferences if needed. 207 208 */ 208 209 public void saveTagsIfNeeded() { … … 258 259 ListCellRenderer<AutoCompletionListItem> cellRenderer = new ListCellRenderer<AutoCompletionListItem>() { 259 260 final DefaultListCellRenderer def = new DefaultListCellRenderer(); 260 @Override 261 public Component getListCellRendererComponent(JList<? extends AutoCompletionListItem> list, 262 AutoCompletionListItem value, int index, boolean isSelected, boolean cellHasFocus){ 263 Component c = def.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 264 if (c instanceof JLabel) { 265 String str = value.getValue(); 266 if (valueCount.containsKey(objKey)) { 267 Map<String, Integer> m = valueCount.get(objKey); 268 if (m.containsKey(str)) { 269 str = tr("{0} ({1})", str, m.get(str)); 270 c.setFont(c.getFont().deriveFont(Font.ITALIC + Font.BOLD)); 271 } 261 @Override 262 public Component getListCellRendererComponent(JList<? extends AutoCompletionListItem> list, 263 AutoCompletionListItem value, int index, boolean isSelected, boolean cellHasFocus){ 264 Component c = def.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 265 if (c instanceof JLabel) { 266 String str = value.getValue(); 267 if (valueCount.containsKey(objKey)) { 268 Map<String, Integer> m = valueCount.get(objKey); 269 if (m.containsKey(str)) { 270 str = tr("{0} ({1})", str, m.get(str)); 271 c.setFont(c.getFont().deriveFont(Font.ITALIC + Font.BOLD)); 272 272 } 273 ((JLabel) c).setText(str); 274 } 275 return c; 276 } 277 }; 273 } 274 ((JLabel) c).setText(str); 275 } 276 return c; 277 } 278 }; 278 279 279 280 private EditTagDialog(String key, int row, Map<String, Integer> map, final boolean initialFocusOnKey) { … … 463 464 464 465 private void selectACComboBoxSavingUnixBuffer(AutoCompletingComboBox cb) { 465 // select com pbobox with saving unix system selection (middle mouse paste)466 // select combobox with saving unix system selection (middle mouse paste) 466 467 Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection(); 467 468 if(sysSel != null) { … … 493 494 protected FocusAdapter addFocusAdapter(final AutoCompletionManager autocomplete, final Comparator<AutoCompletionListItem> comparator) { 494 495 // get the combo box' editor component 495 JTextComponent editor = (JTextComponent)values.getEditor() 496 .getEditorComponent(); 496 JTextComponent editor = (JTextComponent)values.getEditor().getEditorComponent(); 497 497 // Refresh the values model when focus is gained 498 498 FocusAdapter focus = new FocusAdapter() { 499 @Override public void focusGained(FocusEvent e) { 499 @Override 500 public void focusGained(FocusEvent e) { 500 501 String key = keys.getEditor().getItem().toString(); 501 502 … … 665 666 public void actionPerformed(ActionEvent e) { 666 667 keys.setSelectedItem(t.getKey()); 667 // Update list of values (fix #7951) 668 // fix #8298 - update list of values before setting value (?) 668 // fix #7951, #8298 - update list of values before setting value (?) 669 669 focus.focusGained(null); 670 670 values.setSelectedItem(t.getValue()); -
trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java
r7533 r7539 38 38 private final ArrayList<ModifierListener> modifierListeners = new ArrayList<>(); 39 39 private int previousModifiers; 40 41 private boolean enabled = true; 40 42 41 43 /** … … 84 86 public void actionPerformed(ActionEvent e) { 85 87 timer.stop(); 86 if (set.remove(releaseEvent.getKeyCode()) ) {88 if (set.remove(releaseEvent.getKeyCode()) && enabled) { 87 89 synchronized (AdvancedKeyPressDetector.this) { 88 90 for (KeyPressReleaseListener q: keyListeners) { … … 121 123 if (timer.isRunning()) { 122 124 timer.stop(); 123 } else if (set.add((e.getKeyCode())) ) {125 } else if (set.add((e.getKeyCode())) && enabled) { 124 126 synchronized (this) { 125 127 for (KeyPressReleaseListener q: keyListeners) { … … 131 133 if (timer.isRunning()) { 132 134 timer.stop(); 133 if (set.remove(e.getKeyCode()) ) {135 if (set.remove(e.getKeyCode()) && enabled) { 134 136 synchronized (this) { 135 137 for (KeyPressReleaseListener q: keyListeners) { … … 178 180 return set.contains(keyCode); 179 181 } 182 183 /** 184 * Sets the enabled state of the key detector. We need to disable it when text fields that disable 185 * shortcuts gain focus. 186 * @param enabled if {@code true}, enables this key detector. If {@code false}, disables it 187 * @since 7539 188 */ 189 public final void setEnabled(boolean enabled) { 190 this.enabled = enabled; 191 } 180 192 } -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r7312 r7539 19 19 import java.awt.event.HierarchyEvent; 20 20 import java.awt.event.HierarchyListener; 21 import java.awt.event.KeyEvent; 21 22 import java.awt.image.FilteredImageSource; 22 23 import java.lang.reflect.InvocationTargetException; … … 330 331 return new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 331 332 } 333 334 /** 335 * Returns extended modifier key used as the appropriate accelerator key for menu shortcuts. 336 * It is advised everywhere to use {@link Toolkit#getMenuShortcutKeyMask()} to get the cross-platform modifier, but: 337 * <ul> 338 * <li>it returns KeyEvent.CTRL_MASK instead of KeyEvent.CTRL_DOWN_MASK. We used the extended 339 * modifier for years, and Oracle recommends to use it instead, so it's best to keep it</li> 340 * <li>the method throws a HeadlessException ! So we would need to handle it for unit tests anyway</li> 341 * </ul> 342 * @return extended modifier key used as the appropriate accelerator key for menu shortcuts 343 * @since 7539 344 */ 345 public static int getMenuShortcutKeyMaskEx() { 346 return Main.isPlatformOsx() ? KeyEvent.META_DOWN_MASK : KeyEvent.CTRL_DOWN_MASK; 347 } 332 348 } -
trunk/src/org/openstreetmap/josm/gui/widgets/DisableShortcutsOnFocusGainedTextField.java
r7005 r7539 113 113 disableMenuActions(); 114 114 unregisterActionShortcuts(); 115 Main.map.keyDetector.setEnabled(false); 115 116 } 116 117 117 118 @Override 118 119 public void focusLost(FocusEvent e) { 120 Main.map.keyDetector.setEnabled(true); 119 121 restoreActionShortcuts(); 120 122 restoreMenuActions(); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r7521 r7539 18 18 import java.util.Map; 19 19 import java.util.Set; 20 20 21 import javax.swing.AbstractAction; 21 22 import javax.swing.JCheckBox; 22 23 23 import javax.swing.JPanel; 24 24 import javax.swing.JTable; … … 69 69 this.num = num; 70 70 } 71 @Override 71 72 public String toString() { 72 73 return tr("<delete from {0} objects>", num); … … 329 330 330 331 /** 331 * Ask user and add the tags he confirm 332 * Ask user and add the tags he confirm. 332 333 * @param keyValue is a table or {{tag1,val1},{tag2,val2},...} 333 334 * @param sender is a string for skipping confirmations. Use epmty string for always confirmed adding. 335 * @param primitives OSM objects that will be modified 336 * @since 7521 334 337 */ 335 338 public static void addTags(String[][] keyValue, String sender, Collection<? extends OsmPrimitive> primitives) { -
trunk/src/org/openstreetmap/josm/tools/InputMapUtils.java
r7509 r7539 13 13 14 14 /** 15 * Tools to work with Swing InputMap 16 * 15 * Tools to work with Swing InputMap. 16 * @since 5200 17 17 */ 18 18 public final class InputMapUtils { … … 62 62 63 63 /** 64 * Enable activating button on Enter (which is replaced with spacebar for certain Look-And-Feels) 64 * Enable activating button on Enter (which is replaced with spacebar for certain Look-And-Feels). 65 * @param b Button 65 66 */ 66 67 public static void enableEnter(JButton b) { 67 68 b.setFocusable(true); 68 69 b.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); 69 b.getActionMap().put("enter", b.getAction());70 b.getActionMap().put("enter", b.getAction()); 70 71 } 71 72 73 /** 74 * Add an action activated with Enter key on a component. 75 * @param c The Swing component 76 * @param a action activated with Enter key 77 */ 72 78 public static void addEnterAction(JComponent c, Action a) { 73 79 c.getActionMap().put("enter", a); … … 75 81 } 76 82 83 /** 84 * Add an action activated with Spacebar key on a component. 85 * @param c The Swing component 86 * @param a action activated with Spacebar key 87 */ 77 88 public static void addSpacebarAction(JComponent c, Action a) { 78 89 c.getActionMap().put("spacebar", a); -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r7012 r7539 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui.util.GuiHelper; 21 22 22 23 /** … … 27 28 * finally manages loading and saving shortcuts to/from the preferences. 28 29 * 29 * Action authors: You only need the {@link #registerShortcut} factory. Ignore everything 30 * else. 30 * Action authors: You only need the {@link #registerShortcut} factory. Ignore everything else. 31 31 * 32 32 * All: Use only public methods that are also marked to be used. The others are 33 33 * public so the shortcut preferences can use them. 34 * 34 * @since 1084 35 35 */ 36 36 public final class Shortcut { … … 262 262 } 263 263 264 /** None group: used with KeyEvent.CHAR_UNDEFINED if no shortcut is defined */ 264 265 public static final int NONE = 5000; 265 266 public static final int MNEMONIC = 5001; 267 /** Reserved group: for system shortcuts only */ 266 268 public static final int RESERVED = 5002; 269 /** Direct group: no modifier */ 267 270 public static final int DIRECT = 5003; 271 /** Alt group */ 268 272 public static final int ALT = 5004; 273 /** Shift group */ 269 274 public static final int SHIFT = 5005; 275 /** Command group. Matches CTRL modifier on Windows/Linux but META modifier on OS X */ 270 276 public static final int CTRL = 5006; 277 /** Alt-Shift group */ 271 278 public static final int ALT_SHIFT = 5007; 279 /** Alt-Command group. Matches ALT-CTRL modifier on Windows/Linux but ALT-META modifier on OS X */ 272 280 public static final int ALT_CTRL = 5008; 281 /** Command-Shift group. Matches CTRL-SHIFT modifier on Windows/Linux but META-SHIFT modifier on OS X */ 273 282 public static final int CTRL_SHIFT = 5009; 283 /** Alt-Command-Shift group. Matches ALT-CTRL-SHIFT modifier on Windows/Linux but ALT-META-SHIFT modifier on OS X */ 274 284 public static final int ALT_CTRL_SHIFT = 5010; 275 285 … … 285 295 if (initdone) return; 286 296 initdone = true; 297 int commandDownMask = GuiHelper.getMenuShortcutKeyMaskEx(); 287 298 groups.put(NONE, -1); 288 299 groups.put(MNEMONIC, KeyEvent.ALT_DOWN_MASK); … … 290 301 groups.put(ALT, KeyEvent.ALT_DOWN_MASK); 291 302 groups.put(SHIFT, KeyEvent.SHIFT_DOWN_MASK); 292 groups.put(CTRL, KeyEvent.CTRL_DOWN_MASK);303 groups.put(CTRL, commandDownMask); 293 304 groups.put(ALT_SHIFT, KeyEvent.ALT_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK); 294 groups.put(ALT_CTRL, KeyEvent.ALT_DOWN_MASK| KeyEvent.CTRL_DOWN_MASK);295 groups.put(CTRL_SHIFT, KeyEvent.CTRL_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK);296 groups.put(ALT_CTRL_SHIFT, KeyEvent.ALT_DOWN_MASK| KeyEvent.CTRL_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK);305 groups.put(ALT_CTRL, KeyEvent.ALT_DOWN_MASK|commandDownMask); 306 groups.put(CTRL_SHIFT, commandDownMask|KeyEvent.SHIFT_DOWN_MASK); 307 groups.put(ALT_CTRL_SHIFT, KeyEvent.ALT_DOWN_MASK|commandDownMask|KeyEvent.SHIFT_DOWN_MASK); 297 308 298 309 // (1) System reserved shortcuts
Note:
See TracChangeset
for help on using the changeset viewer.