public void nextStep() {
    ArrayList<Game> selectedGames = new ArrayList<Game>();

    TreePath[] tps = this.checkboxTree.getCheckingPaths();

    for (TreePath tp : tps) {
      if (tp.getPathCount() == 3) {
        DefaultMutableTreeNode gameNode = (DefaultMutableTreeNode) tp.getLastPathComponent();
        Game g = (Game) gameNode.getUserObject();
        selectedGames.add(g);
      }
    }

    /*		for(Game g : selectedGames) {
    			System.out.println(g.getTitle() + " : " + g.getShortDescription());
    			System.out.println("-------");
    		}

    		System.out.println("####");
    */
    this.getController().setGamesToInstall(selectedGames);
    ArrayList<Game> unselectedGames = this.games;
    unselectedGames.removeAll(selectedGames);
    this.getController().setGamesToUninstall(unselectedGames);
    this.getController().nextStep();
  }
Esempio n. 2
0
  protected TreePath getNextPath(TreePath path) {
    TreeModel model = tree.getModel();

    // return the first node
    if (path == null) {
      return new TreePath(model.getRoot());
    }

    Object lastNode = path.getLastPathComponent();

    // if the NODE has children

    if (model.getChildCount(lastNode) > 0) {
      return path.pathByAddingChild(model.getChild(lastNode, 0));
    }

    // if the NODE has NO children

    int index = 0;
    int pathLength = path.getPathCount();
    Object parentNode = path.getPathComponent(pathLength - 2);

    if (pathLength > 1) {
      index = model.getIndexOfChild(parentNode, lastNode);
    }

    // if there is only root node
    if (pathLength == 1) {
      return path;
    }

    // if there are still some siblings (brothers) after this node
    if (index + 1 < model.getChildCount(parentNode)) {
      // replace the lastPathComponent by its next sibling
      return path.getParentPath().pathByAddingChild(model.getChild(parentNode, index + 1));
    } else {
      while (true) {
        // we need to find next sibling for our father
        path = path.getParentPath();

        // if we get to the end of tree then start if
        if (path.getParentPath() == null) {
          // return the root path
          return path;
        }

        pathLength = path.getPathCount();
        parentNode = path.getPathComponent(pathLength - 2);
        index = model.getIndexOfChild(parentNode, path.getLastPathComponent());

        // if there are still some siblings (brothers) after this node
        if (index + 1 < model.getChildCount(parentNode)) {
          // replace the lastPathComponent by its next sibling
          return path.getParentPath().pathByAddingChild(model.getChild(parentNode, index + 1));
        }
      }
    }
  }
Esempio n. 3
0
 public static void unselect(JTree tree, final DefaultMutableTreeNode node) {
   final TreePath rootPath = new TreePath(node.getPath());
   final TreePath[] selectionPaths = tree.getSelectionPaths();
   if (selectionPaths != null) {
     for (TreePath selectionPath : selectionPaths) {
       if (selectionPath.getPathCount() > rootPath.getPathCount()
           && rootPath.isDescendant(selectionPath)) {
         tree.removeSelectionPath(selectionPath);
       }
     }
   }
 }
 protected boolean haveSelectedFileType(final Object tag) {
   final TreePath[] paths = getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       if (path.getPathCount() > 1) {
         ChangesBrowserNode firstNode = (ChangesBrowserNode) path.getPathComponent(1);
         if ((tag == null || firstNode.getUserObject() == tag) && path.getPathCount() > 2) {
           return true;
         }
       }
     }
   }
   return false;
 }
