当前位置: 首页>>代码示例>>Java>>正文


Java EditorKit.getActions方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DiffContentPanel.java

示例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));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:EditorActionUtilities.java

示例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));
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:KeyBindingsUpdater.java

示例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.");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:EditorUtilitiesTest.java

示例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
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:EditorBridge.java


注:本文中的javax.swing.text.EditorKit.getActions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。