当我双击树查看器文件时,文件名应出现在下一个表单视图中
Sample.dat - >双击 - >应该出现名称Sample.dat和File相关属性。 我创建了一个treeViewer文件,然后双击未显示名称的文件名。 请帮助我注意这个,eclipse rcp,Juno,e4等。
答案 0 :(得分:0)
您需要向树中添加点击侦听器
final Tree tree = new Tree(parent, SWT.BORDER);
tree.addMouseListener(new MouseListener(){
public void mouseDoubleClick(MouseEvent e) {
//get data of selected element
//we use array[0], because we have not multiselect tree
MyDataObject data = (MyDataObject) tree.getSelection()[0].getData();
//now you need to pass "data" to your view with file info
//I don't know how to do it in pre e4 RCP apps, so
//please read this answer: https://stackoverflow.com/a/2227764/1030113
//hope that helps
}
public void mouseDown(MouseEvent e) {}
public void mouseUp(MouseEvent e) {}
});
//to test
TreeItem treeItem1 = new TreeItem(tree, SWT.NONE);
treeItem1.setText("some item 1");
treeItem1.setData(new MyDataObject("somedata 1"));
TreeItem treeItem2 = new TreeItem(tree, SWT.NONE);
treeItem2.setText("some item 2");
treeItem2.setData(new MyDataObject("somedata 2"));
我不知道如何在pre e4 RCP应用中的视图之间进行通信,但我在这里找到了一些有用的答案:https://stackoverflow.com/a/2227764/1030113
答案 1 :(得分:0)
透视课...... private void setLayouts(IPageLayout layout){ //范围0.05f至0.95f .... IFolderLayout explorerFolderLayout = layout.createFolder(“explorer”,IPageLayout.LEFT,0.25f,layout.getEditorArea());
查看课程.. viewer.addDoubleClickListener(new IDoubleClickListener(){
@Override
public void doubleClick(DoubleClickEvent event) {
// TODO Auto-generated method stub
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
FileName fn = null;
FileNameContainer fnc = null;
if (selection.isEmpty())
return;
List<Object> list = selection.toList();...
...