/**
   * Create listener for property change on TopComponent.Registry
   *
   * @return
   */
  private PropertyChangeListener createRegistryListener() {
    return (PropertyChangeEvent evt) -> {
      if (TopComponent.Registry.PROP_CURRENT_NODES.equals(evt.getPropertyName())
          || TopComponent.Registry.PROP_OPENED.equals(evt.getPropertyName())
          || TopComponent.Registry.PROP_ACTIVATED.equals(evt.getPropertyName())) {

        if (TopComponent.Registry.PROP_ACTIVATED.equals(evt.getPropertyName())
            || TopComponent.Registry.PROP_OPENED.equals(evt.getPropertyName())) {
          // listen to Lookup changes of showing editor windows
          watchOpenedTCs();
        }

        if (TopComponent.Registry.PROP_ACTIVATED.equals(evt.getPropertyName())) {
          // switch lookup listener for the activated TC
          switchLookupListener();
        }
        run();
      }
    };
  }
Beispiel #2
0
    public synchronized void propertyChange(PropertyChangeEvent evt) {
      String propName = evt.getPropertyName();

      if (TopComponent.Registry.PROP_ACTIVATED.equals(propName)) {
        TopComponent activated = (TopComponent) evt.getNewValue();

        if (activated instanceof CloneableEditorSupport.Pane) editorActivated();
        else editorDeactivated();
      } else if (EditorUI.COMPONENT_PROPERTY.equals(propName)) {
        JTextComponent component = (JTextComponent) evt.getNewValue();

        if (component != null) { // just installed
          component.addPropertyChangeListener(this);
          if (component.isDisplayable()) {
            startTCRegistryListening();
          }

        } else { // just deinstalled
          component = (JTextComponent) evt.getOldValue();
          component.removePropertyChangeListener(this);
          stopTCRegistryListening();
        }

        reset();

      } else if ("editorKit".equals(propName)) { // NOI18N
        reset();

      } else if ("ancestor".equals(propName)) { // NOI18N
        if (((Component) evt.getSource()).isDisplayable()) { // now displayable
          startTCRegistryListening();
        } else { // not displayable
          stopTCRegistryListening();
        }
      }
    }