Search in sources :

Example 6 with IPerspectiveRegistry

use of org.eclipse.ui.IPerspectiveRegistry in project liferay-ide by liferay.

the class UIUtil method switchToLiferayPerspective.

public static void switchToLiferayPerspective(String perspectiveId, boolean confirm) {
    // Retrieve the new project open perspective preference setting
    String perspSetting = PrefUtil.getAPIPreferenceStore().getString(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE);
    IDEWorkbenchPlugin plugin = IDEWorkbenchPlugin.getDefault();
    String promptSetting = plugin.getPreferenceStore().getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
    if (!(promptSetting.equals(MessageDialogWithToggle.PROMPT)) && perspSetting.equals(IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE)) {
        return;
    }
    // Map perspective id to descriptor.
    IWorkbench workbench = PlatformUI.getWorkbench();
    IPerspectiveRegistry reg = workbench.getPerspectiveRegistry();
    IPerspectiveDescriptor finalPersp = reg.findPerspectiveWithId(perspectiveId);
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            IPerspectiveDescriptor currentPersp = page.getPerspective();
            if (finalPersp.equals(currentPersp)) {
                return;
            }
        }
        if (confirm && !_confirmPerspectiveSwitch(window, finalPersp)) {
            return;
        }
    }
    // replace active perspective setting otherwise
    _replaceCurrentPerspective(finalPersp);
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPerspectiveRegistry(org.eclipse.ui.IPerspectiveRegistry) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IDEWorkbenchPlugin(org.eclipse.ui.internal.ide.IDEWorkbenchPlugin)

Example 7 with IPerspectiveRegistry

use of org.eclipse.ui.IPerspectiveRegistry in project pmd-eclipse-plugin by pmd.

the class ReviewCodeCmd method switchToPmdPerspective.

/**
 * opens the PMD perspective
 *
 * @author SebastianRaffel ( 07.05.2005 )
 */
private static void switchToPmdPerspective() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    final IPerspectiveRegistry reg = workbench.getPerspectiveRegistry();
    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    window.getActivePage().setPerspective(reg.findPerspectiveWithId(PMDRuntimeConstants.ID_PERSPECTIVE));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPerspectiveRegistry(org.eclipse.ui.IPerspectiveRegistry)

Aggregations

IPerspectiveRegistry (org.eclipse.ui.IPerspectiveRegistry)7 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)6 IWorkbench (org.eclipse.ui.IWorkbench)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 Method (java.lang.reflect.Method)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 WorkbenchPage (org.eclipse.ui.internal.WorkbenchPage)1 IDEWorkbenchPlugin (org.eclipse.ui.internal.ide.IDEWorkbenchPlugin)1 BackingStoreException (org.osgi.service.prefs.BackingStoreException)1