Skip to content

Commit

Permalink
Impl #2402 - Migrate model processors from extension point to OSGi DS
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Fauth <[email protected]>
  • Loading branch information
fipro78 authored and HannesWell committed Nov 7, 2024
1 parent 908db0f commit 10ecda2
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 66 deletions.
5 changes: 5 additions & 0 deletions bundles/org.eclipse.e4.ui.workbench.addons.swt/.project
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dsVersion=V1_4
eclipse.preferences.version=1
enabled=true
generateBundleActivationPolicyLazy=true
path=OSGI-INF
validationErrorLevel=error
validationErrorLevel.missingImplicitUnbindMethod=error
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bin.includes = META-INF/,\
.,\
about.html,\
plugin.properties,\
plugin.xml,\
icons/
icons/,\
OSGI-INF/
src.includes = icons/,\
about.html
26 changes: 0 additions & 26 deletions bundles/org.eclipse.e4.ui.workbench.addons.swt/plugin.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<MAddon> addons = app.getAddons();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<MAddon> addons = app.getAddons();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<MAddon> addons = app.getAddons();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<MAddon> addons = app.getAddons();
Expand Down
5 changes: 4 additions & 1 deletion bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<String, MBindingContext> contexts = new HashMap<>();
private Map<String, MCommand> commands = new HashMap<>();
private Map<String, MBindingTable> tables = new HashMap<>();
private Set<MKeyBinding> 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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<String, MCategory> categories = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<String, MBindingContext> contexts = new HashMap<>();

@Execute
Expand Down
16 changes: 0 additions & 16 deletions bundles/org.eclipse.ui.workbench/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@
<initializer
class="org.eclipse.ui.internal.WorkbenchPreferenceInitializer"/>
</extension>
<extension
id="id1"
point="org.eclipse.e4.workbench.model">
<processor
beforefragment="true"
class="org.eclipse.ui.internal.CommandToModelProcessor">
</processor>
<processor
beforefragment="true"
class="org.eclipse.ui.internal.ContextToModelProcessor">
</processor>
<processor
beforefragment="true"
class="org.eclipse.ui.internal.BindingToModelProcessor">
</processor>
</extension>
<extension point="org.eclipse.ui.themes">
<themeElementCategory
id="org.eclipse.ui.themes.CssTheme"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 vogella GmbH and others.
* Copyright (c) 2018, 2024 vogella GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -74,11 +74,11 @@ public void setup() throws Exception {
bundleContext = bundle.getBundleContext();
bundlesWithPluginXml = List.of("org.eclipse.e4.ui.css.swt", "org.eclipse.e4.ui.model.workbench",
"org.eclipse.e4.ui.workbench.swt", "org.eclipse.ui.forms", "org.eclipse.ui.themes",
"org.eclipse.e4.ui.workbench", "org.eclipse.e4.ui.workbench.addons.swt", "org.eclipse.ui.ide",
"org.eclipse.e4.ui.css.core", "org.eclipse.ui.workbench", "org.eclipse.ui.navigator.resources",
"org.eclipse.ui.navigator", "org.eclipse.ui.views", "org.eclipse.ui.views.properties.tabbed",
"org.eclipse.ui", "org.eclipse.ui.browser", "org.eclipse.e4.ui.css.swt.theme",
"org.eclipse.ui.ide.application", "org.eclipse.ui.monitoring");
"org.eclipse.e4.ui.workbench", "org.eclipse.ui.ide", "org.eclipse.e4.ui.css.core",
"org.eclipse.ui.workbench", "org.eclipse.ui.navigator.resources", "org.eclipse.ui.navigator",
"org.eclipse.ui.views", "org.eclipse.ui.views.properties.tabbed", "org.eclipse.ui",
"org.eclipse.ui.browser", "org.eclipse.e4.ui.css.swt.theme", "org.eclipse.ui.ide.application",
"org.eclipse.ui.monitoring");
}

@Test
Expand Down

0 comments on commit 10ecda2

Please sign in to comment.