Changeset 1050 in josm


Ignore:
Timestamp:
2008-10-23T11:25:14+02:00 (16 years ago)
Author:
stoecker
Message:

added modifier support to ShortCut definitions. Removed all internal conflicts

Location:
trunk/src/org/openstreetmap/josm
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r1023 r1050  
    6868
    6969        public AboutAction() {
    70                 super(tr("About"), "about", tr("Display the about screen."), ShortCut.registerShortCut("system:about", tr("About..."), KeyEvent.VK_F1, ShortCut.GROUP_DIRECT), true);
     70                super(tr("About"), "about", tr("Display the about screen."), ShortCut.registerShortCut("system:about", tr("About..."), KeyEvent.VK_F1, ShortCut.GROUP_DIRECT, ShortCut.SHIFT), true);
    7171        }
    7272
  • trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

    r1023 r1050  
    3636        public CreateCircleAction() {
    3737                super(tr("Create Circle"), "createcircle", tr("Create a circle from three selected nodes."),
    38                 ShortCut.registerShortCut("tools:createcircle", tr("Tool: Create circle"), KeyEvent.VK_O, ShortCut.GROUP_EDIT), true);
     38                ShortCut.registerShortCut("tools:createcircle", tr("Tool: Create circle"), KeyEvent.VK_O, ShortCut.GROUP_EDIT, ShortCut.SHIFT), true);
    3939        }
    4040
  • trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java

    r1023 r1050  
    2727                super(tr("Paste Tags"), "pastetags",
    2828                        tr("Apply tags of contents of paste buffer to all selected items."),
    29                         ShortCut.registerShortCut("system:pastestyle", tr("Edit: Paste tags"), KeyEvent.VK_V, ShortCut.GROUP_MENU), true);
     29                        ShortCut.registerShortCut("system:pastestyle", tr("Edit: Paste tags"), KeyEvent.VK_V, ShortCut.GROUP_MENU, ShortCut.SHIFT_CTRL), true);
    3030                DataSet.selListeners.add(this);
    3131                copyAction.addListener(this);
  • trunk/src/org/openstreetmap/josm/actions/SaveAsAction.java

    r1047 r1050  
    2323        public SaveAsAction(Layer layer) {
    2424                super(tr("Save as ..."), "save_as", tr("Save the current data to a new file."),
    25                 ShortCut.registerShortCut("system:saveas", tr("File: Save as..."), KeyEvent.VK_S, ShortCut.GROUP_MENU), layer);
     25                ShortCut.registerShortCut("system:saveas", tr("File: Save as..."), KeyEvent.VK_S, ShortCut.GROUP_MENU, ShortCut.SHIFT_CTRL), layer);
    2626        }
    2727
  • trunk/src/org/openstreetmap/josm/actions/UnselectAllAction.java

    r1047 r1050  
    2121                // Add extra shortcut C-S-a
    2222                Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    23                 ShortCut.registerShortCut("edit:unselectall2", tr("Edit: Unselect all (2)"), KeyEvent.VK_A, ShortCut.GROUP_MENU).getKeyStroke(),
     23                ShortCut.registerShortCut("edit:unselectall2", tr("Edit: Unselect all (2)"),
     24                KeyEvent.VK_A, ShortCut.GROUP_MENU, ShortCut.SHIFT_CTRL).getKeyStroke(),
    2425                tr("Unselect All"));
    2526
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioSlowerAction.java

    r1023 r1050  
    1111        public AudioSlowerAction() {
    1212                super(tr("Slower"), "audio-slower", tr("Slower Forward"),
    13                 ShortCut.registerShortCut("audio:slower", tr("Audio: Slower"), KeyEvent.VK_F9, ShortCut.GROUP_DIRECT), true);
     13                ShortCut.registerShortCut("audio:slower", tr("Audio: Slower"), KeyEvent.VK_F4, ShortCut.GROUP_DIRECT), true);
    1414        }
    1515}
  • trunk/src/org/openstreetmap/josm/tools/ShortCut.java

    r1023 r1050  
    2929 */
    3030public class ShortCut {
     31        public static final int SHIFT = KeyEvent.SHIFT_DOWN_MASK;
     32        public static final int CTRL = KeyEvent.CTRL_DOWN_MASK;
     33        public static final int SHIFT_CTRL = KeyEvent.SHIFT_DOWN_MASK|KeyEvent.CTRL_DOWN_MASK;
    3134        private String shortText;        // the unique ID of the shortcut
    3235        private String longText;         // a human readable description that will be shown in the preferences
     
    306309                int i = 0;
    307310                for (ShortCut sc : ShortCuts.values()) {
    308                         if (!sc.getAutomatic() && !sc.getReset()) {
     311                        if (!sc.getAutomatic() && !sc.getReset() && sc.getAssignedUser()) {
    309312                                Main.pref.put("shortcut.shortcut."+i, sc.asPrefString());
    310313                                i++;
     
    316319        // this is used to register a shortcut that was read from the preferences
    317320        private static void registerShortCut(ShortCut sc) {
    318                 if (sc.getAssignedDefault()) { // a 100% default shortcut will go though unchanged -- unless the groups have been reconfigured
    319                         registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc);
    320                 } else if (sc.getAssignedUser()) { // put a user configured shortcut in as-is -- unless there's a conflict
    321                         ShortCut potentialShortCut = findShortcut(sc.getAssignedKey(), sc.getAssignedModifier());
    322                         if (potentialShortCut == null) {
    323                                 ShortCuts.put(sc.getShortText(), sc);
    324                         } else {
    325                                 registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc);
    326                         }
    327                 } else { // this shortcut was auto-moved before, re-register and warn if it changes
    328                         registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc);
    329                 }
     321                registerShortCut(sc.getShortText(), sc.getLongText(), sc.getRequestedKey(), sc.getRequestedGroup(), sc.getAssignedModifier(), sc);
    330322        }
    331323
     
    367359         *                  constants defined above.
    368360         */
     361        public static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup, int modifier) {
     362                return registerShortCut(shortText, longText, requestedKey, requestedGroup, modifier, null);
     363        }
    369364        public static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup) {
    370                 return registerShortCut(shortText, longText, requestedKey, requestedGroup, null);
     365                return registerShortCut(shortText, longText, requestedKey, requestedGroup, null, null);
     366        }
     367
     368        private static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup,
     369        ShortCut originalShortCut) {
     370                return registerShortCut(shortText, longText, requestedKey, requestedGroup, null, originalShortCut);
    371371        }
    372372
     
    376376        // read from the preferences file). New shortcuts will never warn, even when they land on some funny
    377377        // random fallback key like Ctrl+Alt+Shift+Z for "File Open..." <g>
    378         private static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup, ShortCut originalShortCut) {
     378        private static ShortCut registerShortCut(String shortText, String longText, int requestedKey, int requestedGroup, Integer modifier,
     379        ShortCut originalShortCut) {
    379380                doInit();
    380381                if (ShortCuts.containsKey(shortText)) { // a re-register? maybe a sc already read from the preferences?
     
    384385                }
    385386                Integer defaultModifier = Groups.get(requestedGroup + GROUPS_DEFAULT);
    386                 if (defaultModifier == null) { // garbage in, no shortcurt out
     387                if(modifier != null) {
     388                        defaultModifier = modifier;
     389                }
     390                else if (defaultModifier == null) { // garbage in, no shortcurt out
    387391                        defaultModifier = Groups.get(GROUP_NONE + GROUPS_DEFAULT);
    388392                }
Note: See TracChangeset for help on using the changeset viewer.