Beispiel #1
0
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              String eventType = evt.getPropertyName();

              if (eventType.equals(IngestManager.IngestModuleEvent.CONTENT_CHANGED.toString())) {
                /**
                 * Checking for a current case is a stop gap measure until a different way of
                 * handling the closing of cases is worked out. Currently, remote events may be
                 * received for a case that is already closed.
                 */
                try {
                  // new file was added
                  // @@@ could check the size here and only fire off updates if we know the file
                  // meets the min size criteria
                  Case.getCurrentCase();
                  update();
                } catch (IllegalStateException notUsed) {
                  /** Case is closed, do nothing. */
                }
              } else if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
                  || eventType.equals(IngestManager.IngestJobEvent.CANCELLED.toString())
                  || eventType.equals(Case.Events.DATA_SOURCE_ADDED.toString())) {
                /**
                 * Checking for a current case is a stop gap measure until a different way of
                 * handling the closing of cases is worked out. Currently, remote events may be
                 * received for a case that is already closed.
                 */
                try {
                  Case.getCurrentCase();
                  update();
                } catch (IllegalStateException notUsed) {
                  /** Case is closed, do nothing. */
                }
              } else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
                // case was closed. Remove listeners so that we don't get called with a stale case
                // handle
                if (evt.getNewValue() == null) {
                  removeListeners();
                }
              }
            }
  /**
   * The "listener" that listens to any changes made in the Case.java class. It will do something
   * based on the changes in the Case.java class.
   *
   * @param evt the property change event
   */
  @Override
  public void propertyChange(PropertyChangeEvent evt) {
    String changed = evt.getPropertyName();
    Object oldValue = evt.getOldValue();
    Object newValue = evt.getNewValue();

    // change in the case name
    if (changed.equals(Case.Events.NAME.toString())) {
      // set the main title of the window
      String oldCaseName = oldValue.toString();
      String newCaseName = newValue.toString();

      // update the case name
      if ((!oldCaseName.equals("")) && (!newCaseName.equals(""))) {
        // change the root name and display name
        em.getRootContext().setName(newCaseName);
        em.getRootContext().setDisplayName(newCaseName);
      }
    } // changed current case
    else if (changed.equals(Case.Events.CURRENT_CASE.toString())) {
      // When a case is closed, the old value of this property is the
      // closed Case object and the new value is null. When a case is
      // opened, the old value is null and the new value is the new Case
      // object.
      // @@@ This needs to be revisited. Perhaps case closed and case
      // opened events instead of property change events would be a better
      // solution. Either way, more probably needs to be done to clean up
      // data model objects when a case is closed.
      if (oldValue != null && newValue == null) {
        // The current case has been closed. Reset the ExplorerManager.
        Node emptyNode = new AbstractNode(Children.LEAF);
        em.setRootContext(emptyNode);
      } else if (newValue != null) {
        // A new case has been opened. Reset the forward and back
        // buttons. Note that a call to CoreComponentControl.openCoreWindows()
        // by the new Case object will lead to a componentOpened() call
        // that will repopulate the tree.
        // @@@ The repopulation of the tree in this fashion also merits
        // reconsideration.
        resetHistory();
      }
    } // if the image is added to the case
    else if (changed.equals(Case.Events.DATA_SOURCE_ADDED.toString())) {
      componentOpened();
    }
    // change in node selection
    else if (changed.equals(ExplorerManager.PROP_SELECTED_NODES)) {
      respondSelection((Node[]) oldValue, (Node[]) newValue);
    } else if (changed.equals(IngestManager.IngestModuleEvent.DATA_ADDED.toString())) {
      // nothing to do here.
      // all nodes should be listening for these events and update accordingly.
    } else if (changed.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
        || changed.equals(IngestManager.IngestJobEvent.CANCELLED.toString())) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              refreshDataSourceTree();
            }
          });
    } else if (changed.equals(IngestManager.IngestModuleEvent.CONTENT_CHANGED.toString())) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              refreshDataSourceTree();
            }
          });
    }
  }