0
我正在創建一個將顯示樹結構的RCP應用程序。爲此我使用了下面的代碼。但是,我需要使節點可編輯。怎麼做? 請找到我寫的下面的代碼。如何在SWT中編輯樹節點
public class TreeView extends ViewPart {
public static final String ID = "TreeProject.project";
public TreeView() {
}
public static ProjectTree mc = new ProjectTree("root");
public static TreeViewer treeViewer;
@Override
public void createPartControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
treeViewer = new TreeViewer(composite);
Tree tree = treeViewer.getTree();
tree.setLocation(0, 0);
tree.setSize(181, 469);
StyledText styledText = new StyledText(composite, SWT.BORDER);
styledText.setText("Welcome\"!");
styledText.setBounds(179, 0, 415, 469);
treeViewer.setContentProvider(new ProjectContentProvider());
treeViewer.setInput(getRootNode());
treeViewer.expandAll();
System.out.println(tree.getSelection());
}
private ProjectTree getRootNode() {
ProjectTree node0 = new ProjectTree("Node0");
ProjectTree node1 = new ProjectTree("Node1");
mc.addChild(node0, "");
node0.addChild(node1, "");
return mc;
}
@Override
public void setFocus() {
}
}
'editable'是什麼意思?編輯節點文本?添加/刪除節點? –
對不起,我給了我錯誤的印象。編輯節點的文本 - 我已經完成了。我需要從UI中刪除或添加更多的父節點。 –