private void watchOpenedTCs() {
    ArrayList<TopComponent> windowsToWatch = findShowingTCs();
    ArrayList<TopComponent> toAddListeners = new ArrayList<>(windowsToWatch);
    toAddListeners.removeAll(watchedLkpResults.keySet());

    ArrayList<TopComponent> toRemoveListeners = new ArrayList<>(watchedLkpResults.keySet());
    toRemoveListeners.removeAll(windowsToWatch);

    toRemoveListeners
        .stream()
        .forEach(
            (tc) -> {
              Lookup.Result res = watchedLkpResults.get(tc);
              if (null != res) {
                res.removeLookupListener(this);
                watchedLkpResults.remove(tc);
              }
            });

    toAddListeners
        .stream()
        .forEach(
            (tc) -> {
              Lookup.Result res = tc.getLookup().lookupResult(LayoutScene.class);
              res.addLookupListener(this);
              res.allItems();
              watchedLkpResults.put(tc, res);
            });
  }
  @Override
  public void componentOpened() {
    customerNodeResult = context().lookupResult(Node.class);
    customerResult = context().lookupResult(Customer.class);
    customerQueryResult = context().lookupResult(CustomerCollection.class);

    customerNodeResult.addLookupListener(this);
    customerQueryResult.addLookupListener(this);
    customerResult.addLookupListener(this);

    resultChanged(new LookupEvent(customerResult));
  }
  public NbEditorToolBar(JTextComponent component) {
    this.componentRef = new WeakReference(component);

    setFloatable(false);
    // mkleint - instead of here, assign the border in CloneableEditor and MultiView module.
    //        // special border installed by core or no border if not available
    //        Border b = (Border)UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
    //        setBorder(b);
    addMouseListener(sharedMouseListener);

    installModulesInstallationListener();
    installNoOpActionMappings();

    lookupResult =
        MimeLookup.getLookup(DocumentUtilities.getMimeType(component))
            .lookupResult(KeyBindingSettings.class);
    lookupResult.addLookupListener(
        WeakListeners.create(LookupListener.class, keybindingsTracker, lookupResult));

    String mimeType = DocumentUtilities.getMimeType(component);
    preferences =
        MimeLookup.getLookup(mimeType == null ? MimePath.EMPTY : MimePath.parse(mimeType))
            .lookup(Preferences.class);
    preferences.addPreferenceChangeListener(
        WeakListeners.create(PreferenceChangeListener.class, prefsTracker, preferences));

    refreshToolbarButtons();
    setBorderPainted(true);
  }
  // Variables declaration - do not modify//GEN-BEGIN:variables
  // End of variables declaration//GEN-END:variables
  @Override
  public void componentOpened() {
    // Register to the global context and declare your interest
    devices = Utilities.actionsGlobalContext().lookupResult(BrickletRotaryPoti.class);

    devices.addLookupListener(this);
  }
 @Override
 public void componentOpened() {
   TopComponent projWindow = WindowManager.getDefault().findTopComponent("projectTabLogical_tc");
   trainingResultSets = projWindow.getLookup().lookupResult(DataSet.class);
   trainingResultSets.addLookupListener(this);
   resultChanged(new LookupEvent(trainingResultSets));
 }
  @Override
  public void componentOpened() {
    result = PartLookup.getDefault().lookupResult(Part.class);
    result.addLookupListener(this);

    fillData();
  }
  public PropertiesViewTopComponent() {
    initComponents();
    setName(Bundle.CTL_PropertiesViewTopComponent());
    setToolTipText(Bundle.HINT_PropertiesViewTopComponent());

    global = Utilities.actionsGlobalContext().lookupResult(IEntityWrapper.class);
    global.addLookupListener(listener);
  }
 public CreateGeoCodingDisplacementBandsAction(Lookup lookup) {
   super(Bundle.CTL_CreateGeoCodingDisplacementBandsActionText());
   this.lookup = lookup;
   Lookup.Result<ProductNode> lkpContext = lookup.lookupResult(ProductNode.class);
   lkpContext.addLookupListener(WeakListeners.create(LookupListener.class, this, lkpContext));
   setEnableState();
   putValue(Action.SHORT_DESCRIPTION, Bundle.CTL_CreateGeoCodingDisplacementBandsDescription());
 }
 @Override
 public Component getToolbarPresenter() {
   // actually start listening here
   if (res == null) {
     res = lookup.lookupResult(Scene.class);
     res.addLookupListener(this);
   }
   return getZoomDropdown();
 }
 @Override
 public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
   boolean startListening = getPropertyChangeListeners().length == 0;
   super.addPropertyChangeListener(l);
   if (startListening) {
     res = lookup.lookupResult(Scene.class);
     res.addLookupListener(this);
   }
 }
 public ImportVectorDataNodeFromCsvAction(Lookup lookup) {
   this.lookup = lookup;
   result = lookup.lookupResult(Product.class);
   result.addLookupListener(WeakListeners.create(LookupListener.class, this, result));
   setEnableState();
   setHelpId(Bundle.CTL_ImportVectorDataNodeFromCsvActionHelp());
   putValue(Action.NAME, Bundle.CTL_ImportVectorDataNodeFromCsvActionText());
   putValue(Action.SHORT_DESCRIPTION, Bundle.CTL_ImportVectorDataNodeFromCsvActionDescription());
 }
  public BlueDataObjectManagerImpl() {
    final Lookup.Result<BlueDataObjectLoader> results =
        Lookup.getDefault().lookupResult(BlueDataObjectLoader.class);

    updateLoaders(results.allInstances());

    results.addLookupListener(
        (LookupEvent ev) -> {
          updateLoaders(results.allInstances());
        });
  }
 /**
  * multiview components do not fire events when switching their inner tabs so we have to listen to
  * changes in lookup contents
  */
 private void switchLookupListener() {
   TopComponent active = TopComponent.getRegistry().getActivated();
   if (null != lookupRes) {
     lookupRes.removeLookupListener(SatelliteViewSwitch.this);
     lookupRes = null;
   }
   if (null != active) {
     lookupRes = active.getLookup().lookupResult(LayoutScene.class);
     lookupRes.addLookupListener(SatelliteViewSwitch.this);
     lookupRes.allItems();
   }
 }
