Example usage for javax.swing.tree DefaultTreeModel DefaultTreeModel

List of usage examples for javax.swing.tree DefaultTreeModel DefaultTreeModel

Introduction

In this page you can find the example usage for javax.swing.tree DefaultTreeModel DefaultTreeModel.

Prototype

@ConstructorProperties({ "root" })
public DefaultTreeModel(TreeNode root) 

Source Link

Document

Creates a tree in which any node can have children.

Usage

From source file:src.gui.ItSIMPLE.java

/**
 * Creates the project selection panel in the main analysis panel
 * @return // w w w  .ja  va2 s .  c  o  m
 */
private JPanel getProjectPDDLSelectionPane() {

    JPanel anPanel = new JPanel(new BorderLayout());

    //TOP panel Domain/problem selection
    ItFramePanel projectSelPanel = new ItFramePanel(":: Domain/Problem Selection",
            ItFramePanel.NO_MINIMIZE_MAXIMIZE);
    projectSelPanel.setPreferredSize(new Dimension(screenSize.width / 4 - 20, screenSize.height));

    //Instanciate project selection tree
    ItTreeNode root = new ItTreeNode("Projects");
    root.setIcon(new ImageIcon("resources/images/projects.png"));
    pddlTranslationTreeModel = new DefaultTreeModel(root);
    pddlTranslationTree = new JTree(pddlTranslationTreeModel);
    pddlTranslationTree.setShowsRootHandles(true);
    pddlTranslationTree.setCellRenderer(new ItTreeCellRenderer());
    pddlTranslationTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    pddlTranslationTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
        public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
            ItTreeNode selectedNode = (ItTreeNode) pddlTranslationTree.getLastSelectedPathComponent();
            //if(selectedNode != null && selectedNode.getLevel() == 3){

            //}
            //else{

            //}
        }
    });

    // create a main pane for putting the tree inside
    JPanel mainTreePanel = new JPanel(new BorderLayout());
    mainTreePanel.add(new JScrollPane(pddlTranslationTree), BorderLayout.CENTER);

    //Translate button
    translateDomainProblemButton = new JButton("Translate", new ImageIcon("resources/images/play.png"));
    //solveProblemButton.setEnabled(false);
    translateDomainProblemButton.setActionCommand("translate");
    translateDomainProblemButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ItTreeNode selectedNode = (ItTreeNode) pddlTranslationTree.getLastSelectedPathComponent();
            if (selectedNode != null) {
                if (selectedNode.getLevel() == 2 && selectedNode.getData().getName().equals("domain")) {
                    Element domain = selectedNode.getData();
                    translateDomainToPddl(domain);

                } else if (selectedNode.getLevel() == 3 && selectedNode.getData().getName().equals("problem")) {
                    Element problem = selectedNode.getData();
                    translateProblemToPddl(problem);
                } else {
                    JOptionPane.showMessageDialog(ItSIMPLE.this,
                            "<html>Please chose a domain or problem node (from a UML project)<br> in the Domain/Problem Selection tree.</html>");
                }
            }
        }

    });
    mainTreePanel.add(translateDomainProblemButton, BorderLayout.SOUTH);

    projectSelPanel.setContent(mainTreePanel, false);
    //projectSelPanel.setParentSplitPane(petriEditorSplitPane);

    anPanel.add(projectSelPanel, BorderLayout.CENTER);

    //BOTTOM panels (pddl version settings)
    ItFramePanel pddlSettingFramePanel = new ItFramePanel(":: PDDL Version Settings",
            ItFramePanel.NO_MINIMIZE_MAXIMIZE);
    //pddlSettingPanel.setPreferredSize(new Dimension(screenSize.width/4 - 20, screenSize.height));

    JPanel bottonPanel = new JPanel(new BorderLayout());
    bottonPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
    bottonPanel.add(getPddlVersionSettingsPanel(), BorderLayout.CENTER);

    pddlSettingFramePanel.setContent(bottonPanel, false);
    anPanel.add(pddlSettingFramePanel, BorderLayout.SOUTH);

    return anPanel;
}

From source file:src.gui.ItSIMPLE.java

/**
 * Creates the project selection panel in the main analysis panel
 * @return //from  w w w.j  av a  2s. co m
 */
private JPanel getProjectAnalysisSelectionPane() {

    JPanel anPanel = new JPanel(new BorderLayout());

    ItFramePanel projectSelPanel = new ItFramePanel(":: Project Selection", ItFramePanel.NO_MINIMIZE_MAXIMIZE);
    projectSelPanel.setPreferredSize(new Dimension(screenSize.width / 4 - 20, screenSize.height));

    //Instanciate project selectio tree
    ItTreeNode root = new ItTreeNode("Projects");
    root.setIcon(new ImageIcon("resources/images/projects.png"));
    projectAnalysisTreeModel = new DefaultTreeModel(root);
    projectAnalysisTree = new JTree(projectAnalysisTreeModel);
    projectAnalysisTree.setShowsRootHandles(true);
    projectAnalysisTree.setCellRenderer(new ItTreeCellRenderer());
    projectAnalysisTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    projectAnalysisTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
        public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
            ItTreeNode selectedNode = (ItTreeNode) projectAnalysisTree.getLastSelectedPathComponent();
            //if(selectedNode != null && selectedNode.getLevel() == 3){

            //}
            //else{

            //}
        }
    });

    // create a main pane for putting the tree inside
    JPanel mainTreePanel = new JPanel(new BorderLayout());
    mainTreePanel.add(new JScrollPane(projectAnalysisTree), BorderLayout.CENTER);

    projectSelPanel.setContent(mainTreePanel, false);
    //projectSelPanel.setParentSplitPane(petriEditorSplitPane);

    anPanel.add(projectSelPanel, BorderLayout.CENTER);

    return anPanel;
}