Esempio n. 5
0
 public List getSelectedTriples() {
   List results = new ArrayList();
   TreePath[] paths = getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       if (path.getPathCount() > 1 && path.getLastPathComponent() instanceof LazyTreeNode) {
         LazyTreeNode node = (LazyTreeNode) path.getLastPathComponent();
         Object subject = node.getUserObject();
         if (subject instanceof RDFSNamedClass) {
           RDFSNamedClass subjectClass = (RDFSNamedClass) subject;
           TreeNode parent = node.getParent();
           if (parent instanceof LazyTreeNode) {
             Object object = ((LazyTreeNode) parent).getUserObject();
             if (object instanceof RDFSNamedClass) {
               RDFSNamedClass objectClass = (RDFSNamedClass) object;
               RDFProperty predicate = objectClass.getOWLModel().getRDFSSubClassOfProperty();
               Triple triple = new DefaultTriple(subjectClass, predicate, objectClass);
               results.add(triple);
             }
           }
         }
       }
     }
   }
   return results;
 }
    protected void deleteCurrent() {
      int num_logs_deleted = 0;
      Set<Group> groups_changed = new HashSet<>();

      for (TreePath tp : display.logTree.getSelectionPaths()) {
        if (tp.getPathCount() == 3) {
          Group group = (Group) tp.getPath()[1];
          LogReference reference = (LogReference) tp.getLastPathComponent();

          Debug.warn("deleting {%s} from {%s}", reference, group);
          group.remove(reference);

          ++num_logs_deleted;
          groups_changed.add(group);
        } else {
          Debug.warn("cannot delete {%s}", tp.getLastPathComponent());
        }
      }

      for (Group group : groups_changed) {
        TreeModelEvent removeEvent = new TreeModelEvent(this, new Object[] {this, group});

        for (TreeModelListener listener : listeners) listener.treeStructureChanged(removeEvent);
      }

      ToolMessage.displayAndPrint("deleted %d logs", num_logs_deleted);
    }
 public void removeSelectionPaths(TreePath[] paths) {
   for (int i = 0; i < paths.length; i++) {
     TreePath path = paths[i];
     if (path.getPathCount() == 1) super.removeSelectionPaths(new TreePath[] {path});
     else toggleRemoveSelection(path);
   }
 }
Esempio n. 8
0
  private static List<PathElement> createPath(final TreePath treePath) {
    final ArrayList<PathElement> result = new ArrayList<PathElement>();
    for (int i = 0; i < treePath.getPathCount(); i++) {
      final Object pathComponent = treePath.getPathComponent(i);
      if (pathComponent instanceof DefaultMutableTreeNode) {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathComponent;
        final TreeNode parent = node.getParent();

        final Object userObject = node.getUserObject();
        if (userObject instanceof NodeDescriptor) {
          final NodeDescriptor nodeDescriptor = (NodeDescriptor) userObject;
          // nodeDescriptor.update();
          final int childIndex = parent != null ? parent.getIndex(node) : 0;
          result.add(
              new PathElement(
                  getDescriptorKey(nodeDescriptor),
                  getDescriptorType(nodeDescriptor),
                  childIndex,
                  nodeDescriptor));
        } else {
          result.add(new PathElement("", "", 0, userObject));
        }
      } else {
        return null;
      }
    }
    return result;
  }
