public synchronized void propertyChange(PropertyChangeEvent event) {
   if (propertyChanging) {
     // Avoid an infinite loop whereby changing the lookup contents
     // causes the activated nodes to change, which calls us again.
     return;
   }
   propertyChanging = true;
   try {
     Node[] newNodes = (Node[]) event.getNewValue();
     if (newNodes == null || newNodes.length == 0) {
       setLookups(
           new Lookup[] {
             new ProxyLookup(lookups),
             new NoNodeLookup(delegate.getLookup()),
             Lookups.singleton(delegate)
           });
     } else {
       Lookup[] newNodeLookups = new Lookup[newNodes.length];
       for (int i = 0; i < newNodes.length; i++) {
         newNodeLookups[i] = new NoNodeLookup(newNodes[i].getLookup());
       }
       setLookups(
           new Lookup[] {
             new ProxyLookup(lookups),
             new ProxyLookup(newNodeLookups),
             Lookups.fixed((Object[]) newNodes)
           });
     }
   } finally {
     propertyChanging = false;
   }
 }
示例#2
0
 public static Lookup createAdditionalLookup(final Lookup lookup) {
   final Project project = lookup.lookup(Project.class);
   final ProjectType projectType = lookup(project);
   if (projectType != null) {
     return Lookups.fixed(new Object[] {new ProjectOpenedHookImp(projectType, project)});
   } else {
     return Lookups.fixed(new Object[0]);
   }
 }
  public static synchronized JContextTree getContextTree() {
    if (tree == null) {
      final JContextTree tree = new JContextTree();

      // search available popup menu items
      Lookup lk = Lookups.forPath("/Puzzle/ContextTree/Actions");
      for (TreePopupItem item : lk.lookupAll(TreePopupItem.class)) {
        tree.controls().add(item);
      }

      final List<PropertyPane> configPanes = new ArrayList<PropertyPane>();

      JPropertyTree propertyTree = new JPropertyTree();

      DefaultMutableTreeNode root = new DefaultMutableTreeNode();

      // search available property panels
      lk = Lookups.forPath("/Puzzle/ContextTree/PropertyPanels");
      for (PropertyPane p : lk.lookupAll(PropertyPane.class)) {
        root.add(new DefaultMutableTreeNode(p));
      }

      // search filter panels
      DefaultMutableTreeNode filterNodes =
          new DefaultMutableTreeNode(CoreResource.getString("filter"));
      lk = Lookups.forPath("/Puzzle/ContextTree/FilterPanels");
      for (PropertyPane p : lk.lookupAll(PropertyPane.class)) {
        filterNodes.add(new DefaultMutableTreeNode(p));
      }
      root.add(filterNodes);

      // search style panels
      DefaultMutableTreeNode styleNodes =
          new DefaultMutableTreeNode(CoreResource.getString("symbology"));
      lk = Lookups.forPath("/Puzzle/ContextTree/StylePanels");
      for (PropertyPane p : lk.lookupAll(PropertyPane.class)) {
        styleNodes.add(new DefaultMutableTreeNode(p));
      }
      root.add(styleNodes);

      if (!tree.controls().isEmpty()) {
        tree.controls().add(new SeparatorItem());
      }

      LayerPropertyItem property = new LayerPropertyItem(root);
      tree.controls().add(property);

      tree.revalidate();
      tree.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      ContextTreeTopComponent.tree = tree;
    }
    return tree;
  }
 private void executeInjection() {
   if (this.modello == null) {
     this.modello = Lookup.getDefault().lookup(Modello.class);
   }
   if (this.viewTransformationAction == null) {
     this.viewTransformationAction =
         Lookups.forPath("Azione").lookup(ActionViewTransformation.class);
   }
   if (this.actionViewInstances == null) {
     this.actionViewInstances = Lookups.forPath("Azione").lookup(ActionViewInstances.class);
   }
 }
