public void start(BundleContext context) throws Exception { super.start(context); plugin = this; final boolean switchPerpective = processPluginUpgrading(); if (switchPerpective) { final IWorkbench workbench = PlatformUI.getWorkbench(); new UIJob("Switching perspectives"){ @Override public IStatus runInUIThread(IProgressMonitor monitor) { try { workbench.showPerspective(perspectiveId, workbench.getActiveWorkbenchWindow()); } catch (WorkbenchException e) { return new Status(IStatus.ERROR,PLUGIN_ID,"Error while switching perspectives", e); } return Status.OK_STATUS; }} .run(new NullProgressMonitor()); } }
public void run() { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IAdaptable input; if (page != null) input= page.getInput(); else input= ResourcesPlugin.getWorkspace().getRoot(); try { workbench.showPerspective(JavaUI.ID_PERSPECTIVE, window, input); } catch (WorkbenchException e) { ExceptionHandler.handle(e, window.getShell(), ActionMessages.OpenJavaPerspectiveAction_dialog_title, ActionMessages.OpenJavaPerspectiveAction_error_open_failed); } } }
@Override public void run() { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IAdaptable input; if (page != null) input= page.getInput(); else input= ResourcesPlugin.getWorkspace().getRoot(); try { workbench.showPerspective(JavaUI.ID_PERSPECTIVE, window, input); } catch (WorkbenchException e) { ExceptionHandler.handle(e, window.getShell(), ActionMessages.OpenJavaPerspectiveAction_dialog_title, ActionMessages.OpenJavaPerspectiveAction_error_open_failed); } } }
@Override public void run() { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IAdaptable input; if (page != null) input= page.getInput(); else input= ResourcesPlugin.getWorkspace().getRoot(); try { workbench.showPerspective(JavaUI.ID_BROWSING_PERSPECTIVE, window, input); } catch (WorkbenchException e) { ExceptionHandler.handle(e, window.getShell(), ActionMessages.OpenJavaBrowsingPerspectiveAction_dialog_title, ActionMessages.OpenJavaBrowsingPerspectiveAction_error_open_failed); } } }
public void run() { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IAdaptable input; if (page != null) input= page.getInput(); else input= ResourcesPlugin.getWorkspace().getRoot(); try { workbench.showPerspective(JavaUI.ID_BROWSING_PERSPECTIVE, window, input); } catch (WorkbenchException e) { ExceptionHandler.handle(e, window.getShell(), ActionMessages.OpenJavaBrowsingPerspectiveAction_dialog_title, ActionMessages.OpenJavaBrowsingPerspectiveAction_error_open_failed); } } }
@Override public void run() { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IAdaptable input; if (page != null) input= page.getInput(); else input= ResourcesPlugin.getWorkspace().getRoot(); try { workbench.showPerspective(JavaUI.ID_PERSPECTIVE, window, input); } catch (WorkbenchException e) { ExceptionHandler.handle(e, window.getShell(), ActionMessages.OpenJavaPerspectiveAction_dialog_title, ActionMessages.OpenJavaPerspectiveAction_error_open_failed); } } }
@Override public void run() { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IAdaptable input; if (page != null) input= page.getInput(); else input= ResourcesPlugin.getWorkspace().getRoot(); try { workbench.showPerspective(JavaUI.ID_BROWSING_PERSPECTIVE, window, input); } catch (WorkbenchException e) { ExceptionHandler.handle(e, window.getShell(), ActionMessages.OpenJavaBrowsingPerspectiveAction_dialog_title, ActionMessages.OpenJavaBrowsingPerspectiveAction_error_open_failed); } } }
private void ensureProperContext(SampleWizard wizard) { IConfigurationElement sample = wizard.getSelection(); String perspId = sample.getAttribute("perspectiveId"); //$NON-NLS-1$ if (perspId != null) { try { wizard.enableActivities(); PlatformUI.getWorkbench().showPerspective(perspId, PDEPlugin.getActiveWorkbenchWindow()); wizard.selectReveal(PDEPlugin.getActiveWorkbenchShell()); } catch (WorkbenchException e) { PDEPlugin.logException(e); } } enableActivities(sample); }
private void openPage(IPerspectiveDescriptor desc, int keyStateMask) { // Verify page input. if (pageInput == null) { StatusUtil.handleStatus(PAGE_PROBLEMS_TITLE + ": " + PAGE_PROBLEMS_MESSAGE, StatusManager.SHOW); //$NON-NLS-1$ return; } // Open the page. try { getWindow().getWorkbench().showPerspective(desc.getId(), getWindow(), pageInput); } catch (WorkbenchException e) { StatusUtil.handleStatus( PAGE_PROBLEMS_TITLE + ": " + e.getMessage(), e, //$NON-NLS-1$ StatusManager.SHOW); } }
if (window != null && window.getShell() != null && !window.getShell().isDisposed()) { try { PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window); } catch (WorkbenchException ex) {
/** * Switches to the specified perspective * * @param id perspective identifier */ protected void switchToPerspective(IWorkbenchWindow window, String id) { try { // don't loose the focus dialog if there is one Shell dialog = getModalDialogOpen(window.getShell()); window.getWorkbench().showPerspective(id, window); if (dialog != null) { dialog.setFocus(); } } catch (WorkbenchException e) { DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), LaunchConfigurationsMessages.PerspectiveManager_Error_1, MessageFormat.format(LaunchConfigurationsMessages.PerspectiveManager_Unable_to_switch_to_perspective___0__2, new Object[] { id }), e); } }
if (window != null && window.getShell() != null && !window.getShell().isDisposed()) { try { activePage= PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window); } catch (WorkbenchException ex) {
try { String pId = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE); activePage = workbench.showPerspective(pId, window); } catch (WorkbenchException e) { Utils.handleError(window.getShell(), e, TeamUIMessages.SynchronizeView_14, e.getMessage());
if (window != null && window.getShell() != null && !window.getShell().isDisposed()) { try { activePage= PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window); } catch (WorkbenchException ex) {
try { String pId = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE); activePage = workbench.showPerspective(pId, window); } catch (WorkbenchException e) { Utils.handleError(window.getShell(), e, TeamUIMessages.SynchronizeView_14, e.getMessage());
if (window != null && window.getShell() != null && !window.getShell().isDisposed()) { try { PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window); } catch (WorkbenchException ex) {
private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, IJavaElement[] input) throws WorkbenchException, JavaModelException { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IJavaElement perspectiveInput= input.length == 1 ? input[0] : null; if (perspectiveInput != null && input[0] instanceof IMember) { if (input[0].getElementType() != IJavaElement.TYPE) { perspectiveInput= ((IMember)input[0]).getDeclaringType(); } else { perspectiveInput= input[0]; } } IWorkbenchPage page= workbench.showPerspective(JavaUI.ID_HIERARCHYPERSPECTIVE, window, perspectiveInput); TypeHierarchyViewPart part= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY); if (part != null) { part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible' } part= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY); part.setInputElements(input); if (perspectiveInput != null) { if (page.getEditorReferences().length == 0) { JavaUI.openInEditor(input[0], false, false); // only open when the perspective has been created } } return part; }
private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, IJavaElement[] input) throws WorkbenchException, JavaModelException { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IJavaElement perspectiveInput= input.length == 1 ? input[0] : null; if (perspectiveInput != null && input[0] instanceof IMember) { if (input[0].getElementType() != IJavaElement.TYPE) { perspectiveInput= ((IMember)input[0]).getDeclaringType(); } else { perspectiveInput= input[0]; } } IWorkbenchPage page= workbench.showPerspective(JavaUI.ID_HIERARCHYPERSPECTIVE, window, perspectiveInput); TypeHierarchyViewPart part= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY); if (part != null) { part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible' } part= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY); part.setInputElements(input); if (perspectiveInput != null) { if (page.getEditorReferences().length == 0) { JavaUI.openInEditor(input[0], false, false); // only open when the perspective has been created } } return part; }
private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, IJavaElement input) throws WorkbenchException, JavaModelException { IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); // The problem is that the input element can be a working copy. So we first convert it to the original element if // it exists. IJavaElement perspectiveInput= input; if (input instanceof IMember) { if (input.getElementType() != IJavaElement.TYPE) { perspectiveInput= ((IMember)input).getDeclaringType(); } else { perspectiveInput= input; } } IWorkbenchPage page= workbench.showPerspective(JavaUI.ID_HIERARCHYPERSPECTIVE, window, perspectiveInput); TypeHierarchyViewPart part= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY); if (part != null) { part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible' } part= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY); part.setInputElement(input); if (input instanceof IMember) { if (page.getEditorReferences().length == 0) { JavaUI.openInEditor(input, false, false); // only open when the perspecive has been created } } return part; }
IWorkbenchPage page = PDEPlugin.getActivePage(); if (perspId != null && switchPerspective) { PlatformUI.getWorkbench().showPerspective(perspId, page.getWorkbenchWindow());