Esempio n. 9
0
  // {{{ removeSelectedNode() method
  private void removeSelectedNode() {
    TreePath path = resultTree.getSelectionPath();
    if (path == null) return;

    MutableTreeNode value = (MutableTreeNode) path.getLastPathComponent();

    if (path.getPathCount() > 1) {
      // Adjust selection so that repeating some removals
      // behave naturally.
      TreePath parentPath = path.getParentPath();
      MutableTreeNode parent = (MutableTreeNode) parentPath.getLastPathComponent();
      int removingIndex = parent.getIndex(value);
      int nextIndex = removingIndex + 1;
      if (nextIndex < parent.getChildCount()) {
        TreeNode next = parent.getChildAt(nextIndex);
        resultTree.setSelectionPath(parentPath.pathByAddingChild(next));
      } else {
        resultTree.setSelectionPath(parentPath);
      }

      resultTreeModel.removeNodeFromParent(value);
    }

    HyperSearchOperationNode.removeNodeFromCache(value);
    if (resultTreeRoot.getChildCount() == 0) {
      hideDockable();
    }
  } // }}}
 @Override
 public void calcData(DataKey key, DataSink sink) {
   if (key == VcsDataKeys.CHANGES) {
     sink.put(VcsDataKeys.CHANGES, getSelectedChanges());
   } else if (key == VcsDataKeys.CHANGE_LEAD_SELECTION) {
     sink.put(VcsDataKeys.CHANGE_LEAD_SELECTION, getLeadSelection());
   } else if (key == VcsDataKeys.CHANGE_LISTS) {
     sink.put(VcsDataKeys.CHANGE_LISTS, getSelectedChangeLists());
   } else if (key == PlatformDataKeys.VIRTUAL_FILE_ARRAY) {
     sink.put(PlatformDataKeys.VIRTUAL_FILE_ARRAY, getSelectedFiles());
   } else if (key == PlatformDataKeys.NAVIGATABLE) {
     final VirtualFile[] files = getSelectedFiles();
     if (files.length == 1 && !files[0].isDirectory()) {
       sink.put(PlatformDataKeys.NAVIGATABLE, new OpenFileDescriptor(myProject, files[0], 0));
     }
   } else if (key == PlatformDataKeys.NAVIGATABLE_ARRAY) {
     sink.put(
         PlatformDataKeys.NAVIGATABLE_ARRAY,
         ChangesUtil.getNavigatableArray(myProject, getSelectedFiles()));
   } else if (key == PlatformDataKeys.DELETE_ELEMENT_PROVIDER) {
     final TreePath[] paths = getSelectionPaths();
     if (paths != null) {
       for (TreePath path : paths) {
         ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent();
         if (!(node.getUserObject() instanceof ChangeList)) {
           sink.put(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, new VirtualFileDeleteProvider());
           break;
         }
       }
     }
   } else if (key == PlatformDataKeys.COPY_PROVIDER) {
     sink.put(PlatformDataKeys.COPY_PROVIDER, myCopyProvider);
   } else if (key == UNVERSIONED_FILES_DATA_KEY) {
     sink.put(UNVERSIONED_FILES_DATA_KEY, getSelectedUnversionedFiles());
   } else if (key == VcsDataKeys.MODIFIED_WITHOUT_EDITING_DATA_KEY) {
     sink.put(VcsDataKeys.MODIFIED_WITHOUT_EDITING_DATA_KEY, getSelectedModifiedWithoutEditing());
   } else if (key == LOCALLY_DELETED_CHANGES) {
     sink.put(LOCALLY_DELETED_CHANGES, getSelectedLocallyDeletedChanges());
   } else if (key == MISSING_FILES_DATA_KEY) {
     sink.put(MISSING_FILES_DATA_KEY, getSelectedMissingFiles());
   } else if (VcsDataKeys.HAVE_LOCALLY_DELETED == key) {
     sink.put(VcsDataKeys.HAVE_LOCALLY_DELETED, haveLocallyDeleted());
   } else if (VcsDataKeys.HAVE_MODIFIED_WITHOUT_EDITING == key) {
     sink.put(VcsDataKeys.HAVE_MODIFIED_WITHOUT_EDITING, haveLocallyModified());
   } else if (VcsDataKeys.HAVE_SELECTED_CHANGES == key) {
     sink.put(VcsDataKeys.HAVE_SELECTED_CHANGES, haveSelectedChanges());
   } else if (key == HELP_ID_DATA_KEY) {
     sink.put(HELP_ID_DATA_KEY, ourHelpId);
   } else if (key == VcsDataKeys.CHANGES_IN_LIST_KEY) {
     final TreePath selectionPath = getSelectionPath();
     if (selectionPath != null && selectionPath.getPathCount() > 1) {
       ChangesBrowserNode<?> firstNode = (ChangesBrowserNode) selectionPath.getPathComponent(1);
       if (firstNode instanceof ChangesBrowserChangeListNode) {
         final List<Change> list = firstNode.getAllChangesUnder();
         sink.put(VcsDataKeys.CHANGES_IN_LIST_KEY, list);
       }
     }
   }
 }
Esempio n. 11
0
 private static boolean areComponentsEqual(final TreePath[] paths, final int componentIndex) {
   if (paths[0].getPathCount() <= componentIndex) return false;
   final Object pathComponent = paths[0].getPathComponent(componentIndex);
   for (final TreePath treePath : paths) {
     if (treePath.getPathCount() <= componentIndex) return false;
     if (!pathComponent.equals(treePath.getPathComponent(componentIndex))) return false;
   }
   return true;
 }
 public void collapseSelected() {
   TreePath path = tree.getSelectionPath();
   if (path != null && path.getPathCount() > 1) {
     Object node = path.getPathComponent(1);
     if (node instanceof ResourceTreeFolder) {
       Object root = path.getPathComponent(0);
       processAllNodes(tree, new TreePath(new Object[] {root, node}), false);
     }
   }
 }
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger()) {
     TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
     if (path != null && path.getPathCount() > 2) {
       showresource = false;
       tree.addSelectionPath(path);
       pmenu.show(e.getComponent(), e.getX(), e.getY());
     }
   } else showresource = true;
 }
    @Override
    public Log[] supplyLogsForDrag() {
      ArrayList<Log> refs = new ArrayList<>();
      for (TreePath tp : display.logTree.getSelectionPaths()) {
        if (tp.getPathCount() == 3) {
          LogReference reference = (LogReference) tp.getLastPathComponent();
          refs.add(reference.get());
        }
      }

      return refs.toArray(new Log[0]);
    }
    @Override
    public boolean isPathEditable(TreePath path) {
      Object comp = path.getLastPathComponent();
      if (comp instanceof File) {
        if (comp.equals(SharingSettings.TORRENT_DATA_DIR_SETTING.getValue())) {
          return false;
        }
      }

      // root node is not editable
      return path.getPathCount() != 1;
    }
 @Override
 public void checkPath(TreePath path) {
   // check is propagated to children
   this.model.checkSubTree(path);
   // check all the ancestors with subtrees checked
   TreePath[] parents = new TreePath[path.getPathCount()];
   parents[0] = path;
   TreePath parentPath = path;
   // uncheck is propagated to parents, too
   while ((parentPath = parentPath.getParentPath()) != null) {
     this.model.updatePathGreyness(parentPath);
   }
 }
