Refine search
public int[] getHyperlinkSpan(Document doc, int offset) { JTextComponent target = EditorRegistry.lastFocusedComponent(); final StyledDocument styledDoc = (StyledDocument) target.getDocument(); if (styledDoc == null) { return null; } // Return the position, which was set in the isHyperlink method: return new int[]{startOffset, endOffset}; }
public static JTextComponent findEditor(Document doc) { JTextComponent comp = EditorRegistry.lastFocusedComponent(); if (comp.getDocument() == doc) { return comp; } List<? extends JTextComponent> componentList = EditorRegistry.componentList(); for (JTextComponent component : componentList) { if (comp.getDocument() == doc) { return comp; } } return null; }
public synchronized void initialize() { EditorRegistry.addPropertyChangeListener(this); JTextComponent newComponent = EditorRegistry.lastFocusedComponent(); currentDocument = newComponent != null ? newComponent.getDocument() : null; if (currentDocument != null) { currentDocument.addDocumentListener(this); } }
public CurrentEditorTaskScheduler () { setEditor (EditorRegistry.focusedComponent ()); EditorRegistry.addPropertyChangeListener (new AListener ()); }
private Document getCurrentDocument(int[] span) { JTextComponent pane = EditorRegistry.lastFocusedComponent(); if (pane == null) { return null; } if (span != null) { span[0] = pane.getSelectionStart(); span[1] = pane.getSelectionEnd(); span[2] = pane.getCaretPosition(); if (span[0] == span[1] && requiresSelection()) { return null; } } Document doc = pane.getDocument(); Object stream = doc != null ? doc.getProperty(Document.StreamDescriptionProperty) : null; if (!(stream instanceof DataObject)) { return null; } DataObject dObj = (DataObject) stream; FileObject result = dObj.getPrimaryFile(); if (MIMENames.isHeaderOrCppOrC(FileUtil.getMIMEType(result))) { return doc; } else { return null; } }
codeStyle = CodeStyle.getDefault(doc); for(JTextComponent component : EditorRegistry.componentList()) { if (doc.equals(component.getDocument())) { carret = component.getCaretPosition(); currentComponent = component; break;
private void editorRegistryChanged() { final JTextComponent editor = EditorRegistry.lastFocusedComponent(); final JTextComponent lastEditor = lastEditorRef == null ? null : lastEditorRef.get(); if (lastEditor != editor && (editor == null || editor.getClientProperty("AsTextField") == null)) { if (lastEditor != null) { lastEditor.removeCaretListener(this); lastEditor.removePropertyChangeListener(this); k24.set(false); } lastEditorRef = new WeakReference<JTextComponent>(editor); if (editor != null) { editor.addCaretListener(this); editor.addPropertyChangeListener(this); } final JTextComponent focused = EditorRegistry.focusedComponent(); if (focused != null) { final Document doc = editor.getDocument(); final String mimeType = DocumentUtilities.getMimeType (doc); if (doc != null && mimeType != null) { final Source source = Source.create (doc); if (source != null) { ((EventSupport)SourceEnvironment.forSource(source)).resetState(true, false, -1, -1, true); } } } } }
@Override public String getCustomInsertTemplate() { final String superTemplate = super.getInsertPrefix(); if (endWithDoubleColon) { StringBuilder builder = new StringBuilder(); builder.append(superTemplate); boolean includeDoubleColumn = true; if (EditorRegistry.lastFocusedComponent() != null) { Document doc = EditorRegistry.lastFocusedComponent().getDocument(); int caret = EditorRegistry.lastFocusedComponent().getCaretPosition(); try { if (caret + 2 < doc.getLength() && "::".equals(doc.getText(caret, 2))) { //NOI18N includeDoubleColumn = false; } } catch (BadLocationException ex) { // do nothing } } if (includeDoubleColumn) { builder.append("::"); } builder.append("${cursor}"); //NOI18N scheduleShowingCompletion(); return builder.toString(); } else if (CompletionContext.NEW_CLASS.equals(request.context)) { scheduleShowingCompletion(); } return superTemplate; } }
propName.equals (EditorRegistry.FOCUS_GAINED_PROPERTY) ) { JTextComponent editor = EditorRegistry.focusedComponent (); if (editor == currentEditor || (editor != null && editor.getClientProperty("AsTextField") != null)) { //NOI18N return; currentEditor.removePropertyChangeListener(this); Document document = currentEditor.getDocument (); FileObject fileObject = DataObjectEnvFactory.getFileObject (document); if (fileObject == null) {
public void editorRegistryChanged() { final JTextComponent editor = EditorRegistry.lastFocusedComponent(); final JTextComponent lastEditor = lastEditorRef == null ? null : lastEditorRef.get(); if (lastEditor != editor) { if (lastEditor != null) { lastEditor.removeCaretListener(this); //lastEditor.removePropertyChangeListener(this); final Document doc = lastEditor.getDocument(); Source js = null; if (doc != null) { js = forDocument(doc); } //if (js != null) { // js.k24 = false; //} } lastEditorRef = new WeakReference<JTextComponent>(editor); if (editor != null) { editor.addCaretListener(this); //lastEditor.addPropertyChangeListener(this); } } }
final String propName = evt.getPropertyName(); if (propName == null) { components = EditorRegistry.componentList(); } else if (propName.equals(EditorRegistry.FOCUS_LOST_PROPERTY) || propName.equals(EditorRegistry.LAST_FOCUSED_REMOVED_PROPERTY)) { if (evt.getOldValue() instanceof JTextComponent) { Object newValue = evt.getNewValue(); if (!(newValue instanceof JTextComponent) || ((JTextComponent)newValue).getClientProperty("AsTextField") == null) { deactivate = ((JTextComponent) evt.getOldValue()).getDocument(); if (evt.getNewValue() instanceof JTextComponent) { JTextComponent jtc = (JTextComponent) evt.getNewValue(); if (jtc.getClientProperty("AsTextField") == null) { activate = jtc.getDocument(); JTextComponent activeComponent = activeComponentRef == null ? null : activeComponentRef.get(); JTextComponent jtc = EditorRegistry.focusedComponent(); if (jtc == null) { jtc = EditorRegistry.lastFocusedComponent();
@Override public void run() { JTextComponent component = EditorRegistry.focusedComponent(); if (component != null) { DocumentPreprocessor.updateBlockChain((NbEditorDocument) component.getDocument()); } } });
@Override public Set<? extends Document> getActiveDocuments() { final Set<Document> res = Collections.newSetFromMap(new IdentityHashMap<Document, Boolean>()); for (JTextComponent jtc : EditorRegistry.componentList()) { final Document doc = jtc.getDocument(); if (doc != null) { res.add(doc); } } return res; }
public static boolean isEnabled() { if (EditorRegistry.lastFocusedComponent() == null || !EditorRegistry.lastFocusedComponent().isShowing()) { return false; } if ( OpenProjects.getDefault().getOpenProjects().length == 0 ){ return false; } final FileObject fileObject = NbEditorUtilities.getFileObject( EditorRegistry.lastFocusedComponent().getDocument()); return isEnabled( fileObject ); /*WebModule webModule = WebModule.getWebModule(fileObject); if ( webModule == null ){ return false; } Profile profile = webModule.getJ2eeProfile(); return Profile.JAVA_EE_6_WEB.equals( profile) || Profile.JAVA_EE_6_FULL.equals( profile );*/ }
public void propertyChange(PropertyChangeEvent evt) { JTextComponent last = EditorRegistry.lastFocusedComponent(); if (last != null){ final NbEditorDocument doc = (NbEditorDocument) last.getDocument(); doc.getDocumentProperties().remove(TextSwitcher.TEXT_SWITCH_SUPPORT); doc.removeDocumentListener(dl); } JTextComponent current = EditorRegistry.focusedComponent(); if (current != null){ final NbEditorDocument doc = (NbEditorDocument) current.getDocument(); doc.addDocumentListener(dl); doc.getDocumentProperties().put(TextSwitcher.TEXT_SWITCH_SUPPORT, new ChangeListener() { public void stateChanged(@SuppressWarnings("unused") //NOI18N final ChangeEvent e) { restartTimer(); } }); restartTimer(); } }
final AtomicLong start = new AtomicLong(System.currentTimeMillis()); final boolean templateEdit = GsfUtilities.isCodeTemplateEditing(doc); JTextComponent lastFocusedComponent = templateEdit ? EditorRegistry.lastFocusedComponent() : null; final int caretOffset = lastFocusedComponent != null ? lastFocusedComponent.getCaretPosition() : unitTestCarretPosition == -1 ? 0 : unitTestCarretPosition; FormatVisitor fv = new FormatVisitor(doc, docOptions, caretOffset, formatContext.startOffset(), formatContext.endOffset());
public synchronized void stateChanged() { for (JTextComponent c : visibleEditors) { c.removePropertyChangeListener(this); visibleEditors2Files.remove(c); } visibleEditors.clear(); JTextComponent editor = EditorRegistry.lastFocusedComponent(); FileObject fo = editor != null ? getFileObject(editor) : null; if (editor instanceof JEditorPane && fo != null && Source.forFileObject(fo) != null) { visibleEditors.add(editor); } for (JTextComponent c : visibleEditors) { c.addPropertyChangeListener(this); visibleEditors2Files.put(c, getFileObject(c)); } fireChangeEvent(); }
private void insertLinkToEditor() { if (EditorRegistry.lastFocusedComponent() != null) { new InsertLinkAction(EditorRegistry.lastFocusedComponent(), outbox, true, false).actionPerformed(null); } }
public void start() { // Possibly clear editor from previous error message (#115073) String lastMessage = mostRecentMessage; if (lastMessage != null) { JTextComponent pane = EditorRegistry.lastFocusedComponent(); if (pane != null) { if (pane.isShowing()) { String text = Utilities.getStatusText(pane); if (lastMessage.equals(text)) { Utilities.clearStatusText(pane); } } } mostRecentMessage = null; } resetResults(); }
for (JTextComponent component : EditorRegistry.componentList ()) { ComponentPeer componentPeer = (ComponentPeer) component.getClientProperty (ComponentPeer.class); if (componentPeer != null) componentPeer.reschedule ();