示例#5
0
 private void executeInjection() {
   if (this.modello == null) {
     this.modello = Lookup.getDefault().lookup(Modello.class);
   }
   if (this.actionViewSpicy == null) {
     this.actionViewSpicy = Lookups.forPath("Azione").lookup(ActionViewSpicy.class);
   }
   if (this.actionViewBestMappings == null) {
     this.actionViewBestMappings = Lookups.forPath("Azione").lookup(ActionViewBestMappings.class);
   }
   this.mappingFinder =
       (IFindBestMappingsStrategy)
           Application.getInstance().getComponentInstance(IFindBestMappingsStrategy.class);
 }
  public void showCustomizer(String preselectedCategory, String preselectedSubCategory) {

    Dialog dialog = project2Dialog.get(project);
    if (dialog != null) {
      dialog.setVisible(true);
      return;
    } else {
      SharedRubyProjectProperties uiProperties =
          createUiProperties(project, updateHelper, evaluator, refHelper, genFileHelper);
      Lookup context =
          Lookups.fixed(
              new Object[] {
                project,
                uiProperties,
                new SubCategoryProvider(preselectedCategory, preselectedSubCategory)
              });

      OptionListener listener = new OptionListener(project, uiProperties);
      dialog =
          ProjectCustomizer.createCustomizerDialog(
              getCustomizerFolderPath(), context, preselectedCategory, listener, null);
      dialog.addWindowListener(listener);
      dialog.setTitle(
          MessageFormat.format(
              NbBundle.getMessage(
                  BaseRubyCustomizerProvider.class, "LBL_Customizer_Title"), // NOI18N
              new Object[] {ProjectUtils.getInformation(project).getDisplayName()}));

      project2Dialog.put(project, dialog);
      dialog.setVisible(true);
    }
  }
示例#7
0
 public NetworkVertexNode(Children children, NetworkElementApi data, NetworkCaseSetApi caseData) {
   super(children, Lookups.singleton(data));
   this.setVertexModelData(data);
   this.setCaseModelData(caseData);
   this.setDisplayName(data.getValue());
   this.AddModelListeners();
 }
示例#8
0
  @Override
  @SuppressWarnings("unchecked")
  public TopComponent getTopComponent() {
    // Loading the multiview windows:
    FileObject multiviewsFolder = FileUtil.getConfigFile("skitmultiviews");
    FileObject[] kids = multiviewsFolder.getChildren();
    MultiViewDescription[] descriptionArray = new MultiViewDescription[kids.length];
    ArrayList<MultiViewDescription> listOfDescs = new ArrayList<MultiViewDescription>();

    for (FileObject kid : FileUtil.getOrder(Arrays.asList(kids), true)) {
      MultiViewDescription attribute = (MultiViewDescription) kid.getAttribute("multiview");

      if (attribute instanceof ContextAwareInstance) {
        Lookup lu = Lookups.fixed(this);
        attribute =
            ((ContextAwareInstance<MultiViewDescription>) attribute).createContextAwareInstance(lu);
      }

      listOfDescs.add(attribute);
    }

    for (int i = 0; i < listOfDescs.size(); i++) {
      descriptionArray[i] = listOfDescs.get(i);
    }

    CloneableTopComponent ctc =
        MultiViewFactory.createCloneableMultiView(descriptionArray, descriptionArray[0]);

    return ctc;
  }
 public RootNode(Node node, TitanPlatformProject project) throws DataObjectNotFoundException {
   super(
       node,
       new FilterNode.Children(node),
       new ProxyLookup(new Lookup[] {Lookups.singleton(project), node.getLookup()}));
   this.project = project;
 }
 @Override
 public Lookup getLookup() {
   if (this.lookup == null) {
     this.lookup = Lookups.fixed(this, new Info(), new RIACropModelDatasetLV(this));
   }
   return this.lookup;
 }
示例#11
0
 public SceneComponentNode(MainSceneComponent msc) {
   super(Children.LEAF, Lookups.singleton(msc));
   this.msc = msc;
   this.msc.addPropertyChangeListener(this);
   this.setDisplayName(msc.getType().name() + ": " + msc.getComponentName());
   this.setName(msc.toString());
 }
 /**
  * Creates a new instance of CookieProxyLookup.
  *
  * @param lookups the Lookup instances to which we proxy.
  * @param delegate the Node delegate from which cookies come.
  */
 public SourceCookieProxyLookup(Lookup[] lookups, Node delegate) {
   super();
   this.lookups = lookups;
   this.delegate = delegate;
   setLookups(
       new Lookup[] {new ProxyLookup(lookups), delegate.getLookup(), Lookups.singleton(delegate)});
 }
  DefaultPraxisProject(FileObject directory, FileObject projectFile, ProjectState state)
      throws IOException {
    this.directory = directory;
    this.projectFile = projectFile;
    this.state = state;
    properties = parseProjectFile(projectFile);
    propsListener = new PropertiesListener();
    properties.addPropertyChangeListener(propsListener);

    Lookup base =
        Lookups.fixed(
            new Object[] {
              this,
              properties,
              new Info(),
              new ActionImpl(),
              state,
              new PraxisCustomizerProvider(this),
              new PraxisLogicalViewProvider(this),
              new BaseTemplates(),
              UILookupMergerSupport.createPrivilegedTemplatesMerger()
            });

    this.lookup = LookupProviderSupport.createCompositeLookup(base, LOOKUP_PATH);
    helperListener = new HelperListener();
    ProjectHelper.getDefault()
        .addPropertyChangeListener(
            WeakListeners.propertyChange(helperListener, ProjectHelper.getDefault()));
  }
 @Override
 public void run() {
   try {
     progressHandle.start();
     progressHandle.progress("Creating dataset");
     List<INamedElementProvider<? extends IChromatogram2D, ? extends IScan2D>> providers =
         new ArrayList<>();
     if (!(chromatogram.getChromatogram() instanceof IChromatogram2D)) {
       throw new IllegalArgumentException("Action only of 2D chromatograms!");
     }
     providers.add(
         new Chromatogram2DElementProvider(
             chromatogram.getDisplayName(), (IChromatogram2D) chromatogram.getChromatogram()));
     final Chromatogram2DDataset ds =
         new Chromatogram2DDataset(providers, Lookups.fixed(chromatogram, project));
     onEdt(
         new Runnable() {
           @Override
           public void run() {
             final Chromatogram2DViewTopComponent jtc =
                 new Chromatogram2DViewTopComponent(dobj, ds);
             jtc.open();
             jtc.requestActive();
           }
         });
   } finally {
     progressHandle.finish();
   }
 }
