Esempio n. 1
0
    public ReplicatedTreeView(ReplicatedTree tree, Object title) throws Exception {
      this.tree = tree;
      tree.addReplicatedTreeListener(this);

      addNotify();
      setTitle("ReplicatedTreeDemo: mbr=" + title);

      tree_model = new DefaultTreeModel(root);
      jtree = new JTree(tree_model);
      jtree.setDoubleBuffered(true);
      jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

      JScrollPane scroll_pane = new JScrollPane(jtree);

      populateTree();

      getContentPane().add(scroll_pane, BorderLayout.CENTER);
      addWindowListener(this);

      table_model.setColumnIdentifiers(new String[] {"Name", "Value"});
      table_model.addTableModelListener(this);

      setTableColumnWidths();

      tablePanel = new JPanel();
      tablePanel.setLayout(new BorderLayout());
      tablePanel.add(table.getTableHeader(), BorderLayout.NORTH);
      tablePanel.add(table, BorderLayout.CENTER);

      getContentPane().add(tablePanel, BorderLayout.SOUTH);

      jtree.addTreeSelectionListener(this); // REVISIT

      MouseListener ml =
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              int selRow = jtree.getRowForLocation(e.getX(), e.getY());
              TreePath selPath = jtree.getPathForLocation(e.getX(), e.getY());
              if (selRow != -1) {
                selected_node = makeFQN(selPath.getPath());
                jtree.setSelectionPath(selPath);

                if (e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK) {
                  operationsPopup.show(e.getComponent(), e.getX(), e.getY());
                }
              }
            }
          };

      jtree.addMouseListener(ml);

      createMenus();
      setLocation(50, 50);
      setSize(
          getInsets().left + getInsets().right + 485, getInsets().top + getInsets().bottom + 367);

      init();
      setVisible(true);
    }