Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode


            rootTreeNode.add(createHelpTreeNode(rootNode.getChildAt(i)));
        }
    }

    private DefaultMutableTreeNode createHelpTreeNode(HelpNode hn){
        DefaultMutableTreeNode ret = new DefaultMutableTreeNode((Object)hn);

        // Update node table
        targetToNodeTable.put(hn.getLink(), ret);

        // Add its children
        for(int i =0; i< hn.getChildrenCount();i++){
            ret.add( createHelpTreeNode(hn.getChildAt(i)));
        }
        return ret;
    }
View Full Code Here


            boolean containsAllKeyword= (keywords.length!=0);
            for(int j=0;j<keywords.length;j++)
                containsAllKeyword&= (result.indexOf(keywords[j])!=-1);

            if (containsAllKeyword){
                searchRootTreeNode.add( new DefaultMutableTreeNode(node) );
            }
        }

        // Do the search on children pages
        for(int i=0;i< node.getChildrenCount();i++){
View Full Code Here

    /* (non-Javadoc)
     * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
     */
    public void valueChanged(TreeSelectionEvent e){
        DefaultMutableTreeNode  f = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
        HelpNode hn = (HelpNode)f.getUserObject();
        if (hn!=null){
            displayPageEvent(hn.getLink());
        }

    }
View Full Code Here

            // Set as current page
            currentPage = page;
           
            // Get page tree path
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)targetToNodeTable.get(page);
            if (node != null){
                TreePath path = new TreePath(node.getPath());

                // If page path has changed, update help tree and back stack
                if (!path.equals(helpTree.getSelectionPath())){
                    helpTree.scrollPathToVisible(path);
                    helpTree.setSelectionPath(path);
View Full Code Here

              {
                // Clear the attributes table!
                DefaultTableModel model = (DefaultTableModel)table.getModel();
                model.setRowCount(0);

                DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
                if(node == null)
                  return;

                // Show the current node attributes into the table!
                Object nodeValue = node.getUserObject();
                if(nodeValue instanceof ContentNodeValue)
                {showContentAttributes(((ContentNodeValue)nodeValue).getContent(), model);}
                else if(nodeValue instanceof PageNodeValue)
                {showPageAttributes(((PageNodeValue)nodeValue).getPage().getContents(), model);}

                pack(table);
              }
            }
            );
          tree.addTreeWillExpandListener(
            new TreeWillExpandListener()
            {
              @Override
              public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException
              {/* NOOP */}
              @Override
              public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException
              {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode)event.getPath().getLastPathComponent();
                Object nodeValue = node.getUserObject();
                if(nodeValue instanceof PageNodeValue)
                {
                  // Content placeholder?
                  if(((DefaultMutableTreeNode)node.getFirstChild()).getUserObject() == null)
                  {
                    // Remove the content placeholder!
                    node.removeAllChildren();

                    // Create the page content nodes!
                    createContentNodes(
                      ((PageNodeValue)nodeValue).getPage().getContents(),
                      node
View Full Code Here

    {throw new RuntimeException(file.getAbsolutePath() + " file has a bad file format.",e);}
    catch(Exception e)
    {throw new RuntimeException(file.getAbsolutePath() + " file access error.",e);}

    // Create the root node!
    DefaultMutableTreeNode fileNode = new DefaultMutableTreeNode(file.getName());
    ((DefaultTreeModel)tree.getModel()).setRoot(fileNode);

    // Create the page nodes!
    createPageNodes(fileNode);
View Full Code Here

    DefaultMutableTreeNode parentNode
    )
  {
    for(ContentObject content : contents)
    {
      DefaultMutableTreeNode contentNode = new DefaultMutableTreeNode(
        new ContentNodeValue(content)
        );
      parentNode.add(contentNode);

      if(content instanceof CompositeObject)
View Full Code Here

    DefaultMutableTreeNode fileNode
    )
  {
    for(Page page : file.getDocument().getPages())
    {
      DefaultMutableTreeNode pageNode = new DefaultMutableTreeNode(
        new PageNodeValue(page)
        );
      fileNode.add(pageNode);

      // Add a placeholder node to postpone content parsing!
      DefaultMutableTreeNode contentPlaceholderNode = new DefaultMutableTreeNode();
      pageNode.add(contentPlaceholderNode);
    }
  }
View Full Code Here

         }
      }
      clearSelection();


      DefaultMutableTreeNode parent = (DefaultMutableTreeNode) nodes[0].getParent();

      if (parent != null)
      {
         parent.removeAllChildren();
         startExpandingTree((ObjectTreeNode) parent, false, selectedPathNames, true);
      }
      else
      {
         nodes[0].removeAllChildren();
View Full Code Here

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

TOP

Related Classes of javax.swing.tree.DefaultMutableTreeNode

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.