From source file:net.sourceforge.pmd.util.designer.Designer.java

private void loadASTTreeData(TreeNode rootNode) {
    astTreeWidget.setModel(new DefaultTreeModel(rootNode));
    astTreeWidget.setRootVisible(true);/*  w  w  w. j  a v a2 s .c  om*/
    astTreeWidget.expandAll(true);
}

From source file:net.sourceforge.pmd.util.designer.Designer.java

private void loadSymbolTableTreeData(TreeNode rootNode) {
    if (rootNode != null) {
        symbolTableTreeWidget.setModel(new DefaultTreeModel(rootNode));
        symbolTableTreeWidget.expandAll(true);
    } else {// ww w  . jav a  2 s. c o  m
        symbolTableTreeWidget.setModel(null);
    }
}

From source file:net.sourceforge.squirrel_sql.client.gui.HelpViewerWindow.java

/**
 * Create a tree each node being a link to a document.
 * /*from www  .  j a  va  2  s  .c  om*/
 * @return The contents tree.
 */
private JScrollPane createContentsTree() throws IOException {

    // i18n[HelpViewerWindow.help=Help]
    final FolderNode root = new FolderNode(s_stringMgr.getString("HelpViewerWindow.help"));
    _tree = new JTree(new DefaultTreeModel(root));
    _tree.setShowsRootHandles(true);
    _tree.addTreeSelectionListener(new ObjectTreeSelectionListener());

    // Renderer for tree.
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    SquirrelResources rsrc = _app.getResources();
    renderer.setLeafIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOPIC));
    renderer.setOpenIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_OPEN));
    renderer.setClosedIcon(rsrc.getIcon(SquirrelResources.IImageNames.HELP_TOC_CLOSED));
    _tree.setCellRenderer(renderer);

    // First put the Welcome to SQuirreL node.
    FileWrapper file = applicationFiles.getWelcomeFile();
    try {
        // i18n[HelpViewerWindow.welcome=Welcome]
        DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.welcome"), file);
        root.add(dn);
        _nodes.put(dn.getURL().toString(), dn);
    } catch (MalformedURLException ex) {
        // i18n[HelpViewerWindow.error.loadwelcomefile=Error retrieving Welcome file URL for {0}]
        String msg = s_stringMgr.getString("HelpViewerWindow.error.loadwelcomefile", file.getAbsolutePath());
        s_log.error(msg, ex);
    }

    // Add Help, Licence and Change Log nodes to the tree.
    // i18n[HelpViewerWindow.help=Help]
    final FolderNode helpRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.help"));
    root.add(helpRoot);
    _nodes.put(helpRoot.getURL().toString(), helpRoot);
    // i18n[HelpViewerWindow.licences=Licences]
    final FolderNode licenceRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.licences"));
    root.add(licenceRoot);
    _nodes.put(licenceRoot.getURL().toString(), licenceRoot);
    // i18n[HelpViewerWindow.changelogs=Change Logs]
    final FolderNode changeLogRoot = new FolderNode(s_stringMgr.getString("HelpViewerWindow.changelogs"));
    root.add(changeLogRoot);
    _nodes.put(changeLogRoot.getURL().toString(), changeLogRoot);

    // Add SQuirreL help to the Help node.
    file = applicationFiles.getQuickStartGuideFile();
    try {
        // i18n[HelpViewerWindow.squirrel=SQuirreL]
        DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file);
        helpRoot.add(dn);
        _homeURL = dn.getURL();
        _nodes.put(_homeURL.toString(), dn);
    } catch (MalformedURLException ex) {
        // i18n[HelpViewerWindow.error.loadwelcomefile=Error retrieving Help file URL for {0}]
        String msg = s_stringMgr.getString("HelpViewerWindow.error.loadhelpfile", file.getAbsolutePath());
        s_log.error(msg, ex);
    }

    // Add SQuirreL Licence to the Licence node.
    file = applicationFiles.getLicenceFile();
    try {
        // i18n[HelpViewerWindow.squirrel=SQuirreL]
        DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file);
        licenceRoot.add(dn);
        _nodes.put(dn.getURL().toString(), dn);
    } catch (MalformedURLException ex) {
        // i18n[HelpViewerWindow.error.loadlicencefile=Error retrieving Licence file URL for {0}]
        String msg = s_stringMgr.getString("HelpViewerWindow.error.loadlicencefile", file.getAbsolutePath());
        s_log.error(msg, ex);
    }

    // Add SQuirreL Change Log to the Licence node.
    file = applicationFiles.getChangeLogFile();
    try {
        // i18n[HelpViewerWindow.squirrel=SQuirreL]
        DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.squirrel"), file);
        changeLogRoot.add(dn);
        _nodes.put(dn.getURL().toString(), dn);
    } catch (MalformedURLException ex) {
        // i18n[HelpViewerWindow.error.loadchangelogfile=Error retrieving Change Log file URL for {0}]
        String msg = s_stringMgr.getString("HelpViewerWindow.error.loadchangelogfile", file.getAbsolutePath());
        s_log.error(msg, ex);
    }

    // Add plugin help, licence and change log documents to the tree.
    PluginInfo[] pi = _app.getPluginManager().getPluginInformation();
    for (int i = 0; i < pi.length; ++i) {
        try {
            final FileWrapper dir = pi[i].getPlugin().getPluginAppSettingsFolder();
            final String title = pi[i].getDescriptiveName();

            // Help document.
            try {
                final String fn = pi[i].getHelpFileName();
                if (fn != null && fn.length() > 0) {
                    DocumentNode dn = new DocumentNode(title, fileWrapperFactory.create(dir, fn));
                    helpRoot.add(dn);
                    _nodes.put(dn.getURL().toString(), dn);
                }
            } catch (IOException ex) {
                // i18n[HelpViewerWindow.error.loadpluginhelp=Error generating Help entry for plugin {0}]
                String msg = s_stringMgr.getString("HelpViewerWindow.error.loadpluginhelp",
                        pi[i].getDescriptiveName());
                s_log.error(msg, ex);
            }

            // Licence document.
            try {
                final String fn = pi[i].getLicenceFileName();
                if (fn != null && fn.length() > 0) {
                    DocumentNode dn = new DocumentNode(title, fileWrapperFactory.create(dir, fn));
                    licenceRoot.add(dn);
                    _nodes.put(dn.getURL().toString(), dn);
                }
            } catch (IOException ex) {
                // i18n[HelpViewerWindow.error.loadpluginlicence=Error generating Licence entry for plugin {0}]
                String msg = s_stringMgr.getString("HelpViewerWindow.error.loadpluginlicence",
                        pi[i].getDescriptiveName());
                s_log.error(msg, ex);
            }

            try {
                // Change log.
                final String fn = pi[i].getChangeLogFileName();
                if (fn != null && fn.length() > 0) {
                    DocumentNode dn = new DocumentNode(title, fileWrapperFactory.create(dir, fn));
                    changeLogRoot.add(dn);
                    _nodes.put(dn.getURL().toString(), dn);
                }
            } catch (IOException ex) {
                // i18n[HelpViewerWindow.error.loadchangelog=Error generating Change Log entry for plugin {0}]
                String msg = s_stringMgr.getString("HelpViewerWindow.error.loadchangelog",
                        pi[i].getDescriptiveName());
                s_log.error(msg, ex);
            }
        } catch (IOException ex) {
            // i18n[HelpViewerWindow.error.loadpluginsettings=Error retrieving app settings folder for plugin
            // {0}]
            String msg = s_stringMgr.getString("HelpViewerWindow.error.loadpluginsettings",
                    pi[i].getDescriptiveName());
            s_log.error(msg, ex);
        }
    }

    // FAQ.
    file = applicationFiles.getFAQFile();
    try {
        // i18n[HelpViewerWindow.faq=FAQ]
        DocumentNode dn = new DocumentNode(s_stringMgr.getString("HelpViewerWindow.faq"), file);
        root.add(dn);
        _nodes.put(dn.getURL().toString(), dn);
    } catch (MalformedURLException ex) {
        // i18n[HelpViewerWindow.error.loadfaqfile=Error retrieving FAQ from URL = {0}]
        String msg = s_stringMgr.getString("HelpViewerWindow.error.loadfaqfile", file.getAbsolutePath());
        s_log.error(msg, ex);
    }

    // generate contents file.
    helpRoot.generateContentsFile();
    licenceRoot.generateContentsFile();
    changeLogRoot.generateContentsFile();

    JScrollPane sp = new JScrollPane(_tree);
    sp.setPreferredSize(new Dimension(200, 200));

    return sp;
}

