Eclipse RCP,改变观点

时间:2013-12-08 17:14:39

标签: java eclipse rcp

我需要的是:带有欢迎页面的应用程序,然后切换到另一个视角。要切换透视图,请使用以下代码:

public class SwitchPerspectiveAction extends Action {

    public void run() {
        if (PlatformUI.getWorkbench() != null) {
            try {
                PlatformUI.getWorkbench().showPerspective(Perspective.ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
            } catch (WorkbenchException e) {
                e.printStackTrace();
            }
        }
    }   
}

并且没有任何内容: - (

1 个答案:

答案 0 :(得分:1)

解决:

public class SwitchPerspectiveAction extends Action {

    public void run() {
        if (PlatformUI.getWorkbench() != null) {
            try {
                IPerspectiveDescriptor descriptor = window.getWorkbench()
                    .getPerspectiveRegistry()
                    .findPerspectiveWithId(Perspective.ID);

                PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                    .getActivePage().setPerspective(descriptor);

            } catch (WorkbenchException e) {
                e.printStackTrace();
            }
        }
    }   
}