How create a TreeTable in DebugSession
I'm looking for a way to create a TreeTable in intellij Plugin.
The Tab in the DebugSession can I create in *com.intellij.xdebugger.XDebugProcess#createTabLayouter*, but I cant' create a TreeTable inside that JPanel.
My View looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="debugger.ui.RegisterViewSessionTab">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="86eac">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="8217" class="com.intellij.ui.treeStructure.treetable.TreeTable" binding="tree" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
</form>
And the code behinde (RegisterViewSessionTab):
pc = new DefaultRegisterNode();
sp = new DefaultRegisterNode();
DefaultRegisterNode group = new DefaultRegisterNode();
group.setName("Core Registers");
group.setDescription("Core Registers");
group.setValue("");
DefaultMutableTreeNode root = new DefaultMutableTreeNode(group);
pc.setName("PC");
pc.setDescription("Program Counter [Core]");
pc.setValue("---");
DefaultMutableTreeNode nodePc = new DefaultMutableTreeNode(pc);
root.add(nodePc);
sp.setName("SP");
sp.setDescription("Stack Pointer [Core]");
sp.setValue("---");
DefaultMutableTreeNode node = new DefaultMutableTreeNode(sp);
root.add(node);
ColumnInfo[] columnInfos = new ColumnInfo[3];
columnInfos[0] = new ColumnInfo<DefaultMutableTreeNode, String>("Name") {
@Nullable
@Override
public String valueOf(DefaultMutableTreeNode defaultRegisterNode) {
return ((DefaultRegisterNode)defaultRegisterNode.getUserObject()).getName();
}
};
columnInfos[1] = new TableModelEditor.EditableColumnInfo<DefaultMutableTreeNode, String>("Value") {
@Nullable
@Override
public String valueOf(DefaultMutableTreeNode defaultRegisterNode) {
return ((DefaultRegisterNode)defaultRegisterNode.getUserObject()).getValue();
}
@Nullable
@Override
public TableCellEditor getEditor(DefaultMutableTreeNode defaultRegisterNode) {
return new StringTableCellEditor(project);
}
@Override
public void setValue(DefaultMutableTreeNode defaultRegisterNode, String value) {
((DefaultRegisterNode)defaultRegisterNode.getUserObject()).setValue(value);
}
};
columnInfos[2] = new ColumnInfo<DefaultMutableTreeNode, String>("Description") {
@Nullable
@Override
public String valueOf(DefaultMutableTreeNode defaultRegisterNode) {
return ((DefaultRegisterNode)defaultRegisterNode.getUserObject()).getDescription();
}
};
ListTreeTableModelOnColumns registersModel = new ListTreeTableModelOnColumns(root, columnInfos);
tree = new TreeTable(registersModel);
Model class:
public class DefaultRegisterNode {
private String name;
private String description;
private String value;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String getDescription() {
return null;
}
public void setDescription(String description) {
this.description = description;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
In action:

But there isn't a collapsed/expanded button? How can I enable this feature in the TreeTable?
If you need something more, please contact me!
Thanks
请先登录再写评论。
Whats wrong in my code section?
Hello,
Could you please try to use TreeTableView instead of TreeTable?
Thanks for the replay.
With a TreeTableView the root node will show also. But the error isn't there. I found it.
Add a TreeColumnInfo to the ColumnInfos above. This will add the Expand/Collapse Arrows. Now you must create a TreeCellRenderer and set to the Tree.