javax.swing.text.JTextComponent#getActionMap ( )源码实例Demo

下面列出了javax.swing.text.JTextComponent#getActionMap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: NbEditorUI.java
private void detachSystemActionPerformer(JTextComponent c){
    if (c == null) return;

    Action action = getEditorAction(c);
    if (action == null) return;

    Action globalSystemAction = getSystemAction(c);
    if (globalSystemAction == null) return;

    if (globalSystemAction instanceof CallbackSystemAction){
        Object key = ((CallbackSystemAction)globalSystemAction).getActionMapKey();
        ActionMap am = c.getActionMap();
        if (am != null) {
            Object ea = am.get(key);
            if (action.equals(ea)) {
                am.remove(key);
            }
        }
    }                        
                        
}
 
源代码2 项目: netbeans   文件: TextRegionManager.java
public static ActionMap [] installOverrideActionMap(JTextComponent component) {
    ActionMap origActionMap = component.getActionMap();
    ActionMap actionMap = new ActionMap();
    OverrideAction[] actions = new OverrideAction[]{
        new OverrideAction(TAB),
        new OverrideAction(SHIFT_TAB),
        new OverrideAction(ENTER),
    };

    // Install the actions into new action map
    for (OverrideAction action : actions) {
        Object actionKey = (String) action.getValue(Action.NAME);
        assert (actionKey != null);
        // Translate to the real key in the action map
        actionKey = action.findActionKey(component);
        if (actionKey != null) { // == null may happen during unit tests
            Action origAction = origActionMap.get(actionKey);
            action.putValue(ORIGINAL_ACTION_PROPERTY, origAction);
            actionMap.put(actionKey, action);
        }
    }
    actionMap.setParent(origActionMap);
    // Install the new action map and return the original action map
    component.setActionMap(actionMap);
    return new ActionMap [] { origActionMap, actionMap };
}
 
源代码3 项目: netbeans   文件: TextRegionManager.java
private void removeGroupsUpdate() {
    if (editGroups.size() == 0) {
        JTextComponent component = component();
        if (doc instanceof BaseDocument) {
            BaseDocument bdoc = (BaseDocument) doc;
            // Add the listener to allow doc syncing modifications
            // The listener is never removed (since this object is a property of the document)
            bdoc.removePostModificationDocumentListener(DocListener.INSTANCE);
            bdoc.removeUpdateDocumentListener(UpdateDocListener.INSTANCE);
        }
        activeTextSync = null;
        componentRef = null;

        if (overridingKeys) {
            overridingKeys = false;
            component.removeKeyListener(OverrideKeysListener.INSTANCE);

            // check if the action map is still our overrideActionMap
            if (overrideActionMap != component.getActionMap()) {
                LOG.warning("The action map got tampered with! component=" //NOI18
                    + component.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(component)) //NOI18N
                    + "; doc=" + component.getDocument()); //NOI18N
            } else {
                component.setActionMap(origActionMap);
            }

            overrideActionMap.clear();
            origActionMap = null;
            overrideActionMap = null;
        }
    }
}
 
源代码4 项目: 3Dscript   文件: AnimationAutoCompletion.java
/**
 * Installs this auto-completion on a text component. If this
 * {@link AnimationAutoCompletion} is already installed on another text component,
 * it is uninstalled first.
 *
 * @param c The text component.
 * @see #uninstall()
 */
@Override
public void install(JTextComponent c) {

	if (textComponent != null) {
		uninstall();
	}

	this.textComponent = c;
	installTriggerKey(getTriggerKey());

	// Install the function completion key, if there is one.
	// NOTE: We cannot do this if the start char is ' ' (e.g. just a space
	// between the function name and parameters) because it overrides
	// RSTA's special space action. It seems KeyStorke.getKeyStroke(' ')
	// hoses ctrl+space, shift+space, etc., even though I think it
	// shouldn't...
	char start = provider.getParameterListStart();
	if (start != 0 && start != ' ') {
		InputMap im = c.getInputMap();
		ActionMap am = c.getActionMap();
		KeyStroke ks = KeyStroke.getKeyStroke(start);
		oldParenKey = im.get(ks);
		im.put(ks, PARAM_COMPLETE_KEY);
		oldParenAction = am.get(PARAM_COMPLETE_KEY);
		am.put(PARAM_COMPLETE_KEY, new ParameterizedCompletionStartAction(
				start));
	}

	textComponentListener.addTo(this.textComponent);
	// In case textComponent is already in a window...
	textComponentListener.hierarchyChanged(null);

	if (isAutoActivationEnabled()) {
		autoActivationListener.addTo(this.textComponent);
	}

	UIManager.addPropertyChangeListener(lafListener);
	updateUI(); // In case there have been changes since we uninstalled

}