private void removePerspetives(IPerspectiveRegistry perspectiveRegistry, List<IPerspectiveDescriptor> removePerspectiveDesc) { // If the list is non-empty then remove all such perspectives from the IExtensionChangeHandler if(perspectiveRegistry instanceof IExtensionChangeHandler && !removePerspectiveDesc.isEmpty()) { IExtensionChangeHandler extChgHandler = (IExtensionChangeHandler) perspectiveRegistry; extChgHandler.removeExtension(null, removePerspectiveDesc.toArray()); } }
public static void hidePerspectives(String[] ids) { IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry(); IPerspectiveDescriptor[] descriptors = registry.getPerspectives(); List ignoredPerspectives = Arrays.asList(ids); List removePerspectiveDesc = new ArrayList(); for (IPerspectiveDescriptor desc : descriptors) { if (ignoredPerspectives.contains(desc.getId())) { removePerspectiveDesc.add(desc); } } if (registry instanceof IExtensionChangeHandler && !removePerspectiveDesc.isEmpty()) { IExtensionChangeHandler extChgHandler = (IExtensionChangeHandler) registry; extChgHandler.removeExtension(null, removePerspectiveDesc.toArray()); } }