本文整理了Java中org.netbeans.editor.Utilities.getKit()
方法的一些代码示例,展示了Utilities.getKit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.getKit()
方法的具体详情如下:
包路径:org.netbeans.editor.Utilities
类名称:Utilities
方法名:getKit
[英]Helper method to obtain instance of editor kit from existing JTextComponent. If the kit of the component is not an instance of the org.netbeans.editor.BaseKit the method returns null. The method doesn't require any document locking.
[中]从现有JTextComponent获取编辑器工具包实例的助手方法。如果组件的工具包不是组织的实例。上网本。编辑BaseKit方法返回null。该方法不需要任何文档锁定。
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
private void addAction(JTextComponent target, JMenu menu, String actionName) {
BaseKit kit = Utilities.getKit(target);
if (kit == null) {
return;
}
Action a = kit.getActionByName(actionName);
if (a != null) {
addAction(target, menu, a);
} else { // action-name is null, add the separator
menu.addSeparator();
}
}
代码示例来源:origin: net.java.abeille/abeille
public void mouseClicked(MouseEvent evt) {
if (SwingUtilities.isLeftMouseButton(evt)) {
JTextComponent component = extEditorUI.getComponent();
if (component != null && evt.getClickCount() == 2) {
BaseKit kit = Utilities.getKit(component);
if (kit != null) {
Action a = kit.getActionByName(BaseKit.insertBreakAction);
if (a != null) {
a.actionPerformed(new ActionEvent(component, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
}
}
}
}
}
}
代码示例来源:origin: net.java.abeille/abeille
/**
* Update the tooltip by running corresponding action
* {@link ExtKit#buildToolTipAction}. This method gets called once the
* enterTimer fires and it can be overriden by children.
*/
protected void updateToolTip() {
ExtEditorUI ui = extEditorUI;
if (ui == null)
return;
JTextComponent comp = ui.getComponent();
if (comp == null)
return;
BaseKit kit = Utilities.getKit(comp);
if (kit != null) {
Action a = kit.getActionByName(ExtKit.buildToolTipAction);
if (a != null) {
a.actionPerformed(new ActionEvent(comp, 0, "")); // NOI18N
}
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-deprecated-pre61completion
public Completion getCompletion() {
if (completion == null) {
if (noCompletion) {
return null;
}
synchronized (getComponentLock()) {
JTextComponent component = getComponent();
if (component != null) {
BaseKit kit = Utilities.getKit(component);
if (kit != null && kit instanceof ExtKit) {
try {
Method m = kit.getClass().getMethod("createCompletion", ExtEditorUI.class); //NOI18N
completion = (Completion) m.invoke(kit, this);
} catch (Exception e) {
completion = null;
}
if (completion == null) {
noCompletion = true;
}
}
}
}
}
return completion;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
BaseKit kit = Utilities.getKit(target);
if (kit != null) {
for (int i = 0; i < actionNames.length; i++) {
Action a = kit.getActionByName(actionNames[i]);
if (a != null) {
if (a instanceof BaseAction) {
((BaseAction)a).actionPerformed(evt, target);
} else {
a.actionPerformed(evt);
}
}
}
}
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
/** Initialize this manager */
@Override
public void init(FoldOperation operation) {
this.operation = operation;
EditorKit kit = org.netbeans.editor.Utilities.getKit(operation.getHierarchy().getComponent());
if (kit instanceof NbEditorKit) {
String contentType = ((NbEditorKit) kit).getContentType();
if (contentType != null) {
Preferences prefs = MimeLookup.getLookup(contentType).lookup(Preferences.class);
if (prefs != null) {
foldInitialCommentsPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_INITIAL_COMMENT, false);
foldIncludesPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_IMPORT, false);
foldCodeBlocksPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_METHOD, false);
foldCommentPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_JAVADOC, false);
}
}
}
}
代码示例来源:origin: net.java.abeille/abeille
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
BaseKit kit = Utilities.getKit(target);
if (kit != null) {
for (int i = 0; i < actionNames.length; i++) {
Action a = kit.getActionByName(actionNames[i]);
if (a != null) {
if (a instanceof BaseAction) {
((BaseAction) a).actionPerformed(evt, target);
}
else {
a.actionPerformed(evt);
}
}
}
}
}
}
}
代码示例来源:origin: net.java.abeille/abeille
public void showPopupMenu(int x, int y) {
// First call the build-popup-menu action to possibly rebuild the popup
// menu
JTextComponent component = getComponent();
if (component != null) {
BaseKit kit = Utilities.getKit(component);
if (kit != null) {
Action a = kit.getActionByName(ExtKit.buildPopupMenuAction);
if (a != null) {
a.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N
}
}
JPopupMenu pm = getPopupMenu();
if (pm != null) {
if (component.isShowing()) { // fix of #18808
pm.show(component, x, y);
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/**
* Fetches the factory to be used for building the
* various view fragments that make up the view that
* represents the model. This is what determines
* how the model will be represented. This is implemented
* to fetch the factory provided by the associated
* EditorKit unless that is null, in which case this
* simply returns the BasicTextUI itself which allows
* subclasses to implement a simple factory directly without
* creating extra objects.
*
* @return the factory
*/
public ViewFactory getViewFactory() {
EditorUI editorUI = getEditorUI();
if (editorUI!=null){
BaseKit kit = Utilities.getKit(editorUI.getComponent());
ViewFactory f = kit.getViewFactory();
if (f != null) {
return f;
}
}
return getBaseTextUI();
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void showPopupMenu(int x, int y) {
// First call the build-popup-menu action to possibly rebuild the popup menu
JTextComponent component = getComponent();
if (component != null) {
BaseKit kit = Utilities.getKit(component);
if (kit != null) {
Action a = kit.getActionByName(ExtKit.buildPopupMenuAction);
if (a != null) {
a.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N
}
}
JPopupMenu pm = getPopupMenu();
if (pm != null) {
if (component.isShowing()) { // fix of #18808
pm.show(component, x, y);
}
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-editor
protected static JMenu createMenu(JMenu menu, final JTextComponent c) {
final String menuText = NbBundle.getMessage(PreprocessorActions.class, "Menu/Edit/PreprocessorBlocks"); //NOI18N
if (menu == null) menu = new JMenu(); else menu.removeAll();
Mnemonics.setLocalizedText(menu, menuText);
final BaseKit kit = Utilities.getKit(c);
if (kit == null) return menu;
ProjectConfigurationsHelper cfgHelper = null;
ArrayList<PPLine> lineList = null;
if (c != null && c.getDocument() != null) {
cfgHelper = J2MEProjectUtils.getCfgHelperForDoc(c.getDocument());
lineList = (ArrayList<PPLine>)c.getDocument().getProperty(DocumentPreprocessor.PREPROCESSOR_LINE_LIST);
}
if (lineList == null) lineList = new ArrayList<PPLine>();
addAction(kit, cfgHelper, lineList, c, menu, AddProjectConfigurationAction.NAME);
menu.addSeparator();
addAction(kit, cfgHelper, lineList, c, menu, CreateIfElseBlockAction.NAME);
addAction(kit, cfgHelper, lineList, c, menu, AddElifBlockAction.NAME);
addAction(kit, cfgHelper, lineList, c, menu, CreateDebugBlockAction.NAME);
menu.addSeparator();
addAction(kit, cfgHelper, lineList, c, menu, RecommentAction.NAME);
return menu;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
String macro = stopRecording(target);
if( macro == null ) { // not recording
target.getToolkit().beep();
} else {
// popup a macro dialog
BaseKit kit = Utilities.getKit(target);
MacroDialogSupport support = getMacroDialogSupport(kit.getClass());
support.setBody( macro );
support.showMacroDialog();
}
}
}
}
代码示例来源:origin: net.java.abeille/abeille
public void actionPerformed(ActionEvent evt, JTextComponent target) {
if (target != null) {
String macro = stopRecording(target);
if (macro == null) { // not recording
target.getToolkit().beep();
}
else {
// popup a macro dialog
BaseKit kit = Utilities.getKit(target);
MacroDialogSupport support = new MacroDialogSupport(kit.getClass());
support.setBody(macro);
support.showMacroDialog();
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public Completion getCompletion() {
if (completion == null) {
if (noCompletion) {
return null;
}
synchronized (getComponentLock()) {
JTextComponent component = getComponent();
if (component != null) {
BaseKit kit = Utilities.getKit(component);
if (kit != null && kit instanceof ExtKit) {
completion = ((ExtKit)kit).createCompletion(this);
if (completion == null) {
noCompletion = true;
}
}
}
}
}
return completion;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public CompletionJavaDoc getCompletionJavaDoc() {
if (completionJavaDoc == null) {
if (noCompletionJavaDoc) {
return null;
}
synchronized (getComponentLock()) {
JTextComponent component = getComponent();
if (component != null) {
BaseKit kit = Utilities.getKit(component);
if (kit != null && kit instanceof ExtKit) {
completionJavaDoc = ((ExtKit)kit).createCompletionJavaDoc(this);
if (completionJavaDoc == null) {
noCompletionJavaDoc = true;
}
}
}
}
}
return completionJavaDoc;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Update the tooltip by running corresponding action
* {@link ExtKit#buildToolTipAction}. This method gets
* called once the enterTimer fires and it can be overriden
* by children.
*/
protected void updateToolTip() {
ExtEditorUI ui = extEditorUI;
if (ui == null)
return;
JTextComponent comp = ui.getComponent();
if (comp == null)
return;
if (isGlyphGutterMouseEvent(lastMouseEvent)) {
setToolTipText(extEditorUI.getGlyphGutter().getToolTipText(lastMouseEvent));
} else { // over the text component
BaseKit kit = Utilities.getKit(comp);
if (kit != null) {
Action a = kit.getActionByName(ExtKit.buildToolTipAction);
if (a != null) {
a.actionPerformed(new ActionEvent(comp, 0, "")); // NOI18N
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void run() {
JTextComponent c = component;
if (c != null) {
BaseKit kit = Utilities.getKit(c);
if (kit != null) {
c.setKeymap(kit.getKeymap());
BaseTextUI ui = (BaseTextUI)c.getUI();
if (ui != null) {
ui.updateHeight();
c.repaint();
}
}
}
}
}
代码示例来源:origin: net.java.abeille/abeille
public static void requestFocus(JTextComponent c) {
if (c != null) {
boolean ok = false;
BaseKit kit = getKit(c);
if (kit != null) {
Class fcc = kit.getFocusableComponentClass(c);
if (fcc != null) {
Container container = SwingUtilities.getAncestorOfClass(fcc, c);
if (container != null) {
container.requestFocus();
ok = true;
}
}
}
if (!ok) {
Frame f = EditorUI.getParentFrame(c);
if (f != null) {
f.requestFocus();
}
c.requestFocus();
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public JMenuItem getPopupMenuItem(JTextComponent target) {
EditorUI ui = Utilities.getEditorUI(target);
try {
return ui.getDocument().getAnnotations().createMenu(Utilities.getKit(target), Utilities.getLineOffset(ui.getDocument(),target.getCaret().getDot()));
} catch (BadLocationException ex) {
return null;
}
}
代码示例来源:origin: net.java.abeille/abeille
public JMenuItem getPopupMenuItem(JTextComponent target) {
EditorUI ui = Utilities.getEditorUI(target);
try {
return ui.getDocument().getAnnotations().createMenu(Utilities.getKit(target),
Utilities.getLineOffset(ui.getDocument(), target.getCaret().getDot()));
} catch (BadLocationException ex) {
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!