Esempio n. 17
0
 /** opens pop-up menu or displays context node content */
 public void mouseReleased(MouseEvent e) {
   // on Solaris, the right mouse button somehow seems not be a popup trigger, so we
   // accept mouse 3 explicitly
   if (e.isPopupTrigger() || e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK) {
     popup.pack();
     popup.show(tree, e.getX(), e.getY());
   } else {
     TreePath path = tree.getPathForLocation(e.getX(), e.getY());
     if (path != null) {
       DefaultMutableTreeNode node =
           (DefaultMutableTreeNode) path.getPathComponent(path.getPathCount() - 1);
       ((ContextNode) node.getUserObject()).display();
     }
   }
 }
Esempio n. 18
0
  /**
   * Returns true if <code>aTreePath</code> is a descendant of this {@code TreePath}. A {@code
   * TreePath} {@code P1} is a descendant of a {@code TreePath} {@code P2} if {@code P1} contains
   * all of the elements that make up {@code P2's} path. For example, if this object has the path
   * {@code [a, b]}, and <code>aTreePath</code> has the path {@code [a, b, c]}, then <code>aTreePath
   * </code> is a descendant of this object. However, if <code>aTreePath</code> has the path {@code
   * [a]}, then it is not a descendant of this object. By this definition a {@code TreePath} is
   * always considered a descendant of itself. That is, <code>aTreePath.isDescendant(aTreePath)
   * </code> returns {@code true}.
   *
   * @param aTreePath the {@code TreePath} to check
   * @return true if <code>aTreePath</code> is a descendant of this path
   */
  public boolean isDescendant(TreePath aTreePath) {
    if (aTreePath == this) return true;

    if (aTreePath != null) {
      int pathLength = getPathCount();
      int oPathLength = aTreePath.getPathCount();

      if (oPathLength < pathLength)
        // Can't be a descendant, has fewer components in the path.
        return false;
      while (oPathLength-- > pathLength) aTreePath = aTreePath.getParentPath();
      return equals(aTreePath);
    }
    return false;
  }
 // ======================================================
 // ======================================================
 private void treeMousePressed(java.awt.event.MouseEvent evt) {
   int mask = evt.getModifiers();
   if ((mask & MouseEvent.BUTTON1_MASK) != 0) {
     TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY());
     if (selectedPath == null) return;
     DefaultMutableTreeNode node =
         (DefaultMutableTreeNode) selectedPath.getPathComponent(selectedPath.getPathCount() - 1);
     Object o = node.getUserObject();
     if (o instanceof String) {
       TransferHandler transfer = this.getTransferHandler();
       transfer.exportAsDrag(this, evt, TransferHandler.COPY);
       dragged_node = node;
       parent.setCursor(renderer.getNodeCursor(node));
     }
   }
 }