示例#15
0
文件: Tags.java 项目: halbbob/autopsy
 public TagsRootNode() {
   super(Children.create(new Tags.TagsRootChildren(), true), Lookups.singleton(NAME));
   super.setName(NAME);
   super.setDisplayName(NAME);
   this.setIconBaseWithExtension(TAG_ICON_PATH);
   initData();
 }
示例#16
0
  /**
   * Creates new form GTPanel
   *
   * @param name
   * @param gr
   * @param ds
   */
  public GTPanel(String name, UPGMAItem gr, TypingData<? extends Profile> ds) {
    super(Lookups.singleton(gr));
    initComponents();
    this.setName(name);

    this.ds = ds;
    String distanceProvider = gr.getDistanceProvider();
    int split = distanceProvider.lastIndexOf(".") + 1;
    distanceProvider = distanceProvider.substring(split);
    uv = new UPGMAViewer(name, gr.getRoot(), distanceProvider);

    Visualization viz = gr.getVisualization();
    if (viz != null && viz.pv != null) {
      loadVisualization(viz);
    }

    tvc = uv.generateTreeViewComponent();

    this.add(tvc);
    gvCatListen =
        new CategoryChangeListener() {

          @Override
          public void categoryChange(CategoryProvider cp) {

            if (cp.isOn()) {
              catProvider = cp;
              uv.setDefaultRenderer(new ChartRenderer(cp, uv));
              uv.setCategoryProvider(cp);
            } else {
              catProvider = null;
              uv.resetDefaultRenderer();
              uv.setCategoryProvider(null);
            }
          }
        };

    // Let us track category providers...
    // TODO: implement this within a renderer.
    r = ds.getLookup().lookupResult(CategoryProvider.class);
    Iterator<? extends CategoryProvider> i = r.allInstances().iterator();
    while (i.hasNext()) i.next().addCategoryChangeListener(gvCatListen);

    r.addLookupListener(
        new LookupListener() {

          @SuppressWarnings("unchecked")
          @Override
          public void resultChanged(LookupEvent le) {

            Iterator<? extends CategoryProvider> i =
                ((Result<CategoryProvider>) le.getSource()).allInstances().iterator();
            while (i.hasNext()) {
              CategoryProvider cp = i.next();
              cp.removeCategoryChangeListener(gvCatListen);
              cp.addCategoryChangeListener(gvCatListen);
            }
          }
        });
  }
示例#17
0
 // use version with observer instead so that it updates
 @Deprecated
 FileSizeNode(SleuthkitCase skCase, FileSizeFilter filter) {
   super(
       Children.create(new FileSizeChildren(filter, skCase, null), true),
       Lookups.singleton(filter.getDisplayName()));
   this.filter = filter;
   init();
 }
示例#18
0
 @Override
 public Action[] getActions(boolean context) {
   List<Action> actions = new ArrayList<>();
   actions.add((Action) OpenAction.findObject(OpenAction.class, true));
   actions.addAll(
       Lookups.forPath(OutlineTopComponent.NODE_ACTIONS_FOLDER).lookupAll(Action.class));
   return actions.toArray(new Action[actions.size()]);
 }
