예제 #1
0
  @Override
  public synchronized void setFile(final Long fileID) {
    if (Objects.equals(fileID, this.fileID) == false) {
      this.fileID = fileID;
      disposeContent();

      if (this.fileID == null || Case.isCaseOpen() == false) {
        if (registered == true) {
          ImageGalleryController.getDefault().getCategoryManager().unregisterListener(this);
          TagUtils.unregisterListener(this);
          registered = false;
        }
        file = null;
        Platform.runLater(
            () -> {
              clearContent();
            });
      } else {
        if (registered == false) {
          ImageGalleryController.getDefault().getCategoryManager().registerListener(this);
          TagUtils.registerListener(this);
          registered = true;
        }
        file = null;
        getFile();
        updateSelectionState();
        updateCategoryBorder();
        updateFollowUpIcon();
        updateUI();
        Platform.runLater(getContentUpdateRunnable());
      }
    }
  }
예제 #2
0
  @Override
  public JComponent[] getMenuPresenters() {
    List<DataContentTopComponent> newWindowLists = DataContentTopComponent.getNewWindowList();

    // Get DataContent provider to include in the menu
    int totalItems = newWindowLists.size() > 0 ? 2 : 1;
    JComponent[] comps = new JComponent[totalItems];
    int counter = 0;

    TopComponent contentWin = DataContentTopComponent.findInstance();
    JMenuItem defaultItem = new JMenuItem(contentWin.getName()); // set the main name

    defaultItem.addActionListener(new OpenTopComponentAction(contentWin));

    if (!Case.isCaseOpen() || Case.getCurrentCase().hasData() == false) {
      defaultItem.setEnabled(false); // disable the menu items when no case is opened
    } else {
      defaultItem.setEnabled(true); // enable the menu items when there's a case opened / created
    }

    comps[counter++] = defaultItem;

    // add the submenu
    if (newWindowLists != null) {
      if (newWindowLists.size() > 0) {

        JMenu submenu =
            new JMenu(
                NbBundle.getMessage(
                    this.getClass(), "DataContentDynamicMenu.menu.dataContentWin.text"));
        for (int i = 0; i < newWindowLists.size(); i++) {
          DataContentTopComponent dctc = newWindowLists.get(i);
          JMenuItem item = new JMenuItem(dctc.getName());
          item.addActionListener(new OpenTopComponentAction(dctc));
          submenu.add(item);
        }

        comps[counter++] = submenu;
      }
    }

    return comps;
  }
  /**
   * Event handler to run when selection changed
   *
   * <p>TODO this needs to be revised
   *
   * @param oldNodes
   * @param newNodes
   */
  private void respondSelection(final Node[] oldNodes, final Node[] newNodes) {
    if (!Case.isCaseOpen()) {
      // handle in-between condition when case is being closed
      // and legacy selection events are pumped
      return;
    }

    // Some lock that prevents certain Node operations is set during the
    // ExplorerManager selection-change, so we must handle changes after the
    // selection-change event is processed.
    // TODO find a different way to refresh data result viewer, scheduling this
    // to EDT breaks loading of nodes in the background
    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            // change the cursor to "waiting cursor" for this operation
            DirectoryTreeTopComponent.this.setCursor(
                Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            try {

              // make sure dataResult is open, redundant?
              // dataResult.open();

              Node treeNode = DirectoryTreeTopComponent.this.getSelectedNode();
              if (treeNode != null) {
                OriginalNode origin = treeNode.getLookup().lookup(OriginalNode.class);
                if (origin == null) {
                  return;
                }
                Node originNode = origin.getNode();

                // set node, wrap in filter node first to filter out children
                Node drfn = new DataResultFilterNode(originNode, DirectoryTreeTopComponent.this.em);
                Node kffn =
                    new KnownFileFilterNode(
                        drfn, KnownFileFilterNode.getSelectionContext(originNode));
                dataResult.setNode(new TableFilterNode(kffn, true));

                String displayName = "";
                Content content = originNode.getLookup().lookup(Content.class);
                if (content != null) {
                  try {
                    displayName = content.getUniquePath();
                  } catch (TskCoreException ex) {
                    logger.log(
                        Level.SEVERE,
                        "Exception while calling Content.getUniquePath() for node: "
                            + originNode); // NON-NLS
                  }
                } else if (originNode.getLookup().lookup(String.class) != null) {
                  displayName = originNode.getLookup().lookup(String.class);
                }
                dataResult.setPath(displayName);
              }

              // set the directory listing to be active
              if (oldNodes != null && newNodes != null && (oldNodes.length == newNodes.length)) {
                boolean sameNodes = true;
                for (int i = 0; i < oldNodes.length; i++) {
                  sameNodes = sameNodes && oldNodes[i].getName().equals(newNodes[i].getName());
                }
                if (!sameNodes) {
                  dataResult.requestActive();
                }
              }
            } finally {
              setCursor(null);
            }
          }
        });

    // update the back and forward list
    updateHistory(em.getSelectedNodes());
  }