Esempio n. 20
0
  /**
   * Compares this {@code TreePath} to the specified object. This returns {@code true} if {@code o}
   * is a {@code TreePath} with the exact same elements (as determined by using {@code equals} on
   * each element of the path).
   *
   * @param o the object to compare
   */
  public boolean equals(Object o) {
    if (o == this) return true;
    if (o instanceof TreePath) {
      TreePath oTreePath = (TreePath) o;

      if (getPathCount() != oTreePath.getPathCount()) return false;
      for (TreePath path = this; path != null; path = path.getParentPath()) {
        if (!(path.getLastPathComponent().equals(oTreePath.getLastPathComponent()))) {
          return false;
        }
        oTreePath = oTreePath.getParentPath();
      }
      return true;
    }
    return false;
  }
 private List<FilePath> getSelectedFilePaths(final Object tag) {
   Set<FilePath> files = new HashSet<FilePath>();
   final TreePath[] paths = getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       if (path.getPathCount() > 1) {
         ChangesBrowserNode firstNode = (ChangesBrowserNode) path.getPathComponent(1);
         if (tag == null || firstNode.getUserObject() == tag) {
           ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent();
           files.addAll(node.getAllFilePathsUnder());
         }
       }
     }
   }
   return new ArrayList<FilePath>(files);
 }
  /**
   * Updates attributes list on node selection change in the tags tree. Loads attributes of the
   * selected node into the attributes list. Just clears attributes if no node is selected.
   *
   * @param e
   */
  public void onTagChange(TreeSelectionEvent e) {
    if (e.getNewLeadSelectionPath() != null) {
      TreePath path = e.getNewLeadSelectionPath();
      attributes.clear();
      if (path.getPathCount() >= 1) {

        DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
        Tag tag = (Tag) node.getUserObject();
        for (String name : tag.getAttributes().keySet()) {
          Attribute attr = new Attribute();
          attr.setName(name);
          attr.setValue(tag.getAttribute(name));
          attributes.add(attr);
        }
      }
    }
  }
Esempio n. 23
0
 public void treeExpanded(TreeExpansionEvent e) {
   TreePath tp = e.getPath();
   if (tp.getPathCount() == 2) {
     // opened a path down to the bottom: close all others
     TreePath topPath = dialog.optionTree.getPathForRow(0);
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) topPath.getLastPathComponent();
     int numChildren = node.getChildCount();
     for (int i = 0; i < numChildren; i++) {
       DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i);
       TreePath descentPath = topPath.pathByAddingChild(child);
       if (!descentPath.getLastPathComponent().equals(tp.getLastPathComponent())) {
         dialog.optionTree.collapsePath(descentPath);
       }
     }
   }
   dialog.pack();
 }
 private List<LocallyDeletedChange> getSelectedLocallyDeletedChanges() {
   Set<LocallyDeletedChange> files = new HashSet<LocallyDeletedChange>();
   final TreePath[] paths = getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       if (path.getPathCount() > 1) {
         ChangesBrowserNode firstNode = (ChangesBrowserNode) path.getPathComponent(1);
         if (firstNode.getUserObject() == TreeModelBuilder.LOCALLY_DELETED_NODE) {
           ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent();
           final List<LocallyDeletedChange> objectsUnder =
               node.getAllObjectsUnder(LocallyDeletedChange.class);
           files.addAll(objectsUnder);
         }
       }
     }
   }
   return new ArrayList<LocallyDeletedChange>(files);
 }
Esempio n. 25
0
    /*
     * Drag Gesture Handler
     */
    @Override
    public void dragGestureRecognized(DragGestureEvent dge) {
      TreePath path = tree.getSelectionPath();

      if ((path == null) || (path.getPathCount() <= 1)) {
        return;
      }

      node = (TreeNode) path.getLastPathComponent();
      node.getNodeData().setCopy(false);
      transferable = new TransferableNode(node);

      if (Model.isResource(node.getNodeData()) || Model.isLiason(node.getNodeData())) {
        source.startDrag(dge, DragSource.DefaultLinkDrop, transferable, this);
      } else {
        source.startDrag(dge, DragSource.DefaultMoveDrop, transferable, this);
      }
    }
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      if (!e.isAddedPath()) {
        // path unselected, ignore
        return;
      }

      TreePath[] selected = display.logTree.getSelectionPaths();
      switch (selected[0].getPathCount()) {
        case 0:
          Debug.error("null selection!");
          break;
        case 1:
          Debug.error("root selected!");
          break;
        case 2:
          {
            Group group = (Group) selected[0].getLastPathComponent();
            displayGroup(group);
            Events.GGroupSelected.generate(this, group);
          }
          return;
        case 3:
          {
            List<Log> all = new LinkedList<>();
            for (TreePath path : selected) {
              if (path.getPathCount() != 3) continue; // it isn't a Log selection

              LogReference ref = (LogReference) path.getLastPathComponent();
              all.add(ref.get());
            }

            Log first = all.remove(0);
            displayLog(first, all);
            Events.GLogSelected.generate(outerClassThis, first, all);
          }
          return;
        default:
          Debug.error(
              "selection count %d %s",
              selected[0].getPathCount(), selected[0].getLastPathComponent());
      }
    }