Exemple #14
0
  void init() {

    if (lcResult != null) {
      return;
    }
    assert SwingUtilities.isEventDispatchThread() : "this shall be called just from AWT thread";

    // The thing we want to listen for the presence or absence of
    // on the global selection
    lcResult = context.lookupResult(LayerController.class);
    lcResult.addLookupListener(this);
    resultChanged(null);
  }
Exemple #15
0
  public MeasureAction() {

    setEnabled(context != null);
    Lookup lkp = Utilities.actionsGlobalContext();

    result = lkp.lookupResult(MeasurableCookie.class);
    result.addLookupListener(
        new LookupListener() {

          @Override
          public void resultChanged(LookupEvent ev) {
            Collection<? extends MeasurableCookie> c = result.allInstances();
            if (!c.isEmpty()) {
              context = c.iterator().next();
            } else {
              context = null;
            }
            setEnabled(context != null);
          }
        });
  }
 // Variables declaration - do not modify//GEN-BEGIN:variables
 // End of variables declaration//GEN-END:variables
 @Override
 public void componentOpened() {
   result = Utilities.actionsGlobalContext().lookupResult(Clustering.class);
   result.addLookupListener(this);
 }
 protected SingleContextAction(Class<T> type, Lookup lookup) {
   result = lookup.lookupResult(type);
   result.addLookupListener(SingleContextAction.this);
   resultChanged(null);
 }
 @Override
 public void restore() {
   lookup = Lookup.getDefault().lookupResult(clazz);
   lookup.addLookupListener(this);
   onRestore();
 }
  static {
    resultContext = Utilities.actionsGlobalContext().lookupResult(GISContextDataObject.class);
    resultContext.addLookupListener(
        new LookupListener() {

          @Override
          public void resultChanged(LookupEvent lookupEvent) {
            final Lookup.Result r = (Lookup.Result) lookupEvent.getSource();
            final Collection c = r.allInstances();
            if (!c.isEmpty()) {

              new Thread() {

                @Override
                public void run() {
                  final Iterator ite = c.iterator();
                  while (ite.hasNext()) {
                    final GISContextDataObject da = (GISContextDataObject) ite.next();
                    final MapContext candidate = da.getContext();
                    updateName(candidate);
                  }
                }
              }.start();
            }
          }
        });
    resultContext.allItems();

    resultViews = Utilities.actionsGlobalContext().lookupResult(ViewComponent.class);
    resultViews.addLookupListener(
        new LookupListener() {

          @Override
          public void resultChanged(LookupEvent lookupEvent) {
            final Lookup.Result r = (Lookup.Result) lookupEvent.getSource();
            final Collection c = r.allInstances();
            if (!c.isEmpty()) {

              new Thread() {

                @Override
                public void run() {
                  final Iterator ite = c.iterator();
                  while (ite.hasNext()) {
                    final ViewComponent da = (ViewComponent) ite.next();
                    final Map2D map = da.getMapView();

                    for (TreePopupItem tpi : getContextTree().controls()) {
                      System.out.println(tpi);
                      tpi.setMapView(map);
                    }

                    final MapContext candidate = da.getContext();
                    updateName(candidate);
                  }
                }
              }.start();
            }
          }
        });
    resultViews.allItems();

    resultGISViews = Utilities.actionsGlobalContext().lookupResult(GISView.class);
    resultGISViews.addLookupListener(
        new LookupListener() {

          @Override
          public void resultChanged(LookupEvent lookupEvent) {
            final Lookup.Result r = (Lookup.Result) lookupEvent.getSource();
            final Collection c = r.allInstances();
            if (!c.isEmpty()) {

              new Thread() {

                @Override
                public void run() {
                  final Iterator ite = c.iterator();
                  while (ite.hasNext()) {
                    final GISView da = (GISView) ite.next();
                    final MapContext candidate = da.getContext().getContext();
                    updateName(candidate);
                  }
                }
              }.start();
            }
          }
        });
    resultGISViews.allItems();
  }
 @Override
 public void componentOpened() {
   personResult = Utilities.actionsGlobalContext().lookupResult(Person.class);
   personResult.addLookupListener(this);
 }