From source file:op.care.med.structure.PnlMed.java

private void initDialog() {
    prepareSearchArea();//from ww  w.j a va2s.  co  m
    product = null;
    treeMed.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
    treeMed.setVisible(false);
}

From source file:op.care.med.structure.PnlMed.java

private void txtSucheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSucheActionPerformed
    //        treeMed.setCellRenderer(new DefaultTreeCellRenderer());
    treeMed.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
    //        treeMed.setVisible(false);
    if (txtSuche.getText().isEmpty()) {
        lstPraep.setModel(new DefaultListModel());
    } else {/*from   w  w w .  j  a  v a  2s. c o m*/
        EntityManager em = OPDE.createEM();
        Query query = em
                .createQuery("SELECT m FROM MedProducts m WHERE m.text LIKE :bezeichnung ORDER BY m.text");
        query.setParameter("bezeichnung", "%" + txtSuche.getText() + "%");
        lstPraep.setModel(SYSTools.list2dlm(query.getResultList()));
        em.close();
    }
}

From source file:op.care.med.structure.PnlMed.java

private void createTree() {
    if (product == null)
        return;// w  w w .  ja v  a  2s .  c  o m
    treeMed.setVisible(true);
    tree = new DefaultTreeModel(getRoot());
    treeMed.setModel(tree);
    treeMed.setCellRenderer(new TreeRenderer());
    SYSTools.expandAll(treeMed);
}