Esempio n. 27
0
      /**
       * Overrides doLayout so that the editor component width is resized to extend the full width
       * of the tree's enclosing panel
       */
      @Override
      public void doLayout() {
        if (editingComponent != null) {
          // get component preferred size
          Dimension eSize = editingComponent.getPreferredSize();

          // expand component width to extend to the enclosing container bounds
          int n = lastPath.getPathCount();
          Rectangle r = new Rectangle();
          r = tree.getParent().getBounds();
          eSize.width = r.width - (offset * n);

          // only show the symbol table icon if the editor is wide enough
          ((MathTextField) editingComponent).setShowSymbolTableIcon(eSize.width > 100);

          // set the component size and location
          editingComponent.setSize(eSize);
          editingComponent.setLocation(offset, 0);
          editingComponent.setBounds(offset, 0, eSize.width, eSize.height);
          setSize(new Dimension(eSize.width + offset, eSize.height));
        }
      }
 // ======================================================
 // ======================================================
 private void treeMouseReleased(java.awt.event.MouseEvent evt) {
   int mask = evt.getModifiers();
   if ((mask & MouseEvent.BUTTON1_MASK) != 0) {
     if (dragged_node == null) return;
     TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY());
     if (selectedPath == null)
       if ((selectedPath = getUpperPath(evt.getX(), evt.getY())) == null) return;
     DefaultMutableTreeNode node =
         (DefaultMutableTreeNode) selectedPath.getPathComponent(selectedPath.getPathCount() - 1);
     Object o = node.getUserObject();
     int pos = 0;
     if (o instanceof String) {
       DefaultMutableTreeNode p_node = (DefaultMutableTreeNode) node.getParent();
       pos = p_node.getIndex(node);
       node = p_node;
     }
     moveLeaf(node, dragged_node, pos);
     dragged_node = null;
     Cursor cursor = new Cursor(Cursor.DEFAULT_CURSOR);
     parent.setCursor(cursor);
   }
 }
Esempio n. 29
0
  /**
   * Called whenever the value of the selection changes, we watch this to cache whenever
   * HermesTreeNode is in the selection path and to change the components tooltip text.
   */
  public void valueChanged(TreeSelectionEvent e) {
    final TreePath treePath = e.getNewLeadSelectionPath();

    try {
      if (treePath != null) {
        for (int i = 0; i < treePath.getPathCount(); i++) {
          if (treePath.getPathComponent(i) instanceof HermesTreeNode) {
            final HermesTreeNode node = (HermesTreeNode) treePath.getPathComponent(i);
            lastSelectedHermesTreeNode = node;

            setToolTipText(node.getHermes().getMetaData().getToolTipText());
          } else if (treePath.getPathComponent(i) instanceof DestinationConfigTreeNode) {
            final DestinationConfigTreeNode node =
                (DestinationConfigTreeNode) treePath.getPathComponent(i);
            setToolTipText(node.getDestinationName());

            maybeRefocusDocument(node);

          } else if (treePath.getPathComponent(i) instanceof RepositoryTreeNode) {
            final RepositoryTreeNode node = (RepositoryTreeNode) treePath.getPathComponent(i);
            setToolTipText(node.getRepository().getId());
          } else if (treePath.getPathComponent(i) instanceof MessageStoreTreeNode) {
            final MessageStoreTreeNode node = (MessageStoreTreeNode) treePath.getPathComponent(i);
            setToolTipText(node.getMessageStore().getTooltipText());
            maybeRefocusDocument(node);

          } else if (treePath.getPathComponent(i) instanceof MessageStoreURLTreeNode) {
            final MessageStoreURLTreeNode node =
                (MessageStoreURLTreeNode) treePath.getPathComponent(i);

            setToolTipText(node.getURL());
          }
        }
      }
    } catch (JMSException ex) {
      Hermes.ui.getDefaultMessageSink().add(ex.getMessage());
    }
  }
Esempio n. 30
0
    public void valueChanged(TreeSelectionEvent evt) {
      TreePath path = evt.getPath();
      String fqn = SEP;
      String component_name;
      HashMap data = null;

      for (int i = 0; i < path.getPathCount(); i++) {
        component_name = ((MyNode) path.getPathComponent(i)).name;
        if (component_name.equals(SEP)) continue;
        if (fqn.equals(SEP)) fqn += component_name;
        else fqn = fqn + SEP + component_name;
      }
      data = getData(tree, fqn);
      if (data != null) {
        getContentPane().add(tablePanel, BorderLayout.SOUTH);
        populateTable(data);
        validate();
      } else {
        clearTable();
        getContentPane().remove(tablePanel);
        validate();
      }
    }