Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode$BreadthFirstEnumeration$Queue


    /**
     * Sets the tree up
     */
    private void setupTree() {
        root = new DefaultMutableTreeNode(resources.getString("preferences"));
        topNode = new DefaultMutableTreeNode(resources.getString("preferences"));
        root.add(topNode);

        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
            public Component getTreeCellRendererComponent(JTree tree,
                    Object value, boolean sel, boolean expanded, boolean leaf,
                    int row, boolean hasFocus) {
                super.getTreeCellRendererComponent(tree, value, sel, expanded,
                        leaf, row, hasFocus);

                DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                setText(((String) node.getUserObject()).replaceAll("^a\\d+ ",
                        ""));

                return this;
            }
        };
        renderer.setLeafIcon(null);

        Iterator i = prefsDialog.getPanels().keySet().iterator();

        while (i.hasNext()) {
            topNode.add(new DefaultMutableTreeNode((String) i.next()));
        }

        TreeMap plugins = PreferencesDialog.getPluginPanels();
        if (plugins.size() > 0) {
            pluginsNode = new DefaultMutableTreeNode(resources
                    .getString("pluginPreferences"));
            i = plugins.keySet().iterator();
            while (i.hasNext()) {
                pluginsNode.add(new DefaultMutableTreeNode((String) i.next()));
            }
            root.add(pluginsNode);
        }

        tree = new JTree(root);
View Full Code Here


     *
     * @return the selected index
     */
    public int getSelectedIndex() {
        TreePath path = tree.getSelectionPath();
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
                .getLastPathComponent();
        DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
        return model.getIndexOfChild(root, node);
    }
View Full Code Here

         *            Description of the Parameter
         */
        public void mouseClicked(MouseEvent e) {
            JTree tree = (JTree) e.getComponent();
            TreePath path = tree.getSelectionPath();
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
                    .getLastPathComponent();
            String string = (String) node.getUserObject();
            if (string != null) {
                prefsDialog.switchPanel(string);
            }
        }
View Full Code Here

    initialize();
   
    ContactDatabase contactDatabase = Pim.getContactDBFactory().createContactDatabase();
   
    // initialize tree content
    DefaultMutableTreeNode localAddressBookTreeNode = new DefaultMutableTreeNode();
    localAddressBook = new ContactCollection(contactDatabase, i18n.tr("Local Address Book"));
    localAddressBookTreeNode.setUserObject(localAddressBook);
    rootNode.add(localAddressBookTreeNode);
    addressBookTree.expandPath(new TreePath(rootNode));
    addressBookTree.setSelectionRow(0);
   
    updateActions();
View Full Code Here

    return result;
  }

  public ContactCollection getSelectedContactCollection()
  {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)addressBookTree.getSelectionPath().getLastPathComponent();
    return (ContactCollection)node.getUserObject();
  }
View Full Code Here

  private void initializeContent()
  {
    horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    horizontalSplitPane.setBorder(GUIHelper.createEmptyBorder(5));
   
    rootNode = new DefaultMutableTreeNode();
    addressBookTreeModel = new DefaultTreeModel(rootNode);
    addressBookTree = new JTree(addressBookTreeModel);
    addressBookTree.setRootVisible(false);
    addressBookTree.setCellRenderer(new ContactCollectionCellRenderer());
    horizontalSplitPane.add(new JScrollPane(addressBookTree));
View Full Code Here

    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
    {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
          row, hasFocus);

      DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
      if (node.getUserObject() instanceof ContactCollection) {
        ContactCollection collection = (ContactCollection)node.getUserObject();
        setIcon((collection.getGroup() != null) ? groupIcon : bookIcon);
      }
     
      return this;
    }
View Full Code Here

    private ProblemInfo getNodeProblem(final Object pNode) {
        if (!(pNode instanceof DefaultMutableTreeNode))
            return null;

        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) pNode;
        final Object userObject = node.getUserObject();
        if (!(userObject instanceof ProblemInfo))
            return null;

        return (ProblemInfo) userObject;
    }
View Full Code Here

     * Creates an instance for the given project.
     *
     * @param pProject the project
     */
    public PomTreeModel(final Project pProject) {
        super(new DefaultMutableTreeNode(), true);
        project = pProject;

        //
        //register for events, to refresh when needed
        //
        PomManager.getInstance(project).addPomManagerListener(this);
        PomPluginGoalsManager.getInstance(project).addPomPluginGoalsListener(this);
        MavenPluginsManager.getInstance(project).addPropertyChangeListener(
                "plugins", MAVEN_PLUGINS_LISTENER);

        //
        //build model
        //
        final DefaultMutableTreeNode root = (DefaultMutableTreeNode) super.root;
        root.insert(projectsNode, root.getChildCount());
        root.insert(pluginsNode, root.getChildCount());
        refresh(false);
    }
View Full Code Here

                boolean sel, boolean expanded, boolean leaf, int row,
                boolean focus) {
            Component result = super.getTreeCellRendererComponent(tree, value,
                    sel, expanded, leaf, row, focus);
            if (value != null) {
                DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value;
                if (treeNode.getUserObject() != null
                        && treeNode.getUserObject() instanceof TransformTarget) {
                    this.setText(((TransformTarget) treeNode.getUserObject())
                            .getType());
                }
            }
            return result;
        }
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultMutableTreeNode$BreadthFirstEnumeration$Queue

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.