aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Roberts2011-10-18 09:57:27 (EDT)
committerRemy Suen2011-10-18 09:57:27 (EDT)
commitf7653986b00e3bda6aa50774168d84c613bd276a (patch)
tree29a47fd0ba4def30680cb1f94cb83d9e27dfdf44
parent9f8dc9cf07e6066ef6570e8b4afbefac494da803 (diff)
downloadeclipse.platform.ui-f7653986b00e3bda6aa50774168d84c613bd276a.zip
eclipse.platform.ui-f7653986b00e3bda6aa50774168d84c613bd276a.tar.gz
eclipse.platform.ui-f7653986b00e3bda6aa50774168d84c613bd276a.tar.bz2
Bug 355497 [Compatibility] Activities/Capabilities in Eclipse4
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/activities/WorkbenchActivityHelper.java9
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistry.java15
2 files changed, 18 insertions, 6 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/activities/WorkbenchActivityHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/activities/WorkbenchActivityHelper.java
index 05933cc..d94c94d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/activities/WorkbenchActivityHelper.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/activities/WorkbenchActivityHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -597,9 +597,10 @@ public final class WorkbenchActivityHelper {
*
* @since 3.4
*/
- public static Collection restrictCollection(Collection toBeFiltered, Collection result) {
- for (Iterator iterator = toBeFiltered.iterator(); iterator.hasNext();) {
- Object item = iterator.next();
+ public static <T> Collection<T> restrictCollection(Collection<T> toBeFiltered,
+ Collection<T> result) {
+ for (Iterator<T> iterator = toBeFiltered.iterator(); iterator.hasNext();) {
+ T item = iterator.next();
if (!restrictUseOf(item)) {
result.add(item);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistry.java
index 940ac53..f57bf5c 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveRegistry.java
@@ -12,6 +12,7 @@
package org.eclipse.ui.internal.registry;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,6 +33,7 @@ import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveRegistry;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.activities.WorkbenchActivityHelper;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.internal.e4.compatibility.E4Util;
import org.eclipse.ui.internal.util.PrefUtil;
@@ -151,7 +153,11 @@ public class PerspectiveRegistry implements IPerspectiveRegistry, IExtensionChan
* )
*/
public IPerspectiveDescriptor findPerspectiveWithId(String perspectiveId) {
- return descriptors.get(perspectiveId);
+ IPerspectiveDescriptor candidate = descriptors.get(perspectiveId);
+ if (WorkbenchActivityHelper.restrictUseOf(candidate)) {
+ return null;
+ }
+ return candidate;
}
/*
@@ -164,6 +170,9 @@ public class PerspectiveRegistry implements IPerspectiveRegistry, IExtensionChan
public IPerspectiveDescriptor findPerspectiveWithLabel(String label) {
for (IPerspectiveDescriptor descriptor : descriptors.values()) {
if (descriptor.getLabel().equals(label)) {
+ if (WorkbenchActivityHelper.restrictUseOf(descriptor)) {
+ return null;
+ }
return descriptor;
}
}
@@ -194,7 +203,9 @@ public class PerspectiveRegistry implements IPerspectiveRegistry, IExtensionChan
* @see org.eclipse.ui.IPerspectiveRegistry#getPerspectives()
*/
public IPerspectiveDescriptor[] getPerspectives() {
- return descriptors.values().toArray(new IPerspectiveDescriptor[descriptors.size()]);
+ Collection<PerspectiveDescriptor> allowedDescriptors = WorkbenchActivityHelper
+ .restrictCollection(descriptors.values(), new ArrayList<PerspectiveDescriptor>());
+ return allowedDescriptors.toArray(new IPerspectiveDescriptor[allowedDescriptors.size()]);
}
/**