List of usage examples for javax.swing.tree DefaultMutableTreeNode removeAllChildren
public void removeAllChildren()
From source file:de.erdesignerng.visual.common.OutlineComponent.java
private void updateDomainTreeNode(Model aModel, Domain aDomain, DefaultMutableTreeNode aDomainNode) { aDomainNode.removeAllChildren(); }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
private void updateCustomTypeTreeNode(Model aModel, CustomType aCustomType, DefaultMutableTreeNode aCustomTypeNode) { aCustomTypeNode.removeAllChildren(); //display only details of ENUMERATION and COMPOSITE CustomTypes if ((aCustomType.getType() == CustomTypeType.ENUMERATION) || (aCustomType.getType() == CustomTypeType.COMPOSITE)) { aCustomType.getAttributes().stream().filter(theAttribute -> isVisible(theAttribute)) .forEach(theAttribute -> { DefaultMutableTreeNode theAttributeNode = new DefaultMutableTreeNode(theAttribute); aCustomTypeNode.add(theAttributeNode); registerUserObject(theAttribute, theAttributeNode); });/*from w w w . ja va 2 s. co m*/ } else { //TODO: handle EXTERNAL CustomTypes here } }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
private void updateTableTreeNode(Model aModel, Table aTable, DefaultMutableTreeNode aTableNode) { aTableNode.removeAllChildren(); aTable.getAttributes().stream().filter(theAttribute -> isVisible(theAttribute)).forEach(theAttribute -> { DefaultMutableTreeNode theAttributeNode = new DefaultMutableTreeNode(theAttribute); aTableNode.add(theAttributeNode); registerUserObject(theAttribute, theAttributeNode); });/*from w ww. j a v a2 s.c o m*/ aTable.getIndexes().stream().filter(theIndex -> isVisible(theIndex)).forEach(theIndex -> { createIndexTreeNode(aTableNode, theIndex); }); aModel.getRelations().getForeignKeysFor(aTable).stream().filter(theRelation -> isVisible(theRelation)) .forEach(theRelation -> { createRelationTreeNode(aTableNode, theRelation); }); Set<Table> theAlreadyKnown = new HashSet<>(); aModel.getRelations().getExportedKeysFor(aTable).stream().filter( theRelation -> isVisible(theRelation) && !theAlreadyKnown.contains(theRelation.getImportingTable())) .forEach(theRelation -> { UsedBy theUsedBy = new UsedBy(); theUsedBy.ref = theRelation.getImportingTable(); DefaultMutableTreeNode theUsedByNode = new DefaultMutableTreeNode(theUsedBy); aTableNode.add(theUsedByNode); theAlreadyKnown.add(theRelation.getImportingTable()); }); }
From source file:fr.jmmc.jmcs.logging.LogbackGui.java
/** * Generate the tree from the current edited list of Loggers *//*from w ww . j av a 2 s . co m*/ private void generateTree() { visitJulLoggers(); final GenericJTree<Logger> treeLoggers = getTreeLoggers(); final LoggerContext loggerContext = _rootLogger.getLoggerContext(); final DefaultMutableTreeNode rootNode = treeLoggers.getRootNode(); // remove complete hierarchy: rootNode.removeAllChildren(); // update the root node with the root logger (Logger[ROOT]): rootNode.setUserObject(_rootLogger); int pos; String path; DefaultMutableTreeNode parentNode; for (Logger logger : loggerContext.getLoggerList()) { // skip root logger if (logger != _rootLogger) { pos = logger.getName().lastIndexOf('.'); if (pos == -1) { // no path path = null; parentNode = null; } else { path = logger.getName().substring(0, pos); parentNode = treeLoggers.findTreeNode(loggerContext.getLogger(path)); } if (parentNode == null) { parentNode = rootNode; } if (parentNode != null) { treeLoggers.addNode(parentNode, logger); } } } // fire node structure changed : treeLoggers.fireNodeChanged(rootNode); // select root node treeLoggers.selectPath(new TreePath(rootNode.getPath())); }
From source file:dataviewer.DataViewer.java
private void fill_tree() { txt_count.setText(""); DefaultTreeModel tm = (DefaultTreeModel) tr_files.getModel(); DefaultMutableTreeNode top; cur_path = new File(cur_path).getAbsolutePath(); if (cur_path.charAt(cur_path.length() - 1) == '.') { cur_path = cur_path.substring(0, cur_path.length() - 1); }/*from www.j a v a 2 s .co m*/ if (cur_path.charAt(cur_path.length() - 1) == File.separatorChar) { cur_path = cur_path.substring(0, cur_path.length() - 1); } if (tm != null) { top = (DefaultMutableTreeNode) tm.getRoot(); top.removeAllChildren(); top.setUserObject(cur_path); } else { top = new DefaultMutableTreeNode(cur_path); } // get all children nodes and remove them // rename the user object ArrayList<String> files = this.getAllFileNames(cur_path); Collections.sort(files); int j = 1; int selected_index = -1; for (String f : files) { String ex = this.getExtension(f); boolean is_folder = (new File(cur_path + File.separator + f)).isDirectory(); if (is_folder || ex.equals(".txt") || ex.equals(".dat") || ex.equals(".csv") || ex.equals(".tsv")) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(f); top.add(node); if (f.equals(selected_file)) { selected_index = j; } j++; } } //DefaultTreeModel treeModel = new DefaultTreeModel(top); //tr_files.setModel(treeModel); if (tm == null) { tr_files.setModel(new DefaultTreeModel(top)); } else { try { tm.reload(); } catch (Exception e) { tm.reload(); } } if (selected_index > -1) { tr_files.setSelectionRow(selected_index); } tr_files.grabFocus(); }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
@Override public void treeExpanded(TreeExpansionEvent event) { if (treeInProgress) return;//w w w .j a va 2s .co m setBusy(true); DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); DefaultMutableTreeNode firstChild = (DefaultMutableTreeNode) node.getFirstChild(); TreePath selectionPath = tree.getSelectionPath(); if (MUST_LOAD_CHILDREN.equals(firstChild.getUserObject())) { node.removeAllChildren(); DocPath expandPath = new DocPath(); for (Object obj : node.getUserObjectPath()) { try { expandPath.add((DocNodeBase) obj); } catch (ClassCastException ex) { expandPath.add(new DocNodeLiteral(obj.toString())); } } List<DocNodeBase> childList; try { childList = DelegateFactory.getInstance().getJCRDocDelegate() .getDocNodeChildrenFromNode(expandPath); setDocNodesOnTree(node, childList, expandPath); } catch (Throwable e) { treeModel.insertNodeInto(new DefaultMutableTreeNode(e), node, 0); } tree.expandPath(new TreePath(node.getPath())); tree.setSelectionPath(selectionPath); } setBusy(false); }
From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java
private void rebuild(ServiceContainer container) { DefaultMutableTreeNode serviceNode = null; for (int i = 0; i < root.getChildCount(); i++) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i); ServiceContainer thisContainer = (ServiceContainer) node.getUserObject(); if (container == thisContainer) { serviceNode = node;//from w w w .jav a2s .c o m break; } } if (serviceNode == null) { throw new RuntimeException("Cannot find container in tree"); } Category rootCategory = container.getRootCategory(); if (rootCategory == null) { throw new NullPointerException(); } serviceNode.removeAllChildren(); buildCategory(serviceNode, rootCategory); model.nodeStructureChanged(serviceNode); }
From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java
public boolean alterParameterTree(final IIntelliContext ctx) { // create initial population final DefaultMutableTreeNode root = ctx.getParameterTreeRootNode(); final DefaultMutableTreeNode newRoot = getAlteredParameterTreeRootNode(ctx); root.removeAllChildren(); final int count = newRoot.getChildCount(); for (int i = 0; i < count; ++i) root.add((DefaultMutableTreeNode) newRoot.getChildAt(0)); return true;/* w ww. j a va 2 s .c o m*/ }
From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java
public boolean alterParameterTree(final IIntelliContext ctx) { // create initial population final DefaultMutableTreeNode root = ctx.getParameterTreeRootNode(); final DefaultMutableTreeNode newRoot = getAlteredParameterTreeRootNode(ctx); if (root != null) { root.removeAllChildren(); final int count = newRoot.getChildCount(); for (int i = 0; i < count; ++i) root.add((DefaultMutableTreeNode) newRoot.getChildAt(0)); }/*from w w w. j a v a 2 s . c o m*/ return true; }
From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java
public void addSubmodelParameter(final SubmodelInfo sInfo, final DefaultMutableTreeNode node) throws ModelInformationException { if (sInfo.getActualType() == null) { if (node.getChildCount() > 0) { node.removeAllChildren(); chromosomeTree.nodeStructureChanged(node); }/*from www.j av a 2 s . c o m*/ return; } final List<ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?>> subparameters = ParameterTreeUtils .fetchSubparameters(currentModelHandler, sInfo); final List<ParameterInfo> convertedSubparameters = new ArrayList<ParameterInfo>(subparameters.size()); for (ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> parameterInfo : subparameters) { final ParameterInfo converted = InfoConverter.parameterInfo2ParameterInfo(parameterInfo); converted.setRuns(0); convertedSubparameters.add(converted); } Collections.sort(convertedSubparameters); if (node.getChildCount() > 0) { node.removeAllChildren(); chromosomeTree.nodeStructureChanged(node); } for (final ParameterInfo pInfo : convertedSubparameters) { final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(new ParameterOrGene(pInfo)); chromosomeTree.insertNodeInto(newNode, node, node.getChildCount()); if (pInfo instanceof SubmodelInfo) { final SubmodelInfo ssInfo = (SubmodelInfo) pInfo; if (ssInfo.getActualType() != null) addSubmodelParameter(ssInfo, newNode); } } }