Package javax.swing

Examples of javax.swing.JTree


    log.info("Start : getMethodRemoteParmsPanel1");
    JPanel panel = new JPanel();
    panel.add(new JLabel(JMeterUtils.getResString("jndi_method_remote_parms")));
    rootRemote = new DefaultMutableTreeNode("Root");
    treeModelRemote = new DefaultTreeModel(rootRemote);
    jTreeRemote = new JTree(treeModelRemote);
    jTreeRemote.getSelectionModel().setSelectionMode(
      TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTreeRemote.addTreeSelectionListener(this);
    jTreeRemote.setPreferredSize(new Dimension(200, 50));
    JPanel jTreePanel = new JPanel();
View Full Code Here


    }

    private JTree makeTree() {
        ManagementModelNode root = new ManagementModelNode();
        root.explore();
        JTree tree = new CommandBuilderTree(new DefaultTreeModel(root));
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        tree.addTreeExpansionListener(new ManagementTreeExpansionListener((DefaultTreeModel) tree.getModel()));
        tree.addTreeSelectionListener(new ManagementTreeSelectionListener());
        tree.addMouseListener(new ManagementTreeMouseListener(tree));
        return tree;
    }
View Full Code Here

          }

          protected Transferable createTransferable(JComponent c) {

            if (c.getClass().equals(JTree.class)) {
              JTree tree = (JTree) c;
              return new SortedTreeNodeTransferable(
                  getSelectedNodes(tree));
            }
            return null;
          }
        };

        ActionListener actionListener = new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            if (cmd.equals("refresh")) {
              MoteDataWrapper.updateMoteList();
            }
          }
        };

        JToolBar jToolBar = new JToolBar();
        jToolBar.setFloatable(false);
        jToolBar.add(ReMote.createButton("refresh",
            IconResources.VIEW_REFRESH, "Refresh the mote list.",
            actionListener));

        JToolBar jBottomBar = new JToolBar();
        jBottomBar.setFloatable(false);
        JComboBox comboBoxes[] = new JComboBox[4];
        for (int i = 0; i < 4; i++) {
          comboBoxes[i] = new JComboBox();
          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());
        jTree.setDragEnabled(true);
        jTree.setTransferHandler(moteTransferHandler);
        ToolTipManager.sharedInstance().registerComponent(jTree);

        JScrollPane scrollPane = new JScrollPane(jTree);
        JPanel jPanel = new JPanel(new BorderLayout());
View Full Code Here

            return true;
          }

          protected Transferable createTransferable(JComponent c) {
            if (c.getClass().equals(JTree.class)) {
              JTree tree = (JTree) c;
              TreePath[] selectedPaths = tree.getSelectionModel()
                  .getSelectionPaths();
              SortedTreeNode[] nodes = getSelectedNodes(tree);
              return new SortedTreeNodeTransferable(nodes);
            }
            return null;
          }

          public boolean importData(JComponent comp, Transferable t) {
            try {
              SortedTreeNode[] nodes = (SortedTreeNode[]) t
                  .getTransferData(myFlavor);
              TableRow[] rows = getLeafValues(nodes);
              long[] ids = getMoteIds(rows);
              boolean[] grants = ReMote.this.getClientMoteAccess().getMoteControlPrivileges(ids,ReMote.this.session.getSessionId());
              for (int i=0; i<grants.length;i++)
              {
                if (!grants[i]){
                  // FIXME: use a default mote identification string
                  JOptionPane.showMessageDialog(ReMote.this,"Unable to get control privilege for mote with ID "+ids[i]+".");
                }
              }
              session.getMoteManager().requestMotes(ids);
            } catch (Exception e) {
              e.printStackTrace();
            }
            return true;
          }
        };

        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