From source file:op.controlling.PnlQMSSchedule.java

private void initPanel() {

    i18n();/*from w  w  w.j  av  a 2s.c  om*/

    txtDueDays.setText(Integer.toString(qmssched.getDuedays()));

    spinTaeglich.setModel(new SpinnerNumberModel(1, 1, 365, 1));
    spinWoche.setModel(new SpinnerNumberModel(1, 1, 52, 1));
    spinMonat.setModel(new SpinnerNumberModel(1, 1, 12, 1));
    spinYearly.setModel(new SpinnerNumberModel(1, 1, 10, 1));
    spinDayInMonth.setModel(new SpinnerNumberModel(1, 1, 31, 1));

    spinTaeglich.setValue(Math.max(qmssched.getDaily(), 1));
    spinWoche.setValue(Math.max(qmssched.getWeekly(), 1));
    spinMonat.setValue(Math.max(qmssched.getMonthly(), 1));
    spinDayInMonth.setValue(Math.max(qmssched.getDayinmonth(), 1));
    spinYearly.setValue(Math.max(qmssched.getYearly(), 1));

    cbMon.setSelected(true);

    cmbMonth.setSelectedIndex(qmssched.isYearly() ? qmssched.getMonthinyear() - 1 : 0);
    spinDayInMonthInYear.setModel(new SpinnerNumberModel(qmssched.isYearly() ? qmssched.getDayinmonth() : 1, 1,
            maxdays[cmbMonth.getSelectedIndex()], 1));
    cmbMonth.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                spinDayInMonthInYear
                        .setModel(new SpinnerNumberModel(1, 1, maxdays[cmbMonth.getSelectedIndex()], 1));
            }
        }
    });

    if (qmssched.isDaily()) {
        tabWdh.setSelectedIndex(TAB_DAILY);
    } else if (qmssched.isWeekly()) {
        cbMon.setSelected(qmssched.getWeekday() == DateTimeConstants.MONDAY);
        cbDie.setSelected(qmssched.getWeekday() == DateTimeConstants.TUESDAY);
        cbMit.setSelected(qmssched.getWeekday() == DateTimeConstants.WEDNESDAY);
        cbDon.setSelected(qmssched.getWeekday() == DateTimeConstants.THURSDAY);
        cbFre.setSelected(qmssched.getWeekday() == DateTimeConstants.FRIDAY);
        cbSam.setSelected(qmssched.getWeekday() == DateTimeConstants.SATURDAY);
        cbSon.setSelected(qmssched.getWeekday() == DateTimeConstants.SUNDAY);

        tabWdh.setSelectedIndex(TAB_WEEKLY);
    } else if (qmssched.isMonthly()) {

        spinDayInMonth.setValue(qmssched.getDayinmonth());
        cmbTag.setSelectedIndex(qmssched.getWeekday());

        tabWdh.setSelectedIndex(TAB_MONTHLY);
    } else if (qmssched.isYearly()) {
        spinYearly.setValue(qmssched.getYearly());
        spinDayInMonthInYear.setValue(qmssched.getDayinmonth());
        cmbMonth.setSelectedIndex(qmssched.getMonthinyear() - 1);
        tabWdh.setSelectedIndex(TAB_YEARLY);
    }

    jdcStartingOn.setMinSelectableDate(new Date());
    jdcStartingOn.setDate(qmssched.getStartingOn());

    ArrayList<Date> timelist = SYSCalendar.getTimeList();
    DefaultComboBoxModel dcbm = new DefaultComboBoxModel(timelist.toArray());
    dcbm.insertElementAt(null, 0);

    txtBemerkung.setText(qmssched.getText());
    txtQMS.setText(qmssched.getMeasure());

    cmbLocation.setTreeModel(new DefaultTreeModel(StationTools.getCompleteStructure()));

    Object userObject = null;
    if (qmssched.getHome() != null) {
        userObject = qmssched.getHome();
    } else if (qmssched.getStation() != null) {
        userObject = qmssched.getStation();
    }

    int row = 0;
    if (userObject == null) {
        cmbLocation.setSelectedItem(null);
    } else {
        DefaultMutableTreeNode root = (DefaultMutableTreeNode) cmbLocation.getTreeModel().getRoot();
        DefaultMutableTreeNode theNode = null;
        for (Enumeration e = root.depthFirstEnumeration(); e.hasMoreElements() && theNode == null;) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
            if (userObject.equals(node.getUserObject())) {
                cmbLocation.setSelectedItem(node);
                break;
            }
            row++;
        }
    }
}

