// check if something collides with an existing shortcut public static Shortcut findShortcut(int requestedKey, int modifier) { if (modifier == getGroupModifier(NONE)) return null; for (Shortcut sc : shortcuts.values()) { if (sc.isSame(requestedKey, modifier)) return sc; } return null; }
// shutdown handling public static boolean savePrefs() { boolean changed = false; for (Shortcut sc : shortcuts.values()) { changed = changed | sc.save(); } return changed; }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { int row1 = shortcutTable.convertRowIndexToModel(row); Shortcut sc = (Shortcut) model.getValueAt(row1, -1); if (sc == null) return null; JLabel label = (JLabel) super.getTableCellRendererComponent( table, name ? sc.getLongText() : sc.getKeyText(), isSelected, hasFocus, row, column); label.setBackground(Main.pref.getUIColor("Table.background")); if (isSelected) { label.setForeground(Main.pref.getUIColor("Table.foreground")); } if (sc.getAssignedUser()) { label.setBackground( Main.pref.getColor(marktr("Shortcut Background: User"), new Color(200, 255, 200))); } else if (!sc.getAssignedDefault()) { label.setBackground( Main.pref.getColor(marktr("Shortcut Background: Modified"), new Color(255, 255, 200))); } return label; }
private JButton addButtonAndShortcut(ActionDefinition action) { Action act = action.getParametrizedAction(); JButton b = control.add(act); Shortcut sc = null; if (action.getAction() instanceof JosmAction) { sc = ((JosmAction) action.getAction()).getShortcut(); if (sc.getAssignedKey() == KeyEvent.CHAR_UNDEFINED) { sc = null; } } long paramCode = 0; if (action.hasParameters()) { paramCode = action.parameters.hashCode(); } String tt = action.getDisplayTooltip(); if (tt == null) { tt = ""; } if (sc == null || paramCode != 0) { String name = (String) action.getAction().getValue("toolbar"); if (name == null) { name = action.getDisplayName(); } if (paramCode != 0) { name = name + paramCode; } String desc = action.getDisplayName() + ((paramCode == 0) ? "" : action.parameters.toString()); sc = Shortcut.registerShortcut( "toolbar:" + name, tr("Toolbar: {0}", desc), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE); Main.unregisterShortcut(sc); Main.registerActionShortcut(act, sc); // add shortcut info to the tooltip if needed if (sc.getAssignedUser()) { if (tt.startsWith("<html>") && tt.endsWith("</html>")) { tt = tt.substring(6, tt.length() - 6); } tt = Main.platform.makeTooltip(tt, sc); } } if (!tt.isEmpty()) { b.setToolTipText(tt); } return b; }
/** * Constructs a new {@code MapView}. * * @param contentPane The content pane used to register shortcuts in its {@link InputMap} and * {@link ActionMap} * @param viewportData the initial viewport of the map. Can be null, then the viewport is derived * from the layer data. */ public MapView(final JPanel contentPane, final ViewportData viewportData) { initialViewport = viewportData; Main.pref.addPreferenceChangeListener(this); final boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null; addComponentListener( new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { removeComponentListener(this); for (JComponent c : getMapNavigationComponents(MapView.this)) { MapView.this.add(c); } mapMover = new MapMover(MapView.this, contentPane); } }); // listend to selection changes to redraw the map DataSet.addSelectionListener(repaintSelectionChangedListener); // store the last mouse action this.addMouseMotionListener( new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { mouseMoved(e); } @Override public void mouseMoved(MouseEvent e) { lastMEvent = e; } }); this.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent me) { // focus the MapView component when mouse is pressed inside it requestFocus(); } }); if (Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null) { setFocusTraversalKeysEnabled(false); } }
public static Shortcut createShortcut() { return Shortcut.registerShortcut( "system:copytags", tr("Edit: {0}", tr("Copy Tags")), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE); }
public CopyAction() { putValue(NAME, tr("Copy")); putValue(SHORT_DESCRIPTION, tr("Copy the selected vias to the clipboard")); putValue(SMALL_ICON, ImageProvider.get("copy")); putValue(ACCELERATOR_KEY, Shortcut.getCopyKeyStroke()); delegate = ViaList.this.getActionMap().get("copy"); }
public PasteAction() { putValue(NAME, tr("Paste")); putValue(SHORT_DESCRIPTION, tr("Insert ''via'' objects from the clipboard")); putValue(SMALL_ICON, ImageProvider.get("paste")); putValue(ACCELERATOR_KEY, Shortcut.getPasteKeyStroke()); delegate = ViaList.this.getActionMap().get("paste"); updateEnabledState(); }
/** * Constructs a new {@code RemoveAction}. * * @param memberTable member table * @param memberTableModel member table model * @param actionMapKey action map key */ public RemoveAction( MemberTable memberTable, MemberTableModel memberTableModel, String actionMapKey) { super(memberTable, memberTableModel, actionMapKey); putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete")); putValue(NAME, tr("Remove")); Shortcut sc = Shortcut.registerShortcut( "relationeditor:remove", tr("Relation Editor: Remove"), KeyEvent.VK_DELETE, Shortcut.ALT); sc.setAccelerator(this); putValue( SHORT_DESCRIPTION, Main.platform.makeTooltip( tr("Remove the currently selected members from this relation"), sc)); setEnabled(false); }
private static Shortcut reassignShortcut( String shortText, String longText, int requestedKey, Shortcut conflict, int m, int k, int newmodifier) { Shortcut newsc = new Shortcut(shortText, longText, requestedKey, m, k, newmodifier, false, false); Main.info( tr( "Silent shortcut conflict: ''{0}'' moved by ''{1}'' to ''{2}''.", shortText, conflict.getShortText(), newsc.getKeyText())); newsc.saveDefault(); shortcuts.put(shortText, newsc); return newsc; }
/** Constructs a new {@code SearchAction}. */ public SearchAction() { super( tr("Search..."), "dialogs/search", tr("Search for objects."), Shortcut.registerShortcut("system:find", tr("Search..."), KeyEvent.VK_F, Shortcut.CTRL), true); putValue("help", ht("/Action/Search")); }
/** Create an open action. The name is "Open a file". */ public OpenFileAction() { super( tr("Open..."), "open", tr("Open a file."), Shortcut.registerShortcut( "system:open", tr("File: {0}", tr("Open...")), KeyEvent.VK_O, Shortcut.CTRL)); putValue("help", ht("/Action/Open")); }
/** * Construct a new DeleteAction. Mnemonic is the delete - key. * * @param mapFrame The frame this action belongs to. */ public DeleteAction(MapFrame mapFrame) { super( tr("Delete Mode"), "delete", tr("Delete nodes or ways."), Shortcut.registerShortcut( "mapmode:delete", tr("Mode: {0}", tr("Delete")), KeyEvent.VK_DELETE, Shortcut.CTRL), mapFrame, ImageProvider.getCursor("normal", "delete")); }
/** * Adds the map navigation components to a * * @param forMapView The map view to get the components for. * @return A list containing the correctly positioned map navigation components. */ public static List<? extends JComponent> getMapNavigationComponents(MapView forMapView) { MapSlider zoomSlider = new MapSlider(forMapView); zoomSlider.setBounds(3, 0, 114, 30); zoomSlider.setFocusTraversalKeysEnabled(Shortcut.findShortcut(KeyEvent.VK_TAB, 0) == null); MapScaler scaler = new MapScaler(forMapView); scaler.setLocation(10, 30); return Arrays.asList(zoomSlider, scaler); }
/** Create a new SplitWayAction. */ public SplitWayAction() { super( tr("Split Way"), "splitway", tr("Split a way at the selected node."), Shortcut.registerShortcut( "tools:splitway", tr("Tool: {0}", tr("Split Way")), KeyEvent.VK_P, Shortcut.DIRECT), true); putValue("help", ht("/Action/SplitWay")); }
public PurgeAction() { /* translator note: other expressions for "purge" might be "forget", "clean", "obliterate", "prune" */ super( tr("Purge..."), "purge", tr("Forget objects but do not delete them on server when uploading."), Shortcut.registerShortcut( "system:purge", tr("Edit: {0}", tr("Purge")), KeyEvent.VK_P, Shortcut.CTRL_SHIFT), true); putValue("help", HelpUtil.ht("/Action/Purge")); }
public AudioFwdAction() { super( trc("audio", "Forward"), "audio-fwd", trc("audio", "Jump forward"), Shortcut.registerShortcut( "audio:forward", tr("Audio: {0}", trc("audio", "Forward")), KeyEvent.VK_F7, Shortcut.GROUP_DIRECT), true); }
// Adds the menu entry, Shortcuts, etc. public JoinAreasAction() { super( tr("Join overlapping Areas"), "joinareas", tr("Joins areas that overlap each other"), Shortcut.registerShortcut( "tools:joinareas", tr("Tool: {0}", tr("Join overlapping Areas")), KeyEvent.VK_J, Shortcut.SHIFT), true); }
private MapillaryFilterDialog() { super( tr("Mapillary filter"), "mapillaryfilter.png", tr("Open Mapillary filter dialog"), Shortcut.registerShortcut( tr("Mapillary filter"), tr("Open Mapillary filter dialog"), KeyEvent.VK_M, Shortcut.NONE), 200); this.panel = new JPanel(); this.signChooser.setEnabled(false); JPanel signChooserPanel = new JPanel(); signChooserPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); signChooserPanel.add(this.signChooser); JPanel fromPanel = new JPanel(); fromPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); fromPanel.add(new JLabel("Not older than: ")); this.spinner = new SpinnerNumberModel(1, 0, 10000, 1); fromPanel.add(new JSpinner(this.spinner)); this.time = new JComboBox<>(TIME_LIST); fromPanel.add(this.time); JPanel userSearchPanel = new JPanel(); userSearchPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); this.user = new JTextField(10); this.user.addActionListener(new UpdateAction()); userSearchPanel.add(new JLabel("User")); userSearchPanel.add(this.user); this.imported.setSelected(true); this.downloaded.setSelected(true); JPanel col1 = new JPanel(new GridLayout(2, 1)); col1.add(this.downloaded); col1.add(fromPanel); this.panel.add(col1); JPanel col2 = new JPanel(new GridLayout(2, 1)); col2.add(this.imported); col2.add(userSearchPanel); this.panel.add(col2); JPanel col3 = new JPanel(new GridLayout(2, 1)); col3.add(this.onlySigns); col3.add(signChooserPanel); this.panel.add(col3); createLayout( this.panel, true, Arrays.asList(new SideButton[] {this.updateButton, this.resetButton})); }
public UndoSelectionAction() { super( tr("Undo selection"), "undoselection", tr("Reselect last added object or selection form history"), Shortcut.registerShortcut( "tools:undoselection", tr("Tool: {0}", "Undo selection"), KeyEvent.VK_Z, Shortcut.CTRL_SHIFT), true); putValue("help", ht("/Action/UndoSelection")); }
PointInfoAction(MapFrame mapFrame) { super( tr("Point info"), "info-sml", tr("Point info."), Shortcut.registerShortcut( "tools:pointInfo", tr("Tool: {0}", tr("Point info")), KeyEvent.VK_X, Shortcut.CTRL_SHIFT), mapFrame, getCursor()); }
/** Constructor */ public CheckAction(LicenseChangePlugin plugin) { super( tr("License Check"), "licensechange", tr("Performs the license check"), Shortcut.registerShortcut( "tools:licensechange", tr("Tool: {0}", tr("License Check")), KeyEvent.VK_C, Shortcut.ALT_CTRL_SHIFT), true); this.plugin = plugin; }
/** * Construct the action with "Save" as label. * * @param layer Save this layer. */ public SaveAsAction() { super( tr("Save As..."), "save_as", tr("Save the current data to a new file."), Shortcut.registerShortcut( "system:saveas", tr("File: {0}", tr("Save As...")), KeyEvent.VK_S, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT)); putValue("help", ht("/Action/SaveAs")); }
public BuildingSizeAction() { super( tr("Set buildings size"), "mapmode/building", tr("Set buildings size"), Shortcut.registerShortcut( "edit:buildingsdialog", tr("Edit: {0}", tr("Set buildings size")), KeyEvent.VK_W, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); }
/** Constructs a new {@code AlignInCircleAction}. */ public AlignInCircleAction() { super( tr("Align Nodes in Circle"), "aligncircle", tr("Move the selected nodes into a circle."), Shortcut.registerShortcut( "tools:aligncircle", tr("Tool: {0}", tr("Align Nodes in Circle")), KeyEvent.VK_O, Shortcut.DIRECT), true); putValue("help", ht("/Action/AlignInCircle")); }
public ConflateAction() { // TODO: make sure shortcuts make sense super( tr("Conflate"), "dialogs/conflation", tr("Conflate selected objects"), Shortcut.registerShortcut( "conflation:replace", tr("Conflation: {0}", tr("Replace")), KeyEvent.VK_F, Shortcut.ALT_CTRL), false); }
public RelationEditMode(MapFrame mapFrame) { super( tr("Edit relation"), "node/autonode", tr("Edit relations"), Shortcut.registerShortcut( "mapmode:editRelation", tr("Mode: {0}", tr("Edit relation")), KeyEvent.VK_H, Shortcut.GROUP_EDIT), mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
/** Constructs a new {@code OrthogonalizeAction}. */ public OrthogonalizeAction() { super( tr("Orthogonalize Shape"), "ortho", tr("Move nodes so all angles are 90 or 180 degrees"), Shortcut.registerShortcut( "tools:orthogonalize", tr("Tool: {0}", tr("Orthogonalize Shape")), KeyEvent.VK_Q, Shortcut.DIRECT), true); putValue("help", ht("/Action/OrthogonalizeShape")); }
public AddNodeAction() { super( tr("Add Node..."), "addnode", tr("Add a node by entering latitude and longitude."), Shortcut.registerShortcut( "addnode", tr("Edit: {0}", tr("Add Node...")), KeyEvent.VK_D, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); putValue("help", ht("/Action/AddNode")); }
/** Constructor */ public Undo() { super( tr("Orthogonalize Shape / Undo"), "ortho", tr("Undo orthogonalization for certain nodes"), Shortcut.registerShortcut( "tools:orthogonalizeUndo", tr("Tool: {0}", tr("Orthogonalize Shape / Undo")), KeyEvent.VK_Q, Shortcut.SHIFT), true, "action/orthogonalize/undo", true); }