本文整理汇总了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
}
}