Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode$PathBetweenNodesEnumeration


     *
     * @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

     *
     * @return tree for selection the transformation target.
     */
    private JTree createTree() {
        DefaultTreeModel treeModel = new DefaultTreeModel(
                new DefaultMutableTreeNode("root"));
        JTree result = new JTree(treeModel);
        result.addTreeSelectionListener(this);
        result.setCellRenderer(new TreeRenderer());
        result.getSelectionModel().setSelectionMode(
                TreeSelectionModel.SINGLE_TREE_SELECTION);
        HashMap lang2list = new HashMap();
        TransformTarget[] available = (TransformTarget[]) XslTransformer
                .getTransformTargets().toArray(new TransformTarget[0]);
        Arrays.sort(available, new LangTypeComp());
        for (int i = 0; i < available.length; i++) {
            String lang = available[i].getLanguage();
            ArrayList list = (ArrayList) lang2list.get(lang);
            if (list == null) {
                list = new ArrayList();
                lang2list.put(lang, list);
            }
            list.add(available[i]);
        }
        String[] languages = (String[]) lang2list.keySet().toArray(
                new String[0]);
        Arrays.sort(languages);
        TreePath tp = null;
        for (int i = 0; i < languages.length; i++) {
            DefaultMutableTreeNode langNode = new DefaultMutableTreeNode(
                    languages[i]);
            ((DefaultMutableTreeNode) result.getModel().getRoot())
                    .add(langNode);
            langNode.setAllowsChildren(true);
            TransformTarget[] targets = (TransformTarget[]) ((ArrayList) lang2list
                    .get(languages[i])).toArray(new TransformTarget[0]);
            Arrays.sort(targets);
            for (int j = 0; j < targets.length; j++) {
                DefaultMutableTreeNode tt = new DefaultMutableTreeNode(
                        targets[j]);
                langNode.add(tt);
                if (targets[j].equals(transformTask.getConfiguration()
                        .getTransformTarget())) {
                    tp = new TreePath(new Object[] {
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultMutableTreeNode$PathBetweenNodesEnumeration

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.