List of usage examples for javax.swing.tree DefaultMutableTreeNode add
public void add(MutableTreeNode newChild)
newChild
from its parent and makes it a child of this node by adding it to the end of this node's child array. From source file:wsattacker.plugin.intelligentdos.ui.dialog.Result_NB.java
private TreeModel createModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); Set<String> dosAttackNameSet = new HashSet<String>(); Set<Position> elementSet = new HashSet<Position>(); for (SuccessfulAttack sa : attacks) { dosAttackNameSet.add(sa.getDoSAttack().getName()); elementSet.add(sa.getPosition()); }//ww w. jav a 2 s .co m for (String dosAttackName : dosAttackNameSet) { DefaultMutableTreeNode dn = new DefaultMutableTreeNode(dosAttackName); root.add(dn); // for (Position position : elementSet) { DefaultMutableTreeNode el = new DefaultMutableTreeNode(position); boolean some = false; for (SuccessfulAttack sa : attacks) { if (sa.getDoSAttack().getName().equals(dosAttackName) && sa.getPosition().equals(position)) { DefaultMutableTreeNode attackNode = new DefaultMutableTreeNode(sa); el.add(attackNode); some = true; } } if (some) { dn.add(el); } } } return new DefaultTreeModel(root); }
From source file:de.rub.syssec.saaf.gui.editor.FileTree.java
/** Add nodes from under "dir" into curTop. Highly recursive. */ DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) { // String curPath = dir.getPath(); String curPath = dir.getName(); DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(curPath); if (curTop != null) { // should only be null at root curTop.add(curDir); }// w w w . j a v a 2 s.c om // ignore some files IOFileFilter fileFilter = new NotFileFilter( new SuffixFileFilter(new String[] { ".class", ".java", ".DS_Store", ".yml" })); LinkedList<File> files = new LinkedList<File>(FileUtils.listFiles(dir, fileFilter, null)); // FIXME: How the hell can directories be listed?! // LinkedList<File> directories = new // LinkedList<File>(FileUtils.listFiles(dir, FalseFileFilter.INSTANCE, // DirectoryFileFilter.INSTANCE)); LinkedList<File> directories = new LinkedList<File>( Arrays.asList(dir.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY))); Collections.sort(files); Collections.sort(directories); // Recursively add directories for (File directory : directories) { addNodes(curDir, directory); } // Add files for (File file : files) { if (file.getAbsolutePath().endsWith(".png") && file.getAbsolutePath().contains("/bytecode/smali")) { /* * Skipping generated PNG CFGs in bytecode folder. Other PNG * files will be shown in the tree, eg, /res/drawable-hdpi This * might not be necessary b/c no PNGs are currently not created * at startup. */ continue; } curDir.add(new DefaultMutableTreeNode(new FileNode(file.getName(), file))); } return curDir; }
From source file:edu.ucla.stat.SOCR.chart.ChartTree.java
private MutableTreeNode createLegendNode() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("Legends"); DefaultMutableTreeNode n1 = new DefaultMutableTreeNode( new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LegendWrapperDemo1", "LegendWrapperDemo1")); root.add(n1); return root;//ww w .java 2s. c om }
From source file:be.fedict.eid.tsl.tool.TslInternalFrame.java
private void addServiceProviderTab(JTabbedPane tabbedPane) { JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); tabbedPane.add("Service Providers", splitPane); DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Service Providers"); this.tree = new JTree(rootNode); this.tree.addTreeSelectionListener(this); for (TrustServiceProvider trustServiceProvider : this.trustServiceList.getTrustServiceProviders()) { DefaultMutableTreeNode trustServiceProviderNode = new DefaultMutableTreeNode( trustServiceProvider.getName()); rootNode.add(trustServiceProviderNode); for (TrustService trustService : trustServiceProvider.getTrustServices()) { MutableTreeNode trustServiceNode = new DefaultMutableTreeNode(trustService); trustServiceProviderNode.add(trustServiceNode); }//from w ww. j a v a 2 s . com } this.tree.expandRow(0); JScrollPane treeScrollPane = new JScrollPane(this.tree); JPanel detailsPanel = new JPanel(); splitPane.setLeftComponent(treeScrollPane); splitPane.setRightComponent(detailsPanel); initDetailsPanel(detailsPanel); }
From source file:it.unibas.spicygui.controllo.window.operator.ProjectTreeGenerator.java
private void createInstacesNode(IDataSourceProxy source, DefaultMutableTreeNode nodeChildFirst) { List<String> sourceInstancesName = (List<String>) source .getAnnotation(SpicyEngineConstants.XML_INSTANCE_FILE_LIST); if (sourceInstancesName != null) { int i = 0; for (String stringa : sourceInstancesName) { String title = findTitle(stringa); TreeTopComponentAdapter ttca = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild = new DefaultMutableTreeNode(ttca); ttca.setName(title);/* ww w.j a v a 2 s . com*/ nodeChildFirst.add(nodeChild); } } else { int i = 1; for (INode instanceNode : source.getOriginalInstances()) { TreeTopComponentAdapter ttca = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild = new DefaultMutableTreeNode(ttca); ttca.setName("Instance: " + i++); nodeChildFirst.add(nodeChild); } } }
From source file:it.unibas.spicygui.controllo.window.operator.ProjectTreeGenerator.java
private void createMappingTaskChild(DefaultMutableTreeNode nodeTopComponent, IDataSourceProxy datasource, String type) {/*from ww w. jav a 2s. co m*/ if (datasource.getType().equalsIgnoreCase(SpicyEngineConstants.TYPE_RELATIONAL)) { AccessConfiguration accessConfiguration = (AccessConfiguration) datasource .getAnnotation(SpicyEngineConstants.ACCESS_CONFIGURATION); TreeTopComponentAdapter ttca0 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild0 = new DefaultMutableTreeNode(ttca0); ttca0.setName(type); nodeTopComponent.add(nodeChild0); TreeTopComponentAdapter ttca1 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild1 = new DefaultMutableTreeNode(ttca1); ttca1.setName("driver: " + accessConfiguration.getDriver()); nodeChild0.add(nodeChild1); TreeTopComponentAdapter ttca2 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild2 = new DefaultMutableTreeNode(ttca2); ttca2.setName("uri: " + accessConfiguration.getUri()); nodeChild0.add(nodeChild2); TreeTopComponentAdapter ttca3 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild3 = new DefaultMutableTreeNode(ttca3); ttca3.setName("login: " + accessConfiguration.getLogin()); nodeChild0.add(nodeChild3); TreeTopComponentAdapter ttca4 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild4 = new DefaultMutableTreeNode(ttca4); ttca4.setName("password: " + accessConfiguration.getPassword()); nodeChild0.add(nodeChild4); } else if (datasource.getType().equalsIgnoreCase(SpicyEngineConstants.TYPE_XML)) { TreeTopComponentAdapter ttca1 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild = new DefaultMutableTreeNode(ttca1); String absolutePathSource = (String) datasource.getAnnotation(SpicyEngineConstants.XML_SCHEMA_FILE); ttca1.setName(type + " : " + absolutePathSource.substring(absolutePathSource.lastIndexOf("\\") + 1)); nodeTopComponent.add(nodeChild); } else if (datasource.getType().equalsIgnoreCase(SpicyEngineConstants.TYPE_OBJECT)) { TreeTopComponentAdapter ttca0 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild0 = new DefaultMutableTreeNode(ttca0); ttca0.setName(type); nodeTopComponent.add(nodeChild0); String classPathFolder = (String) datasource.getAnnotation(SpicyEngineConstants.CLASSPATH_FOLDER); TreeTopComponentAdapter ttca1 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild1 = new DefaultMutableTreeNode(ttca1); ttca1.setName("classPathFolder: " + classPathFolder); nodeChild0.add(nodeChild1); String objectModelFactoryName = (String) datasource .getAnnotation(SpicyEngineConstants.OBJECT_MODEL_FACTORY); TreeTopComponentAdapter ttca2 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild2 = new DefaultMutableTreeNode(ttca2); ttca2.setName("objectModelFactory: " + objectModelFactoryName); nodeChild0.add(nodeChild2); } else if (datasource.getType().equalsIgnoreCase(SpicyEngineConstants.TYPE_MOCK)) { TreeTopComponentAdapter ttca0 = new TreeTopComponentAdapter(null, false, false, true); DefaultMutableTreeNode nodeChild0 = new DefaultMutableTreeNode(ttca0); ttca0.setName(type + " : Mock"); nodeTopComponent.add(nodeChild0); } }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
private void createIndexTreeNode(DefaultMutableTreeNode aParentNode, Index aIndex) { DefaultMutableTreeNode theIndexNode = new DefaultMutableTreeNode(aIndex); aParentNode.add(theIndexNode); registerUserObject(aIndex, theIndexNode); aIndex.getExpressions().stream().filter(theExpression -> isVisible(theExpression)) .forEach(theExpression -> { DefaultMutableTreeNode theExpressionNode = new DefaultMutableTreeNode(theExpression); theIndexNode.add(theExpressionNode); registerUserObject(theExpression, theExpressionNode); });/*from w w w . ja v a 2 s . c o m*/ }
From source file:com.wwidesigner.gui.StudyView.java
protected void updateView() { // Reset the Constraints category as needed. study.updateConstraints();/* w w w.j a va2 s .c om*/ // Build the selection tree. DefaultMutableTreeNode root = new DefaultMutableTreeNode(); List<TreePath> selectionPaths = new ArrayList<TreePath>(); // Add all static categories and selection options to the tree. for (String category : study.getCategoryNames()) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(category); if (node != null) { node.setAllowsChildren(true); root.add(node); } String selectedSub = study.getSelectedSub(category); Map<String, String> toolTips = study.getCategory(category).getToolTips(); for (String name : study.getSubcategories(category)) { TreeNodeWithToolTips childNode = new TreeNodeWithToolTips(name); if (childNode != null) { node.add(childNode); if (name.equals(selectedSub)) { selectionPaths.add(new TreePath(childNode.getPath())); } String tip = toolTips.get(name); if (tip != null) { childNode.setToolTip(tip); } } } } TreeModel model = new DefaultTreeModel(root); tree.setModel(model); TreeUtils.expandAll(tree); tree.setSelectionPaths(selectionPaths.toArray(new TreePath[0])); setStudyViewName(); // Update on the appropriate thread SwingUtilities.invokeLater(new Runnable() { public void run() { updateActions(); } }); }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
private void createRelationTreeNode(DefaultMutableTreeNode aParent, Relation aRelation) { DefaultMutableTreeNode theRelationNode = new DefaultMutableTreeNode(aRelation); aParent.add(theRelationNode); registerUserObject(aRelation, theRelationNode); aRelation.getMapping().entrySet().stream().filter(theEntry -> isVisible(theEntry.getValue())) .forEach(theEntry -> {/*w w w .j a va 2 s .c o m*/ DefaultMutableTreeNode theAttributeNode = new DefaultMutableTreeNode(theEntry.getValue()); theRelationNode.add(theAttributeNode); registerUserObject(theEntry.getKey(), theAttributeNode); }); }
From source file:de.quadrillenschule.azocamsyncd.gui.ExploreWifiSDPanel.java
private void createSubNodes(DefaultMutableTreeNode parent, LinkedList<AZoFTPFile> afs) { String parentNodeName = parent.toString(); for (AZoFTPFile af : afs) { String nodeName = af.dir + af.ftpFile.getName(); if (af.ftpFile.isDirectory()) { if (!parentNodeName.equals(nodeName)) { if (nodeName.contains(parentNodeName)) { if (StringUtils.countMatches(nodeName, "/") - 1 == StringUtils.countMatches(parentNodeName, "/")) { DefaultMutableTreeNode tn = new DefaultMutableTreeNode(nodeName); parent.add(tn); createSubNodes(tn, afs); }//from ww w. j a va 2 s . co m } ; } } //isFile if (af.ftpFile.isFile()) { if (nodeName.contains(parentNodeName)) { if (StringUtils.countMatches(nodeName, "/") == 1 + StringUtils.countMatches(parentNodeName, "/")) { DefaultMutableTreeNode tn = new DefaultMutableTreeNode(nodeName); parent.add(tn); } } ; } } }