001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.util;
003
004import java.util.List;
005
006import javax.swing.Action;
007
008import org.openstreetmap.josm.tools.Shortcut;
009
010/**
011 * Action implementing a multikey shortcut - shortcuts like Ctrl+Alt+S,n will toggle n-th layer visibility.
012 * @since 4595
013 */
014public interface MultikeyShortcutAction extends Action {
015
016    /**
017     * Information for a Multikey action
018     */
019    class MultikeyInfo {
020        private final int index;
021        private final String description;
022
023        public MultikeyInfo(int index, String description) {
024            this.index = index;
025            this.description = description;
026        }
027
028        public int getIndex() {
029            return index;
030        }
031
032        public char getShortcut() {
033            if (index < 9)
034                return (char) ('1' + index);
035            else if (index == 9)
036                return '0';
037            else
038                return (char) ('A' + index - 10);
039        }
040
041        public String getDescription() {
042            return description;
043        }
044    }
045
046    Shortcut getMultikeyShortcut();
047
048    /**
049     * Execute a multi key action
050     * @param index The index to execute
051     * @param repeatLastAction {@code true} if the last action should be executed if no action is found for the given index.
052     */
053    void executeMultikeyAction(int index, boolean repeatLastAction);
054
055    List<MultikeyInfo> getMultikeyCombinations();
056
057    MultikeyInfo getLastMultikeyAction();
058
059}