本文整理匯總了Java中javax.swing.text.EditorKit.getActions方法的典型用法代碼示例。如果您正苦於以下問題:Java EditorKit.getActions方法的具體用法?Java EditorKit.getActions怎麽用?Java EditorKit.getActions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.EditorKit
的用法示例。
在下文中一共展示了EditorKit.getActions方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAction
import javax.swing.text.EditorKit; //導入方法依賴的package包/類
private Action getAction(String key) {
if (key == null) {
return null;
}
// Try to find the action from kit.
EditorKit kit = editorPane.getEditorKit();
if (kit == null) { // kit is cleared in closeDocument()
return null;
}
Action[] actions = kit.getActions();
for (int i = 0; i < actions.length; i++) {
if (key.equals(actions[i].getValue(Action.NAME))) {
return actions[i];
}
}
return null;
}
示例2: DefaultSearchableKit
import javax.swing.text.EditorKit; //導入方法依賴的package包/類
DefaultSearchableKit(EditorKit kit) {
for (Action action : kit.getActions()) {
if (action != null) {
name2actionRef.put((String)action.getValue(Action.NAME), new WeakReference<Action>(action));
}
}
}
示例3: updateKits
import javax.swing.text.EditorKit; //導入方法依賴的package包/類
private static void updateKits(Map<String,List<List<KeyStroke>>> actionName2binding, List<KitReference> kitRefs) {
// Update kits without locks (a.putValue() is done)
for (KitReference kitRef : kitRefs) {
EditorKit kit = kitRef.get();
if (kit == null) { // Might be null since this is a copy of orig. list
continue;
}
Action[] actions = kit.getActions();
for (int i = 0; i < actions.length; i++) {
Action a = actions[i];
String actionName = (String) a.getValue(Action.NAME);
@SuppressWarnings("unchecked")
List<List<KeyStroke>> origAccels = (List<List<KeyStroke>>)
a.getValue(AbstractEditorAction.MULTI_ACCELERATOR_LIST_KEY);
List<List<KeyStroke>> accels = actionName2binding.get(actionName);
if (accels == null) {
accels = Collections.emptyList();
}
if (origAccels == null || !origAccels.equals(accels)) {
a.putValue(AbstractEditorAction.MULTI_ACCELERATOR_LIST_KEY, accels);
if (accels.size() > 0) {
// First keystroke of first multi-key accelerator in the list
a.putValue(Action.ACCELERATOR_KEY, accels.get(0).get(0));
}
}
}
}
}
示例4: testGetAction
import javax.swing.text.EditorKit; //導入方法依賴的package包/類
@Test
public void testGetAction() throws Exception {
EditorKit editorKit = new DefaultEditorKit();
String actionName = DefaultEditorKit.backwardAction;
Action result = EditorUtilities.getAction(editorKit, actionName);
for (Action expected : editorKit.getActions()) {
if (actionName.equals(expected.getValue(Action.NAME))) {
assertEquals(expected, result);
return;
}
}
fail("Action " + actionName + " not found.");
}
示例5: initActionMap
import javax.swing.text.EditorKit; //導入方法依賴的package包/類
/**
* Loads editor actions for given mimeType to editorActionsMap.
*/
private void initActionMap(String mimeType, Map<String, EditorAction> emptyMimePathActions) {
// 1) get EditorKit
EditorKit editorKit = null;
if (mimeType == null) {
editorKit = BaseKit.getKit(NbEditorKit.class);
} else {
Lookup mimeLookup = MimeLookup.getLookup(MimePath.parse(mimeType));
editorKit = mimeLookup.lookup(EditorKit.class);
}
if (editorKit == null) {
if (LOG.isLoggable(Level.WARNING)) {
LOG.fine("EditorKit not found for: " + mimeType); //NOI18N
}
return;
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Loading actions for '" + (mimeType == null ? "" : mimeType) + "' using " + editorKit); //NOI18N
}
// 2) copy actions from EditorKit to actionMap
Action[] as = editorKit.getActions();
for (int i = 0; i < as.length; i++) {
Object isHidden = as[i].getValue(BaseAction.NO_KEYBINDING);
if (isHidden instanceof Boolean && ((Boolean) isHidden).booleanValue()) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("! Action '" + as[i].getValue(Action.NAME) + "' is hidden, ignoring"); //NOI18N
}
continue; // ignore hidden actions
}
EditorAction action = new EditorAction(as [i]);
String id = action.getId();
// filter out actions inherited from an empty mime path (all editors actions)
if (emptyMimePathActions != null && emptyMimePathActions.containsKey(id)) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("Action '" + id + "' was already listed among all alnguages actions, skipping"); //NOI18N
}
continue;
}
getEditorActionsMap().put(id, action);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Action '" + id + "' loaded for '" + (mimeType == null ? "" : mimeType) + "'"); //NOI18N
}
Set<String> s = actionNameToMimeTypes.get(id);
if (s == null) {
// LinkedHS ensures that 'null' mime which is initialized 1st will be
// the 1st enumerated from getMimeTypes(). This invariant is used in saveKeyMap
s = new LinkedHashSet<String>();
actionNameToMimeTypes.put(id, s);
}
s.add(mimeType);
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Actions for '" + (mimeType == null ? "" : mimeType) + "' loaded successfully"); //NOI18N
}
}