2

When ever I double click the tree viewer file that file name should appear in the next form view

Sample.dat -> double click -> name should be appear Sample.dat and File related properties should be appear. I created a treeViewer files and double click the file name that name is not appear. Please kindly help me reg this,eclipse rcp,Juno,e4 etc..

4

2 回答 2

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

于 2012-10-30T09:51:45.347 回答
0

透视类... private void setLayouts(IPageLayout layout) { // Range 0.05f to 0.95f.... IFolderLayout explorerFolderLayout = layout.createFolder("explorer", IPageLayout.LEFT, 0.25f, layout.getEditorArea());

explorerFolderLayout.addView(ExplorerView.ID);

查看类.. 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();...

……

于 2012-11-06T05:12:34.687 回答