コード例 #1
1
  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);
            });
  }
 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());
 }
コード例 #3
0
  @Override
  public void resultChanged(LookupEvent lookupEvent) {
    Lookup.Result r = (Lookup.Result) lookupEvent.getSource();
    Collection<PatientRecord> coll = r.allInstances();
    if (!coll.isEmpty()) {
      for (PatientRecord cus : coll) customerRisks = riskManager.findRiskByClient(cus);
      initializeManager();
    } else {

    }
  }
コード例 #4
0
  public BlueDataObjectManagerImpl() {
    final Lookup.Result<BlueDataObjectLoader> results =
        Lookup.getDefault().lookupResult(BlueDataObjectLoader.class);

    updateLoaders(results.allInstances());

    results.addLookupListener(
        (LookupEvent ev) -> {
          updateLoaders(results.allInstances());
        });
  }
コード例 #5
0
  @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));
  }
コード例 #6
0
 /**
  * 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();
   }
 }
コード例 #7
0
 private static synchronized PackageRenameHandler getRenameHandler() {
   Lookup.Result renameImplementations =
       Lookup.getDefault().lookup(new Lookup.Template(PackageRenameHandler.class));
   List handlers = (List) renameImplementations.allInstances();
   if (handlers.size() == 0) return null;
   if (handlers.size() > 1)
     ErrorManager.getDefault()
         .log(
             ErrorManager.WARNING,
             "Multiple instances of PackageRenameHandler found in Lookup; only using first one: "
                 + handlers); // NOI18N
   return (PackageRenameHandler) handlers.get(0);
 }
 @Override
 public void componentOpened() {
   TopComponent projWindow = WindowManager.getDefault().findTopComponent("projectTabLogical_tc");
   trainingResultSets = projWindow.getLookup().lookupResult(DataSet.class);
   trainingResultSets.addLookupListener(this);
   resultChanged(new LookupEvent(trainingResultSets));
 }
コード例 #9
0
  // 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);
  }
コード例 #10
0
 @Override
 public void resultChanged(LookupEvent ev) {
   for (final BrickletRotaryPoti device : devices.allInstances()) {
     ((BrickletRotaryPoti) device).setPositionCallbackPeriod(100);
     ((BrickletRotaryPoti) device).addListener(new PositionListenerImpl());
   }
 }
コード例 #11
0
  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);
  }
コード例 #12
0
  @Override
  public void componentOpened() {
    result = PartLookup.getDefault().lookupResult(Part.class);
    result.addLookupListener(this);

    fillData();
  }
コード例 #13
0
  private void fillData() {
    Collection<? extends Part> partCol = result.allInstances();
    if (!partCol.isEmpty()) {
      Part tempart = partCol.iterator().next();
      if (part != tempart) {
        part = tempart;
        clearGeneral();
        clearNotes();

        idTextField.setText(part.getId().toString());
        makeTextField.setText(part.getMake());
        modelTextField.setText(part.getModel());
        categoryTextField.setText(part.getCategory());

        if (part.getPrice() != null) {
          priceWithoutIVATextField.setText(formatWithoutIVA(part.getPrice()));
          priceWithIVATextField.setText(formatWithIVA(part.getPrice()));
        }

        notesTextArea.setText(part.getNotes());
        fillStock();

        printButton.setEnabled(true);
      }
    } else {
      //            clear();
    }
  }
コード例 #14
0
  @Override
  public void resultChanged(LookupEvent lookupEvent) {
    nameField.setText("[no name]");
    cityField.setText("[no city]");

    // Get the query:
    Collection allQueries = customerQueryResult.allInstances();
    Iterator it1 = allQueries.iterator();
    while (it1.hasNext()) {
      query = (CustomerCollection) it1.next();
      setDisplayName("Customers");
    }
    // Get the customer:
    Collection allCustomers = customerResult.allInstances();
    Iterator it2 = allCustomers.iterator();
    while (it2.hasNext()) {
      customer = (Customer) it2.next();
      nameField.setText(customer.getName());
      cityField.setText(customer.getCity());
    }
    // Get the node:
    Collection allNodes = customerNodeResult.allInstances();
    Iterator it3 = allNodes.iterator();
    while (it3.hasNext()) {
      customerNode = (Node) it3.next();
    }
    // Need to Clear Save and Undo here
    nameText = nameField.getText();
    cityText = cityField.getText();

    // Remove New Type?
    Lookup.Result<NewType> newTypeResult = getLookup().lookupResult(NewType.class);
    Collection allNewTypes = newTypeResult.allInstances();
    Iterator it4 = allNewTypes.iterator();
    while (it4.hasNext()) {
      instanceContent.remove(it4.next());
    }

    if (customerNode != null) {
      this.setActivatedNodes(new Node[] {customerNode});
      for (NewType nt : customerNode.getNewTypes()) {
        instanceContent.add(nt);
      }
    }
    manager.discardAllEdits();
    modify();
  }
コード例 #15
0
 @Override
 public synchronized void removePropertyChangeListener(PropertyChangeListener l) {
   super.removePropertyChangeListener(l);
   if (getPropertyChangeListeners().length == 0) {
     res.removeLookupListener(this);
     res = null;
   }
 }
コード例 #16
0
  public PropertiesViewTopComponent() {
    initComponents();
    setName(Bundle.CTL_PropertiesViewTopComponent());
    setToolTipText(Bundle.HINT_PropertiesViewTopComponent());

    global = Utilities.actionsGlobalContext().lookupResult(IEntityWrapper.class);
    global.addLookupListener(listener);
  }
コード例 #17
0
 @Override
 public Component getToolbarPresenter() {
   // actually start listening here
   if (res == null) {
     res = lookup.lookupResult(Scene.class);
     res.addLookupListener(this);
   }
   return getZoomDropdown();
 }
コード例 #18
0
 @Override
 public void close() {
   onClose();
   // TODO: find out why it is sometimes null here
   if (lookup != null) {
     lookup.removeLookupListener(this);
     lookup = null;
   }
 }
コード例 #19
0
 private List<? extends MultiKeyBinding> getKeyBindingList() {
   Collection<? extends KeyBindingSettings> c = lookupResult.allInstances();
   if (!c.isEmpty()) {
     KeyBindingSettings kbs = c.iterator().next();
     return kbs.getKeyBindings();
   } else {
     return Collections.<MultiKeyBinding>emptyList();
   }
 }
コード例 #20
0
 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());
 }
コード例 #21
0
 @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);
   }
 }
コード例 #22
0
 @Override
 public void resultChanged(LookupEvent ev) {
   // treeView.removeAll();
   Collection<? extends Clustering> allClusterings = result.allInstances();
   for (Clustering c : allClusterings) {
     root = new ClustersNode(c);
   }
   mgr.setRootContext(root);
 }
 @Override
 public void resultChanged(LookupEvent le) {
   Lookup.Result r = (Lookup.Result) le.getSource();
   Collection c = r.allInstances();
   if (!c.isEmpty()) {
     dataset = (DataSet) c.iterator().next();
     datasetTextField.setEnabled(true);
     datasetTextField.setText(dataset.getLabel());
     graphTypeCombo.removeAllItems();
     if (nnet != null && dataset != null) {
       graphTypeCombo.addItem(new OutputSurface3D(nnet, dataset));
       graphTypeCombo.addItem(new ErrorSurface3D(nnet, dataset));
       graphTypeCombo.addItem(new OutputForAttributeSurface3D(nnet, dataset));
       graphTypeCombo.addItem(new ErrorForAttributeSurface3D(nnet, dataset));
       datasetRowCount = dataset.getRows().size();
       drawButton.setEnabled(true);
     }
   }
 }
コード例 #24
0
 public static HandlerCreator getHandlerCreator(Project project, WizardDescriptor wiz) {
   Collection<? extends HandlerCreatorProvider> instances = handlerProviders.allInstances();
   for (HandlerCreatorProvider impl : instances) {
     HandlerCreator creator = impl.getHandlerCreator(project, wiz);
     if (creator != null) {
       return creator;
     }
   }
   return null;
 }
コード例 #25
0
 public static ServiceCreator getServiceCreator(Project project, WizardDescriptor wiz) {
   Collection<? extends ServiceCreatorProvider> instances = serviceProviders.allInstances();
   for (ServiceCreatorProvider impl : instances) {
     ServiceCreator creator = impl.getServiceCreator(project, wiz);
     if (creator != null) {
       return creator;
     }
   }
   return null;
 }
コード例 #26
0
 public static ClientCreator getClientCreator(Project project, WizardDescriptor wiz) {
   Collection<? extends ClientCreatorProvider> instances = clientProviders.allInstances();
   for (ClientCreatorProvider impl : instances) {
     ClientCreator creator = impl.getClientCreator(project, wiz);
     if (creator != null) {
       return creator;
     }
   }
   return null;
 }
コード例 #27
0
  @Override
  public void resultChanged(LookupEvent ev) {
    if (!res.allInstances().isEmpty()) {
      if (scene != null) {
        // remove listener on previous scene
        scene.removeSceneListener(this);
      }
      scene = res.allInstances().iterator().next();
      scene.addSceneListener(this);
      Lookup.Result<StrategicZoom> strategies = scene.getLookup().lookupResult(StrategicZoom.class);
      if (!strategies.allInstances().isEmpty()) {
        // set the flag bahwa sekarang ini mau ganti model.
        // by default, setModel akan trigger setItem dari first item di model
        // jadi kalo first item nya toFit, tiap kali pindah tab, bakal jadi toFit
        lagiPindahModel = true;
        zoomlist.setModel(new DefaultComboBoxModel(strategies.allInstances().toArray()));
        lagiPindahModel = false;
      } else {
        zoomlist.setModel(new DefaultComboBoxModel());
      }

      ((ZoomComboBoxEditor) zoomlist.getEditor()).setZoomText(getCalibratedZoomFactor());
    } else {
      if (scene != null) {
        // remove listener on previous scene
        scene.removeSceneListener(this);
      }
    }

    setEnabled(!res.allItems().isEmpty());
  }
コード例 #28
0
ファイル: DeleteLayerAction.java プロジェクト: danurwenda/JB4
  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);
  }
コード例 #29
0
  private void getLatestExperimentContext() {
    final Collection<? extends ExperimentContext> items = expContextResults.allInstances();
    if (!items.isEmpty()) {
      ExperimentContext data = null;
      Iterator<ExperimentContext> it = (Iterator<ExperimentContext>) items.iterator();
      while (it.hasNext()) {
        data = it.next();
      }

      expContext = data;
      update(expContext);
    }
  }
コード例 #30
0
 @Override
 public void resultChanged(LookupEvent le) {
   Collection<? extends Person> p = personResult.allInstances();
   if (p.size() == 1) {
     Person currentPerson = p.iterator().next();
     for (Node node : em.getRootContext().getChildren().getNodes()) {
       if (node.getLookup().lookup(Synchronizable.class).getPerson() == currentPerson) {
         try {
           em.setSelectedNodes(new Node[] {node});
         } catch (PropertyVetoException ex) {
           Exceptions.printStackTrace(ex);
         }
       }
     }
   }
 }