コード例 #1
0
 @Override
 public void run() {
   JTextComponent component = EditorRegistry.focusedComponent();
   if (component != null) {
     DocumentPreprocessor.updateBlockChain(
         (NbEditorDocument) component.getDocument());
   }
 }
コード例 #2
0
  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);
                }
              });
    }
  }
コード例 #3
0
 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();
   }
 }