Java Code Examples for org.openide.util.Utilities#keyToString()
The following examples show how to use
org.openide.util.Utilities#keyToString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoalsPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** Creates new form POMInheritancePanel */ @Messages("HINT_Panel_hide=Click or press {0} to hide/show when the Navigator is active") public GoalsPanel() { initComponents(); treeView = (BeanTreeView)jScrollPane1; preferences = NbPreferences.forModule(GoalsPanel.class).node("goalNavigator"); filtersPanel = new TapPanel(); filtersPanel.setOrientation(TapPanel.DOWN); // tooltip KeyStroke toggleKey = KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); String keyText = Utilities.keyToString(toggleKey); filtersPanel.setToolTipText(HINT_Panel_hide(keyText)); //NOI18N JComponent buttons = createFilterButtons(); buttons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0)); filtersPanel.add(buttons); if( "Aqua".equals(UIManager.getLookAndFeel().getID()) ) { filtersPanel.setBackground(UIManager.getColor("NbExplorerView.background"));//NOI18N } add(filtersPanel, BorderLayout.SOUTH); }
Example 2
Source File: ShortcutListener.java From netbeans with Apache License 2.0 | 6 votes |
private void addKeyStroke(KeyStroke keyStroke, boolean add) { String s = Utilities.keyToString(keyStroke, true); KeyStroke mappedStroke = Utilities.stringToKey(s); if (!keyStroke.equals(mappedStroke)) { return; } String k = KeyStrokeUtils.getKeyStrokeAsText(keyStroke); // check if the text can be mapped back if (key.equals("")) { //NOI18N textField.setText(k); if (add) key = k; } else { textField.setText(key + " " + k); //NOI18N if (add) key += " " + k; //NOI18N } }
Example 3
Source File: MutableShortcutsModel.java From netbeans with Apache License 2.0 | 6 votes |
/** * Converts Map (ShortcutAction > Set (String (shortcut Alt+Shift+P))) to * Map (ShortcutAction > Set (String (shortcut AS-P))). */ private static Map<ShortcutAction, Set<String>> convertToEmacs (Map<ShortcutAction, Set<String>> shortcuts) { Map<ShortcutAction, Set<String>> result = new HashMap<ShortcutAction, Set<String>> (); for (Map.Entry<ShortcutAction, Set<String>> entry: shortcuts.entrySet()) { ShortcutAction action = entry.getKey(); Set<String> newSet = new HashSet<String> (); for (String s: entry.getValue()) { if (s.length () == 0) continue; KeyStroke[] ks = getKeyStrokes (s, " "); if (ks == null) continue; // unparsable shortcuts ignorred StringBuffer sb = new StringBuffer ( Utilities.keyToString (ks [0], true) ); int i, k = ks.length; for (i = 1; i < k; i++) sb.append (' ').append (Utilities.keyToString (ks [i], true)); newSet.add (sb.toString ()); } result.put (action, newSet); } return result; }
Example 4
Source File: Pre90403Phase1CompatibilityTest.java From netbeans with Apache License 2.0 | 6 votes |
private static Map<String, String> normalize(List<MultiKeyBinding> keybindings) { Map<String, String> norm = new TreeMap<String, String>(); for(MultiKeyBinding mkb : keybindings) { StringBuilder strokes = new StringBuilder(); for(Iterator<KeyStroke> i = mkb.getKeyStrokeList().iterator(); i.hasNext(); ) { KeyStroke stroke = i.next(); String s = Utilities.keyToString(stroke); strokes.append(s); if (i.hasNext()) { strokes.append(" "); } } String mkbId = "'" + strokes.toString() + "'"; String normalizedActionName = mkb.getActionName() == null ? "'null'" : "'" + mkb.getActionName() + "'"; assertFalse("Dulicate MultiKeyBinding '" + mkbId + "'", norm.containsKey(mkbId)); norm.put(mkbId, normalizedActionName); } return norm; }
Example 5
Source File: ShortcutAndMenuKeyEventProcessor.java From netbeans with Apache License 2.0 | 5 votes |
private boolean processShortcut(KeyEvent ev) { //ignore shortcut keys when the IDE is shutting down if (NbLifecycleManager.isExiting()) { ev.consume(); return true; } KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ev); Window w = SwingUtilities.windowForComponent(ev.getComponent()); // don't process shortcuts if this is a help frame if ((w instanceof JFrame) && ((JFrame)w).getRootPane().getClientProperty("netbeans.helpframe") != null) // NOI18N return true; // don't let action keystrokes to propagate from both // modal and nonmodal dialogs, but propagate from separate floating windows, // even if they are backed by JDialog if ((w instanceof Dialog) && !WindowManagerImpl.isSeparateWindow(w) && !isTransmodalAction(ks)) { return false; } // Provide a reasonably useful action event that identifies what was focused // when the key was pressed, as well as what keystroke ran the action. ActionEvent aev = new ActionEvent( ev.getSource(), ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)); Keymap root = Lookup.getDefault().lookup(Keymap.class); Action a = root.getAction (ks); if (a != null && a.isEnabled()) { ActionManager am = Lookup.getDefault().lookup(ActionManager.class); am.invokeAction(a, aev); ev.consume(); return true; } return false; }
Example 6
Source File: ClassMemberPanelUI.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates new form ClassMemberPanelUi */ public ClassMemberPanelUI(final Language language) { initComponents(); // Tree view of the elements elementView = createBeanTreeView(); add(elementView, BorderLayout.CENTER); filters = new ClassMemberFilters( this ); filters.getInstance().hookChangeListener(this); // See http://www.netbeans.org/issues/show_bug.cgi?id=186407 // Making the calls to getStructure() out of AWT EDT RP.post(new UpdateFilterState(language)); // filters filtersPanel = new TapPanel(); filtersLbl = new JLabel(NbBundle.getMessage(ClassMemberPanelUI.class, "LBL_Filter")); //NOI18N filtersLbl.setBorder(new EmptyBorder(0, 5, 5, 0)); filtersPanel.add(filtersLbl); filtersPanel.setOrientation(TapPanel.DOWN); // tooltip KeyStroke toggleKey = KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); String keyText = Utilities.keyToString(toggleKey); filtersPanel.setToolTipText(NbBundle.getMessage(ClassMemberPanelUI.class, "TIP_TapPanel", keyText)); filtersPanel.add(filters.getComponent()); add(filtersPanel, BorderLayout.SOUTH); manager.setRootContext(ElementNode.getWaitNode()); lookup = ExplorerUtils.createLookup(manager, getActionMap()); }
Example 7
Source File: ClassMemberPanelUI.java From netbeans with Apache License 2.0 | 4 votes |
/** Creates new form ClassMemberPanelUi */ public ClassMemberPanelUI() { inheritedColor = UIManager.getColor(INHERITED_COLOR_KEY); typeColor = UIManager.getColor(TYPE_COLOR_KEY); history = HistorySupport.getInstnace(this.getClass()); jdocFinder = SelectJavadocTask.create(this); jdocTask = RP.create(jdocFinder); initComponents(); manager.addPropertyChangeListener(this); // Tree view of the elements elementView = createBeanTreeView(); add(elementView, BorderLayout.CENTER); // filters filtersPanel = new TapPanel(); filtersPanel.setOrientation(TapPanel.DOWN); // tooltip KeyStroke toggleKey = KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); String keyText = Utilities.keyToString(toggleKey); filtersPanel.setToolTipText(NbBundle.getMessage(ClassMemberPanelUI.class, "TIP_TapPanel", keyText)); //NOI18N filters = new ClassMemberFilters( this ); filters.getFiltersManager().hookChangeListener(this); JComponent buttons = filters.getComponent(); buttons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0)); filtersPanel.add(buttons); Utils.updateBackground(filtersPanel); actions = new Action[] { SortActions.createSortByNameAction(filters), SortActions.createSortBySourceAction(filters), null, new FilterSubmenuAction(filters.getFiltersManager()) }; add(filtersPanel, BorderLayout.SOUTH); boolean expanded = NbPreferences.forModule(ClassMemberPanelUI.class).getBoolean("filtersPanelTap.expanded", true); //NOI18N filtersPanel.setExpanded(expanded); filtersPanel.addPropertyChangeListener(this); }
Example 8
Source File: WizardUtils.java From netbeans with Apache License 2.0 | 4 votes |
public static String keyToLogicalString(KeyStroke keyStroke) { String keyDesc = Utilities.keyToString(keyStroke); int dash = keyDesc.indexOf('-'); return dash == -1 ? keyDesc : keyDesc.substring(0, dash).replace('C', 'D').replace('A', 'O') + keyDesc.substring(dash); }