Java Code Examples for javax.swing.tree.DefaultMutableTreeNode#add()
The following examples show how to use
javax.swing.tree.DefaultMutableTreeNode#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Chunk_tEXt.java From freeinternals with Apache License 2.0 | 6 votes |
@Override protected void generateTreeNodeChunkData(DefaultMutableTreeNode parent) { int start = this.startPos + 4 + 4; parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, this.Keyword.length(), String.format("Keyword = %s", this.Keyword)))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start = start + this.Keyword.length(), 1, "Null separator"))); if (this.Text.length() > 0) { parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start + 1, this.Text.length(), String.format("Text = %s", this.Text)))); } }
Example 2
Source File: ColopediaGameObjectTypePanel.java From freecol with GNU General Public License v2.0 | 6 votes |
/** * Builds a subtree including all the given objects. * * @param root a {@code DefaultMutableTreeNode} * @param id The object identifier of the new branch node. * @param types a List of FreeColSpecObjectTypes */ protected void addSubTrees(DefaultMutableTreeNode root, String id, List<T> types) { final ImageLibrary lib = getImageLibrary(); String name = getName(); ColopediaTreeItem cti = new ColopediaTreeItem(this, id, name, null); DefaultMutableTreeNode node = new DefaultMutableTreeNode(cti); int width = ImageLibrary.ICON_SIZE.width; int height = ImageLibrary.ICON_SIZE.height; for (FreeColSpecObjectType type : types) { Image image = lib.getObjectImage(type, ImageLibrary.ICON_SIZE); int x = (width - image.getWidth(null)) / 2; int y = (height - image.getHeight(null)) / 2; BufferedImage centeredImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = centeredImage.createGraphics(); g.drawImage(image, x, y, null); g.dispose(); node.add(buildItem(type, new ImageIcon(centeredImage))); } root.add(node); }
Example 3
Source File: Chunk_hIST.java From freeinternals with Apache License 2.0 | 6 votes |
@Override protected void generateTreeNodeChunkData(DefaultMutableTreeNode parent) { int start = this.startPos + 4 + 4; if (this.Frequency == null) { return; } for (int i = 0; i < this.Frequency.length; i++) { parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, 2, String.format("Frequency [%d] = %d", i, this.Frequency[i])))); start += 2; } }
Example 4
Source File: SymbolizerTreeItemTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.ui.tree.item.SymbolizerTreeItem#itemSelected(javax.swing.tree.DefaultMutableTreeNode, * java.lang.Object)}. */ @Test public void testItemSelected() { SymbolizerTreeItem item = new SymbolizerTreeItem(); item.itemSelected(null, null); Symbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); Rule rule = DefaultSymbols.createNewRule(); DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode(); parentNode.setUserObject(rule); DefaultMutableTreeNode node = new DefaultMutableTreeNode(); parentNode.add(node); item.itemSelected(node, symbolizer); // Get the code coverage stats up item.itemSelected(parentNode, symbolizer); parentNode.setUserObject(item); item.itemSelected(node, null); }
Example 5
Source File: FeatureTypeTree.java From importer-exporter with Apache License 2.0 | 6 votes |
private List<DefaultMutableTreeNode> getADENodes() { List<DefaultMutableTreeNode> adeNodes = new ArrayList<>(); for (ADEExtension extension : adeManager.getExtensions()) { DefaultMutableTreeNode adeNode = new DefaultMutableTreeNode(extension.getMetadata().getName()); for (AppSchema schema : extension.getSchemas()) { for (FeatureType featureType : schema.listTopLevelFeatureTypes(true)) { DefaultMutableTreeNode child = new DefaultMutableTreeNode(featureType); adeNode.add(child); leafs.add(child); } } if (adeNode.getChildCount() > 0) adeNodes.add(adeNode); } return adeNodes; }
Example 6
Source File: MinificationPanel.java From minifierbeans with Apache License 2.0 | 6 votes |
MinificationPanel(MinificationOptionsPanelController controller) { this.controller = controller; initComponents(); DefaultMutableTreeNode defaultMutableTreeNode = new DefaultMutableTreeNode("Minification options"); defaultMutableTreeNode.add(new DefaultMutableTreeNode("JavaScript")); defaultMutableTreeNode.add(new DefaultMutableTreeNode("CSS")); defaultMutableTreeNode.add(new DefaultMutableTreeNode("HTML")); defaultMutableTreeNode.add(new DefaultMutableTreeNode("XML")); defaultMutableTreeNode.add(new DefaultMutableTreeNode("JSON")); defaultMutableTreeNode.add(new DefaultMutableTreeNode("Project")); final DefaultTreeModel defaultTreeModel = new DefaultTreeModel(defaultMutableTreeNode); optionsTree.setModel(defaultTreeModel); optionsTree.setRootVisible(false); //Where the tree is initialized: optionsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Listen for when the selection changes. optionsTree.addTreeSelectionListener(this); optionsTree.setSelectionRow(1); }
Example 7
Source File: ApplicationPanel.java From EchoSim with Apache License 2.0 | 5 votes |
private void doNewApplication() { if (mRuntime.getApp().getEndpoint() == null) mEndpoint.setText(""); else if (!mRuntime.getApp().getEndpoint().equals(mEndpoint.getText())) mEndpoint.setText(mRuntime.getApp().getEndpoint()); if (mRuntime.getApp().getApplicationID() == null) mApplicationID.setText(""); else if (!mRuntime.getApp().getApplicationID().equals(mApplicationID.getText())) mApplicationID.setText(mRuntime.getApp().getApplicationID()); if (mRuntime.getApp().getUserID() == null) mUserID.setText(""); else if (!mRuntime.getApp().getUserID().equals(mUserID.getText())) mUserID.setText(mRuntime.getApp().getUserID()); mRoot.removeAllChildren(); if (mRuntime.getApp().getSchema() != null) for (IntentBean intent : mRuntime.getApp().getSchema().getIntents()) { DefaultMutableTreeNode i = new DefaultMutableTreeNode(intent); mRoot.add(i); for (SlotBean slot : intent.getSlots()) { DefaultMutableTreeNode s = new DefaultMutableTreeNode(slot); i.add(s); } } DefaultTreeModel m = (DefaultTreeModel)mIntents.getModel(); m.reload(); mIntents.expandRow(0); List<String> data = new ArrayList<String>(); for (UtteranceBean u : mRuntime.getApp().getUtterances()) data.add(u.toString()); mUtterances.setListData(data.toArray(new String[0])); //mUtterances.setText("<html><body>"+UtteranceLogic.renderAsHTML(mRuntime.getApp().getUtterances())+"</body></html>"); }
Example 8
Source File: VimDasa.java From Astrosoft with GNU General Public License v2.0 | 5 votes |
public DefaultMutableTreeNode createTreeNode(){ DefaultMutableTreeNode node = new DefaultMutableTreeNode(this); if(subDasas == null){ return node; }else{ for(Dasa d : subDasas()){ node.add(d.createTreeNode()); } return node; } }
Example 9
Source File: AttributeBootstrapMethods.java From freeinternals with Apache License 2.0 | 5 votes |
@Override public void generateTreeNode(DefaultMutableTreeNode parentNode, final ClassFile classFile) { int startPosMoving = this.getStartPos(); parentNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPosMoving + 6, 2, "num_bootstrap_methods: " + this.num_bootstrap_methods.value ))); if (this.bootstrap_methods != null && this.bootstrap_methods.length > 0) { DefaultMutableTreeNode bootstrap_methods_node = new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPosMoving + 8, this.getLength() - 8, "bootstrap_methods")); parentNode.add(bootstrap_methods_node); for (int i = 0; i < this.bootstrap_methods.length; i++) { BootstrapMethod m = this.bootstrap_methods[i]; DefaultMutableTreeNode bootstrap_method = new DefaultMutableTreeNode(new JTreeNodeFileComponent( m.getStartPos(), m.getLength(), String.format("bootstrap_method %d", i + 1) )); bootstrap_methods_node.add(bootstrap_method); this.generateSubnode(bootstrap_method, m, classFile); } } }
Example 10
Source File: ConstantMethodrefInfo.java From freeinternals with Apache License 2.0 | 5 votes |
@Override public void generateTreeNode(DefaultMutableTreeNode parentNode, ClassFile classFile) { parentNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPos + 1, 2, "class_index: " + this.class_index.value + " - " + classFile.getCPDescription(this.class_index.value) ))); parentNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPos + 3, 2, "name_and_type_index: " + this.name_and_type_index.value + " - " + classFile.getCPDescription(this.name_and_type_index.value) ))); }
Example 11
Source File: PropertiesPanel.java From ontopia with Apache License 2.0 | 5 votes |
private void addSubjectIdentifiersTreeNodeTo(DefaultMutableTreeNode parent) { Iterator subjInds = target.getSubjectIdentifiers().iterator(); if (subjInds.hasNext()) { DefaultMutableTreeNode root = new DefaultMutableTreeNode(Messages .getString("Viz.PropertiesSubjectIndicators")); while (subjInds.hasNext()) { root.add(new DynamicUtilTreeNode(((LocatorIF) subjInds.next()) .getAddress(), null)); } parent.add(root); } }
Example 12
Source File: TreeNodeGenerator.java From freeinternals with Apache License 2.0 | 5 votes |
private void generateStringIds() { if (this.dexFile.string_ids == null || this.dexFile.string_ids.length < 1) { return; } int startPos = this.dexFile.header.string_ids_off.intValue(); int size = this.dexFile.string_ids.length; DefaultMutableTreeNode node = new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPos, size * Dex_uint.LENGTH, "string_ids")); this.rootNode.add(node); for (int i = 0; i < size; i++) { StringIdItem item = this.dexFile.string_ids[i]; DefaultMutableTreeNode itemNode = new DefaultMutableTreeNode(new JTreeNodeFileComponent( item.getStartPos(), item.getLength(), "string_id_item[" + String.format("%,d", i) + "].string_data_off: " + item.string_data_off.toString())); node.add(itemNode); FileComponent fc = this.dexFile.data.get(item.string_data_off.value); if (fc instanceof StringDataItem) { this.generateData(itemNode, (StringDataItem) fc); } else { itemNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( 0, 0, "ERROR: No String Item Found"))); } } }
Example 13
Source File: CustomTreeTable.java From azure-devops-intellij with MIT License | 5 votes |
private static <T> void addChildren(final DefaultMutableTreeNode parentNode, final ContentProvider<T> contentProvider) { //noinspection unchecked final Collection<? extends T> children = contentProvider.getChildren((T) parentNode.getUserObject()); for (final T child : children) { final DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child); parentNode.add(childNode); addChildren(childNode, contentProvider); } }
Example 14
Source File: ScriptTreeTransferHandler.java From zap-extensions with Apache License 2.0 | 5 votes |
@Override protected Transferable createTransferable(JComponent c) { JTree tree = (JTree) c; TreePath[] paths = tree.getSelectionPaths(); if (paths != null) { // Make up a node array of copies for transfer and // another for/of the nodes that will be removed in // exportDone after a successful drop. List<DefaultMutableTreeNode> copies = new ArrayList<DefaultMutableTreeNode>(); List<DefaultMutableTreeNode> toRemove = new ArrayList<DefaultMutableTreeNode>(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[0].getLastPathComponent(); DefaultMutableTreeNode copy = copy(node); copies.add(copy); toRemove.add(node); for (int i = 1; i < paths.length; i++) { DefaultMutableTreeNode next = (DefaultMutableTreeNode) paths[i].getLastPathComponent(); // Do not allow higher level nodes to be added to list. if (next.getLevel() < node.getLevel()) { break; } else if (next.getLevel() > node.getLevel()) { // child node copy.add(copy(next)); // node already contains child } else { // sibling copies.add(copy(next)); toRemove.add(next); } } DefaultMutableTreeNode[] nodes = copies.toArray(new DefaultMutableTreeNode[copies.size()]); nodesToRemove = toRemove.toArray(new DefaultMutableTreeNode[toRemove.size()]); return new NodesTransferable(nodes); } return null; }
Example 15
Source File: TreeManager.java From cst with GNU Lesser General Public License v3.0 | 5 votes |
private static DefaultMutableTreeNode addProperty(Property p) { DefaultMutableTreeNode propertyNode = new DefaultMutableTreeNode(new TreeElement(p.getName(), TreeElement.NODE_NORMAL, p, TreeElement.ICON_PROPERTY)); int size = ((Property) p).getQualityDimensions().size(); for (int s = 0; s < size; s++) { String chave = ((Property) p).getQualityDimensions().get(s).getName(); String value = (((Property) p).getQualityDimensions().get(s).getValue()).toString(); DefaultMutableTreeNode qualityDimensionNode = new DefaultMutableTreeNode(new TreeElement(chave + " : " + value, TreeElement.NODE_NORMAL, chave + " : " + value, TreeElement.ICON_QUALITYDIM)); propertyNode.add(qualityDimensionNode); } return (propertyNode); }
Example 16
Source File: AttributeModule.java From freeinternals with Apache License 2.0 | 4 votes |
private void generateSubnode(final DefaultMutableTreeNode rootNode, final AttributeModule.Exports export, final ClassFile classFile) { int startPosMoving = export.getStartPos(); rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPosMoving, u2.LENGTH, "exports_index: " + export.exports_index.value + " - " + classFile.getCPDescription(export.exports_index.value) ))); startPosMoving += u2.LENGTH; rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPosMoving, u2.LENGTH, "exports_flags: " + export.exports_flags.value + " " + export.getExportFlags() ))); startPosMoving += u2.LENGTH; rootNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPosMoving, u2.LENGTH, "exports_to_count: " + export.exports_to_count.value ))); startPosMoving += u2.LENGTH; if (export.exports_to_count.value > 0) { final DefaultMutableTreeNode exportsToIndexNode = new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPosMoving, u2.LENGTH * export.exports_to_count.value, "exports_to_index[" + export.exports_to_count.value + "]" )); rootNode.add(exportsToIndexNode); for (int i = 0; i < export.exports_to_index.length; i++) { exportsToIndexNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( startPosMoving + i * u2.LENGTH, u2.LENGTH, "exports_to_index[" + i + "]: " + export.exports_to_index[i].value + " - " + classFile.getCPDescription(export.exports_to_index[i].value) ))); } } }
Example 17
Source File: ClassExplorerDialog.java From jar-explorer with Apache License 2.0 | 4 votes |
/** * COnstructs an instance * * @param owner - top level frame * @param classInformation - instance */ public ClassExplorerDialog(Frame owner, ClassInformation classInformation) { super(owner, classInformation.getJarFileName() + ":" + classInformation.getClassPath(), false); getContentPane().setLayout(new BorderLayout()); //build center panel - tree DefaultMutableTreeNode classNode; DefaultMutableTreeNode constructorsNode; DefaultMutableTreeNode interfacesNode; DefaultMutableTreeNode fieldsNode; DefaultMutableTreeNode methodsNode; DefaultMutableTreeNode modifiersNode; DefaultMutableTreeNode root = new DefaultMutableTreeNode("<html><font color='blue'>Class:</font>" + classInformation.getClassName() + "</html>"); root.add(classNode = new DefaultMutableTreeNode("<html><font color='blue'>General Class Information</font></html>")); root.add(interfacesNode = new DefaultMutableTreeNode("<html><font color='blue'>Implemented Interfaces</font></html>")); root.add(constructorsNode = new DefaultMutableTreeNode("<html><font color='blue'>Constructors</font></html>")); root.add(fieldsNode = new DefaultMutableTreeNode("<html><font color='blue'>Fields</font></html>")); root.add(methodsNode = new DefaultMutableTreeNode("<html><font color='blue'>Methods</font></html>")); JTree tree = new JTree(); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)tree.getCellRenderer(); renderer.setFont(new Font("Monospaced", Font.PLAIN, 14)); classNode.add(new DefaultMutableTreeNode("<html><font color='blue'>Jar File: </font>" + classInformation.getJarFileName() + "</html>")); classNode.add(new DefaultMutableTreeNode("<html><font color='blue'>Superclass: </font>" + classInformation.getSuperclass() + "</html>")); classNode.add(modifiersNode = new DefaultMutableTreeNode("<html><font color='blue'>Modifiers:</font>" + classInformation.getModifiers() + "</html>")); ((DefaultTreeModel)tree.getModel()).setRoot(root); //interfaces String[] interfacesArray = classInformation.getInterfaces(); for (int i = 0; i < interfacesArray.length; i++) { String interfaceName = interfacesArray[i]; interfacesNode.add(new DefaultMutableTreeNode(interfaceName)); } //constructors ArrayList constructorList = classInformation.getConstructors(); for (int i = 0; i < constructorList.size(); i++) { String constructor = (String) constructorList.get(i); constructorsNode.add(new DefaultMutableTreeNode(constructor)); } //methods ArrayList methodsList = classInformation.getMethods(); for (int i = 0; i < methodsList.size(); i++) { String method = (String) methodsList.get(i); methodsNode.add(new DefaultMutableTreeNode(method)); } //fields String[] fieldsList = classInformation.getFields(); for (int i = 0; i < fieldsList.length; i++) { String field = fieldsList[i]; fieldsNode.add(new DefaultMutableTreeNode(field)); } //build south panel JPanel southPanel = new JPanel(); JButton closeB = new JButton("Close"); southPanel.add(closeB); closeB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); //build mail panel getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER); getContentPane().add(southPanel, BorderLayout.SOUTH); }
Example 18
Source File: JarDataReader.java From Hook-Manager with Mozilla Public License 2.0 | 4 votes |
public JarData read(File file) throws IOException { DefaultMutableTreeNode root = new DefaultMutableTreeNode(file.getName()); JarData jarData = new JarData(); JarInputStream input = new JarInputStream(new FileInputStream(file)); for(JarEntry entry; (entry = input.getNextJarEntry()) != null;) if(entry.isDirectory()) root.add(new DefaultMutableTreeNode(entry.getName() .substring(0, entry.getName().length() - 1) .replace("/", "."), true)); else if(entry.getName().endsWith(".class")) { ClassReader reader = new ClassReader(input); ClassDataReader wReader = new ClassDataReader(Opcodes.ASM4, jarData); reader.accept(wReader, 0); if(entry.getName().contains("/")) getNode( root, entry.getName() .substring(0, entry.getName().lastIndexOf("/")) .replace("/", ".")).add( new DefaultMutableTreeNode(entry.getName().substring( entry.getName().lastIndexOf("/") + 1), false)); else root.add(new DefaultMutableTreeNode(entry.getName(), false)); }else if(entry.getName().contains("/")) getNode( root, entry.getName() .substring(0, entry.getName().lastIndexOf("/")) .replace("/", ".")).add( new DefaultMutableTreeNode(entry.getName().substring( entry.getName().lastIndexOf("/") + 1), false)); else root.add(new DefaultMutableTreeNode(entry, false)); input.close(); getNode(root, "META-INF").add( new DefaultMutableTreeNode("MANIFEST.MF", false)); sortNode(root); tree.setModel(new DefaultTreeModel(root)); return jarData; }
Example 19
Source File: Chunk_sBIT.java From freeinternals with Apache License 2.0 | 4 votes |
@Override protected void generateTreeNodeChunkData(DefaultMutableTreeNode parent) { int start = this.startPos + 4 + 4; switch (this.ChunkData.length) { case 1: parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, 1, String.format("significant = %d", this.ChunkData[0])))); break; case 2: parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, 1, String.format("significant source grayscale data = %d", this.ChunkData[0])))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start + 1, 1, String.format("significant source alpha data = %d", this.ChunkData[1])))); break; case 3: parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, 1, String.format("significant red = %d", this.ChunkData[0])))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start + 1, 1, String.format("significant green = %d", this.ChunkData[1])))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start + 2, 1, String.format("significant blue = %d", this.ChunkData[2])))); break; case 4: parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, 1, String.format("significant red = %d", this.ChunkData[0])))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start + 1, 1, String.format("significant green = %d", this.ChunkData[1])))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start + 2, 1, String.format("significant blue = %d", this.ChunkData[2])))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start + 3, 1, String.format("significant alpha = %d", this.ChunkData[3])))); break; default: parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, this.ChunkData.length, "Un-recognized"))); } }
Example 20
Source File: Chunk_iTXt.java From freeinternals with Apache License 2.0 | 4 votes |
@Override protected void generateTreeNodeChunkData(DefaultMutableTreeNode parent) { int start = this.startPos + 4 + 4; parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, this.Keyword.length(), String.format("Keyword = %s", this.Keyword)))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start += this.Keyword.length(), 1, "Null separator"))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start += 1, 1, String.format("Compression flag = %d", this.CompressionFlag)))); parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start += 1, 1, String.format("Compression method = %d", this.CompressionMethod)))); if (this.LanguageTag.length() > 0) { parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start += 1, this.LanguageTag.length(), String.format("Language tag = %s", this.LanguageTag)))); start += this.LanguageTag.length(); } parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, 1, "Null separator"))); if (this.TranslatedKeyword != null) { parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start += 1, this.TranslatedKeyword.length, "Translated keyword"))); start += this.TranslatedKeyword.length; } parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start, 1, "Null separator"))); if (this.Text != null) { parent.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent( start += 1, this.Text.length, "Text"))); } }