示例#19
0
 /**
  * @param skCase
  * @param filter
  * @param o Observable that provides updates when events are fired
  */
 FileSizeNode(SleuthkitCase skCase, FileSizeFilter filter, Observable o) {
   super(
       Children.create(new FileSizeChildren(filter, skCase, o), true),
       Lookups.singleton(filter.getDisplayName()));
   this.filter = filter;
   init();
   o.addObserver(new FileSizeNodeObserver());
 }
示例#20
0
 public static void renameProject(Project p, Object caller) {
   if (p == null) {
     return;
   }
   ContextAwareAction action = (ContextAwareAction) CommonProjectActions.renameProjectAction();
   Lookup ctx = Lookups.singleton(p);
   Action ctxAction = action.createContextAwareInstance(ctx);
   ctxAction.actionPerformed(new ActionEvent(caller, 0, "")); // NOI18N
 }
  @Override
  public Lookup createAdditionalLookup(Lookup lkp) {
    final Project j2seProject = lkp.lookup(Project.class);

    return Lookups.fixed(
        new KotlinPrivilegedTemplates(),
        new J2SEExtendedClassPathProvider(j2seProject),
        new J2SEProjectOpenedHook(j2seProject));
  }
示例#22
0
 public PackageNode(FileObject root, DataFolder dataFolder, boolean empty) {
   super(
       dataFolder.getNodeDelegate(),
       empty ? Children.LEAF : dataFolder.createNodeChildren(NO_FOLDERS_FILTER),
       new ProxyLookup(
           new Lookup[] {
             Lookups.singleton(new NoFoldersContainer(dataFolder)),
             dataFolder.getNodeDelegate().getLookup(),
             Lookups.singleton(
                 PackageRootNode.alwaysSearchableSearchInfo(
                     SearchInfoFactory.createSearchInfo(
                         dataFolder.getPrimaryFile(),
                         false, // not recursive
                         new FileObjectFilter[] {SearchInfoFactory.VISIBILITY_FILTER}))),
           }));
   this.root = root;
   this.dataFolder = dataFolder;
   this.isDefaultPackage = root.equals(dataFolder.getPrimaryFile());
 }
示例#23
0
 public PathNode(Children children, List<NetworkElementApi> edges) {
   super(children, Lookups.singleton(edges));
   this.setPathModel(edges);
   if (edges.get(0).getNetworkElementType() == NetworkElementApi.NetworkElementType.NODE) {
     this.setDisplayName("End Points");
   }
   if (edges.get(0).getNetworkElementType() == NetworkElementApi.NetworkElementType.EDGE) {
     this.setDisplayName("Path-Size: " + mEdges.size());
   }
 }
  @Override
  protected Node[] createNodes(Object key) {

    final Enterprise enterprise1 = (Enterprise) key;
    Node result;
    result =
        new AbstractNode(new EnterpriseChildren(enterprise1), Lookups.singleton(enterprise1)) {

          @Override
          protected Sheet createSheet() {
            Sheet sheet = Sheet.createDefault();
            Sheet.Set set = Sheet.createPropertiesSet();

            Property giamDocProperty =
                new PropertySupport.ReadOnly<String>(Giamdoc_PROPERTY, String.class, "Thu", "aaa") {

                  @Override
                  public String getValue()
                      throws IllegalAccessException, InvocationTargetException {
                    return String.valueOf(calculateSPI.calculateSumImportByEnterprise(enterprise1));
                  }

                  @Override
                  public PropertyEditor getPropertyEditor() {
                    return new PropertyEditorSupport();
                  }
                };
            set.put(giamDocProperty);
            Property congTyMeProperty =
                new PropertySupport.ReadOnly<String>(
                    Congtyme_PROPERTY, String.class, "Chi", "bbb") {

                  @Override
                  public String getValue()
                      throws IllegalAccessException, InvocationTargetException {
                    return String.valueOf(calculateSPI.calculateSumExportByEnterprise(enterprise1));
                  }

                  @Override
                  public PropertyEditor getPropertyEditor() {
                    return new PropertyEditorSupport();
                  }
                };
            set.put(congTyMeProperty);
            sheet.put(set);
            return sheet;
          }
        };

    result.setDisplayName(enterprise1.getEnterpriseName());
    return new Node[] {result};
  }
