Ignore:
Timestamp:
2015-06-20T23:42:21+02:00 (9 years ago)
Author:
Don-vip
Message:

checkstyle: enable relevant whitespace checks and fix them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r8509 r8510  
    3535 */
    3636public final class Shortcut {
    37     private String shortText;        // the unique ID of the shortcut
    38     private String longText;         // a human readable description that will be shown in the preferences
    39     private final int requestedKey;  // the key, the caller requested
    40     private final int requestedGroup;// the group, the caller requested
    41     private int assignedKey;         // the key that actually is used
    42     private int assignedModifier;    // the modifiers that are used
    43     private boolean assignedDefault; // true if it got assigned what was requested. (Note: modifiers will be ignored in favour of group when loading it from the preferences then.)
    44     private boolean assignedUser;    // true if the user changed this shortcut
    45     private boolean automatic;       // true if the user cannot change this shortcut (Note: it also will not be saved into the preferences)
    46     private boolean reset;           // true if the user requested this shortcut to be set to its default value (will happen on next restart, as this shortcut will not be saved to the preferences)
     37    /** the unique ID of the shortcut */
     38    private final String shortText;
     39    /** a human readable description that will be shown in the preferences */
     40    private String longText;
     41    /** the key, the caller requested */
     42    private final int requestedKey;
     43    /** the group, the caller requested */
     44    private final int requestedGroup;
     45    /** the key that actually is used */
     46    private int assignedKey;
     47    /** the modifiers that are used */
     48    private int assignedModifier;
     49    /** true if it got assigned what was requested.
     50     * (Note: modifiers will be ignored in favour of group when loading it from the preferences then.) */
     51    private boolean assignedDefault;
     52    /** true if the user changed this shortcut */
     53    private boolean assignedUser;
     54    /** true if the user cannot change this shortcut (Note: it also will not be saved into the preferences) */
     55    private boolean automatic;
     56    /** true if the user requested this shortcut to be set to its default value
     57     * (will happen on next restart, as this shortcut will not be saved to the preferences) */
     58    private boolean reset;
    4759
    4860    // simple constructor
     
    218230        if (keyStroke == null) return "";
    219231        String modifText = KeyEvent.getKeyModifiersText(keyStroke.getModifiers());
    220         if ("".equals (modifText)) return KeyEvent.getKeyText(keyStroke.getKeyCode());
     232        if ("".equals(modifText)) return KeyEvent.getKeyText(keyStroke.getKeyCode());
    221233        return modifText + "+" + KeyEvent.getKeyText(keyStroke.getKeyCode());
    222234    }
     
    235247
    236248    // and here our modifier groups
    237     private static Map<Integer, Integer> groups= new HashMap<>();
     249    private static Map<Integer, Integer> groups = new HashMap<>();
    238250
    239251    // check if something collides with an existing shortcut
     
    301313        groups.put(SHIFT, KeyEvent.SHIFT_DOWN_MASK);
    302314        groups.put(CTRL, commandDownMask);
    303         groups.put(ALT_SHIFT, KeyEvent.ALT_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK);
    304         groups.put(ALT_CTRL, KeyEvent.ALT_DOWN_MASK|commandDownMask);
    305         groups.put(CTRL_SHIFT, commandDownMask|KeyEvent.SHIFT_DOWN_MASK);
    306         groups.put(ALT_CTRL_SHIFT, KeyEvent.ALT_DOWN_MASK|commandDownMask|KeyEvent.SHIFT_DOWN_MASK);
     315        groups.put(ALT_SHIFT, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
     316        groups.put(ALT_CTRL, KeyEvent.ALT_DOWN_MASK | commandDownMask);
     317        groups.put(CTRL_SHIFT, commandDownMask | KeyEvent.SHIFT_DOWN_MASK);
     318        groups.put(ALT_CTRL_SHIFT, KeyEvent.ALT_DOWN_MASK | commandDownMask | KeyEvent.SHIFT_DOWN_MASK);
    307319
    308320        // (1) System reserved shortcuts
     
    310322        // (2) User defined shortcuts
    311323        List<Shortcut> newshortcuts = new LinkedList<>();
    312         for(String s : Main.pref.getAllPrefixCollectionKeys("shortcut.entry.")) {
     324        for (String s : Main.pref.getAllPrefixCollectionKeys("shortcut.entry.")) {
    313325            newshortcuts.add(new Shortcut(s));
    314326        }
    315327
    316         for(Shortcut sc : newshortcuts) {
     328        for (Shortcut sc : newshortcuts) {
    317329            if (sc.isAssignedUser()
    318330            && findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()) == null) {
     
    321333        }
    322334        // Shortcuts at their default values
    323         for(Shortcut sc : newshortcuts) {
     335        for (Shortcut sc : newshortcuts) {
    324336            if (!sc.isAssignedUser() && sc.isAssignedDefault()
    325337            && findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()) == null) {
     
    328340        }
    329341        // Shortcuts that were automatically moved
    330         for(Shortcut sc : newshortcuts) {
     342        for (Shortcut sc : newshortcuts) {
    331343            if (!sc.isAssignedUser() && !sc.isAssignedDefault()
    332344            && findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()) == null) {
     
    338350    private static int getGroupModifier(int group) {
    339351        Integer m = groups.get(group);
    340         if(m == null)
     352        if (m == null)
    341353            m = -1;
    342354        return m;
     
    344356
    345357    private static int findModifier(int group, Integer modifier) {
    346         if(modifier == null) {
     358        if (modifier == null) {
    347359            modifier = getGroupModifier(group);
    348360            if (modifier == null) { // garbage in, no shortcut out
     
    440452        switch (requestedGroup) {
    441453            case CTRL: return KeyEvent.CTRL_DOWN_MASK;
    442             case ALT_CTRL: return KeyEvent.ALT_DOWN_MASK|KeyEvent.CTRL_DOWN_MASK;
    443             case CTRL_SHIFT: return KeyEvent.CTRL_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK;
    444             case ALT_CTRL_SHIFT: return KeyEvent.ALT_DOWN_MASK|KeyEvent.CTRL_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK;
     454            case ALT_CTRL: return KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK;
     455            case CTRL_SHIFT: return KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK;
     456            case ALT_CTRL_SHIFT: return KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK;
    445457            default: return 0;
    446458        }
Note: See TracChangeset for help on using the changeset viewer.