From f6af0c32313c32ad6842f42928db9853ccc17128 Mon Sep 17 00:00:00 2001 From: raghucssit Date: Mon, 26 Aug 2024 22:09:00 +0200 Subject: [PATCH] Add support for activities filtering in quick access view provider Views hidden by activities should not be shown in Quick Access (Ctrl+3) See https://github.com/eclipse-platform/eclipse.platform.ui/issues/2217 --- .../quickaccess/providers/ViewProvider.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/quickaccess/providers/ViewProvider.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/quickaccess/providers/ViewProvider.java index 9f008f7e222..bd6fc7ba617 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/quickaccess/providers/ViewProvider.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/quickaccess/providers/ViewProvider.java @@ -23,6 +23,8 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.activities.IActivityManager; +import org.eclipse.ui.activities.IIdentifier; import org.eclipse.ui.activities.WorkbenchActivityHelper; import org.eclipse.ui.internal.IWorkbenchGraphicConstants; import org.eclipse.ui.internal.WorkbenchImages; @@ -39,6 +41,11 @@ */ public class ViewProvider extends QuickAccessProvider { + /** + * URI of any view on the platform has this prefix. ex: + * bundleclass://org.eclipse.pde.spy.bundle/org.eclipse.pde.spy.bundle.BundleSpyPart + */ + private static final String BUNDLE_CLASS_SCHEME = "bundleclass://"; //$NON-NLS-1$ private MApplication application; private MWindow window; private Map idToElement = new HashMap<>(); @@ -69,6 +76,7 @@ public QuickAccessElement[] getElements() { } if (idToElement.isEmpty()) { + IActivityManager activityManager = PlatformUI.getWorkbench().getActivitySupport().getActivityManager(); for (MPartDescriptor descriptor : application.getDescriptors()) { String uri = descriptor.getContributionURI(); if (uri != null) { @@ -85,7 +93,15 @@ public QuickAccessElement[] getElements() { idToElement.put(element.getId(), element); } } else { - idToElement.put(id, element); + if (uri.startsWith(BUNDLE_CLASS_SCHEME)) { + String viewQualUri = uri.substring(BUNDLE_CLASS_SCHEME.length()); + IIdentifier identifier = activityManager.getIdentifier(viewQualUri); + if (identifier.isEnabled()) { + idToElement.put(element.getId(), element); + } + } else { + idToElement.put(element.getId(), element); + } } } }