From 10ecda2e39840fd5a78692d5b6cbf43a1febef27 Mon Sep 17 00:00:00 2001 From: Dirk Fauth Date: Thu, 7 Nov 2024 13:02:57 +0100 Subject: [PATCH] Impl #2402 - Migrate model processors from extension point to OSGi DS Signed-off-by: Dirk Fauth --- .../.project | 5 ++++ .../org.eclipse.pde.ds.annotations.prefs | 7 +++++ .../META-INF/MANIFEST.MF | 4 +++ .../build.properties | 4 +-- .../plugin.xml | 26 ------------------- .../addons/swt/CleanupProcessor.java | 7 +++-- .../ui/workbench/addons/swt/DnDProcessor.java | 7 +++-- .../workbench/addons/swt/MinMaxProcessor.java | 7 +++-- .../addons/swt/SplitterProcessor.java | 8 +++--- .../META-INF/MANIFEST.MF | 5 +++- .../ui/internal/BindingToModelProcessor.java | 18 +++++++++++-- .../ui/internal/CommandToModelProcessor.java | 7 +++-- .../ui/internal/ContextToModelProcessor.java | 7 +++-- bundles/org.eclipse.ui.workbench/plugin.xml | 16 ------------ .../tests/pluginchecks/PluginWalkerTest.java | 12 ++++----- 15 files changed, 74 insertions(+), 66 deletions(-) create mode 100644 bundles/org.eclipse.e4.ui.workbench.addons.swt/.settings/org.eclipse.pde.ds.annotations.prefs delete mode 100644 bundles/org.eclipse.e4.ui.workbench.addons.swt/plugin.xml diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/.project b/bundles/org.eclipse.e4.ui.workbench.addons.swt/.project index 2091c485f6e..8e8b8db761b 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/.project +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/.project @@ -30,6 +30,11 @@ + + org.eclipse.pde.ds.core.builder + + + org.eclipse.m2e.core.maven2Nature diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/.settings/org.eclipse.pde.ds.annotations.prefs b/bundles/org.eclipse.e4.ui.workbench.addons.swt/.settings/org.eclipse.pde.ds.annotations.prefs new file mode 100644 index 00000000000..5faf08b7d5c --- /dev/null +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/.settings/org.eclipse.pde.ds.annotations.prefs @@ -0,0 +1,7 @@ +dsVersion=V1_4 +eclipse.preferences.version=1 +enabled=true +generateBundleActivationPolicyLazy=true +path=OSGI-INF +validationErrorLevel=error +validationErrorLevel.missingImplicitUnbindMethod=error diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.workbench.addons.swt/META-INF/MANIFEST.MF index d1349e8e07e..96bf7818898 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/META-INF/MANIFEST.MF @@ -18,6 +18,10 @@ Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="1.0.0", org.eclipse.e4.ui.di;bundle-version="0.10.0", org.eclipse.e4.ui.services;bundle-version="1.0.0", org.eclipse.emf.ecore.xmi;bundle-version="2.7.0" +Service-Component: OSGI-INF/org.eclipse.e4.ui.workbench.addons.swt.CleanupProcessor.xml, + OSGI-INF/org.eclipse.e4.ui.workbench.addons.swt.DnDProcessor.xml, + OSGI-INF/org.eclipse.e4.ui.workbench.addons.swt.MinMaxProcessor.xml, + OSGI-INF/org.eclipse.e4.ui.workbench.addons.swt.SplitterProcessor.xml Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy Import-Package: jakarta.annotation;version="[2.1.0,3.0.0)", diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/build.properties b/bundles/org.eclipse.e4.ui.workbench.addons.swt/build.properties index 774cbbd3226..cf9fdf20869 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/build.properties +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/build.properties @@ -17,7 +17,7 @@ bin.includes = META-INF/,\ .,\ about.html,\ plugin.properties,\ - plugin.xml,\ - icons/ + icons/,\ + OSGI-INF/ src.includes = icons/,\ about.html diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/plugin.xml b/bundles/org.eclipse.e4.ui.workbench.addons.swt/plugin.xml deleted file mode 100644 index f6c46652e79..00000000000 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/plugin.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/CleanupProcessor.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/CleanupProcessor.java index 190c518ff0f..f50a82be30c 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/CleanupProcessor.java +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/CleanupProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 IBM Corporation and others. + * Copyright (c) 2013, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -19,11 +19,14 @@ import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.e4.ui.workbench.modeling.IModelProcessorContribution; +import org.osgi.service.component.annotations.Component; /** * Model processors which adds the cleanup add-on to the application model */ -public class CleanupProcessor { +@Component +public class CleanupProcessor implements IModelProcessorContribution { @Execute void addCleanupAddon(MApplication app, EModelService modelService) { List addons = app.getAddons(); diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/DnDProcessor.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/DnDProcessor.java index b0a755230b3..3c89c46f14e 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/DnDProcessor.java +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/DnDProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 IBM Corporation and others. + * Copyright (c) 2013, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -19,11 +19,14 @@ import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.e4.ui.workbench.modeling.IModelProcessorContribution; +import org.osgi.service.component.annotations.Component; /** * Model processors which adds the DnD add-on to the application model */ -public class DnDProcessor { +@Component +public class DnDProcessor implements IModelProcessorContribution { @Execute void addDnDAddon(MApplication app, EModelService modelService) { List addons = app.getAddons(); diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/MinMaxProcessor.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/MinMaxProcessor.java index 075825f72a7..463ff6a32bb 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/MinMaxProcessor.java +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/MinMaxProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 IBM Corporation and others. + * Copyright (c) 2013, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -19,11 +19,14 @@ import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.e4.ui.workbench.modeling.IModelProcessorContribution; +import org.osgi.service.component.annotations.Component; /** * Model processors which adds the MinMax add-on to the application model */ -public class MinMaxProcessor { +@Component +public class MinMaxProcessor implements IModelProcessorContribution { @Execute void addMinMaxAddon(MApplication app, EModelService modelService) { List addons = app.getAddons(); diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/SplitterProcessor.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/SplitterProcessor.java index 8c1130cc85a..823353040ac 100644 --- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/SplitterProcessor.java +++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/swt/SplitterProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 IBM Corporation and others. + * Copyright (c) 2013, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -19,12 +19,14 @@ import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.e4.ui.workbench.modeling.IModelProcessorContribution; +import org.osgi.service.component.annotations.Component; /** * Model processors which adds the Splitter add-on to the application model */ - -public class SplitterProcessor { +@Component +public class SplitterProcessor implements IModelProcessorContribution { @Execute void addSplitterAddon(MApplication app, EModelService modelService) { List addons = app.getAddons(); diff --git a/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF index 36729f7f926..b43589cf1f6 100644 --- a/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF @@ -136,5 +136,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Capability: osgi.extender; filter:="(&(osgi.extender=osgi.component)(version>=1.2)(!(version>=2.0)))" Automatic-Module-Name: org.eclipse.ui.workbench -Service-Component: OSGI-INF/org.eclipse.ui.internal.WindowsDefenderConfigurator.xml, +Service-Component: OSGI-INF/org.eclipse.ui.internal.BindingToModelProcessor.xml, + OSGI-INF/org.eclipse.ui.internal.CommandToModelProcessor.xml, + OSGI-INF/org.eclipse.ui.internal.ContextToModelProcessor.xml, + OSGI-INF/org.eclipse.ui.internal.WindowsDefenderConfigurator.xml, OSGI-INF/org.eclipse.ui.internal.themes.ColorAndFontProviderImpl.xml diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/BindingToModelProcessor.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/BindingToModelProcessor.java index 9def779f0de..15d160e95d5 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/BindingToModelProcessor.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/BindingToModelProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 IBM Corporation and others. + * Copyright (c) 2010, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -33,19 +33,33 @@ import org.eclipse.e4.ui.model.application.commands.MCommandsFactory; import org.eclipse.e4.ui.model.application.commands.MKeyBinding; import org.eclipse.e4.ui.model.application.commands.impl.CommandsFactoryImpl; +import org.eclipse.e4.ui.workbench.modeling.IModelProcessorContribution; import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.bindings.Binding; import org.eclipse.jface.bindings.BindingManager; import org.eclipse.ui.internal.keys.BindingPersistence; import org.eclipse.ui.internal.keys.BindingService; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; -public class BindingToModelProcessor { +@Component(service = IModelProcessorContribution.class) +public class BindingToModelProcessor implements IModelProcessorContribution { private Map contexts = new HashMap<>(); private Map commands = new HashMap<>(); private Map tables = new HashMap<>(); private Set keys = new HashSet<>(); + // define dependencies to CommandToModelProcessor and ContextToModelProcessor to + // ensure these two IModelProcessorContributions are registered before this + // BindingToModelProcessor + + @Reference + private CommandToModelProcessor commandToModelProcessor; + + @Reference + private ContextToModelProcessor contextToModelProcessor; + @Execute void process(final MApplication application, IEclipseContext context) { gatherContexts(application.getRootContext()); diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/CommandToModelProcessor.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/CommandToModelProcessor.java index dceb328dde1..d295b399c5f 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/CommandToModelProcessor.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/CommandToModelProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2018 IBM Corporation and others. + * Copyright (c) 2010, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -30,12 +30,15 @@ import org.eclipse.e4.ui.model.application.commands.MCategory; import org.eclipse.e4.ui.model.application.commands.MCommand; import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.e4.ui.workbench.modeling.IModelProcessorContribution; import org.eclipse.ui.internal.commands.CommandPersistence; +import org.osgi.service.component.annotations.Component; /** * @since 3.5 */ -public class CommandToModelProcessor { +@Component(service = { IModelProcessorContribution.class, CommandToModelProcessor.class }) +public class CommandToModelProcessor implements IModelProcessorContribution { private Map categories = new HashMap<>(); diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/ContextToModelProcessor.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/ContextToModelProcessor.java index be8c2bea3f8..1b1db7ff996 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/ContextToModelProcessor.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/ContextToModelProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 IBM Corporation and others. + * Copyright (c) 2010, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -26,12 +26,15 @@ import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.commands.MBindingContext; import org.eclipse.e4.ui.model.application.commands.impl.CommandsFactoryImpl; +import org.eclipse.e4.ui.workbench.modeling.IModelProcessorContribution; import org.eclipse.ui.internal.contexts.ContextPersistence; +import org.osgi.service.component.annotations.Component; /** * @since 3.5 */ -public class ContextToModelProcessor { +@Component(service = { IModelProcessorContribution.class, ContextToModelProcessor.class }) +public class ContextToModelProcessor implements IModelProcessorContribution { private Map contexts = new HashMap<>(); @Execute diff --git a/bundles/org.eclipse.ui.workbench/plugin.xml b/bundles/org.eclipse.ui.workbench/plugin.xml index 4bb0ed0b704..60430be86db 100644 --- a/bundles/org.eclipse.ui.workbench/plugin.xml +++ b/bundles/org.eclipse.ui.workbench/plugin.xml @@ -7,22 +7,6 @@ - - - - - - - -