문제

What I need is: An app with welcome page and then to switch to another perspective. To switch the perspective the following code was used:

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();
            }
        }
    }   
}

and nothing has hapend :-(

도움이 되었습니까?

해결책

Solved:

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();
            }
        }
    }   
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top