سؤال

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