javax.swing.plaf.TextUI#getEditorKit ( )源码实例Demo

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

源代码1 项目: netbeans   文件: DocumentationScrollPane.java
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                 Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
源代码2 项目: netbeans   文件: DocumentationScrollPane.java
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
源代码3 项目: netbeans   文件: DocumentationScrollPane.java
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
源代码4 项目: netbeans   文件: PresenterEditorAction.java
public void actionPerformed(ActionEvent evt) {
    // Find the right action for the corresponding editor kit
    JTextComponent component = getTextComponent(evt);
    if (component != null) {
        TextUI ui = component.getUI();
        if (ui != null) {
            EditorKit kit = ui.getEditorKit(component);
            if (kit != null) {
                Action action = EditorUtilities.getAction(kit, actionName);
                if (action != null) {
                    action.actionPerformed(evt);
                } else {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Action '" + actionName + "' not found in editor kit " + kit + '\n'); // NOI18N
                    }
                }
            }
        }
    }
}
 
源代码5 项目: netbeans   文件: DocumentationScrollPane.java
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                 Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
源代码6 项目: netbeans   文件: CompletionImpl.java
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    if (editorActionName != null && getActiveComponent() != null) {
        TextUI ui = getActiveComponent().getUI();
        Keymap km = getActiveComponent().getKeymap();
        if (ui != null && km != null) {
            EditorKit kit = ui.getEditorKit(getActiveComponent());
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        return keys;
                    } else {
                        // try kit's keymap
                        Keymap km2 = ((BaseKit)kit).getKeymap();
                        KeyStroke[] keys2 = km2.getKeyStrokesForAction(a);
                        if (keys2 != null && keys2.length > 0) {
                            return keys2;
                        }
                    }
                }
            }
        }
    }
    return new KeyStroke[0];
}
 
源代码7 项目: netbeans   文件: NbEditorToolBar.java
/** Attempt to find the editor keystroke for the given action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey) {
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    JTextComponent comp = getComponent();
    if (editorActionName != null && comp != null) {
        TextUI textUI = comp.getUI();
        Keymap km = comp.getKeymap();
        if (textUI != null && km != null) {
            EditorKit kit = textUI.getEditorKit(comp);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    } else {
                        // try kit's keymap
                        Keymap km2 = ((BaseKit)kit).getKeymap();
                        KeyStroke[] keys2 = km2.getKeyStrokesForAction(a);
                        if (keys2 != null && keys2.length > 0) {
                            ret = keys2;
                        }                            
                    }
                }
            }
        }
    }
    return ret;
}
 
源代码8 项目: netbeans   文件: PresenterEditorAction.java
public void propertyChange(PropertyChangeEvent evt) {
    if (EditorRegistry.FOCUS_GAINED_PROPERTY.equals(evt.getPropertyName())) {
        JTextComponent focusedTextComponent = (JTextComponent) evt.getNewValue();
        SearchableEditorKit oldActiveKit = activeKit();
        EditorKit kit = null;
        if (focusedTextComponent != null) {
            TextUI ui = focusedTextComponent.getUI();
            if (ui != null) {
                kit = ui.getEditorKit(focusedTextComponent);
            }
        }

        synchronized (PresenterEditorAction.class) {
            SearchableEditorKit newActiveKit = (kit != null)
                    ? EditorActionUtilities.getSearchableKit(kit)
                    : null;
            boolean kitChanged;
            if (newActiveKit != oldActiveKit) {
                if (oldActiveKit != null) {
                    oldActiveKit.removeActionsChangeListener(actionsChangeListener);
                }
                activeKitRef = (newActiveKit != null)
                        ? new WeakReference<SearchableEditorKit>(newActiveKit)
                        : null;
                if (newActiveKit != null) {
                    newActiveKit.addActionsChangeListener(actionsChangeListener);
                }
                kitChanged = true;
            } else {
                kitChanged = false;
            }
            boolean focusChanged = (activeKitLastFocused == false);
            activeKitLastFocused = true;
            if (focusChanged || kitChanged) {
                refreshActiveKitActions(newActiveKit, kitChanged);
            }
        }

    } else if (EditorRegistry.FOCUS_LOST_PROPERTY.equals(evt.getPropertyName())) {
        synchronized (PresenterEditorAction.class) {
            boolean newActiveKitLastFocused = (EditorRegistry.lastFocusedComponent() != null);
            if (newActiveKitLastFocused != activeKitLastFocused) {
                activeKitLastFocused = newActiveKitLastFocused;
                for (PresenterEditorAction a : presenterActions) {
                    a.refreshActiveKitAction(null, false);
                }
            }
        }
    }
}