Question

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 :-(

Was it helpful?

Solution

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();
            }
        }
    }   
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top