From source file:org.adl.sequencer.impl.ADLSequencer.java

/**
 * Method added 8/24/2007 JLR// w w  w  .j a va 2  s .  com
 * 
 * This is an attempt to more efficiently generate the TreeModel object that we pass around
 * instead of the ADLTOC List that ADL uses in their reference implementation.
 * 
 */
private DefaultTreeModel getTreeModel(SeqActivity iStart) {

    List<ActivityNode> nodes = new ArrayList<ActivityNode>();

    log.debug("Generating the table of contents tree model");

    boolean done = false;

    // Make sure we have an activity tree
    if (mSeqTree == null) {
        log.warn("No activity tree found");
        done = true;
    }

    // Perform a breadth-first walk of the activity tree.
    SeqActivity walk = iStart;
    int depth = 0;
    int parentTOC = -1;
    List<SeqActivity> lookAt = new ArrayList<SeqActivity>();
    List<SeqActivity> flatTOC = new ArrayList<SeqActivity>();

    // Tree traversal status indicators
    boolean next = false;

    // Make sure the activity has been associated with this sequencer
    // If not, build the TOC from the root
    if (walk == null) {
        walk = mSeqTree.getRoot();
    }

    if (!done) {
        if (log.isDebugEnabled()) {
            log.debug("  ::--> Building TOC from:  " + walk.getID());
        }
    }

    SeqActivity cur = (mSeqTree != null ? mSeqTree.getFirstCandidate() : null);
    int curIdx = -1;

    if (cur == null) {
        cur = mSeqTree.getCurrentActivity();
    }

    while (!done) {
        next = false;

        ActivityNode node = new ActivityNode(walk);
        node.setParentLocation(parentTOC);
        node.setEnabled(!checkActivity(walk));
        node.setHidden(!walk.getIsVisible());
        node.setLeaf(!walk.hasChildren(false));

        // Check to see if this activity can be included -- JLR
        if (canBeIncluded(walk, cur, node)) {
            ISeqActivity parent = walk.getParent();
            node.setIncluded(true);

            // Not sure why we're checking this twice... but I'm sticking with the ADL template here -- JLR
            if (parent != null) {
                node.setInChoice(parent.getControlModeChoice());
            } else {
                node.setInChoice(true);
            }

            node.setDepth(depth);

            // Check if we looking at the 'current' cluster
            if (cur != null) {
                if (walk.getID().equals(cur.getID())) {
                    node.setCurrent(true);
                    curIdx = nodes.size();
                }
            }
        } else {
            node.setDepth(-depth);
            node.setSelectable(false);
        }

        // Doesn't really matter if it's included or not, we still add it... strangely enough
        nodes.add(node);

        // Add this activity to the "flat TOC"
        flatTOC.add(walk);

        // If this activity has children, look at them later...
        if (walk.hasChildren(false)) {
            // Remember where we are at and look at the children now,
            // unless we are at the root
            if (walk.getParent() != null) {
                lookAt.add(walk);
            }

            // Go to the first child
            walk = (walk.getChildren(false)).get(0);
            parentTOC = nodes.size() - 1;
            depth++;

            next = true;
        }

        if (!next) {
            // Move to its sibling
            walk = walk.getNextSibling(false);

            ActivityNode tempNode = nodes.get(nodes.size() - 1);
            parentTOC = tempNode.getParentLocation();

            while (walk == null && !done) {
                if (lookAt.size() > 0) {
                    // Walk back up the tree to the parent's next sibling
                    walk = lookAt.get(lookAt.size() - 1);
                    lookAt.remove(lookAt.size() - 1);
                    depth--;

                    // Find the correct parent
                    tempNode = nodes.get(parentTOC);

                    String tempNodeId = tempNode.getActivity().getID();
                    walk.getID();

                    while (!tempNodeId.equals(walk.getID())) {
                        parentTOC = tempNode.getParentLocation();
                        tempNode = nodes.get(parentTOC);
                        tempNodeId = tempNode.getActivity().getID();
                    }

                    walk = walk.getNextSibling(false);
                } else {
                    done = true;
                }
            }

            if (walk != null) {
                parentTOC = tempNode.getParentLocation();
            }
        }
    }

    log.debug("  ::--> Completed first pass");

    // After the TOC has been created, mark activites unselectable
    // if the Prevent Activation prevents them being selected,
    // and mark them invisible if they are descendents of a hidden
    // from choice activity
    int hidden = -1;
    int prevented = -1;

    for (int i = 0; i < nodes.size(); i++) {
        SeqActivity tempAct = flatTOC.get(i);
        ActivityNode tempNode = nodes.get(i);

        if (log.isDebugEnabled()) {
            log.debug("  ::--> Evaluating --> " + tempAct.getID());
            log.debug("                   --> " + tempAct.getTitle());
        }

        int tempDepth = tempNode.getDepth();

        // Flipping the cardinality of the hidden depths, apparently -- JLR
        int checkDepth = ((tempDepth >= 0) ? tempDepth : (-tempDepth));

        if (hidden != -1) {
            // Check to see if we are done hiding activities
            if (checkDepth <= hidden) {
                hidden = -1;
            } else {
                // This must be a descendent
                tempNode.setDepth(-depth);
                tempNode.setSelectable(false);
                tempNode.setHidden(true);
            }
        }

        // Evaluate hide from choice rules if we are not hidden
        if (hidden == -1) {
            // Attempt to get rule information from the activity
            ISeqRuleset hiddenRules = tempAct.getPreSeqRules();

            String result = null;

            if (hiddenRules != null) {
                result = hiddenRules.evaluate(SeqRuleset.RULE_TYPE_HIDDEN, tempAct, false);
            }

            // If the rule evaluation did not return null, the activity
            // must be hidden.
            if (result != null) {
                // The depth we are looking for should be positive
                hidden = -tempNode.getDepth();
                prevented = -1;
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("  ::--> Prevented ??" + prevented);
                }

                if (prevented != -1) {
                    // Check to see if we are done preventing activities
                    if (checkDepth <= prevented) {
                        // Reset the check until we find another prevented
                        prevented = -1;
                    } else {
                        // This must be a prevented descendent
                        tempNode.setDepth(-1);
                        tempNode.setSelectable(false);
                    }
                } else {
                    // Check if this activity is prevented from activation
                    if (tempAct.getPreventActivation() && !tempAct.getIsActive()) {
                        if (cur != null) {
                            if (tempAct != cur && cur.getParent() != tempAct) {
                                if (log.isDebugEnabled()) {
                                    log.debug("  ::--> PREVENTED !!");
                                    log.debug(" " + tempAct.getID() + " != " + cur.getParent().getID());
                                }

                                // Not sure why we need to check this again -- JLR
                                tempNode.setIncluded(false);

                                // Flipping the cardinality of the hidden depths, apparently -- JLR
                                int td = tempNode.getDepth();
                                prevented = (td > 0) ? td : -td;

                                // The activity cannot be selected
                                tempNode.setDepth(-1);
                                tempNode.setSelectable(false);
                            }
                        }
                    }
                }
            }
        }
    }

    if (log.isDebugEnabled()) {
        log.debug("  ::--> Completed post-1 pass");
    }

    // After the TOC has been created, mark activites unselectable
    // if the Choice Exit control prevents them being selected
    SeqActivity noExit = null;

    if (mSeqTree.getFirstCandidate() != null) {
        walk = mSeqTree.getFirstCandidate().getParent();
    } else {
        walk = null;
    }

    // Walk up the active path looking for a non-exiting cluster
    while (walk != null && noExit == null) {
        // We cannot choose any target that is outside of the activiy tree,
        // so choice exit does not apply to the root of the tree
        if (walk.getParent() != null) {
            if (!walk.getControlModeChoiceExit()) {
                noExit = walk;
            }
        }

        // Move up the tree
        walk = walk.getParent();
    }

    if (noExit != null) {
        depth = -1;

        if (log.isDebugEnabled()) {
            log.debug("  ::--> Found NoExit Cluster -- " + noExit.getID());
        }

        // Only descendents of this activity can be selected.
        for (int i = 0; i < nodes.size(); i++) {
            ActivityNode tempNode = nodes.get(i);
            int td = tempNode.getDepth();

            // When we find the the 'non-exiting' activity, remember its
            // depth
            if (tempNode.getActivity().getID().equals(noExit.getID())) {
                depth = (td > 0) ? td : -td;

                // The cluster activity cannot be selected
                tempNode.setDepth(-1);
                tempNode.setSelectable(false);
            }
            // If we haven't found the the 'non-exiting' activity yet, then
            // the
            // activity being considered cannot be selected.
            else if (depth == -1) {
                tempNode.setDepth(-1);
                tempNode.setSelectable(false);
            }

            // When we back out of the depth-first-walk and encounter a
            // sibling
            // or parent of the 'non-exiting' activity, start making
            // activity
            // unselectable
            else if (((td > 0) ? td : -td) <= depth) {
                depth = -1;

                tempNode.setDepth(-1);
                tempNode.setSelectable(false);
            }
        }
    }

    // Boundary Condition -- evaluate choice exit on root
    ActivityNode tempNode = nodes.get(0);
    SeqActivity root = mSeqTree.getRoot();

    if (!root.getControlModeChoiceExit()) {
        tempNode.setSelectable(false);
    }

    log.debug("  ::--> Completed second pass");

    // Look for constrained activities relative to the current activity and
    // mark activites unselectable if they are outside of the avaliable set
    SeqActivity con = null;

    if (mSeqTree.getFirstCandidate() != null) {
        walk = mSeqTree.getFirstCandidate().getParent();
    } else {
        walk = null;
    }

    // Walk up the tree to the root
    while (walk != null && con == null) {

        if (walk.getConstrainChoice()) {
            con = walk;
        }

        walk = walk.getParent();
    }

    // Evaluate constrained choice set
    if (con != null) {

        if (log.isDebugEnabled()) {
            log.debug("  ::-->  Constrained Choice Activity Found");
            log.debug("  ::-->  Stopped at --> " + con.getID());
        }

        int forwardAct = -1;
        int backwardAct = -1;
        List<SeqActivity> list = null;

        Walk walkCon = new Walk();
        walkCon.at = con;

        // Find the next activity relative to the constrained activity.
        processFlow(FLOW_FORWARD, false, walkCon, true);

        if (walkCon.at == null) {
            if (log.isDebugEnabled()) {
                log.debug("  ::--> Walked forward off the tree");
            }

            walkCon.at = con;
        }

        String lookFor = "";
        list = walkCon.at.getChildren(false);
        if (list != null) {
            int size = list.size();
            lookFor = list.get(size - 1).getID();
        } else {
            lookFor = walkCon.at.getID();
        }

        for (int j = 0; j < nodes.size(); j++) {
            tempNode = nodes.get(j);

            if (tempNode.getActivity().getID().equals(lookFor)) {
                forwardAct = j;
                break;
            }
        }

        // Find the previous activity relative to the constrained activity.
        walkCon.at = con;
        processFlow(FLOW_BACKWARD, false, walkCon, true);

        if (walkCon.at == null) {
            log.debug("  ::--> Walked backward off the tree");
            walkCon.at = con;
        }

        lookFor = walkCon.at.getID();
        for (int j = 0; j < nodes.size(); j++) {
            tempNode = nodes.get(j);

            if (tempNode.getActivity().getID().equals(lookFor)) {
                backwardAct = j;
                break;
            }
        }

        // If the forward activity on either end of the range is a cluster,
        // we need to include its descendents
        tempNode = nodes.get(forwardAct);
        if (!tempNode.isLeaf()) {
            int idx = forwardAct;
            boolean foundLeaf = false;

            while (!foundLeaf) {
                for (int i = nodes.size() - 1; i > idx; i--) {
                    tempNode = nodes.get(i);

                    if (tempNode.getParentLocation() == idx) {
                        idx = i;
                        foundLeaf = tempNode.isLeaf();
                        break;
                    }
                }
            }

            if (idx != nodes.size()) {
                forwardAct = idx;
            }
        }

        if (log.isDebugEnabled()) {
            log.debug("  ::--> Constrained Range == [ " + backwardAct + " , " + forwardAct + " ]");
        }

        // Disable activities outside of the avaliable range
        for (int i = 0; i < nodes.size(); i++) {
            tempNode = nodes.get(i);

            if (i < backwardAct || i > forwardAct) {
                tempNode.setSelectable(false);

                if (log.isDebugEnabled()) {
                    log.debug("  ::--> Turn off -- " + tempNode.getActivity().getID());
                }
            }
        }
    }

    log.debug("  ::--> Completed third pass");

    // Walk the TOC looking for disabled activities...
    if (nodes != null) {
        depth = -1;

        for (int i = 0; i < nodes.size(); i++) {
            tempNode = nodes.get(i);

            if (depth != -1) {
                int td = tempNode.getDepth();
                if (depth >= ((td > 0) ? td : -td)) {
                    depth = -1;
                } else {
                    tempNode.setEnabled(false);
                    tempNode.setSelectable(false);
                }
            }

            if (!tempNode.isEnabled() && depth == -1) {
                int td = tempNode.getDepth();
                // Remember where the disabled activity is
                depth = (td > 0) ? td : -td;

                if (log.isDebugEnabled()) {
                    log.debug("  ::--> [" + i + "]  " + "Found Disabled -->  " + tempNode.getActivity().getID()
                            + "  <<" + tempNode.getDepth() + ">>");
                }
            }

        }
    }

    log.debug("  ::--> Completed fourth pass");

    // If there is a current activity, check availablity of its siblings
    // This pass corresponds to Case #2 of the Choice Sequencing Request
    if (nodes != null && curIdx != -1) {
        log.debug("  ::--> Checking Current Activity Siblings");

        int par = (nodes.get(curIdx)).getParentLocation();
        int idx;

        // Check if the current activity is in a forward only cluster
        if (cur.getParent() != null && cur.getParent().getControlForwardOnly()) {
            idx = curIdx - 1;

            tempNode = nodes.get(idx);
            while (tempNode.getParentLocation() == par) {
                tempNode.setSelectable(false);

                idx--;
                tempNode = nodes.get(idx);
            }
        }

        // Check for Stop Forward Traversal Rules
        idx = curIdx;
        boolean blocked = false;

        while (idx < nodes.size()) {
            tempNode = nodes.get(idx);
            if (tempNode.getParentLocation() == par) {
                if (!blocked) {
                    ISeqRuleset stopTrav = tempNode.getActivity().getPreSeqRules();

                    String result = null;
                    if (stopTrav != null) {
                        result = stopTrav.evaluate(SeqRuleset.RULE_TYPE_FORWARDBLOCK, tempNode.getActivity(),
                                false);
                    }

                    // If the rule evaluation did not return null, the
                    // activity is blocked
                    blocked = (result != null);
                } else {
                    tempNode.setSelectable(false);
                }
            }

            idx++;
        }
    }

    log.debug("  ::--> Completed fifth pass");

    // Evaluate Stop Forward Traversal Rules -- this pass cooresponds to
    // Case #3 and #5 of the Choice Sequencing Request Subprocess. In these
    // cases, we need to check if the target activity is forward in the
    // Activity Tree relative to the commen ancestor and cuurent activity
    if (nodes != null && curIdx != -1) {
        log.debug("  ::--> Checking Stop Forward Traversal");

        int curParent = (nodes.get(curIdx)).getParentLocation();

        int idx = nodes.size() - 1;
        tempNode = nodes.get(idx);

        // Walk backward from last available activity,
        // checking each until we get to a sibling of the current activity
        while (tempNode.getParentLocation() != -1 && tempNode.getParentLocation() != curParent) {
            tempNode = nodes.get(tempNode.getParentLocation());
            ISeqRuleset stopTrav = tempNode.getActivity().getPreSeqRules();

            String result = null;
            if (stopTrav != null) {
                result = stopTrav.evaluate(SeqRuleset.RULE_TYPE_FORWARDBLOCK, tempNode.getActivity(), false);
            }

            // If the rule evaluation did not return null,
            // then all of its descendents are blocked
            if (result != null) {
                if (log.isDebugEnabled()) {
                    log.debug("  ::--> BLOCKED SOURCE --> " + tempNode.getActivity().getID() + " ["
                            + tempNode.getDepth() + "]");
                }

                // The depth of the blocked activity
                int blocked = tempNode.getDepth();

                for (int i = idx; i < nodes.size(); i++) {
                    ActivityNode tempAN = nodes.get(i);

                    int td = tempAN.getDepth();
                    int checkDepth = ((td >= 0) ? td : (-td));

                    // Check to see if we are done blocking activities
                    if (checkDepth <= blocked) {
                        break;
                    }

                    // This activity must be a descendent
                    tempAN.setSelectable(false);
                }
            }

            idx--;
            tempNode = nodes.get(idx);
        }
    }

    log.debug("  ::--> Completed sixth pass");

    // Boundary condition -- if there is a TOC make sure all "selectable"
    // clusters actually flow into content
    for (int i = 0; i < nodes.size(); i++) {
        tempNode = nodes.get(i);

        if (!tempNode.isLeaf()) {
            if (log.isDebugEnabled()) {
                log.debug("  ::--> Process 'Continue' request from " + tempNode.getActivity().getID());
            }

            SeqActivity from = tempNode.getActivity();

            // Confirm 'flow' is enabled from this cluster
            if (from.getControlModeFlow()) {
                // Begin traversing the activity tree from the root
                Walk treeWalk = new Walk();
                treeWalk.at = from;

                boolean success = processFlow(ADLSequencer.FLOW_FORWARD, true, treeWalk, false);

                if (!success) {
                    tempNode.setSelectable(false);

                    if (log.isDebugEnabled()) {
                        log.debug("  :+: CONTINUE FAILED :+:  --> " + treeWalk.at.getID());
                    }
                }
            } else {
                // Cluster does not have flow == true
                tempNode.setSelectable(false);
            }
        }
    }

    log.debug("  ::--> Completed seventh pass");

    for (int i = nodes.size() - 1; i >= 0; i--) {
        tempNode = nodes.get(i);

        if (tempNode.isCurrent() && tempNode.isInChoice()) {
            if (tempNode.getDepth() < 0) {
                tempNode.setDepth(-tempNode.getDepth());
            }
        }

        if (tempNode.getDepth() >= 0) {
            while (tempNode.getParentLocation() != -1) {
                tempNode = nodes.get(tempNode.getParentLocation());

                if (tempNode.getDepth() < 0) {
                    tempNode.setDepth(-tempNode.getDepth());
                }
            }
        } else if (!tempNode.isHidden()) {
            tempNode.setDepth(-1);
        }
    }

    for (int i = 0; i < nodes.size(); i++) {
        tempNode = nodes.get(i);

        if (tempNode.isHidden()) {
            tempNode.setDepth(-1);
            List<Integer> parents = new ArrayList<Integer>();

            for (int j = i + 1; j < nodes.size(); j++) {
                tempNode = nodes.get(j);

                if (tempNode.getParentLocation() == i && tempNode.getDepth() > 0) {
                    tempNode.setDepth(tempNode.getDepth() - 1);
                    parents.add(Integer.valueOf(j));
                } else {
                    if (tempNode.getDepth() != -1) {
                        int idx = parents.indexOf(Integer.valueOf(tempNode.getParentLocation()));

                        if (idx != -1) {
                            tempNode.setDepth(tempNode.getDepth() - 1);
                            parents.add(Integer.valueOf(j));
                        }
                    }
                }
            }
        }
    }

    log.debug("  ::--> Completed TOC walk up");

    log.debug("  :: ADLSequencer --> END   - getTOC");

    ActivityNode rootNode = null;

    for (int i = 0; i < nodes.size(); i++) {
        ActivityNode node = nodes.get(i);

        if (node.getParentLocation() == -1) {
            rootNode = node;
        } else if (node.getDepth() >= 0) {
            ActivityNode parentNode = nodes.get(node.getParentLocation());
            parentNode.add(node);
        }
    }

    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    return treeModel;
}