Examples of DefaultMutableTreeNode


Examples of javax.swing.tree.DefaultMutableTreeNode

        targetToNodeTable = new HashMap();

        // Create help tree
        rootNode = new HelpNode();

        rootTreeNode = new DefaultMutableTreeNode();
        DefaultTreeModel treeModel = new DefaultTreeModel(rootTreeNode);
        helpTree = new JTree();
        helpTree.setModel(treeModel);
        helpTree.setRootVisible(false);
        helpTree.setShowsRootHandles(true);
        helpTree.addTreeSelectionListener(this);

        // Renderer
        DefaultTreeCellRenderer  helpTreeRenderer = (DefaultTreeCellRenderer) helpTree.getCellRenderer();
        helpTreeRenderer.setOpenIcon(resources.getIcon("folderIcon"));
        helpTreeRenderer.setClosedIcon(resources.getIcon("folderIcon"));
        helpTreeRenderer.setLeafIcon(resources.getIcon("leafIcon"));

        createHelpContents();


        // Create help search panel

        // search tree
        searchRootTreeNode = new DefaultMutableTreeNode();
        searchTreeModel = new DefaultTreeModel(searchRootTreeNode);
        searchTree = new JTree();
        searchTree.setModel(searchTreeModel);
        searchTree.setRootVisible(false);
        searchTree.setShowsRootHandles(true);
View Full Code Here

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

Examples of javax.swing.tree.DefaultMutableTreeNode

            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

Examples of javax.swing.tree.DefaultMutableTreeNode

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

Examples of javax.swing.tree.DefaultMutableTreeNode

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

Examples of javax.swing.tree.DefaultMutableTreeNode

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

Examples of javax.swing.tree.DefaultMutableTreeNode

    {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

Examples of javax.swing.tree.DefaultMutableTreeNode

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

      if(content instanceof CompositeObject)
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

    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

Examples of javax.swing.tree.DefaultMutableTreeNode

         }
      }
      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
TOP
Copyright © 2018 www.massapi.com. 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.