我可以将视图放入CTabFolder SWT吗?

时间:2015-06-30 08:01:31

标签: java swt

作为标题,我想知道有没有办法将ViewPart扩展到CtabFolder?

我做了一些谷歌搜索,但没有什么可以帮助。所以我决定把我的问题带到这里。

感谢。

1 个答案:

答案 0 :(得分:0)

经过多方研究后,我发现如何在CTabFolder中将ViewPart显示为CTabItem。这是它:

            // create a container for the View part with tabFolder as a parent CTabFolder
            Composite composite = new Composite(tabFolder, SWT.NONE);
            composite.setLayout(new FillLayout());

            CTabItem item = null;

            item = new CTabItem(tabFolder, SWT.NONE);

            // Create the one of the ViewPart I want to show in my CTabFolder
            ProjectVersionDriversView myTestViewer = new ProjectVersionDriversView();

            // call the init method on the ViewPart with the current ViewSite
            try {
                myTestViewer.init(this.getViewSite());
            } catch (PartInitException e) {
                e.printStackTrace();
            }

            // Build the ViewPart within our composite container.
            myTestViewer.createPartControl(composite);
            item.setText("Your Title");
            // set the composite containing the view part as the control for tabItem2.
            item.setControl(composite);

来自here