コード例 #1
0
  /** refresh all of the cross nodes */
  private void refreshCrossNodes() {
    ProjectTreeNode projectNode = (ProjectTreeNode) this.getModel().getRoot();
    QtlProject project = projectNode.getProject();

    QtlDataModel dataModel = project.getDataModel();

    // remove tree nodes not in the QTL data model
    for (int crossNodeIndex = projectNode.getChildCount() - 1;
        crossNodeIndex >= 0;
        crossNodeIndex--) {
      CrossTreeNode currCrossNode = (CrossTreeNode) projectNode.getChildAt(crossNodeIndex);
      boolean crossInDataModel =
          dataModel
              .getCrossMap()
              .containsKey(currCrossNode.getCross().getAccessorExpressionString());
      if (!crossInDataModel) {
        this.getModel().removeNodeFromParent(currCrossNode);
      }
    }

    // add nodes that are missing (refresh existing)
    for (Cross currCross : dataModel.getCrossMap().values()) {
      int indexOfCross = SwingTreeUtilities.indexOfChildWithUserObject(projectNode, currCross);

      CrossTreeNode currCrossNode;
      if (indexOfCross == -1) {
        // append the cross to the end of the project node
        currCrossNode = new CrossTreeNode(currCross);
        this.getModel().insertNodeInto(currCrossNode, projectNode, projectNode.getChildCount());
        this.getModel()
            .insertNodeInto(
                currCrossNode.getScanOneFolderNode(), currCrossNode, currCrossNode.getChildCount());
        this.getModel()
            .insertNodeInto(
                currCrossNode.getScanTwoFolderNode(), currCrossNode, currCrossNode.getChildCount());
        this.getModel()
            .insertNodeInto(
                currCrossNode.getQtlBasketFolderNode(),
                currCrossNode,
                currCrossNode.getChildCount());
        this.getModel()
            .insertNodeInto(
                currCrossNode.getFitResultsFolderNode(),
                currCrossNode,
                currCrossNode.getChildCount());
        this.expandPath(new TreePath(currCrossNode.getPath()));
      } else {
        currCrossNode = (CrossTreeNode) projectNode.getChildAt(indexOfCross);
      }

      this.refreshCross(currCrossNode);
    }

    this.getModel().nodeChanged(projectNode);
  }
コード例 #2
0
  /**
   * Set the currently active project
   *
   * @param activeProject the new active project
   */
  @Override
  public void setActiveProject(Project activeProject) {
    QtlProject qtlActiveProject = (QtlProject) activeProject;
    {
      QtlProject oldActiveProject = this.getActiveProject();
      if (oldActiveProject != null) {
        oldActiveProject.getDataModel().removeQtlDataModelListener(this.dataModelListener);
      }
    }

    if (qtlActiveProject != null) {
      qtlActiveProject.getDataModel().addQtlDataModelListener(this.dataModelListener);
    }

    super.setActiveProject(activeProject);
  }