Search in sources :

Example 51 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project qi4j-sdk by Qi4j.

the class StructureModelBuilder method buildApplicationNode.

private MutableTreeNode buildApplicationNode(ApplicationDetailDescriptor descriptor) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(descriptor);
    buildLayersNode(node, descriptor.layers());
    return node;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 52 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project qi4j-sdk by Qi4j.

the class StructureModelBuilder method addTypeChildren.

private void addTypeChildren(DefaultMutableTreeNode parent, List<Object> childList) {
    Collections.sort(childList, nameComparator);
    for (int i = 0; i < childList.size(); i++) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(childList.get(i));
        parent.add(node);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 53 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project LogisticsPipes by RS485.

the class DebugHelper method handleItemTooltip.

@Override
public List<String> handleItemTooltip(GuiContainer gui, final ItemStack itemstack, int paramInt1, int paramInt2, List<String> currenttip) {
    if (Configs.TOOLTIP_INFO && itemstack != null) {
        if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_H)) {
            if (DebugHelper.lastTime + 1000 < System.currentTimeMillis()) {
                DebugHelper.lastTime = System.currentTimeMillis();
                new Thread(() -> {
                    while (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_H)) {
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    DefaultMutableTreeNode node = new DefaultMutableTreeNode(ItemIdentifier.get(itemstack).getFriendlyName());
                    node.add(new DefaultMutableTreeNode("ItemId: " + Item.getIdFromItem(itemstack.getItem())));
                    node.add(new DefaultMutableTreeNode("ItemDamage: " + itemstack.getItemDamage()));
                    if (itemstack.hasTagCompound()) {
                        DefaultMutableTreeNode tag = new DefaultMutableTreeNode("Tag:");
                        try {
                            addNBTToTree(itemstack.getTagCompound(), tag);
                        } catch (Exception e) {
                            tag.add(new DefaultMutableTreeNode(e));
                        }
                        node.add(tag);
                    }
                    JTree tree = new JTree(node);
                    JScrollPane treeView = new JScrollPane(tree);
                    JFrame frame = new JFrame("Item Info");
                    frame.getContentPane().add(treeView, BorderLayout.CENTER);
                    frame.setLocationRelativeTo(null);
                    frame.pack();
                    frame.setVisible(true);
                }).start();
            }
        }
    }
    return currenttip;
}
Also used : JScrollPane(javax.swing.JScrollPane) JTree(javax.swing.JTree) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JFrame(javax.swing.JFrame)

Example 54 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project LogisticsPipes by RS485.

the class LogWindow method compareLists.

private void compareLists(List<StatusEntry> newList, List<StatusEntry> oldList, DefaultMutableTreeNode node) {
    for (int i = 0; i < newList.size() && i < oldList.size(); i++) {
        if (!newList.get(i).equals(oldList.get(i))) {
            StatusEntry entry = newList.get(i);
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i);
            child.setUserObject(entry.name);
            if (entry.subEntry != null) {
                if (oldList.get(i).subEntry != null) {
                    compareLists(entry.subEntry, oldList.get(i).subEntry, child);
                } else {
                    compareLists(entry.subEntry, new ArrayList<>(0), child);
                }
            } else if (oldList.get(i).subEntry != null) {
                child.removeAllChildren();
            }
            ((DefaultTreeModel) tree.getModel()).reload(child);
        }
    }
    for (int i = newList.size(); i < oldList.size(); i++) {
        node.remove(i);
        ((DefaultTreeModel) tree.getModel()).reload(node);
    }
    for (int i = oldList.size(); i < newList.size(); i++) {
        StatusEntry entry = newList.get(i);
        DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(entry.name);
        node.add(newNode);
        if (entry.subEntry != null) {
            compareLists(entry.subEntry, new ArrayList<>(0), newNode);
        }
        ((DefaultTreeModel) tree.getModel()).reload(node);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 55 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project darkFunction-Editor by darkFunction.

the class AddNodeCommand method execute.

public boolean execute() {
    if (parentNode != null) {
        DefaultMutableTreeNode selectedNode = null;
        TreePath treePath = nameTree.getSelectionPath();
        if (treePath != null)
            selectedNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
        if (selectedNode != null)
            this.prevSelectedPath = new TreePath(selectedNode.getPath());
        else
            this.prevSelectedPath = null;
        insertNewNode(parentNode, newNode);
        return true;
    }
    return false;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath)

Aggregations

DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)692 TreePath (javax.swing.tree.TreePath)185 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)98 ArrayList (java.util.ArrayList)51 Nullable (org.jetbrains.annotations.Nullable)50 TreeNode (javax.swing.tree.TreeNode)42 Test (org.junit.Test)39 JTree (javax.swing.JTree)38 NotNull (org.jetbrains.annotations.NotNull)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 JScrollPane (javax.swing.JScrollPane)25 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)23 TreeSelectionListener (javax.swing.event.TreeSelectionListener)23 Module (com.intellij.openapi.module.Module)20 File (java.io.File)20 Tree (com.intellij.ui.treeStructure.Tree)19 Enumeration (java.util.Enumeration)19 MouseEvent (java.awt.event.MouseEvent)18 IOException (java.io.IOException)17 MProduct (org.compiere.model.MProduct)17