org.eclipse.ui.IPerspectiveRegistry Java Examples
The following examples show how to use
org.eclipse.ui.IPerspectiveRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PerspectiveHelper.java From gama with GNU General Public License v3.0 | 6 votes |
public static void cleanPerspectives() { final EModelService e = PlatformUI.getWorkbench().getService(EModelService.class); final MApplication a = PlatformUI.getWorkbench().getService(MApplication.class); final List<PerspectiveImpl> perspectives = e.findElements(a, PerspectiveImpl.class, EModelService.ANYWHERE, element -> matches(element.getElementId())); for ( final PerspectiveImpl p : perspectives ) { // DEBUG.OUT("Dirty perspective implementation found and removed: " + p.getElementId()); p.getParent().getChildren().remove(p); } final IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry(); for ( final IPerspectiveDescriptor desc : reg.getPerspectives() ) { if ( matches(desc.getId()) ) { // DEBUG.OUT("Dirty perspective descriptor found and removed: " + desc.getId()); reg.deletePerspective(desc); } } // DEBUG.OUT("Current perspectives: " + listCurrentPerspectives()); }
Example #2
Source File: BonitaPerspectivesUtils.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Switch to the perspective with id given as parameter * * @param perspectiveID */ public static synchronized void switchToPerspective(final String perspectiveID) { final IWorkbench workbench = PlatformUI.getWorkbench(); final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window != null) { final IWorkbenchPage activePage = window.getActivePage(); if (activePage != null) { final IPerspectiveDescriptor activePerspective = activePage.getPerspective(); if (activePerspective == null || !activePerspective.getId().equals(perspectiveID)) { final IPerspectiveRegistry registry = workbench.getPerspectiveRegistry(); final IWorkbenchPage page = window.getActivePage(); final IPerspectiveDescriptor desc = registry.findPerspectiveWithId(perspectiveID); page.setPerspective(desc); } } } }
Example #3
Source File: PerspektiveImportHandler.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("restriction") private IPerspectiveDescriptor savePerspectiveToRegistryLegacy(MPerspective perspective){ IPerspectiveRegistry perspectiveRegistry = (PerspectiveRegistry) PlatformUI.getWorkbench().getPerspectiveRegistry(); IPerspectiveDescriptor pd = perspectiveRegistry.findPerspectiveWithId(perspective.getElementId()); if (pd == null) { ((PerspectiveRegistry) perspectiveRegistry).addPerspective(perspective); pd = perspectiveRegistry.findPerspectiveWithId(perspective.getElementId()); } else { LoggerFactory.getLogger(PerspektiveImportHandler.class) .error("perspective descriptor already exists for perspective id: " + perspective.getElementId()); } return pd; }
Example #4
Source File: PerspectiveImportService.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public int deletePerspective(String perspectiveId){ IPerspectiveRegistry iPerspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry(); MApplication mApplication = getService(MApplication.class); IPerspectiveDescriptor existingPerspectiveDescriptor = iPerspectiveRegistry.findPerspectiveWithId(perspectiveId); int idx = -1; if (existingPerspectiveDescriptor != null) { idx = closePerspective(existingPerspectiveDescriptor); //NOT WORKING IF PERSPECTIVE IS PREDEFINED - workaround with generics iPerspectiveRegistry.deletePerspective(existingPerspectiveDescriptor); PerspectiveImportService.genericInvokMethod(iPerspectiveRegistry, "removeSnippet", MSnippetContainer.class, String.class, mApplication, existingPerspectiveDescriptor.getId()); } return idx; }
Example #5
Source File: AbstractNewProjectWizard.java From typescript.java with MIT License | 5 votes |
/** * Adds to the list all perspective IDs in the Workbench who's original ID * matches the given ID. * * @param perspectiveIds * the list of perspective IDs to supplement. * @param id * the id to query. * @since 3.0 */ private static void addPerspectiveAndDescendants(List perspectiveIds, String id) { IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry(); IPerspectiveDescriptor[] perspectives = registry.getPerspectives(); for (int i = 0; i < perspectives.length; i++) { // @issue illegal ref to workbench internal class; // consider adding getOriginalId() as API on IPerspectiveDescriptor PerspectiveDescriptor descriptor = ((PerspectiveDescriptor) perspectives[i]); if (descriptor.getOriginalId().equals(id)) { perspectiveIds.add(descriptor.getId()); } } }
Example #6
Source File: PerspectiveUtil.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public static void switchToModelingPerspective(IWorkbenchWindow window) { IPreferenceStore prefs = UIPluginActivator.getDefault() .getPreferenceStore(); boolean hide = prefs.getBoolean(AUTO_SWITCH_PERSPECTIVE); IWorkbenchPage page = window.getActivePage(); if (!hide) { IWorkbench workbench = window.getWorkbench(); IPerspectiveRegistry registry = workbench.getPerspectiveRegistry(); IPerspectiveDescriptor descriptor = registry .findPerspectiveWithId(IYakinduSctPerspectives.ID_PERSPECTIVE_SCT_MODELING); if ((page != null) && (page.getPerspective() != descriptor)) { MessageDialogWithToggle dialog = MessageDialogWithToggle .openYesNoQuestion( window.getShell(), "Confirm Perspective Switch", "This kind of editor is associated with the YAKINDU Modeling perspective. Do you want to switch to this perspective now?", "Do not offer to switch perspective in the future", hide, prefs, AUTO_SWITCH_PERSPECTIVE); if (dialog.getReturnCode() == 2) page.setPerspective(descriptor); hide = dialog.getToggleState(); prefs.setValue(AUTO_SWITCH_PERSPECTIVE, hide); try { InstanceScope.INSTANCE.getNode(UIPluginActivator.PLUGIN_ID) .flush(); } catch (BackingStoreException e) { e.printStackTrace(); } } } }
Example #7
Source File: ApplicationWorkbenchAdvisor.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public String getInitialWindowPerspectiveId(){ String initPerspective = CoreOperationAdvisorHolder.get().getInitialPerspective(); // avoid that nothing opens up after login in case the stored perspective can't be found IPerspectiveRegistry perspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry(); if (perspectiveRegistry.findPerspectiveWithId(initPerspective) == null) { initPerspective = UiResourceConstants.PatientPerspektive_ID; } return initPerspective; }
Example #8
Source File: PerspectiveHelper.java From gama with GNU General Public License v3.0 | 4 votes |
public static IPerspectiveRegistry getPerspectiveRegistry() { return PlatformUI.getWorkbench().getPerspectiveRegistry(); }
Example #9
Source File: PerspectiveImportService.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings("restriction") private IPerspectiveDescriptor importPerspectiveFromStream(InputStream in, IStateCallback iStateHandle, boolean openPerspectiveIfAdded) throws IOException{ MPerspective mPerspective = loadPerspectiveFromStream(in); if (mPerspective != null) { IPerspectiveRegistry iPerspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry(); // the perspective id to import String id = mPerspective.getElementId(); IPerspectiveDescriptor existingPerspectiveDescriptor = iPerspectiveRegistry.findPerspectiveWithId(id); // the active perspective id String activePerspectiveId = getActivePerspectiveId(); // check if the import should be done if (existingPerspectiveDescriptor == null || iStateHandle == null || iStateHandle.state(State.OVERRIDE)) { IPerspectiveDescriptor activePd = iPerspectiveRegistry.findPerspectiveWithId(activePerspectiveId); // delete if a perspective with the id already exists int idx = deletePerspective(id); // add the new perspective to the registry ((PerspectiveRegistry) iPerspectiveRegistry).addPerspective(mPerspective); IPerspectiveDescriptor createdPd = iPerspectiveRegistry.findPerspectiveWithId(id); if (createdPd != null) { ((PerspectiveDescriptor) createdPd).setHasCustomDefinition(false); //no original descriptor should exists } // check if the new perspective should be opened if (idx > -1 || openPerspectiveIfAdded) { openPerspective(createdPd); // there was already an opened active perspective switch back to it openPerspective(activePd); } return createdPd; } } return null; }
Example #10
Source File: PerspectiveImportService.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public int isPerspectiveInStack(String perspectiveId){ IPerspectiveRegistry iPerspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry(); return isPerspectiveInsideStack(iPerspectiveRegistry.findPerspectiveWithId(perspectiveId)); }