@Override public void run() { JTextComponent component = EditorRegistry.focusedComponent(); if (component != null) { DocumentPreprocessor.updateBlockChain((NbEditorDocument) component.getDocument()); } } });
public DocumentPreprocessor(){ dl = new DL(); JTextComponent component = EditorRegistry.focusedComponent(); if (component != null) { updateBlockChain((NbEditorDocument) component.getDocument()); final NbEditorDocument doc = (NbEditorDocument) component.getDocument(); doc.addDocumentListener(dl); doc.getDocumentProperties().put(TextSwitcher.TEXT_SWITCH_SUPPORT, new ChangeListener() { public void stateChanged(@SuppressWarnings("unused") final ChangeEvent e) { updateBlockChain(doc); } }); } }
public CurrentEditorTaskScheduler () { setEditor (EditorRegistry.focusedComponent ()); EditorRegistry.addPropertyChangeListener (new AListener ()); }
JTextComponent jtc = EditorRegistry.focusedComponent(); if (jtc == null) { jtc = EditorRegistry.lastFocusedComponent();
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(); } }
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); } } } } }
propName.equals (EditorRegistry.FOCUS_GAINED_PROPERTY) ) { JTextComponent editor = EditorRegistry.focusedComponent (); if (editor == currentEditor || (editor != null && editor.getClientProperty("AsTextField") != null)) { //NOI18N return;