Java Code Examples for javax.swing.tree.DefaultMutableTreeNode#setAllowsChildren()
The following examples show how to use
javax.swing.tree.DefaultMutableTreeNode#setAllowsChildren() .
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: InspectorPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
void setupTreeNode(DefaultMutableTreeNode node, DiagnosticsNode diagnosticsNode, boolean expandChildren) { node.setUserObject(diagnosticsNode); node.setAllowsChildren(diagnosticsNode.hasChildren()); final InspectorInstanceRef valueRef = diagnosticsNode.getValueRef(); // Properties do not have unique values so should not go in the valueToTreeNode map. if (valueRef.getId() != null && !diagnosticsNode.isProperty()) { valueToTreeNode.put(valueRef, node); } if (parentTree != null) { parentTree.maybeUpdateValueUI(valueRef); } if (diagnosticsNode.hasChildren() || !diagnosticsNode.getInlineProperties().isEmpty()) { if (diagnosticsNode.childrenReady() || !diagnosticsNode.hasChildren()) { final CompletableFuture<ArrayList<DiagnosticsNode>> childrenFuture = diagnosticsNode.getChildren(); assert (childrenFuture.isDone()); setupChildren(diagnosticsNode, node, childrenFuture.getNow(null), expandChildren); } else { node.removeAllChildren(); node.add(new DefaultMutableTreeNode("Loading...")); } } }
Example 2
Source File: InspectorPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
void setupTreeNode(DefaultMutableTreeNode node, DiagnosticsNode diagnosticsNode, boolean expandChildren) { node.setUserObject(diagnosticsNode); node.setAllowsChildren(diagnosticsNode.hasChildren()); final InspectorInstanceRef valueRef = diagnosticsNode.getValueRef(); // Properties do not have unique values so should not go in the valueToTreeNode map. if (valueRef.getId() != null && !diagnosticsNode.isProperty()) { valueToTreeNode.put(valueRef, node); } if (parentTree != null) { parentTree.maybeUpdateValueUI(valueRef); } if (diagnosticsNode.hasChildren() || !diagnosticsNode.getInlineProperties().isEmpty()) { if (diagnosticsNode.childrenReady() || !diagnosticsNode.hasChildren()) { final CompletableFuture<ArrayList<DiagnosticsNode>> childrenFuture = diagnosticsNode.getChildren(); assert (childrenFuture.isDone()); setupChildren(diagnosticsNode, node, childrenFuture.getNow(null), expandChildren); } else { node.removeAllChildren(); node.add(new DefaultMutableTreeNode("Loading...")); } } }
Example 3
Source File: Header.java From DiskBrowser with GNU General Public License v3.0 | 6 votes |
private void linkPictures (String title, DiskAddress da, DefaultMutableTreeNode headerNode) // ---------------------------------------------------------------------------------// { List<DiskAddress> blocks = new ArrayList<> (); blocks.add (da); byte[] buffer = owner.getDisk ().readBlock (da); String text = printChars (buffer, 0); DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, text, owner); dafs.setSectors (blocks); DefaultMutableTreeNode node = new DefaultMutableTreeNode (dafs); node.setAllowsChildren (false); headerNode.add (node); }
Example 4
Source File: CodeManager.java From DiskBrowser with GNU General Public License v3.0 | 6 votes |
void addNodes (DefaultMutableTreeNode root, InfocomDisk disk) // ---------------------------------------------------------------------------------// { root.setAllowsChildren (true); // should be set by now - do this better! codeSize = header.stringPointer - header.highMemory; int count = 0; for (Routine routine : routines.values ()) { String name = String.format ("%3d %s (%04X)", ++count, routine.getName (), routine.startPtr / 2); DefaultAppleFileSource dafs = new DefaultAppleFileSource (name, routine, disk); dafs.setSectors (getSectors (routine, disk.getDisk ())); DefaultMutableTreeNode node = new DefaultMutableTreeNode (dafs); node.setAllowsChildren (false); root.add (node); } }
Example 5
Source File: Wizardry4BootDisk.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private void linkOracle (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry) // ---------------------------------------------------------------------------------// { byte[] buffer = fileEntry.getDataSource ().buffer; List<DiskAddress> blocks = fileEntry.getSectors (); StringBuilder text = new StringBuilder (); for (int i = 0; i < 320; i++) { // System.out.println (HexFormatter.format (buffer, 0x08600 + i * 32, 32)); int offset = 0x08600 + i * 32 + 18; int key = Utility.unsignedShort (buffer, offset); if (key > 0) text.append (String.format ("%04X %04X * %s%n", offset, key, messageBlock.getMessageText (key))); key = Utility.unsignedShort (buffer, offset + 8); if (key > 0) text.append (String.format ("%04X %04X %s%n", offset + 8, key, messageBlock.getMessageText (key))); } List<DiskAddress> allOracleBlocks = new ArrayList<> (); for (int i = 0; i < 20; i++) { allOracleBlocks.add (blocks.get (67 + i)); } DefaultMutableTreeNode oracleNode = linkNode ("Oracle", text.toString (), scenarioNode); oracleNode.setAllowsChildren (false); DefaultAppleFileSource afs = (DefaultAppleFileSource) oracleNode.getUserObject (); afs.setSectors (allOracleBlocks); }
Example 6
Source File: Wizardry4BootDisk.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private void linkBlock2 (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry) // ---------------------------------------------------------------------------------// { byte[] buffer = fileEntry.getDataSource ().buffer; List<DiskAddress> blocks = fileEntry.getSectors (); StringBuilder text = new StringBuilder (); List<DiskAddress> allBlocks = new ArrayList<> (); for (int i = 0; i < 19; i++) { allBlocks.add (blocks.get (87 + i)); } int offset = 0xAE00; int length = 60; for (int i = 0; i < 150; i++) { text.append (String.format ("%04X : %s%n", (offset + i * length), HexFormatter.getHexString (buffer, offset + i * length, length))); } DefaultMutableTreeNode oracleNode = linkNode ("Block2", text.toString (), scenarioNode); oracleNode.setAllowsChildren (false); DefaultAppleFileSource afs = (DefaultAppleFileSource) oracleNode.getUserObject (); afs.setSectors (allBlocks); }
Example 7
Source File: FilterTreeModel.java From swing_library with MIT License | 5 votes |
/** * Clone/Copy a tree node. TreeNodes in Swing don't support deep cloning. * * @param orig to be cloned * @return cloned copy */ private DefaultMutableTreeNode copyNode(final DefaultMutableTreeNode orig) { if (orig == null) return null; DefaultMutableTreeNode newOne = new DefaultMutableTreeNode(); newOne.setUserObject(orig.getUserObject()); newOne.setAllowsChildren(!orig.isLeaf()); Enumeration<DefaultMutableTreeNode> enm = orig.children(); while (enm.hasMoreElements()) { DefaultMutableTreeNode child = enm.nextElement(); newOne.add(copyNode(child)); } return newOne; }
Example 8
Source File: Header.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private void linkSpells (String title, DiskAddress da, DefaultMutableTreeNode headerNode) // ---------------------------------------------------------------------------------// { List<DiskAddress> blocks = new ArrayList<> (); blocks.add (da); int level = 1; StringBuilder list = new StringBuilder ("Level " + level + ":\n"); byte[] buffer = owner.getDisk ().readBlock (da); String text = HexFormatter.getString (buffer, 0, 512); String[] spells = text.split ("\n"); for (String s : spells) { if (s.length () == 0) break; if (s.startsWith ("*")) { s = s.substring (1); level++; list.append ("\nLevel " + level + ":\n"); } list.append (" " + s + "\n"); } DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, list.toString (), owner); dafs.setSectors (blocks); DefaultMutableTreeNode node = new DefaultMutableTreeNode (dafs); node.setAllowsChildren (false); headerNode.add (node); }
Example 9
Source File: Header.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private void linkText (String title, DiskAddress da, DefaultMutableTreeNode headerNode) // ---------------------------------------------------------------------------------// { List<DiskAddress> blocks = new ArrayList<> (); blocks.add (da); StringBuilder text = new StringBuilder (scenarioTitle + "\n\n"); int ptr = 106; byte[] buffer = owner.getDisk ().readBlock (da); while (buffer[ptr] != -1) { text.append (HexFormatter.getPascalString (buffer, ptr) + "\n"); ptr += 10; } ptr += 2; text.append ("\n"); while (ptr < 512) { int value = Utility.intValue (buffer[ptr], buffer[ptr + 1]); text.append (String.format ("%04X %,6d%n", value, value)); ptr += 2; } DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, text.toString (), owner); dafs.setSectors (blocks); DefaultMutableTreeNode node = new DefaultMutableTreeNode (dafs); node.setAllowsChildren (false); headerNode.add (node); }
Example 10
Source File: TreeBuilder.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private DefaultMutableTreeNode createNode (File file, boolean allowsChildren) // ---------------------------------------------------------------------------------// { FileNode fileNode = new FileNode (file); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode (fileNode); fileNode.setTreeNode (newNode); newNode.setAllowsChildren (allowsChildren); return newNode; }
Example 11
Source File: PropertyManager.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk) // ---------------------------------------------------------------------------------// { node.setAllowsChildren (true); for (Statistic stat : list) if (stat.list.size () > 0) { String title = "Property " + header.getPropertyName (stat.id).trim (); DefaultMutableTreeNode child = new DefaultMutableTreeNode ( new DefaultAppleFileSource (title, stat.getText (), disk)); node.add (child); child.setAllowsChildren (false); } }
Example 12
Source File: AttributeManager.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk) // ---------------------------------------------------------------------------------// { node.setAllowsChildren (true); int count = 0; for (Statistic stat : list) { DefaultMutableTreeNode child = new DefaultMutableTreeNode ( new DefaultAppleFileSource (("Attribute " + count++), stat.getText (), disk)); node.add (child); child.setAllowsChildren (false); } }
Example 13
Source File: InfocomDisk.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private DefaultMutableTreeNode addToTree (DefaultMutableTreeNode root, String title, DataSource af, boolean allowsChildren) // ---------------------------------------------------------------------------------// { DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, af, this); // dafs.setSectors (blocks); DefaultMutableTreeNode node = new DefaultMutableTreeNode (dafs); node.setAllowsChildren (allowsChildren); root.add (node); return node; }
Example 14
Source File: ObjectManager.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private void buildObjectTree (ZObject object, DefaultMutableTreeNode parentNode, FormattedDisk disk) // ---------------------------------------------------------------------------------// { DefaultMutableTreeNode child = new DefaultMutableTreeNode ( new DefaultAppleFileSource (object.getName (), object, disk)); parentNode.add (child); if (object.sibling > 0) buildObjectTree (list.get (object.sibling - 1), parentNode, disk); if (object.child > 0) buildObjectTree (list.get (object.child - 1), child, disk); else child.setAllowsChildren (false); }
Example 15
Source File: ObjectManager.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
public void addNodes (DefaultMutableTreeNode root, FormattedDisk disk) // ---------------------------------------------------------------------------------// { root.setAllowsChildren (true); for (ZObject zo : list) if (zo.parent == 0) buildObjectTree (zo, root, disk); }
Example 16
Source File: ClusterTreeVisualization.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private MutableTreeNode createLeaf(Object id) { ObjectVisualizer viz = ObjectVisualizerService.getVisualizerForObject(clusterModel); String title = viz.getTitle(id); if (title == null) { if (id instanceof String) { title = (String) id; } else { title = ((Integer) id).toString(); } } DefaultMutableTreeNode newLeaf = new DefaultMutableTreeNode(new ClusterTreeLeaf(title, id)); newLeaf.setAllowsChildren(false); return newLeaf; }
Example 17
Source File: ClusterTreeVisualization.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private DefaultMutableTreeNode generateTreeModel(HierarchicalClusterNode cl) { DefaultMutableTreeNode result = new DefaultMutableTreeNode(cl); result.setAllowsChildren(true); // Add sub clusters for (HierarchicalClusterNode subNode : cl.getSubNodes()) { result.add(generateTreeModel(subNode)); } // Add objects for (Object exampleId : cl.getExampleIdsInSubtree()) { result.add(createLeaf(exampleId)); } return result; }
Example 18
Source File: WizardryScenarioDisk.java From DiskBrowser with GNU General Public License v3.0 | 5 votes |
private void addToNode (AbstractFile af, DefaultMutableTreeNode node, List<DiskAddress> blocks, SectorType type) // ---------------------------------------------------------------------------------// { DefaultAppleFileSource dafs = new DefaultAppleFileSource (af.getName (), af, this, blocks); DefaultMutableTreeNode childNode = new DefaultMutableTreeNode (dafs); node.add (childNode); childNode.setAllowsChildren (false); }
Example 19
Source File: WizardryScenarioDisk.java From DiskBrowser with GNU General Public License v3.0 | 4 votes |
public WizardryScenarioDisk (Disk disk) // ---------------------------------------------------------------------------------// { super (disk); if (false) { sectorTypesList.add (mazeSector); sectorTypesList.add (monsterSector); sectorTypesList.add (itemSector); sectorTypesList.add (characterSector); sectorTypesList.add (spellSector); sectorTypesList.add (messageSector); sectorTypesList.add (imageSector); sectorTypesList.add (experienceSector); sectorTypesList.add (treasureSector); } CodedMessage.codeOffset = 185; Monster.counter = 0; Item.counter = 0; DefaultTreeModel model = (DefaultTreeModel) catalogTree.getModel (); DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot (); DefaultMutableTreeNode dataNode = findNode (currentRoot, "SCENARIO.DATA"); DefaultMutableTreeNode msgNode = findNode (currentRoot, "SCENARIO.MESGS"); if (dataNode == null || msgNode == null) { System.out.println ("Wizardry data or msg node not found"); return; } dataNode.setAllowsChildren (true); msgNode.setAllowsChildren (true); scenarioHeader = new Header (dataNode, this); // Process SCENARIO.MESGS (requires scenario) AppleFileSource afs = (AppleFileSource) msgNode.getUserObject (); // DefaultMutableTreeNode node = linkNode ("Messages", "Messages string", msgNode); extractMessages (msgNode, afs.getSectors ()); // makeNodeVisible (node); // Process SCENARIO.DATA (requires scenario and messages) afs = (AppleFileSource) dataNode.getUserObject (); List<DiskAddress> sectors = afs.getSectors (); extractItems (linkNode ("Items", "Items string", dataNode), sectors); extractRewards (linkNode ("Rewards", "Treasure string", dataNode), sectors); extractMonsters (linkNode ("Monsters", "Monsters string", dataNode), sectors); extractCharacters (linkNode ("Characters", "Characters string", dataNode), sectors); extractImages (linkNode ("Images", "Images string", dataNode), sectors); extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode), sectors); // node = linkNode ("Spells", "Spells string", dataNode); DefaultMutableTreeNode node = null; extractSpells (node, sectors); extractLevels (linkNode ("Maze", "Levels string", dataNode), sectors); // Make the Spells node (and its siblings) visible // makeNodeVisible (node); // add information about each characters' baggage, spells known etc. for (Character c : characters) { c.linkItems (items); c.linkSpells (spells); int type = c.getStatistics ().typeInt; c.linkExperience (experiences.get (type)); } }
Example 20
Source File: PascalDisk.java From DiskBrowser with GNU General Public License v3.0 | 4 votes |
public PascalDisk (Disk disk) // ---------------------------------------------------------------------------------// { super (disk); sectorTypesList.add (diskBootSector); sectorTypesList.add (catalogSector); sectorTypesList.add (dataSector); sectorTypesList.add (codeSector); sectorTypesList.add (textSector); sectorTypesList.add (infoSector); sectorTypesList.add (grafSector); sectorTypesList.add (fotoSector); sectorTypesList.add (badSector); List<DiskAddress> blocks = disk.getDiskAddressList (0, 1); // B0, B1 this.bootSector = new BootSector (disk, disk.readBlocks (blocks), "Pascal"); for (int i = 0; i < 2; i++) if (!disk.isBlockEmpty (i)) { sectorTypes[i] = diskBootSector; freeBlocks.set (i, false); } for (int i = 2; i < disk.getTotalBlocks (); i++) freeBlocks.set (i, true); byte[] buffer = disk.readBlock (2); byte[] data = new byte[CATALOG_ENTRY_SIZE]; System.arraycopy (buffer, 0, data, 0, CATALOG_ENTRY_SIZE); volumeEntry = new VolumeEntry (this, data); DefaultMutableTreeNode root = getCatalogTreeRoot (); DefaultMutableTreeNode volumeNode = new DefaultMutableTreeNode (volumeEntry); root.add (volumeNode); List<DiskAddress> sectors = new ArrayList<> (); int max = Math.min (volumeEntry.lastBlock, disk.getTotalBlocks ()); for (int i = 2; i < max; i++) { DiskAddress da = disk.getDiskAddress (i); if (!disk.isBlockEmpty (da)) sectorTypes[i] = catalogSector; sectors.add (da); freeBlocks.set (i, false); } diskCatalogSector = new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors); // read the catalog List<DiskAddress> addresses = new ArrayList<> (); for (int i = 2; i < max; i++) addresses.add (disk.getDiskAddress (i)); buffer = disk.readBlocks (addresses); // loop through each catalog entry (what if there are deleted files?) for (int i = 1; i <= volumeEntry.totalFiles; i++) { int ptr = i * CATALOG_ENTRY_SIZE; data = new byte[CATALOG_ENTRY_SIZE]; System.arraycopy (buffer, ptr, data, 0, CATALOG_ENTRY_SIZE); FileEntry fileEntry = new FileEntry (this, data); fileEntries.add (fileEntry); DefaultMutableTreeNode node = new DefaultMutableTreeNode (fileEntry); fileEntry.setNode (node); if (fileEntry.fileType == 2) { node.setAllowsChildren (true); fileEntry.getDataSource (); // build segments } else node.setAllowsChildren (false); volumeNode.add (node); for (int j = fileEntry.firstBlock; j < fileEntry.lastBlock; j++) freeBlocks.set (j, false); } volumeNode.setUserObject (getCatalog ()); makeNodeVisible (volumeNode.getFirstLeaf ()); }