private Node getNextMeaningfullNode() {
    if (comp.nodesForNext == null) {
      comp.nodesForNext = new LinkedList<Node>();
      comp.nodesForNext.add(comp.getExplorerManager().getRootContext());
    }

    List<Node> nodesForNext = comp.nodesForNext;

    while (!nodesForNext.isEmpty()) {
      Node top = nodesForNext.remove(0);

      if (top.getChildren() != Children.LEAF) {
        nodesForNext.addAll(0, Arrays.asList(top.getChildren().getNodes(true)));
        continue;
      }

      ErrorDescription ed = top.getLookup().lookup(ErrorDescription.class);

      if (ed != null) {
        Node[] selected = comp.getExplorerManager().getSelectedNodes();

        if (selected.length == 1 && selected[0] == top) {
          addToSeenNodes(top);
          continue;
        }

        return top;
      }
    }

    return null;
  }
Exemple #2
0
 /**
  * DOCUMENT ME!
  *
  * @param libNodes DOCUMENT ME!
  * @return DOCUMENT ME!
  */
 private boolean performDeploy(final List<Node> libNodes) {
   final List<DeployInformation> infos = new LinkedList<DeployInformation>();
   final ModificationStore modStore = ModificationStore.getInstance();
   for (final Node libNode : libNodes) {
     for (final Node node : libNode.getChildren().getNodes(true)) {
       for (final Action a : node.getActions(false)) {
         // if this action is registered it node should be of type
         // LocalManagement or StarterManagement
         if (a instanceof DeployChangedJarsAction) {
           for (final Node ch : node.getChildren().getNodes()) {
             final DeployInformation info = DeployInformation.getDeployInformation(ch);
             final String path = FileUtil.toFile(info.getSourceDir()).getAbsolutePath();
             if (modStore.anyModifiedInContext(path, ModificationStore.MOD_CHANGED)) {
               infos.add(info);
             }
           }
           // continue with outer loop since only one action of
           // this type should be registered
           break;
         }
       }
     }
   }
   try {
     JarHandler.deployAllJars(infos, JarHandler.ANT_TARGET_DEPLOY_CHANGED_JARS);
     for (final DeployInformation info : infos) {
       final String path = FileUtil.toFile(info.getSourceDir()).getAbsolutePath();
       modStore.removeAllModificationsInContext(path, ModificationStore.MOD_CHANGED);
     }
     return true;
   } catch (final IOException ex) {
     LOG.warn("could not deploy changed jars", ex); // NOI18N
     return false;
   }
 }
  /** Refreshes changed content nodes */
  private void refreshDataSourceTree() {
    Node selectedNode = getSelectedNode();
    final String[] selectedPath = NodeOp.createPath(selectedNode, em.getRootContext());

    Children rootChildren = em.getRootContext().getChildren();
    Node dataSourcesFilterNode = rootChildren.findChild(DataSourcesNode.NAME);
    if (dataSourcesFilterNode == null) {
      logger.log(
          Level.SEVERE,
          "Cannot find data sources filter node, won't refresh the content tree"); // NON-NLS
      return;
    }
    OriginalNode imagesNodeOrig = dataSourcesFilterNode.getLookup().lookup(OriginalNode.class);

    if (imagesNodeOrig == null) {
      logger.log(
          Level.SEVERE, "Cannot find data sources node, won't refresh the content tree"); // NON-NLS
      return;
    }

    Node imagesNode = imagesNodeOrig.getNode();

    RootContentChildren contentRootChildren = (RootContentChildren) imagesNode.getChildren();
    contentRootChildren.refreshContentKeys();

    // final TreeView tree = getTree();
    // tree.expandNode(imagesNode);

    setSelectedNode(selectedPath, DataSourcesNode.NAME);
  }
  public Node[] getServiceNodes(Project project) {
    WebServicesSupport jaxrpcWsSupport =
        WebServicesSupport.getWebServicesSupport(project.getProjectDirectory());

    if (jaxrpcWsSupport != null) {
      Sources sources = (Sources) project.getLookup().lookup(Sources.class);
      if (sources != null) {
        SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        if (groups != null) {
          List<FileObject> roots = new ArrayList<FileObject>();
          for (SourceGroup group : groups) {
            roots.add(group.getRootFolder());
          }
          if (jaxrpcWsSupport.getServices().size() > 0 && roots.size() > 0) {
            FileObject srcRoot = roots.get(0);
            Node servicesNode =
                WebServicesView.getWebServicesView(srcRoot).createWebServicesView(srcRoot);
            if (servicesNode != null) {
              return servicesNode.getChildren().getNodes();
            }
          }
        }
      }
    }
    return null;
  }
 @Override
 protected Node[] createNodes(Object key) {
   Node node;
   if (key == keyLayout) node = new LayoutNode((RADVisualContainer) container);
   else {
     node = new RADComponentNode((RADComponent) key);
     node.getChildren().getNodes(); // enforce subnodes creation
   }
   return new Node[] {node};
 }
 public ModelItem[] getChildren() {
   if (group == null) return null;
   if (children == null) {
     final Node n = PackageView.createPackageView(group);
     if (n == null) return null;
     final Children ch = n.getChildren();
     if (ch == null) return null;
     final Node nodes[] = ch.getNodes(true);
     children = new ModelItem[nodes.length];
     for (int i = 0; i < nodes.length; i++) {
       children[i] = new ModelItem(nodes[i]);
     }
   }
   return children;
 }
 /**
  * Expands the node if the node's state is not equal to "Not started" (i.e. it has been completed)
  * and selects it. Then, continues down it's children by calling this same method.
  *
  * <p>The recursion stops as soon as it gets to a node which has not been started.
  *
  * @param n The node down which to recurse
  */
 private void openTreeToCurrentStateRecursivly(Node n) {
   if (n instanceof ActivityNode) {
     if (!((ActivityNode) n).getCompletionState().equals("Planned")
         && !((ActivityNode) n).getCompletionState().equals("Contingent")
         && !((ActivityNode) n).getCompletionState().equals("Precluded")) {
       try {
         em.setSelectedNodes(new Node[] {n});
       } catch (PropertyVetoException ex) {
         Exceptions.printStackTrace(ex);
       }
       treeTableView.expandNode(n);
     } else {
     }
   } else {
   }
   for (Node child : n.getChildren().getNodes()) {
     openTreeToCurrentStateRecursivly(child);
   }
 }
