List of usage examples for javax.swing.tree DefaultMutableTreeNode breadthFirstEnumeration
public Enumeration<TreeNode> breadthFirstEnumeration()
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private String checkInfos(final boolean submodel) { final DefaultListModel listModel = (DefaultListModel) parameterList.getModel(); for (int i = 0; i < listModel.getSize(); ++i) { final AvailableParameter param = (AvailableParameter) listModel.get(i); final String invalid = submodel ? checkSubmodelInfo(param.info) : checkFileInfo(param); if (invalid != null) return invalid; }//from ww w .jav a 2 s. co m for (final ParameterCombinationGUI pGUI : parameterTreeBranches) { final DefaultMutableTreeNode root = pGUI.combinationRoot; @SuppressWarnings("rawtypes") final Enumeration nodes = root.breadthFirstEnumeration(); nodes.nextElement(); // root while (nodes.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement(); final ParameterInATree userObj = (ParameterInATree) node.getUserObject(); final String invalid = submodel ? checkSubmodelInfo(userObj.info) : checkFileInfo(userObj); if (invalid != null) return invalid; } } return null; }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private String checkInfosInGeneTree() { final DefaultTreeModel treeModel = gaSearchHandler.getChromosomeTree(); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot(); @SuppressWarnings("rawtypes") final Enumeration nodes = root.breadthFirstEnumeration(); nodes.nextElement(); // root while (nodes.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement(); final ParameterOrGene userObj = (ParameterOrGene) node.getUserObject(); final String invalid = checkSubmodelInfo(userObj.getInfo()); if (invalid != null) return invalid; }/*from w w w . ja v a 2s.c o m*/ return null; }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private DefaultMutableTreeNode convertInfoValueTreeToInfoComponentTree(DefaultMutableTreeNode infoValueTree) throws ModelInformationException { @SuppressWarnings("rawtypes") final Enumeration nodes = infoValueTree.breadthFirstEnumeration(); nodes.nextElement(); // root while (nodes.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement(); if (node.getUserObject() != null) { @SuppressWarnings("unchecked") final Pair<ParameterInfo, String> userObj = (Pair<ParameterInfo, String>) node.getUserObject(); final JComponent component = convertStringToComponent(userObj.getKey(), userObj.getValue()); final Pair<ParameterInfo, JComponent> newUserObj = new Pair<ParameterInfo, JComponent>( userObj.getKey(), component); node.setUserObject(newUserObj); }/*from w w w. jav a 2 s .c o m*/ } return infoValueTree; }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private ParameterTree createParameterTreeFromParamSweepGUI() throws ModelInformationException { final ParameterTree result = new ParameterTree(); final DefaultListModel listModel = (DefaultListModel) parameterList.getModel(); for (int i = 0; i < listModel.getSize(); ++i) { final AvailableParameter param = (AvailableParameter) listModel.get(i); final AbstractParameterInfo<?> batchParameter = InfoConverter.parameterInfo2ParameterInfo(param.info); ParameterTreeUtils.addConstantParameterToParameterTree(batchParameter, result, currentModelHandler); }//from www . j a va 2 s . com for (final ParameterCombinationGUI pGUI : parameterTreeBranches) { final DefaultMutableTreeNode root = pGUI.combinationRoot; @SuppressWarnings("rawtypes") final Enumeration nodes = root.breadthFirstEnumeration(); nodes.nextElement(); // root; while (nodes.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement(); final ParameterInATree userObj = (ParameterInATree) node.getUserObject(); ParameterTreeUtils.filterConstants(userObj, result, currentModelHandler); } } for (final ParameterCombinationGUI pGUI : parameterTreeBranches) { final DefaultMutableTreeNode root = pGUI.combinationRoot; @SuppressWarnings("rawtypes") final Enumeration nodes = root.preorderEnumeration(); nodes.nextElement(); // root ParameterNode parent = result.getRoot(); while (nodes.hasMoreElements()) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement(); final ParameterInATree userObj = (ParameterInATree) node.getUserObject(); if (ParameterTreeUtils.isMutableParameter(userObj)) { final AbstractParameterInfo<?> batchParameter = InfoConverter .parameterInfo2ParameterInfo(userObj.info); batchParameter.setRunNumber(1); final ParameterNode parameterNode = new ParameterNode(batchParameter); parent.add(parameterNode); parent = parameterNode; } } } return result; }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Expand all the nodes in the tree representation of the model * /*from www. ja va 2 s. c om*/ * @return The final status to display */ private String expandAll() { int numNodes; ProgressMonitor progress; boolean canceled; final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ontModelTree.getModel().getRoot(); @SuppressWarnings("rawtypes") final Enumeration enumerateNodes = root.breadthFirstEnumeration(); numNodes = 0; while (enumerateNodes.hasMoreElements()) { enumerateNodes.nextElement(); ++numNodes; } LOGGER.debug("Expanding tree with row count: " + numNodes); progress = new ProgressMonitor(this, "Expanding Tree Nodes", "Starting node expansion", 0, numNodes); setStatus("Expanding all tree nodes"); for (int row = 0; !progress.isCanceled() && row < numNodes; ++row) { progress.setProgress(row); if (row % 1000 == 0) { progress.setNote("Row " + row + " of " + numNodes); } ontModelTree.expandRow(row); } canceled = progress.isCanceled(); progress.close(); ontModelTree.scrollRowToVisible(0); if (!canceled) { // Select the tree view tab SwingUtilities.invokeLater(new Runnable() { public void run() { tabbedPane.setSelectedIndex(TAB_NUMBER_TREE_VIEW); } }); } return canceled ? "Tree node expansion canceled by user" : "Tree nodes expanded"; }
From source file:org.sakaiproject.scorm.ui.player.components.ActivityTree.java
public TreeNode selectNode(String activityId) { if (activityId == null) return null; Model model = (Model) this.getModel(); DefaultTreeModel treeModel = (DefaultTreeModel) model.getObject(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot(); for (Enumeration<DefaultMutableTreeNode> e = root.breadthFirstEnumeration(); e.hasMoreElements();) { DefaultMutableTreeNode node = e.nextElement(); SeqActivity activity = (SeqActivity) node.getUserObject(); if (log.isDebugEnabled()) { log.debug("Activity: " + activity.getID()); log.debug("Title: " + activity.getTitle()); log.debug("Is Constrain Choice: " + activity.getConstrainChoice()); log.debug("Is Control Forward Only: " + activity.getControlForwardOnly()); log.debug("Is Control Mode Choice: " + activity.getControlModeChoice()); log.debug("Is Control Mode Choice Exit: " + activity.getControlModeChoiceExit()); log.debug("Is Control Mode Flow: " + activity.getControlModeFlow()); }/*from ww w . ja v a 2 s . c o m*/ String id = activity == null ? null : activity.getID(); if (id != null && id.equals(activityId)) { if (!getTreeState().isNodeSelected(node)) getTreeState().selectNode(node, true); return node; } } return null; }