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;
}
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);
}
}
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;
}
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);
}
}
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;
}
Aggregations