本文整理匯總了Java中org.openide.util.Utilities.keyToString方法的典型用法代碼示例。如果您正苦於以下問題:Java Utilities.keyToString方法的具體用法?Java Utilities.keyToString怎麽用?Java Utilities.keyToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.util.Utilities
的用法示例。
在下文中一共展示了Utilities.keyToString方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GoalsPanel
import org.openide.util.Utilities; //導入方法依賴的package包/類
/** 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);
}
示例2: addKeyStroke
import org.openide.util.Utilities; //導入方法依賴的package包/類
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
}
}
示例3: convertToEmacs
import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
* 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;
}
示例4: normalize
import org.openide.util.Utilities; //導入方法依賴的package包/類
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;
}
示例5: ClassMemberPanelUI
import org.openide.util.Utilities; //導入方法依賴的package包/類
/** 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());
}
示例6: processShortcut
import org.openide.util.Utilities; //導入方法依賴的package包/類
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;
}
示例7: ClassMemberPanelUI
import org.openide.util.Utilities; //導入方法依賴的package包/類
/** 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);
}
示例8: keyToLogicalString
import org.openide.util.Utilities; //導入方法依賴的package包/類
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);
}