From d3dd4bf19692884b2a47019724c9c5f51167103f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 31 Jan 2025 09:07:50 +0100 Subject: [PATCH] Enhance the IContributionFactory to filter contributions Currently there is no way for filtering a contribution to the model on a global level. This adds a new method to IContributionFactory#isEnabled that allows extenders to mark a given contribution as being disabled. See https://github.com/eclipse-platform/eclipse.platform.ui/issues/2217 --- .../services/contributions/IContributionFactory.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/contributions/IContributionFactory.java b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/contributions/IContributionFactory.java index d3378ce0fb1..c671623404f 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/contributions/IContributionFactory.java +++ b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/contributions/IContributionFactory.java @@ -16,8 +16,10 @@ import org.eclipse.e4.core.contexts.IEclipseContext; import org.osgi.framework.Bundle; -// TBD this became an utility method to create object from a bundle. -// Change it into an utility method somewhere. +/** + * {@link IContributionFactory} is responsible to create contributions and check + * if a contribution is enabled + */ public interface IContributionFactory { Object create(String uriString, IEclipseContext context); @@ -26,4 +28,8 @@ public interface IContributionFactory { Bundle getBundle(String uriString); + default boolean isEnabled(String uriString) { + return uriString != null; + } + }