void onDelete() {
    TreePath path = m_tree.getSelectionPath();
    if (path != null) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

      Object[] options = {"Yes", "No"};
      int choise =
          JOptionPane.showOptionDialog(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(),
              "Are you sure deleting this " + node + " ?",
              "Confirm",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              options[1]);

      if (choise == JOptionPane.YES_OPTION) {
        try {
          deleteNodeParent(node);
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this, ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
        }
      }
    }
  }
Exemple #2
0
 void lookupByXPath(String xpath) {
   NodeList nl = DOMInfoExtractor.locateNodes(document, xpath);
   System.out.println("lookupByXPath: " + xpath);
   if (nl == null) {
     JOptionPane.showMessageDialog(this, "error xpath: " + xpath);
   }
   System.out.println("find " + nl.getLength() + " items");
   FoundItem[] fis = new FoundItem[nl.getLength()];
   for (int i = 0; i < nl.getLength(); i++) {
     fis[i] = getFoundItem(nl.item(i), null);
   }
   foundList.setListData(fis);
 }
  /**
   * Expands the sub folders and image informations under the specified node.
   *
   * @param node the node.
   */
  protected void expandNode(DefaultMutableTreeNode node) {
    try {
      Object[] paths = node.getPath();

      String path_str = "";
      Vector folder_list = new Vector();
      for (int i = 1; i < paths.length; i++) {
        String name = (String) ((DefaultMutableTreeNode) paths[i]).getUserObject();
        path_str += "/" + name;

        // Converts January...December to 1...12.
        if (mode == DATE_ORIENTED && i == 2) {
          for (int m = 1; m <= 12; m++) {
            if (JulianDay.getFullSpellMonthString(m).equals(name)) name = String.valueOf(m);
          }
        }

        folder_list.addElement(name);
      }

      // When to expand sub folders.
      Vector folders = new Vector();
      if (mode == DATE_ORIENTED) folders = db_manager.getDateOrientedFolders(folder_list);
      if (mode == PATH_ORIENTED) folders = db_manager.getPathOrientedFolders(folder_list);
      addNode(node, folders);

      // When to expand image informations.
      XmlDBAccessor accessor = null;
      if (mode == DATE_ORIENTED) accessor = db_manager.getDateOrientedAccessor(folder_list);
      if (mode == PATH_ORIENTED) accessor = db_manager.getPathOrientedAccessor(folder_list);
      if (accessor != null) {
        Vector name_list = new Vector();
        XmlInformation info = (XmlInformation) accessor.getFirstElement();
        while (info != null) {
          name_list.addElement(info.getPath());
          hash_info.put(path_str + "/" + info.getPath(), info);
          info = (XmlInformation) accessor.getNextElement();
        }
        addNode(node, name_list);
      }

      revalidate();
      repaint();
    } catch (IOException exception) {
      String message = "Failed to read the database.";
      JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
Exemple #4
0
  private void showDetails(TreePath p) {

    if (p == null) {
      return;
    }

    MyNode selectedNode = (MyNode) p.getLastPathComponent();
    String textPath = textGen(p);

    JOptionPane.showMessageDialog(
        this,
        selectedNode.getLevelName()
            + ": "
            + selectedNode.getUserObject()
            + "\n"
            + selectedNode.getText()
            + "\n"
            + textPath);
  }
Exemple #5
0
 void reloadJTree(String url) {
   System.out.println("reload " + url);
   Document dom;
   try {
     URL uurl = new URL(url);
     HTMLWrapper hw = new HTMLWrapper(url);
     dom = hw.getDOM();
   } catch (IOException e) {
     e.printStackTrace();
     try {
       dom = HTML2DOM.getDOM(new FileInputStream(url));
     } catch (IOException ie) {
       JOptionPane.showMessageDialog(this, "can't get document of the url: " + url);
       ie.printStackTrace();
       return;
     }
   }
   document = dom;
   jtree.setRootNode(dom);
 }
 public void actionPerformed(ActionEvent e) {
   JTextField fqnTextField = new JTextField();
   if (selected_node != null) fqnTextField.setText(selected_node);
   Object[] information = {"Enter fully qualified name", fqnTextField};
   final String btnString1 = "OK";
   final String btnString2 = "Cancel";
   Object[] options = {btnString1, btnString2};
   int userChoice =
       JOptionPane.showOptionDialog(
           null,
           information,
           "Add Node",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.PLAIN_MESSAGE,
           null,
           options,
           options[0]);
   if (userChoice == 0) {
     String userInput = fqnTextField.getText();
     tree.put(userInput, null);
   }
 }
 private void m12_Clicked() // 閫�嚭绯荤粺
     {
   JOptionPane.showMessageDialog(this, "书是人类进步的阶梯!");
   System.exit(0);
 }