Package remote.gui.util

Examples of remote.gui.util.TableBasedTree


          jBottomBar.add(comboBoxes[i]);
        }
        MoteDataWrapper.setSession(this.getSession());
        MoteDataWrapper.updateMoteList();
        Table table = MoteDataWrapper.getMoteTable();
        TableBasedTree treeModel = new TableBasedTree(table, "Root",
            new TableRowOrdering[] { OrderingsAllMotesView.BY_NET });

        final JTree jTree = new JTree(treeModel);
        jTree.setRootVisible(false);
        jTree.setCellRenderer(new TableBasedTreeCellRenderer());
View Full Code Here


        };

        MoteControlTable table = new MoteControlTable(session
            .getMoteManager().getMoteList());

        final TableBasedTree treeModel = new TableBasedTree(
            table,
            "Control",
            new TableRowOrdering[] { OrderingsControlledMotesView.BY_NET });

        final JTree jTree = new JTree(treeModel);
        jTree.setRootVisible(true);
        jTree.setCellRenderer(new TableBasedTreeCellRenderer());
        jTree.setTransferHandler(moteControlTransferHandler);
        jTree.setDragEnabled(true);
        jTree.setToggleClickCount(0);
        ToolTipManager.sharedInstance().registerComponent(jTree);

        ActionListener actionListener = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int i;
            String cmd = e.getActionCommand();
            SortedTreeNode[] nodes = getSelectedNodes(jTree);
            TableRow[] rows = getLeafValues(nodes);
            long[] motes = getMoteIds(rows);
            SimpleMoteManager moteManager = (SimpleMoteManager) session
                .getMoteManager();
            if (cmd.equals("release")) {
              moteManager.releaseMotes(motes);

            } else if (cmd.equals("console")) {
              for (i = 0; i < rows.length; i++) {
                getMoteView((MoteControlRow) rows[i]);
              }
            } else if (cmd.equals("program")) {
              java.util.Properties settings = getSettings();
              try {
                JFileChooser fc = new JFileChooser(settings
                    .getProperty("flashImagePath", "/"));
                fc.setFileFilter(new FlashImageFilter());
                int returnVal = fc
                    .showOpenDialog(getRootWindow());

                if (returnVal == JFileChooser.APPROVE_OPTION) {
                  File file = fc.getSelectedFile();
                  FileInputStream fi = new FileInputStream(
                      file);
                  byte[] bytes = new byte[(int) file.length()];
                  fi.read(bytes);
                  moteManager.program(motes, bytes);
                  fi.close();
                  settings.setProperty("flashImagePath", file
                      .getParent());
                  saveSettings();
                }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            } else if (cmd.equals("start")) {
              moteManager.start(motes);
            } else if (cmd.equals("stop")) {
              moteManager.stop(motes);
            } else if (cmd.equals("reset")) {
              moteManager.reset(motes);
            }
          }

        };

        MouseListener ml = new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            TreePath selPath = jTree.getPathForLocation(e.getX(), e
                .getY());
            if (selPath != null && e.getClickCount() > 0) {
              TableRow[] rows = getLeafValues(new SortedTreeNode[] { (SortedTreeNode) selPath
                  .getLastPathComponent() });
              for (int i = 0; i < rows.length; i++) {
                if (MoteControlRow.class
                    .isAssignableFrom(rows[i].getClass())) {
                  MoteControlRow row = (MoteControlRow) rows[i];
                  if (e.getClickCount() == 1) {
                    View moteView = (View) moteViews
                        .get(row);
                    if (moteView != null) {
                      moteView.requestFocusInWindow();
                      DockingWindow parent = moteView
                          .getWindowParent();
                      if (parent != null && TabWindow.class
                          .isAssignableFrom(parent
                              .getClass())) {
                        TabWindow tab = (TabWindow) parent;
                        tab
                            .setSelectedTab(tab
                                .getChildWindowIndex(moteView));
                      }

                    }
                  } else if (e.getClickCount() == 2) {
                    getMoteTabView().addTab(
                        getMoteView(row));
                  }
                }
              }
            }
          }
        };
        jTree.addMouseListener(ml);

        TreeModelListener treeModelListener = new TreeModelListener() {

          public void treeNodesChanged(TreeModelEvent e) {
            // TODO Auto-generated method stub

          }

          public void treeNodesInserted(TreeModelEvent e) {
            jTree.expandPath(e.getTreePath().getParentPath());
          }

          public void treeNodesRemoved(TreeModelEvent e) {
            // TODO Auto-generated method stub

          }

          public void treeStructureChanged(TreeModelEvent e) {
            // TODO Auto-generated method stub

          }

        };

        treeModel.addTreeModelListener(treeModelListener);

        JToolBar jBottomBar = new JToolBar();
        jBottomBar.setFloatable(false);
        JComboBox comboBoxes[] = new JComboBox[4];
        for (int i = 0; i < 4; i++) {
View Full Code Here

TOP

Related Classes of remote.gui.util.TableBasedTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.