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