View Full Code Here

      // enable ?
      final Content content = toolWindow.getContentManager().getContent(0);

      if (content != null) {
        final ToolWindowPanel panel = (ToolWindowPanel) content.getComponent();
        final JTree tree = panel.getBugTreePanel().getBugTree();
        _enabled = tree.isCollapsed(1) && tree.getRowCount() > 1;
        presentation.setEnabled(toolWindow.isAvailable() && isEnabled());
        presentation.setVisible(true);
      }
    } catch (final Throwable e) {
      final FindBugsPluginException processed = FindBugsPluginImpl.processError("Action update failed", e);
View Full Code Here

      // enable ?
      final Content content = toolWindow.getContentManager().getContent(0);

      if (content != null) {
        final ToolWindowPanel panel = (ToolWindowPanel) content.getComponent();
        final JTree tree = panel.getBugTreePanel().getBugTree();
        _enabled = tree.isExpanded(1) && tree.getRowCount() > 1;
        presentation.setEnabled(toolWindow.isAvailable() && isEnabled());
        presentation.setVisible(true);
      }
    } catch (final Throwable e) {
      final FindBugsPluginException processed = FindBugsPluginImpl.processError("Action update failed", e);
View Full Code Here

    }
  }


  private void showJTree(final JScrollPane view, final Point pt) {
    final JTree tree = (JTree) view.getViewport().getView();
    final Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, tree);

    final int row = tree.getClosestRowForLocation(p.x, p.y);

    final TreePath path = tree.getClosestPathForLocation(p.x, p.y);

    final Rectangle bds = tree.getPathBounds(path);
    if (bds == null || !bds.contains(p)) {
      hide();
      return;
    }
    if (setCompAndRow(tree, row)) {
View Full Code Here

    ROOTSAMPLE = new SampleResult();
    ROOTSAMPLE.setSampleLabel(SERVER_TITLE);
    ROOTSAMPLE.setSuccessful(true);
    ROOTNODE = new DefaultMutableTreeNode(ROOTSAMPLE);
    TREEMODEL = new DefaultTreeModel(ROOTNODE);
    SERVERTREE = new JTree(TREEMODEL);
    SERVERTREE.getSelectionModel().setSelectionMode(
      TreeSelectionModel.SINGLE_TREE_SELECTION);
    SERVERTREE.addTreeSelectionListener(this);
    SERVERTREE.setShowsRootHandles(true);
    TREEPANE = new JScrollPane(SERVERTREE);
View Full Code Here

        rootSampleResult.setSampleLabel("Root");
        rootSampleResult.setSuccessful(true);
        root = new DefaultMutableTreeNode(rootSampleResult);

        treeModel = new DefaultTreeModel(root);
        jTree = new JTree(treeModel);
        jTree.setCellRenderer(new ResultsNodeRenderer());
        jTree.getSelectionModel().setSelectionMode(
            TreeSelectionModel.SINGLE_TREE_SELECTION);
        jTree.addTreeSelectionListener(this);
        jTree.setShowsRootHandles(true);
View Full Code Here

        renderer.setBackground(Color.RED);
        assertSame(Color.RED, renderer.getBackground());
    }

    public void testGetTreeCellRendererComponent() throws Exception {
        JTree tree = new JTree();
        tree.setFont(new Font("font", 20, 1));
        tree.setBackground(Color.MAGENTA);
        assertSame(renderer, renderer.getTreeCellRendererComponent(tree, "value", false, false,
                false, 0, false));
        assertFalse(renderer.isOpaque());
        assertNull(renderer.getBackground());
        assertSame(renderer.textNonSelectionColor, renderer.getForeground());
        assertEquals("value", renderer.getText());
        assertSame(tree.getFont(), renderer.getFont());
        assertSame(renderer.getDefaultClosedIcon(), renderer.getIcon());
        assertNull(renderer.getBorder());
        renderer.getTreeCellRendererComponent(tree, "value", true, true, false, 0, false);
        assertFalse(renderer.isOpaque());
        assertNull(renderer.getBackground());
        assertSame(renderer.textSelectionColor, renderer.getForeground());
        assertEquals("value", renderer.getText());
        assertSame(tree.getFont(), renderer.getFont());
        assertSame(renderer.getDefaultOpenIcon(), renderer.getIcon());
        assertNull(renderer.getBorder());
        renderer.getTreeCellRendererComponent(tree, "value", true, true, true, 0, true);
        assertFalse(renderer.isOpaque());
        assertNull(renderer.getBackground());
        assertSame(renderer.textSelectionColor, renderer.getForeground());
        assertEquals("value", renderer.getText());
        assertSame(tree.getFont(), renderer.getFont());
        assertSame(renderer.getDefaultLeafIcon(), renderer.getIcon());
        assertNull(renderer.getBorder());
        renderer.setBackgroundSelectionColor(Color.RED);
        renderer.getTreeCellRendererComponent(tree, "value", true, true, true, 0, true);
        if (isHarmony()) {
View Full Code Here

TOP

Related Classes of javax.swing.JTree

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.