Changeset 3247 in josm for trunk/src/org


Ignore:
Timestamp:
2010-05-15T10:37:03+02:00 (14 years ago)
Author:
jttt
Message:

Fix #4807 Preferences: shortcut edting broken

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/PrefJPanel.java

    r3083 r3247  
    1313import java.util.Map;
    1414
     15import javax.swing.AbstractAction;
    1516import javax.swing.JEditorPane;
    1617import javax.swing.JScrollPane;
     
    370371    // even have some duplicated code. Feel free to refactor, If you have
    371372    // more expirience with GUI coding than I have.
    372     private class cbAction extends javax.swing.AbstractAction implements ListSelectionListener {
     373    private class cbAction extends AbstractAction implements ListSelectionListener {
    373374        private PrefJPanel panel;
    374375        public cbAction (PrefJPanel panel) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/ShortcutPreference.java

    r3083 r3247  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.util.Collection;
     6import java.util.List;
    77
    88import javax.swing.JPanel;
     
    3636
    3737    public boolean ok() {
    38         return false;
     38        return Shortcut.savePrefs();
    3939    }
    4040
    4141    // Maybe move this to prefPanel? There's no need for it to be here.
    4242    private static class scListModel extends AbstractTableModel {
    43 //      private String[] columnNames = new String[]{tr("Action"), tr("Shortcut"), tr("Group"), tr("ID")};
    4443        private String[] columnNames = new String[]{tr("Action"), tr("Shortcut")};
    45         private Collection<Shortcut> data;
     44        private List<Shortcut> data;
     45
    4646        public scListModel() {
    4747            data = Shortcut.listAll();
     
    5353            return data.size();
    5454        }
     55        @Override
    5556        public String getColumnName(int col) {
    5657            return columnNames[col];
    5758        }
    5859        public Object getValueAt(int row, int col) {
    59             Shortcut sc = (Shortcut)data.toArray()[row];
    60             if (col == 0) {
     60            Shortcut sc = data.get(row);
     61            if (col == 0)
    6162                return sc.getLongText();
    62             } else if (col == 1) {
     63            else if (col == 1)
    6364                return sc.getKeyText();
    64             } /*else if (col == 2) {
    65                 if (sc.getRequestedGroup() == Shortcut.GROUP_NONE) {
    66                     return tr("None");
    67                 } else if (sc.getRequestedGroup() == Shortcut.GROUP_HOTKEY) {
    68                     return tr("Hotkey");
    69                 } else if (sc.getRequestedGroup() == Shortcut.GROUP_MENU) {
    70                     return tr("Menu");
    71                 } else if (sc.getRequestedGroup() == Shortcut.GROUP_EDIT) {
    72                     return tr("Edit");
    73                 } else if (sc.getRequestedGroup() == Shortcut.GROUP_LAYER) {
    74                     return tr("Subwindow");
    75                 } else if (sc.getRequestedGroup() == Shortcut.GROUP_DIRECT) {
    76                     return tr("Direct");
    77                 } else if (sc.getRequestedGroup() == Shortcut.GROUP_MNEMONIC) {
    78                     return tr("Mnemonic");
    79                 } else if (sc.getRequestedGroup() == Shortcut.GROUP_RESERVED) {
    80                     return tr("System");
    81                 } else {
    82                     return tr("Unknown");
    83                 }
    84             } else if (col == 3) {
    85                 return sc.getShortText();
    86             } */else {
     65            else
    8766                // This is a kind of hack that allows the actions on the editing controls
    8867                // to access the underlying shortcut object without introducing another
    8968                // method. I opted to stay within the interface.
    9069                return sc;
    91             }
    9270        }
     71        @Override
    9372        public boolean isCellEditable(int row, int col) {
    9473            return false;
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r3135 r3247  
    55
    66import java.awt.event.KeyEvent;
    7 import java.util.Collection;
     7import java.util.ArrayList;
    88import java.util.HashMap;
    99import java.util.LinkedHashMap;
     10import java.util.List;
    1011import java.util.Map;
    1112
     
    231232     * FOR PREF PANE ONLY
    232233     */
    233     public static Collection<Shortcut> listAll() {
    234         return shortcuts.values();
     234    public static List<Shortcut> listAll() {
     235        return new ArrayList<Shortcut>(shortcuts.values());
    235236    }
    236237
     
    313314
    314315    // shutdown handling
    315     public static void savePrefs() {
     316    public static boolean savePrefs() {
    316317        //      we save this directly from the preferences pane, so don't overwrite these values here
    317318        //      for (int i = GROUP_NONE; i < GROUP__MAX+GROUPS_ALT2; i++) {
    318319        //      Main.pref.put("shortcut.groups."+i, Groups.get(i).toString());
    319320        //      }
     321        boolean changed = false;
    320322        int i = 0;
    321323        for (Shortcut sc : shortcuts.values()) {
    322324            //          TODO: Remove sc.getAssignedUser() when we fixed all internal conflicts
    323325            if (!sc.getAutomatic() && !sc.getReset() && sc.getAssignedUser()) {
    324                 Main.pref.put("shortcut.shortcut."+i, sc.asPrefString());
     326                changed = changed | Main.pref.put("shortcut.shortcut."+i, sc.asPrefString());
    325327                i++;
    326328            }
    327329        }
    328         Main.pref.put("shortcut.shortcut."+i, "");
     330        changed = changed | Main.pref.put("shortcut.shortcut."+i, "");
     331        return changed;
    329332    }
    330333
     
    465468     * 'Ctrl-C' on windows or 'Meta-C' on a Mac. null, if the platform specific
    466469     * copy command isn't known.
    467      * 
     470     *
    468471     * @return the platform specific key stroke for the  'Copy' command
    469472     */
     
    478481     * 'Ctrl-V' on windows or 'Meta-V' on a Mac. null, if the platform specific
    479482     * paste command isn't known.
    480      * 
     483     *
    481484     * @return the platform specific key stroke for the 'Paste' command
    482485     */
     
    491494     * 'Ctrl-X' on windows or 'Meta-X' on a Mac. null, if the platform specific
    492495     * 'Cut' command isn't known.
    493      * 
     496     *
    494497     * @return the platform specific key stroke for the 'Cut' command
    495498     */
Note: See TracChangeset for help on using the changeset viewer.