Exemple #1
0
  public void addLayerStorageNode(LayerStorageNode layerStorageNode) {
    treeModel.insertNodeInto(layerStorageNode, root, root.getChildCount());

    TreeNode[] path = treeModel.getPathToRoot(root);
    expandPath(new TreePath(path));
    setSelectionPath(new TreePath(path));
  }
Exemple #2
0
 /**
  * @param title
  * @param type
  * @return
  */
 public LayerStorageNode getLayerStorageNode(String title, String type) {
   for (int i = 0; i < root.getChildCount(); i++) {
     LayerStorageNode child = (LayerStorageNode) root.getChildAt(i);
     if (child.getTitle().equals(title) && child.getType().equals(type)) {
       return child;
     }
   }
   return null;
 }
Exemple #3
0
  /**
   * Returns the position of the specified LayerNode or -1 if it is not contained in the ContentTree.<br>
   * In the following example this method will return 4 for the 'X'-LayerNode.
   *
   * <pre>
   *   -O
   *    |-O
   *    |-O
   *    |-O
   *   -O
   *    |-O
   *    |-X
   *    |-O
   *
   * &#064;param layerNode
   * @return
   *
   */
  public int positionOf(LayerNode layerNode) {
    int position = 0;
    for (int i = 0; i < root.getChildCount(); i++) {
      TreeNode storageNode = root.getChildAt(i);

      for (int j = 0; j < storageNode.getChildCount(); j++) {

        if (storageNode.getChildAt(j) != layerNode) {
          position++;
        } else {
          return position;
        }
      }
    }

    return -1;
  }
Exemple #4
0
 public void clearTree() {
   while (root.getChildCount() > 0) {
     removeNode(root.getFirstLeaf());
   }
 }