Example #1
0
  /**
   * A group of tool groups have been added.
   *
   * @param name The catalog name
   * @param groups The list of tool groups added
   */
  public void toolGroupsAdded(String name, List<ToolGroup> groups) {
    if (!name.equals(catalog.getName())) return;

    TreePath path = new TreePath(catalogRoot);
    Object[] children = new Object[groups.size()];
    int[] indicies = new int[groups.size()];

    for (int i = 0; i < groups.size(); i++) {
      ToolGroup group = groups.get(i);
      ToolGroupTreeNode child = new ToolGroupTreeNode(group, catalogRoot);
      catalogRoot.insert(child, catalogRoot.getChildCount());

      int index = catalogRoot.getIndex(child);
      indicies[i] = index;
      children[i] = child;
      // System.out.println("Catalog bulk root adding group " + group.getName());
    }

    TreeModelEvent treeEvent = new TreeModelEvent(this, path, indicies, children);
    fireTreeNodesInserted(treeEvent);

    // Add listeners later to make sure we don't end up with any weird
    // side effects of a fast building tree.
    for (int i = 0; i < groups.size(); i++) {
      ToolGroup group = groups.get(i);
      group.addToolGroupListener(this);
    }
  }
Example #2
0
  /**
   * Construct a new tree model around this catalog.
   *
   * @param cat The catalog to handle.
   */
  CatalogTreeModel(Catalog cat) {
    errorReporter = DefaultErrorReporter.getDefaultReporter();

    catalog = cat;
    catalog.addCatalogListener(this);

    catalogRoot = new ToolGroupTreeNode(null, null);
    listeners = new ArrayList<TreeModelListener>();
  }
Example #3
0
  /**
   * A tool has been removed. Batched removes will come through the toolsRemoved method.
   *
   * @param name The catalog name
   * @param group The toolGroup removed from
   */
  public void toolGroupRemoved(String name, ToolGroup group) {
    if (!name.equals(catalog.getName())) return;

    group.removeToolGroupListener(this);

    TreePath path = new TreePath(catalogRoot);
    Object[] children = new Object[1];
    int[] indicies = new int[1];

    ToolGroupTreeNode child = catalogRoot.getTreeNodeChild(group);
    int index = catalogRoot.getIndex(child);
    indicies[0] = index;
    children[0] = child;

    catalogRoot.remove(child);

    TreeModelEvent treeEvent = new TreeModelEvent(this, path, indicies, children);
    fireTreeNodesRemoved(treeEvent);
  }
Example #4
0
  /**
   * A tool group has been added. Batched adds will come through the toolsAdded method.
   *
   * @param name The catalog name
   * @param group The toolGroup added to
   */
  public void toolGroupAdded(String name, ToolGroup group) {
    if (!name.equals(catalog.getName())) return;

    TreePath path = new TreePath(catalogRoot);
    Object[] children = new Object[1];
    int[] indicies = new int[1];

    ToolGroupTreeNode child = new ToolGroupTreeNode(group, catalogRoot);
    catalogRoot.insert(child, catalogRoot.getChildCount());

    int index = catalogRoot.getIndex(child);
    indicies[0] = index;
    children[0] = child;

    // System.out.println("Catalog root adding group " + group.getName());

    TreeModelEvent treeEvent = new TreeModelEvent(this, path, indicies, children);
    fireTreeNodesInserted(treeEvent);

    group.addToolGroupListener(this);
  }
Example #5
0
  /**
   * A group of tool groups have been removed.
   *
   * @param name The catalog name
   * @param groups The list of tool groups that have been removed
   */
  public void toolGroupsRemoved(String name, List<ToolGroup> groups) {
    if (!name.equals(catalog.getName())) return;

    TreePath path = new TreePath(catalogRoot);
    Object[] children = new Object[groups.size()];
    int[] indicies = new int[groups.size()];

    for (int i = 0; i < groups.size(); i++) {
      ToolGroup group = groups.get(i);

      group.removeToolGroupListener(this);

      ToolGroupTreeNode child = catalogRoot.getTreeNodeChild(group);

      int index = catalogRoot.getIndex(child);
      indicies[i] = index;
      children[i] = child;

      catalogRoot.remove(child);
    }

    TreeModelEvent treeEvent = new TreeModelEvent(this, path, indicies, children);
    fireTreeNodesRemoved(treeEvent);
  }