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(); } }
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 } } } } } }
/** * 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 } } }
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; }
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); } } } } } } }
/** 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); } } } }
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); } } } } } } }
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); } } } }
/** * 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(); }
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); } } } }
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; }
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(); } } } }
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(); } } } }
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; }
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; }
/** 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 } } } }
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(); } } } } }
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(); } } }
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; } }
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; } }