Changeset 5200 in josm


Ignore:
Timestamp:
Apr 18, 2012 12:18:56 PM (13 months ago)
Author:
akks
Message:

see #7626, fix #7463: keys Ctrl-Shift-Up/Down, Enter, Spacebar work better in toggle dialogs
Enter and Spacebar = useful actions for list items (select, toggle, etc.)

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
13 edited

Legend:

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

    r4816 r5200  
    1818import org.openstreetmap.josm.gui.help.HelpUtil; 
    1919import org.openstreetmap.josm.tools.ImageProvider; 
     20import org.openstreetmap.josm.tools.InputMapUtils; 
    2021import org.openstreetmap.josm.tools.WindowGeometry; 
    2122 
     
    108109        }; 
    109110        b.addActionListener(a); 
    110         b.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 
    111         b.getActionMap().put("enter", a); 
     111        InputMapUtils.enableEnter(b); 
    112112        return b; 
    113113    } 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r4982 r5200  
    2020import javax.swing.AbstractAction; 
    2121import javax.swing.Box; 
     22import javax.swing.JComponent; 
    2223import javax.swing.JLabel; 
    2324import javax.swing.JPanel; 
     
    4849import org.openstreetmap.josm.tools.GBC; 
    4950import org.openstreetmap.josm.tools.ImageProvider; 
     51import org.openstreetmap.josm.tools.InputMapUtils; 
    5052import org.openstreetmap.josm.tools.Predicate; 
    5153import org.openstreetmap.josm.tools.Shortcut; 
     
    8385        undoSelectionListener = new UndoRedoSelectionListener(undoTree); 
    8486        undoTree.getSelectionModel().addTreeSelectionListener(undoSelectionListener); 
    85  
     87        InputMapUtils.unassignCtrlShiftUpDown(undoTree, JComponent.WHEN_FOCUSED); 
     88         
    8689        redoTree.addMouseListener(new PopupMenuHandler()); 
    8790        redoTree.setRootVisible(false); 
     
    119122            new SideButton(redoAction) 
    120123        })); 
     124         
     125        InputMapUtils.addEnterAction(undoTree, selectAction); 
     126        InputMapUtils.addEnterAction(redoTree, selectAction); 
    121127    } 
    122128 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

    r5028 r5200  
    4848import org.openstreetmap.josm.gui.SideButton; 
    4949import org.openstreetmap.josm.tools.ImageProvider; 
     50import org.openstreetmap.josm.tools.InputMapUtils; 
    5051import org.openstreetmap.josm.tools.MultikeyActionsHandler; 
    5152import org.openstreetmap.josm.tools.MultikeyShortcutAction; 
     
    213214            } 
    214215        }); 
     216         
     217        // Toggle filter "enabled" on Enter 
     218        InputMapUtils.addEnterAction(userTable, new AbstractAction() { 
     219            public void actionPerformed(ActionEvent e) { 
     220                int index = userTable.getSelectedRow(); 
     221                if (index<0) return; 
     222                Filter filter = filterModel.getFilter(index); 
     223                filterModel.setValueAt(!filter.enable, index, FilterTableModel.COL_ENABLED); 
     224            } 
     225        }); 
     226 
     227        // Toggle filter "hiding" on Spacebar 
     228        InputMapUtils.addSpacebarAction(userTable, new AbstractAction() { 
     229            public void actionPerformed(ActionEvent e) { 
     230                int index = userTable.getSelectedRow(); 
     231                if (index<0) return; 
     232                Filter filter = filterModel.getFilter(index); 
     233                filterModel.setValueAt(!filter.hiding, index, FilterTableModel.COL_HIDING); 
     234            } 
     235        }); 
    215236 
    216237        createLayout(userTable, true, Arrays.asList(new SideButton[] { 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java

    r4982 r5200  
    4343import org.openstreetmap.josm.gui.history.HistoryLoadTask; 
    4444import org.openstreetmap.josm.tools.ImageProvider; 
     45import org.openstreetmap.josm.tools.InputMapUtils; 
    4546import org.openstreetmap.josm.tools.Shortcut; 
    4647 
     
    107108        historyTable.getSelectionModel().addListSelectionListener(showHistoryAction); 
    108109        historyTable.getSelectionModel().addListSelectionListener(reloadAction); 
     110         
     111        // Show history dialog on Enter/Spacebar 
     112        InputMapUtils.addEnterAction(historyTable, showHistoryAction); 
     113        InputMapUtils.addSpacebarAction(historyTable, showHistoryAction); 
    109114    } 
    110115 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r5127 r5200  
    6565import org.openstreetmap.josm.tools.CheckParameterUtil; 
    6666import org.openstreetmap.josm.tools.ImageProvider; 
     67import org.openstreetmap.josm.tools.InputMapUtils; 
    6768import org.openstreetmap.josm.tools.MultikeyActionsHandler; 
    6869import org.openstreetmap.josm.tools.MultikeyShortcutAction; 
     
    271272                ); 
    272273        getActionMap().put("delete", deleteLayerAction); 
    273  
    274  
     274         
     275        // Activate layer on Enter key press 
     276        InputMapUtils.addEnterAction(layerList, new AbstractAction() { 
     277            public void actionPerformed(ActionEvent e) { 
     278                activateLayerAction.actionPerformed(null); 
     279                layerList.requestFocus(); 
     280            } 
     281        }); 
     282         
     283        // Show/Activate layer on Enter key press 
     284        InputMapUtils.addSpacebarAction(layerList, showHideLayerAction); 
     285         
    275286        createLayout(layerList, true, Arrays.asList(new SideButton[] { 
    276287                new SideButton(moveUpAction, false), 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r5088 r5200  
    6969import org.openstreetmap.josm.tools.GBC; 
    7070import org.openstreetmap.josm.tools.ImageProvider; 
     71import org.openstreetmap.josm.tools.InputMapUtils; 
    7172import org.openstreetmap.josm.tools.Shortcut; 
    7273import org.openstreetmap.josm.tools.Utils; 
     
    142143        selectionModel.addListSelectionListener(upAction); 
    143144        selectionModel.addListSelectionListener(downAction); 
    144  
     145         
     146        // Toggle style on Enter and Spacebar 
     147        InputMapUtils.addEnterAction(tblStyles, onoffAction); 
     148        InputMapUtils.addSpacebarAction(tblStyles, onoffAction); 
     149         
    145150        createLayout(p, true, Arrays.asList(new SideButton[] { 
    146151                new SideButton(onoffAction, false), 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r5082 r5200  
    2525import javax.swing.Action; 
    2626import javax.swing.DefaultListSelectionModel; 
     27import javax.swing.JComponent; 
    2728import javax.swing.JList; 
    2829import javax.swing.JMenuItem; 
     30import javax.swing.KeyStroke; 
    2931import javax.swing.ListSelectionModel; 
    3032import javax.swing.SwingUtilities; 
     
    6567import org.openstreetmap.josm.gui.widgets.ListPopupMenu; 
    6668import org.openstreetmap.josm.tools.ImageProvider; 
     69import org.openstreetmap.josm.tools.InputMapUtils; 
    6770import org.openstreetmap.josm.tools.Shortcut; 
    6871 
     
    151154        //displaylist.getActionMap().put("deleteRelation", deleteAction); 
    152155 
     156        InputMapUtils.unassignCtrlShiftUpDown(displaylist, JComponent.WHEN_FOCUSED); 
     157         
     158        // Select relation on Ctrl-Enter 
     159        InputMapUtils.addEnterAction(displaylist, selectAction); 
     160 
    153161        addToRelation = new AddToRelation(); 
    154162        popupMenu = new RelationDialogPopupMenu(displaylist); 
     163 
     164        // Edit relation on Ctrl-Enter 
     165        displaylist.getActionMap().put("edit", editAction); 
     166        displaylist.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_MASK), "edit"); 
    155167    } 
    156168 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r5036 r5200  
    7272import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 
    7373import org.openstreetmap.josm.tools.ImageProvider; 
     74import org.openstreetmap.josm.tools.InputMapUtils; 
    7475import org.openstreetmap.josm.tools.Shortcut; 
    7576 
     
    148149 
    149150        popupMenu = new SelectionPopup(lstPrimitives); 
     151        InputMapUtils.addEnterAction(lstPrimitives, actZoomToListSelection); 
    150152    } 
    151153 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

    r5037 r5200  
    2121 
    2222import javax.swing.AbstractAction; 
     23import javax.swing.JComponent; 
    2324import javax.swing.JMenuItem; 
    2425import javax.swing.JOptionPane; 
    2526import javax.swing.JPopupMenu; 
     27import javax.swing.KeyStroke; 
    2628import javax.swing.SwingUtilities; 
    2729import javax.swing.event.TreeSelectionEvent; 
     
    5355import org.openstreetmap.josm.io.OsmTransferException; 
    5456import org.openstreetmap.josm.tools.ImageProvider; 
     57import org.openstreetmap.josm.tools.InputMapUtils; 
    5558import org.openstreetmap.josm.tools.Shortcut; 
    5659import org.xml.sax.SAXException; 
     
    105108        tree.addMouseListener(new ClickWatch()); 
    106109        tree.addTreeSelectionListener(new SelectionWatch()); 
    107  
     110        InputMapUtils.unassignCtrlShiftUpDown(tree, JComponent.WHEN_FOCUSED); 
     111                 
    108112        List<SideButton> buttons = new LinkedList<SideButton>(); 
    109113 
     
    119123            } 
    120124        }); 
     125        InputMapUtils.addEnterAction(tree, selectButton.getAction()); 
     126         
    121127        selectButton.setEnabled(false); 
    122128        buttons.add(selectButton); 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r5155 r5200  
    112112import org.openstreetmap.josm.tools.GBC; 
    113113import org.openstreetmap.josm.tools.ImageProvider; 
     114import org.openstreetmap.josm.tools.InputMapUtils; 
    114115import org.openstreetmap.josm.tools.LanguageInfo; 
    115116import org.openstreetmap.josm.tools.OpenBrowser; 
     
    846847         
    847848        //  unassign some standard shortcuts for JTable to allow upload / download 
    848         InputMap inputMap=SwingUtilities.getUIInputMap(propertyTable,JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); 
    849         inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_UP,InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK)); 
    850         inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK)); 
    851         inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_UP,InputEvent.ALT_MASK|InputEvent.SHIFT_MASK)); 
    852         inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,InputEvent.ALT_MASK|InputEvent.SHIFT_MASK)); 
    853         SwingUtilities.replaceUIInputMap(propertyTable,JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,inputMap); 
     849        InputMapUtils.unassignCtrlShiftUpDown(propertyTable, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); 
    854850         
    855851        // -- add action and shortcut 
    856852        this.btnAdd = new SideButton(addAction); 
    857         btnAdd.setFocusable(true); 
    858         btnAdd.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onEnter"); 
    859         btnAdd.getActionMap().put("onEnter", addAction); 
     853        InputMapUtils.enableEnter(this.btnAdd); 
    860854 
    861855        // -- edit action 
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r5113 r5200  
    4242import org.openstreetmap.josm.tools.GBC; 
    4343import org.openstreetmap.josm.tools.ImageProvider; 
     44import org.openstreetmap.josm.tools.InputMapUtils; 
    4445import org.openstreetmap.josm.tools.OsmUrlToBounds; 
    4546import org.openstreetmap.josm.tools.Utils; 
     
    163164        // -- download button 
    164165        pnl.add(btnDownload = new SideButton(actDownload = new DownloadAction())); 
    165         btnDownload.setFocusable(true); 
    166         btnDownload.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "download"); 
    167         btnDownload.getActionMap().put("download",actDownload); 
     166        InputMapUtils.enableEnter(btnDownload); 
     167         
    168168        makeCheckBoxRespondToEnter(cbDownloadGpxData); 
    169169        makeCheckBoxRespondToEnter(cbDownloadOsmData); 
     
    174174        CancelAction actCancel = new CancelAction(); 
    175175        pnl.add(btnCancel = new SideButton(actCancel)); 
    176         btnCancel.setFocusable(true); 
    177         btnCancel.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 
    178         btnCancel.getActionMap().put("enter",actCancel); 
     176        InputMapUtils.enableEnter(btnCancel); 
    179177 
    180178        // -- cancel on ESC 
     
    185183        SideButton btnHelp; 
    186184        pnl.add(btnHelp = new SideButton(new ContextSensitiveHelpAction(ht("/Action/Download")))); 
    187         btnHelp.setFocusable(true); 
    188         btnHelp.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 
    189         btnHelp.getActionMap().put("enter",btnHelp.getAction()); 
     185        InputMapUtils.enableEnter(btnHelp); 
    190186 
    191187        return pnl; 
  • trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetDialog.java

    r4310 r5200  
    3232import org.openstreetmap.josm.gui.SideButton; 
    3333import org.openstreetmap.josm.tools.ImageProvider; 
     34import org.openstreetmap.josm.tools.InputMapUtils; 
    3435import org.openstreetmap.josm.tools.WindowGeometry; 
    3536 
     
    7475        lstOpenChangesets.addListSelectionListener(closeAction); 
    7576        pnl.add(btnCloseChangesets = new SideButton(closeAction)); 
    76         btnCloseChangesets.setFocusable(true); 
    77         btnCloseChangesets.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 
    78         btnCloseChangesets.getActionMap().put("enter",closeAction); 
     77        InputMapUtils.enableEnter(btnCloseChangesets); 
    7978 
    8079        // -- cancel action 
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r4414 r5200  
    4545import org.openstreetmap.josm.io.OsmApi; 
    4646import org.openstreetmap.josm.tools.ImageProvider; 
     47import org.openstreetmap.josm.tools.InputMapUtils; 
    4748import org.openstreetmap.josm.tools.WindowGeometry; 
    4849 
     
    154155        pnl.add(btnUpload = new SideButton(uploadAction)); 
    155156        btnUpload.setFocusable(true); 
    156         InputMap inputMap = btnUpload.getInputMap(); 
    157         inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "doUpload"); 
    158         btnUpload.getActionMap().put("doUpload", uploadAction); 
     157        InputMapUtils.enableEnter(btnUpload); 
    159158 
    160159        // -- cancel button 
Note: See TracChangeset for help on using the changeset viewer.