Exemplo n.º 1
0
 /**
  * Called whenever the value of the selection changes.
  *
  * @param e the event that characterizes the change.
  */
 public void valueChanged(TreeSelectionEvent e) {
   TreePath path = e.getPath();
   if (path != null) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
     if (node.isLeaf()) {
       if (getInformation(path) != null) {
         // When selecting an image information.
         XmlInformation info = getInformation(path);
         for (int i = 0; i < listener_list.size(); i++) {
           InformationTreeSelectionListener listener =
               (InformationTreeSelectionListener) listener_list.elementAt(i);
           listener.select(info);
         }
       } else {
         // When expanding a folder.
         expandNode(node);
       }
     }
   }
 }
Exemplo n.º 2
0
  /**
   * Returns the image information of the specified path, if it represents an image information.
   * Otherwise returns null.
   *
   * @param path the tree path.
   * @return the image information.
   */
  protected XmlInformation getInformation(TreePath path) {
    String path_str = "";
    Object[] paths = path.getPath();
    for (int i = 1; i < paths.length; i++) {
      String name = (String) ((DefaultMutableTreeNode) paths[i]).getUserObject();
      path_str += "/" + name;
    }

    XmlInformation info = (XmlInformation) hash_info.get(path_str);
    return info;
  }