Changeset 4604 in josm


Ignore:
Timestamp:
Nov 21, 2011 10:16:25 PM (18 months ago)
Author:
jttt
Message:

Multikey action improvements (see #5515):

  • show text in status bar after shortcut is pressed
  • number layers from 1
  • do not allow Repeat for last layer if layer index conflicts with shortcut
Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

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

    r3783 r4604  
    9595    } 
    9696 
    97     ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 11); 
    98     ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20); 
    99     JTextField helpText = new JTextField(); 
    100     ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 11); 
    101     ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6); 
    102     ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6); 
    103     ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 10); 
     97    final ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 11); 
     98    final ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20); 
     99    final JTextField helpText = new JTextField(); 
     100    final ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 11); 
     101    final ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6); 
     102    final ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6); 
     103    final ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 10); 
    104104 
    105105    /** 
     
    108108     */ 
    109109    public Thread thread; 
     110 
     111    private final List<StatusTextHistory> statusText = new ArrayList<StatusTextHistory>(); 
     112 
     113    private static class StatusTextHistory { 
     114        final Object id; 
     115        final String text; 
     116 
     117        public StatusTextHistory(Object id, String text) { 
     118            this.id = id; 
     119            this.text = text; 
     120        } 
     121 
     122        @Override 
     123        public boolean equals(Object obj) { 
     124            return obj instanceof StatusTextHistory && ((StatusTextHistory)obj).id == id; 
     125        } 
     126 
     127        @Override 
     128        public int hashCode() { 
     129            return System.identityHashCode(id); 
     130        } 
     131    } 
    110132 
    111133    /** 
     
    218240                                        final JLabel lbl = new JLabel( 
    219241                                                "<html>"+tr("Middle click again to cycle through.<br>"+ 
    220                                                 "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>", 
    221                                                 null, 
    222                                                 JLabel.HORIZONTAL 
    223                                         ); 
     242                                                        "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>", 
     243                                                        null, 
     244                                                        JLabel.HORIZONTAL 
     245                                                ); 
    224246                                        lbl.setHorizontalAlignment(JLabel.LEFT); 
    225247                                        c.add(lbl, GBC.eol().insets(2, 0, 2, 0)); 
     
    472494                    ImageProvider.get(OsmPrimitiveType.from(osm)), 
    473495                    JLabel.HORIZONTAL 
    474             ) { 
     496                    ) { 
    475497                // This is necessary so the label updates its colors when the 
    476498                // selection is changed from the outside 
     
    656678 
    657679    public void setHelpText(String t) { 
    658         helpText.setText(t); 
    659         helpText.setToolTipText(t); 
     680        setHelpText(null, t); 
     681    } 
     682    public void setHelpText(Object id, String text)  { 
     683 
     684        StatusTextHistory entry = new StatusTextHistory(id, text); 
     685 
     686        statusText.remove(entry); 
     687        statusText.add(entry); 
     688 
     689        helpText.setText(text); 
     690        helpText.setToolTipText(text); 
     691    } 
     692    public void resetHelpText(Object id) { 
     693        if (statusText.isEmpty()) 
     694            return; 
     695 
     696        StatusTextHistory entry = new StatusTextHistory(id, null); 
     697        if (statusText.get(statusText.size() - 1).equals(entry)) { 
     698            if (statusText.size() == 1) { 
     699                setHelpText(""); 
     700            } else { 
     701                StatusTextHistory history = statusText.get(statusText.size() - 2); 
     702                setHelpText(history.id, history.text); 
     703            } 
     704        } 
     705        statusText.remove(entry); 
    660706    } 
    661707    public void setAngle(double a) { 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r4596 r4604  
    460460 
    461461        @Override 
    462         public void executeMultikeyAction(int index) { 
     462        public void executeMultikeyAction(int index, boolean repeat) { 
    463463            Layer l = LayerListDialog.getLayerForIndex(index); 
    464464            if (l != null) { 
    465465                l.toggleVisible(); 
    466466                lastLayer = new WeakReference<Layer>(l); 
    467             } 
    468         } 
    469  
    470         @Override 
    471         public void repeateLastMultikeyAction() { 
    472             if (lastLayer != null) { 
    473                 Layer l = lastLayer.get(); 
     467            } else if (repeat && lastLayer != null) { 
     468                l = lastLayer.get(); 
    474469                if (LayerListDialog.isLayerValid(l)) { 
    475470                    l.toggleVisible(); 
     
    690685 
    691686        @Override 
    692         public void executeMultikeyAction(int index) { 
     687        public void executeMultikeyAction(int index, boolean repeat) { 
    693688            Layer l = LayerListDialog.getLayerForIndex(index); 
    694689            if (l != null) { 
    695690                execute(l); 
    696691            } 
    697         } 
    698  
    699         @Override 
    700         public void repeateLastMultikeyAction() { 
    701             // Do nothing, repating not supported 
    702692        } 
    703693 
     
    15581548        List<Layer> layers = Main.map.mapView.getAllLayersAsList(); 
    15591549 
    1560         if (index < layers.size()) 
     1550        if (index < layers.size() && index >= 0) 
    15611551            return layers.get(index); 
    15621552        else 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r4536 r4604  
    3232import java.util.LinkedList; 
    3333import java.util.List; 
     34import java.util.Map; 
    3435import java.util.Map.Entry; 
    35 import java.util.Map; 
    3636import java.util.Set; 
    3737import java.util.TreeMap; 
     
    6767import org.openstreetmap.josm.Main; 
    6868import org.openstreetmap.josm.actions.JosmAction; 
     69import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 
     70import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 
    6971import org.openstreetmap.josm.command.ChangeCommand; 
    7072import org.openstreetmap.josm.command.ChangePropertyCommand; 
     
    7274import org.openstreetmap.josm.command.SequenceCommand; 
    7375import org.openstreetmap.josm.data.SelectionChangedListener; 
     76import org.openstreetmap.josm.data.osm.DataSet; 
    7477import org.openstreetmap.josm.data.osm.IRelation; 
    7578import org.openstreetmap.josm.data.osm.Node; 
     
    105108import org.openstreetmap.josm.tools.Shortcut; 
    106109import org.openstreetmap.josm.tools.Utils; 
    107 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 
    108 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 
    109110 
    110111/** 
     
    170171    // button in the upper right corner of this dialog 
    171172    public static JPanel pluginHook = new JPanel(); 
    172      
     173 
    173174    private JPopupMenu propertyMenu; 
    174175    private JPopupMenu membershipMenu; 
     
    338339                    ed.setButtonIcons(new String[]{"purge", "cancel"}); 
    339340                    ed.setContent(tr("You changed the key from ''{0}'' to ''{1}''.\n" 
    340                     + "The new key is already used, overwrite values?", key, newkey)); 
     341                            + "The new key is already used, overwrite values?", key, newkey)); 
    341342                    ed.setCancelButton(2); 
    342343                    ed.toggleEnable("overwriteEditKey"); 
    343344                    ed.showDialog(); 
    344345 
    345                     if (ed.getValue() != 1) { 
     346                    if (ed.getValue() != 1) 
    346347                        return; 
    347                     } 
    348348                    break; 
    349349                } 
     
    389389 
    390390    /** 
    391      * For a given key k, return a list of keys which are used as keys for  
     391     * For a given key k, return a list of keys which are used as keys for 
    392392     * auto-completing values to increase the search space. 
    393393     * @param key the key k 
     
    395395     */ 
    396396    static List<String> getAutocompletionKeys(String key) { 
    397         if ("name".equals(key) || "addr:street".equals(key)) { 
     397        if ("name".equals(key) || "addr:street".equals(key)) 
    398398            return Arrays.asList("addr:street", "name"); 
    399         } else { 
     399        else 
    400400            return Arrays.asList(key); 
    401         } 
    402401    } 
    403402 
     
    424423     */ 
    425424    void add() { 
    426         Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 
     425        DataSet ds = Main.main.getCurrentDataSet(); 
     426        if (ds == null) return; 
     427        Collection<OsmPrimitive> sel = ds.getSelected(); 
    427428        if (sel.isEmpty()) return; 
    428429 
     
    435436        List<AutoCompletionListItem> keyList = autocomplete.getKeys(); 
    436437 
    437         AutoCompletionListItem itemToSelect = null;  
     438        AutoCompletionListItem itemToSelect = null; 
    438439        // remove the object's tag keys from the list 
    439440        Iterator<AutoCompletionListItem> iter = keyList.iterator(); 
     
    445446            for (int i = 0; i < propertyData.getRowCount(); ++i) { 
    446447                if (item.getValue().equals(propertyData.getValueAt(i, 0))) { 
    447                     if (itemToSelect == item) 
     448                    if (itemToSelect == item) { 
    448449                        itemToSelect = null; 
     450                    } 
    449451                    iter.remove(); 
    450452                    break; 
     
    468470            keys.setSelectedItem(itemToSelect); 
    469471            /* don't add single chars, as they are no properly selected */ 
    470             if(lastAddValue != null && lastAddValue.length() > 1) 
     472            if(lastAddValue != null && lastAddValue.length() > 1) { 
    471473                values.setSelectedItem(lastAddValue); 
     474            } 
    472475        } 
    473476 
     
    506509        // get the combo box' editor component 
    507510        JTextComponent editor = (JTextComponent)values.getEditor() 
    508         .getEditorComponent(); 
     511                .getEditorComponent(); 
    509512        // Refresh the values model when focus is gained 
    510513        FocusAdapter focus = new FocusAdapter() { 
     
    632635        propertyMenu.addSeparator(); 
    633636        propertyMenu.add(helpAction); 
    634          
     637 
    635638        propertyData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")}); 
    636639        propertyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
     
    813816        getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 
    814817                KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),"delete" 
    815         ); 
     818                ); 
    816819        getActionMap().put("delete", deleteAction); 
    817820 
    818821        JScrollPane scrollPane = (JScrollPane) createLayout(bothTables, true, Arrays.asList(new SideButton[] { 
    819             this.btnAdd, this.btnEdit, this.btnDel 
     822                this.btnAdd, this.btnEdit, this.btnDel 
    820823        })); 
    821824 
     
    962965                return comp; 
    963966            }} 
    964         ); 
     967                ); 
    965968 
    966969        for (Relation r: sortedRelations) { 
     
    10271030            super(tr("Delete"), "dialogs/delete", tr("Delete the selected key in all objects"), 
    10281031                    Shortcut.registerShortcut("properties:delete", tr("Delete Properties"), KeyEvent.VK_D, 
    1029                     Shortcut.GROUP_MNEMONIC), false); 
     1032                            Shortcut.GROUP_MNEMONIC), false); 
    10301033            updateEnabledState(); 
    10311034        } 
     
    10981101                    (propertyTable != null && propertyTable.getSelectedRowCount() == 1) 
    10991102                    ^ (membershipTable != null && membershipTable.getSelectedRowCount() == 1) 
    1100             ); 
     1103                    ); 
    11011104        } 
    11021105 
     
    11111114            super(tr("Add"), "dialogs/add", tr("Add a new key/value pair to all objects"), 
    11121115                    Shortcut.registerShortcut("properties:add", tr("Add Property"), KeyEvent.VK_A, 
    1113                     Shortcut.GROUP_MNEMONIC), false); 
     1116                            Shortcut.GROUP_MNEMONIC), false); 
    11141117        } 
    11151118 
     
    11241127            super(tr("Edit"), "dialogs/edit", tr("Edit the value of the selected key for all objects"), 
    11251128                    Shortcut.registerShortcut("properties:edit", tr("Edit Properties"), KeyEvent.VK_S, 
    1126                     Shortcut.GROUP_MNEMONIC), false); 
     1129                            Shortcut.GROUP_MNEMONIC), false); 
    11271130            updateEnabledState(); 
    11281131        } 
     
    11461149                    (propertyTable != null && propertyTable.getSelectedRowCount() == 1) 
    11471150                    ^ (membershipTable != null && membershipTable.getSelectedRowCount() == 1) 
    1148             ); 
     1151                    ); 
    11491152        } 
    11501153 
     
    11741177                            ((Map<String,Integer>)propertyData.getValueAt(row, 1)) 
    11751178                            .entrySet().iterator().next().getKey(), "UTF-8" 
    1176                     ); 
     1179                            ); 
    11771180 
    11781181                    uris.add(new URI(String.format("%s%sTag:%s=%s", base, lang, key, val))); 
     
    11861189                    String type = URLEncoder.encode( 
    11871190                            ((Relation)membershipData.getValueAt(row, 0)).get("type"), "UTF-8" 
    1188                     ); 
     1191                            ); 
    11891192 
    11901193                    if (type != null && !type.equals("")) { 
     
    12201223                                            .replace("=", "%3D") /* do not URLencode whole string! */ 
    12211224                                            .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 
    1222                                     ).toURL().openConnection(); 
     1225                                            ).toURL().openConnection(); 
    12231226                                    conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000); 
    12241227 
     
    12571260        return propertyMenu.add(a); 
    12581261    } 
    1259      
     1262 
    12601263    public void addPropertyPopupMenuListener(PopupMenuListener l) { 
    12611264        propertyMenu.addPopupMenuListener(l); 
     
    12651268        propertyMenu.addPopupMenuListener(l); 
    12661269    } 
    1267      
     1270 
    12681271    @SuppressWarnings("unchecked") 
    12691272    public Tag getSelectedProperty() { 
     
    12721275        TreeMap<String, Integer> map = (TreeMap<String, Integer>) propertyData.getValueAt(row, 1); 
    12731276        return new Tag( 
    1274                 propertyData.getValueAt(row, 0).toString(),  
     1277                propertyData.getValueAt(row, 0).toString(), 
    12751278                map.size() > 1 ? "" : map.keySet().iterator().next()); 
    12761279    } 
    1277      
     1280 
    12781281    public void addMembershipPopupMenuSeparator() { 
    12791282        membershipMenu.addSeparator(); 
    12801283    } 
    1281      
     1284 
    12821285    public JMenuItem addMembershipPopupMenuAction(Action a) { 
    12831286        return membershipMenu.add(a); 
    12841287    } 
    1285      
     1288 
    12861289    public void addMembershipPopupMenuListener(PopupMenuListener l) { 
    12871290        membershipMenu.addPopupMenuListener(l); 
     
    12911294        membershipMenu.addPopupMenuListener(l); 
    12921295    } 
    1293      
     1296 
    12941297    public IRelation getSelectedMembershipRelation() { 
    12951298        int row = membershipTable.getSelectedRow(); 
     
    13011304        public void setRelation(Relation relation); 
    13021305    } 
    1303      
     1306 
    13041307    static abstract class AbstractRelationAction extends AbstractAction implements RelationRelated { 
    13051308        protected Relation relation; 
     
    13111314        } 
    13121315    } 
    1313      
     1316 
    13141317    static class SelectRelationAction extends AbstractRelationAction { 
    13151318        boolean selectionmode; 
     
    13821385                    buildSetOfIncompleteMembers(relation), 
    13831386                    Main.map.mapView.getEditLayer() 
    1384             )); 
     1387                    )); 
    13851388        } 
    13861389    } 
     
    13921395        @Override 
    13931396        public void actionPerformed(ActionEvent ae) { 
    1394             if (propertyTable.getSelectedRowCount() != 1) { 
     1397            if (propertyTable.getSelectedRowCount() != 1) 
    13951398                return; 
    1396             } 
    13971399            String key = propertyData.getValueAt(propertyTable.getSelectedRow(), 0).toString(); 
    13981400            Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 
    1399             if (sel.isEmpty()) { 
     1401            if (sel.isEmpty()) 
    14001402                return; 
    1401             } 
    14021403            Set<String> values = new TreeSet<String>(); 
    14031404            for (OsmPrimitive p : sel) { 
     
    14701471 
    14711472        public void actionPerformed(ActionEvent e) { 
    1472             if (propertyTable.getSelectedRowCount() != 1) { 
     1473            if (propertyTable.getSelectedRowCount() != 1) 
    14731474                return; 
    1474             } 
    14751475            String key = propertyData.getValueAt(propertyTable.getSelectedRow(), 0).toString(); 
    14761476            Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 
    1477             if (sel.isEmpty()) { 
     1477            if (sel.isEmpty()) 
    14781478                return; 
    1479             } 
    14801479            String sep = ""; 
    14811480            String s = ""; 
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r4595 r4604  
    460460 
    461461        @Override 
    462         public void executeMultikeyAction(int index) { 
     462        public void executeMultikeyAction(int index, boolean repeat) { 
    463463            Layer l = LayerListDialog.getLayerForIndex(index); 
    464             if (l != null && l instanceof MarkerLayer) { 
    465                 execute((MarkerLayer) l); 
    466             } 
    467         } 
    468  
    469         @Override 
    470         public void repeateLastMultikeyAction() { 
    471             if (lastLayer != null) { 
    472                 MarkerLayer l = lastLayer.get(); 
     464            if (l != null) { 
     465                if (l instanceof MarkerLayer) { 
     466                    execute((MarkerLayer) l); 
     467                } 
     468            } else if (repeat && lastLayer != null) { 
     469                l = lastLayer.get(); 
    473470                if (LayerListDialog.isLayerValid(l)) { 
    474                     execute(l); 
    475                 } 
    476             } 
    477         } 
     471                    execute((MarkerLayer) l); 
     472                } 
     473            } 
     474        } 
     475 
    478476 
    479477        private void execute(MarkerLayer l) { 
     
    516514 
    517515        @Override 
    518         public void executeMultikeyAction(int index) { 
     516        public void executeMultikeyAction(int index, boolean repeat) { 
    519517            Layer l = LayerListDialog.getLayerForIndex(index); 
    520             if (l != null && l instanceof MarkerLayer) { 
    521                 execute((MarkerLayer) l); 
    522             } 
    523         } 
    524  
    525         @Override 
    526         public void repeateLastMultikeyAction() { 
    527             if (lastLayer != null) { 
    528                 MarkerLayer l = lastLayer.get(); 
     518            if (l != null) { 
     519                if (l instanceof MarkerLayer) { 
     520                    execute((MarkerLayer) l); 
     521                } 
     522            } else if (repeat && lastLayer != null) { 
     523                l = lastLayer.get(); 
    529524                if (LayerListDialog.isLayerValid(l)) { 
    530                     execute(l); 
     525                    execute((MarkerLayer) l); 
    531526                } 
    532527            } 
  • trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java

    r4595 r4604  
    11// License: GPL. For details, see LICENSE file. 
    22package org.openstreetmap.josm.tools; 
     3 
     4import static org.openstreetmap.josm.tools.I18n.tr; 
    35 
    46import java.awt.KeyEventDispatcher; 
     
    2123public class MultikeyActionsHandler { 
    2224 
    23     private static final long DIALOG_DELAY = 2000; 
     25    private static final long DIALOG_DELAY = 1000; 
     26    private static final String STATUS_BAR_ID = new String("multikeyShortcut"); 
    2427 
    2528    private class MyKeyEventDispatcher implements KeyEventDispatcher { 
     
    3134 
    3235            if (lastAction != null && e.getID() == KeyEvent.KEY_PRESSED) { 
    33                 if (e.getKeyCode() == lastAction.shortcut.getKeyCode()) { 
    34                     lastAction.action.repeateLastMultikeyAction(); 
    35                 } else { 
    36                     int index = getIndex(e.getKeyChar()); 
    37                     if (index >= 0) { 
    38                         lastAction.action.executeMultikeyAction(index); 
    39                     } 
     36                int index = getIndex(e.getKeyCode()); 
     37                if (index >= 0) { 
     38                    lastAction.action.executeMultikeyAction(index, e.getKeyCode() == lastAction.shortcut.getKeyCode()); 
    4039                } 
    4140                lastAction = null; 
     41                Main.map.statusLine.resetHelpText(STATUS_BAR_ID); 
    4242                return true; 
    4343            } 
     
    4545        } 
    4646 
    47         private int getIndex(char lastKey) { 
    48             if (lastKey >= KeyEvent.VK_0 && lastKey <= KeyEvent.VK_9) 
    49                 return lastKey - KeyEvent.VK_0; 
     47        private int getIndex(int lastKey) { 
     48            if (lastKey >= KeyEvent.VK_1 && lastKey <= KeyEvent.VK_9) 
     49                return lastKey - KeyEvent.VK_1; 
     50            else if (lastKey == KeyEvent.VK_0) 
     51                return 9; 
    5052            else if (lastKey >= KeyEvent.VK_A && lastKey <= KeyEvent.VK_Z) 
    5153                return lastKey - KeyEvent.VK_A + 10; 
     
    7072            lastAction = this; 
    7173            timer.schedule(new MyTimerTask(lastTimestamp, lastAction), DIALOG_DELAY); 
     74            Main.map.statusLine.setHelpText(STATUS_BAR_ID, tr("{0}... [please type its number]", (String) action.getValue(SHORT_DESCRIPTION))); 
    7275        } 
    7376 
     
    132135        layers.add(lbTitle); 
    133136 
     137        char repeatKey = (char) action.shortcut.getKeyCode(); 
     138        boolean repeatKeyUsed = false; 
     139 
    134140 
    135141        for (final MultikeyInfo info: action.action.getMultikeyCombinations()) { 
     142 
     143            if (info.getShortcut() == repeatKey) { 
     144                repeatKeyUsed = true; 
     145            } 
     146 
    136147            JMenuItem item = new JMenuItem(formatMenuText(action.shortcut, String.valueOf(info.getShortcut()), info.getDescription())); 
    137148            item.setMnemonic(info.getShortcut()); 
     
    139150                @Override 
    140151                public void actionPerformed(ActionEvent e) { 
    141                     action.action.executeMultikeyAction(info.getIndex()); 
     152                    Main.map.statusLine.resetHelpText(STATUS_BAR_ID); 
     153                    action.action.executeMultikeyAction(info.getIndex(), false); 
    142154                } 
    143155            }); 
     
    145157        } 
    146158 
    147         MultikeyInfo lastLayer = action.action.getLastMultikeyAction(); 
    148         if (lastLayer != null) { 
    149             JMenuItem repeateItem = new JMenuItem(formatMenuText(action.shortcut, 
    150                     KeyEvent.getKeyText(action.shortcut.getKeyCode()), 
    151                     "Repeat " + lastLayer.getDescription())); 
    152             repeateItem.addActionListener(new ActionListener() { 
    153                 @Override 
    154                 public void actionPerformed(ActionEvent e) { 
    155                     action.action.repeateLastMultikeyAction(); 
    156                 } 
    157             }); 
    158             layers.add(repeateItem); 
     159        if (!repeatKeyUsed) { 
     160            MultikeyInfo lastLayer = action.action.getLastMultikeyAction(); 
     161            if (lastLayer != null) { 
     162                JMenuItem repeateItem = new JMenuItem(formatMenuText(action.shortcut, 
     163                        KeyEvent.getKeyText(action.shortcut.getKeyCode()), 
     164                        "Repeat " + lastLayer.getDescription())); 
     165                repeateItem.setMnemonic(action.shortcut.getKeyCode()); 
     166                repeateItem.addActionListener(new ActionListener() { 
     167                    @Override 
     168                    public void actionPerformed(ActionEvent e) { 
     169                        Main.map.statusLine.resetHelpText(STATUS_BAR_ID); 
     170                        action.action.executeMultikeyAction(-1, true); 
     171                    } 
     172                }); 
     173                layers.add(repeateItem); 
     174            } 
    159175        } 
    160176 
  • trunk/src/org/openstreetmap/josm/tools/MultikeyShortcutAction.java

    r4595 r4604  
    2222 
    2323        public char getShortcut() { 
    24             if (index < 10) 
    25                 return (char)('0' + index); 
     24            if (index < 9) 
     25                return (char)('1' + index); 
     26            else if (index == 9) 
     27                return '0'; 
    2628            else 
    2729                return (char)('A' +  index - 10); 
     
    3335    } 
    3436 
    35     void executeMultikeyAction(int index); 
    36     void repeateLastMultikeyAction(); 
     37    void executeMultikeyAction(int index, boolean repeatLastAction); 
    3738    List<MultikeyInfo> getMultikeyCombinations(); 
    3839    MultikeyInfo getLastMultikeyAction(); 
Note: See TracChangeset for help on using the changeset viewer.