示例#25
0
 public static ModelSource createModelSource(final FileObject thisFileObj, boolean editable)
     throws DataObjectNotFoundException {
   assert thisFileObj != null : "Null file object.";
   final DataObject dobj = DataObject.find(thisFileObj);
   final Document document = getDocument(thisFileObj);
   Lookup proxyLookup =
       Lookups.proxy(
           new Lookup.Provider() {
             public Lookup getLookup() {
               return Lookups.fixed(
                   new Object[] {FileUtil.toFile(thisFileObj), thisFileObj, document, dobj});
             }
           });
   return new ModelSource(proxyLookup, editable);
 }
  @ServiceProvider(service = MimeDataProvider.class)
  public static final class JavacParserProvider implements MimeDataProvider {

    private Lookup javaLookup =
        Lookups.fixed(new JavacParserFactory(), new JavaCustomIndexer.Factory());

    @Override
    public Lookup getLookup(MimePath mimePath) {
      if (mimePath.getPath().endsWith(JavacParser.MIME_TYPE)) {
        return javaLookup;
      }

      return Lookup.EMPTY;
    }
  }
  private Lookup getDefaultLookup() {
    // The Lookup is not created in the constructor, so that we do not need
    // to share "this" in the constructor.
    Lookup result = defaultLookupRef.get();
    if (result == null) {
      GradleAuxiliaryConfiguration auxConfig = new GradleAuxiliaryConfiguration(this);

      Lookup newLookup =
          Lookups.fixed(
              new Object[] {
                this,
                state, // allow outside code to mark the project as needing saving
                NbGradleSingleProjectConfigProvider.create(this),
                new GradleProjectInformation(this),
                new GradleProjectLogicalViewProvider(this),
                new GradleActionProvider(this),
                new GradleSharabilityQuery(this),
                new GradleSourceEncodingQuery(this),
                new GradleCustomizer(this),
                new OpenHook(),
                auxConfig,
                new GradleAuxiliaryProperties(auxConfig),
                new GradleTemplateAttrProvider(this),
                new DefaultGradleCommandExecutor(this),
                ProjectPropertiesApi.buildPlatform(getProperties().getPlatform()),
                ProjectPropertiesApi.scriptPlatform(getProperties().getScriptPlatform()),
                ProjectPropertiesApi.sourceEncoding(getProperties().getSourceEncoding()),
                ProjectPropertiesApi.sourceLevel(getProperties().getSourceLevel()),
                new ProjectInfoManager(),

                // FileOwnerQueryImplementation cannot be added to the project's
                // lookup, since NetBeans will ignore it. It must be added
                // using the ServiceProviders annotation. Our implementation is
                // GradleFileOwnerQuery and is added using the annotation.
              });

      if (defaultLookupRef.compareAndSet(null, newLookup)) {
        for (ProjectInitListener listener : newLookup.lookupAll(ProjectInitListener.class)) {
          listener.onInitProject();
        }

        loadProject(true, true);
      }
      result = defaultLookupRef.get();
    }
    return result;
  }
示例#28
0
 private NamedOption findOption(String name) {
   for (String category :
       Arrays.asList(
           HIGHLIGTING_CATEGORY, HINTS_CATEGORY, MAKE_PROJECT_CATEGORY, OTHER_CATEGORY)) {
     for (NamedOption option : Lookups.forPath(category).lookupAll(NamedOption.class)) {
       if (name.equals(option.getName())) {
         return option;
       }
     }
   }
   for (NamedOption option : Lookup.getDefault().lookupAll(NamedOption.class)) {
     if (name.equals(option.getName())) {
       return option;
     }
   }
   throw new IllegalArgumentException("Not found option " + name); // NOI18N
 }
 @Override
 public void showCustomizer() {
   Dialog dialog =
       ProjectCustomizer.createCustomizerDialog(
           // Path to layer folder:
           CUSTOMIZER_FOLDER_PATH,
           // Lookup, which must contain, at least, the Project:
           Lookups.fixed(project),
           // Preselected category:
           "",
           // OK button listener:
           new OKOptionListener(),
           // HelpCtx for Help button of dialog:
           null);
   dialog.setTitle(ProjectUtils.getInformation(project).getDisplayName());
   dialog.setVisible(true);
 }
示例#30
0
文件: Tags.java 项目: halbbob/autopsy
    TagNodeRoot(
        BlackboardArtifact.ARTIFACT_TYPE tagType,
        String tagName,
        List<BlackboardArtifact> artifacts) {
      super(
          Children.create(new Tags.TagsChildrenNode(tagType, tagName, artifacts), true),
          Lookups.singleton(tagName));

      super.setName(tagName);
      super.setDisplayName(tagName + " (" + artifacts.size() + ")");

      if (tagName.equals(BOOKMARK_TAG_NAME)) {
        this.setIconBaseWithExtension(BOOKMARK_ICON_PATH);
      } else {
        this.setIconBaseWithExtension(TAG_ICON_PATH);
      }
    }