Exemple #8
0
 private static void disableCreateCategoryAction(Node proxyRootNode) {
   ResourceBundle bundle = NbBundle.getBundle(proxyRootNode.getClass());
   if (bundle != null) {
     String createCategoryName = null;
     try {
       createCategoryName = bundle.getString("CTL_CreateCategory"); // NOI18N
     } catch (MissingResourceException e) {
       // Cannot disable the action, it's key name may have changed.
       // We must be aware of this and visibly fail so development
       // can update the key name.
       ErrorManager.getDefault().notify(e);
       return;
     }
     if (createCategoryName != null) {
       disableActionByName(proxyRootNode, createCategoryName);
       for (Node childProxyNode : proxyRootNode.getChildren().getNodes()) {
         disableActionByName(childProxyNode, createCategoryName);
       }
     }
   }
 }
Exemple #9
0
 public CheckNode getCheckNodeAt(int index) {
   return (CheckNode) rootNode.getChildren().getNodes()[index];
 }
  @Override
  public void viewArtifact(final BlackboardArtifact art) {
    BlackboardArtifact.ARTIFACT_TYPE type =
        BlackboardArtifact.ARTIFACT_TYPE.fromID(art.getArtifactTypeID());
    Children rootChilds = em.getRootContext().getChildren();
    Node treeNode = null;
    Node resultsNode = rootChilds.findChild(ResultsNode.NAME);
    Children resultsChilds = resultsNode.getChildren();
    if (type.equals(BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT)) {
      Node hashsetRootNode = resultsChilds.findChild(type.getLabel());
      Children hashsetRootChilds = hashsetRootNode.getChildren();
      try {
        String setName = null;
        List<BlackboardAttribute> attributes = art.getAttributes();
        for (BlackboardAttribute att : attributes) {
          int typeId = att.getAttributeTypeID();
          if (typeId == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID()) {
            setName = att.getValueString();
          }
        }
        treeNode = hashsetRootChilds.findChild(setName);
      } catch (TskException ex) {
        logger.log(Level.WARNING, "Error retrieving attributes", ex); // NON-NLS
      }
    } else if (type.equals(BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT)) {
      Node keywordRootNode = resultsChilds.findChild(type.getLabel());
      Children keywordRootChilds = keywordRootNode.getChildren();
      try {
        String listName = null;
        String keywordName = null;
        List<BlackboardAttribute> attributes = art.getAttributes();
        for (BlackboardAttribute att : attributes) {
          int typeId = att.getAttributeTypeID();
          if (typeId == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID()) {
            listName = att.getValueString();
          } else if (typeId == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID()) {
            keywordName = att.getValueString();
          }
        }
        Node listNode = keywordRootChilds.findChild(listName);
        Children listChildren = listNode.getChildren();
        treeNode = listChildren.findChild(keywordName);
      } catch (TskException ex) {
        logger.log(Level.WARNING, "Error retrieving attributes", ex); // NON-NLS
      }
    } else if (type.equals(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT)
        || type.equals(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT)) {
      Node interestingItemsRootNode = resultsChilds.findChild(type.getLabel());
      Children interestingItemsRootChildren = interestingItemsRootNode.getChildren();
      try {
        String setName = null;
        List<BlackboardAttribute> attributes = art.getAttributes();
        for (BlackboardAttribute att : attributes) {
          int typeId = att.getAttributeTypeID();
          if (typeId == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID()) {
            setName = att.getValueString();
          }
        }
        treeNode = interestingItemsRootChildren.findChild(setName);
      } catch (TskException ex) {
        logger.log(Level.WARNING, "Error retrieving attributes", ex); // NON-NLS
      }
    } else {
      Node extractedContent = resultsChilds.findChild(ExtractedContent.NAME);
      Children extractedChilds = extractedContent.getChildren();
      treeNode = extractedChilds.findChild(type.getLabel());
    }
    try {
      em.setExploredContextAndSelection(treeNode, new Node[] {treeNode});
    } catch (PropertyVetoException ex) {
      logger.log(Level.WARNING, "Property Veto: ", ex); // NON-NLS
    }

    // Another thread is needed because we have to wait for dataResult to populate
    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            Children resultChilds = dataResult.getRootNode().getChildren();
            Node select = resultChilds.findChild(Long.toString(art.getArtifactID()));
            if (select != null) {
              dataResult.requestActive();
              dataResult.setSelectedNodes(new Node[] {select});
              fireViewerComplete();
            }
          }
        });
  }
  /**
   * Called only when top component was closed on all workspaces before and now is opened for the
   * first time on some workspace. The intent is to provide subclasses information about
   * TopComponent's life cycle across all existing workspaces. Subclasses will usually perform
   * initializing tasks here.
   */
  @Override
  public void componentOpened() {
    // change the cursor to "waiting cursor" for this operation
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    try {
      if (Case.existsCurrentCase()) {
        Case currentCase = Case.getCurrentCase();

        // close the top component if there's no image in this case
        if (currentCase.hasData() == false) {
          // this.close();
          ((BeanTreeView) this.jScrollPane1).setRootVisible(false); // hide the root
        } else {
          // if there's at least one image, load the image and open the top component
          List<Object> items = new ArrayList<>();
          final SleuthkitCase tskCase = currentCase.getSleuthkitCase();
          items.add(new DataSources());
          items.add(new Views(tskCase));
          items.add(new Results(tskCase));
          items.add(new Reports());
          contentChildren = new RootContentChildren(items);
          Node root =
              new AbstractNode(contentChildren) {
                /**
                 * to override the right click action in the white blank space area on the directory
                 * tree window
                 */
                @Override
                public Action[] getActions(boolean popup) {
                  return new Action[] {};
                }

                // Overide the AbstractNode use of DefaultHandle to return
                // a handle which can be serialized without a parent
                @Override
                public Node.Handle getHandle() {
                  return new Node.Handle() {
                    @Override
                    public Node getNode() throws IOException {
                      return em.getRootContext();
                    }
                  };
                }
              };

          root = new DirectoryTreeFilterNode(root, true);

          em.setRootContext(root);
          em.getRootContext().setName(currentCase.getName());
          em.getRootContext().setDisplayName(currentCase.getName());
          ((BeanTreeView) this.jScrollPane1).setRootVisible(false); // hide the root

          // Reset the forward and back lists because we're resetting the root context
          resetHistory();

          Children childNodes = em.getRootContext().getChildren();
          TreeView tree = getTree();

          Node results = childNodes.findChild(ResultsNode.NAME);
          tree.expandNode(results);

          Children resultsChilds = results.getChildren();
          tree.expandNode(resultsChilds.findChild(KeywordHits.NAME));
          tree.expandNode(resultsChilds.findChild(ExtractedContent.NAME));

          Node views = childNodes.findChild(ViewsNode.NAME);
          Children viewsChilds = views.getChildren();
          for (Node n : viewsChilds.getNodes()) {
            tree.expandNode(n);
          }

          tree.collapseNode(views);

          // if the dataResult is not opened
          if (!dataResult.isOpened()) {
            dataResult
                .open(); // open the data result top component as well when the directory tree is
                         // opened
          }

          // select the first image node, if there is one
          // (this has to happen after dataResult is opened, because the event
          // of changing the selected node fires a handler that tries to make
          // dataResult active)
          if (childNodes.getNodesCount() > 0) {
            try {
              em.setSelectedNodes(new Node[] {childNodes.getNodeAt(0)});
            } catch (Exception ex) {
              logger.log(Level.SEVERE, "Error setting default selected node.", ex); // NON-NLS
            }
          }
        }
      }
    } finally {
      this.setCursor(null);
    }
  }