Esempio n. 1
0
 public void editSelected() {
   TreePath selected = tree.getSelectionPath();
   if (selected != null) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) selected.getLastPathComponent();
     Object obj = node.getUserObject();
     if (obj instanceof CavityDBObject) {
       CavityDBObject dbObj = (CavityDBObject) obj;
       new ObjectEditingFrame(new ObjectEditingPanel(dbObj));
     }
   }
 }
Esempio n. 2
0
  public Browser(CavityNestingDB cndb) throws SQLException {
    super(new BorderLayout());
    setPreferredSize(new Dimension(300, 500));
    db = cndb;
    displayer = new NodeDisplay();

    top = new DefaultMutableTreeNode("CavityNestingDB");
    tree = new JTree(top);
    DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel();
    selModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setSelectionModel(selModel);

    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {
            if (e.isAddedPath()) {
              TreePath path = e.getPath();
              DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
              Object value = node.getUserObject();

              // System.out.println(String.valueOf(value));
              if (value instanceof CavityDBObject) {
                displayer.display((CavityDBObject) value);
              } else {
                // System.out.println(value.getClass().getSimpleName());
              }
            }
          }
        });

    JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    add(splitter, BorderLayout.CENTER);
    splitter.add(new JScrollPane(tree));
    splitter.add(displayer);

    populate();
  }