diff options
| author | Lars Vogel | 2014-03-02 17:20:07 +0000 |
|---|---|---|
| committer | Lars Vogel | 2014-03-20 23:25:58 +0000 |
| commit | 1f01dc809dd52b4e00143e8d567826a12d5b8898 (patch) | |
| tree | 2f950687bd3f6cc4f7833d52e9dcfd2cc0769265 | |
| parent | 8db76f67073ad0b196f7f14f48c843461d46aaec (diff) | |
| download | eclipse.platform.ui-1f01dc809dd52b4e00143e8d567826a12d5b8898.tar.gz eclipse.platform.ui-1f01dc809dd52b4e00143e8d567826a12d5b8898.tar.xz eclipse.platform.ui-1f01dc809dd52b4e00143e8d567826a12d5b8898.zip | |
org.eclipse.e4.ui.workbench.addons.swt processors should use
ModelService for object creation
Change-Id: I0a6ecfd15a20cc90cefef0a6cf6f8f658e4d442f
Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com>
4 files changed, 45 insertions, 28 deletions
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 b7f7044c1b1..6e99b500859 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 IBM Corporation and others. + * Copyright (c) 2013, 2014 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 429421 *******************************************************************************/ package org.eclipse.e4.ui.workbench.addons.swt; @@ -14,22 +15,25 @@ import java.util.List; import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.e4.ui.model.application.impl.ApplicationFactoryImpl; +import org.eclipse.e4.ui.workbench.modeling.EModelService; +/** + * Model processors which adds the cleanup add-on to the application model + */ public class CleanupProcessor { @Execute - void addCleanupAddon(MApplication app) { + void addCleanupAddon(MApplication app, EModelService modelService) { List<MAddon> addons = app.getAddons(); - // Prevent multiple copies + // prevent multiple copies for (MAddon addon : addons) { if (addon.getContributionURI() - .contains("ui.workbench.addons.cleanupaddon.CleanupAddon")) + .contains("ui.workbench.addons.cleanupaddon.CleanupAddon")) //$NON-NLS-1$ return; } - // Insert the addon into the system - MAddon cleanupAddon = ApplicationFactoryImpl.eINSTANCE.createAddon(); + // adds the add-on to the application model + MAddon cleanupAddon = modelService.createModelElement(MAddon.class); cleanupAddon.setElementId("CleanupAddon"); //$NON-NLS-1$ cleanupAddon .setContributionURI("bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon"); //$NON-NLS-1$ 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 3567a46fc54..03f27af8e15 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 IBM Corporation and others. + * Copyright (c) 2013, 2014 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 429421 *******************************************************************************/ package org.eclipse.e4.ui.workbench.addons.swt; @@ -14,21 +15,24 @@ import java.util.List; import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.e4.ui.model.application.impl.ApplicationFactoryImpl; +import org.eclipse.e4.ui.workbench.modeling.EModelService; +/** + * Model processors which adds the DnD add-on to the application model + */ public class DnDProcessor { @Execute - void addDnDAddon(MApplication app) { + void addDnDAddon(MApplication app, EModelService modelService) { List<MAddon> addons = app.getAddons(); - // Prevent multiple copies + // prevent multiple copies for (MAddon addon : addons) { - if (addon.getContributionURI().contains("ui.workbench.addons.dndaddon.DnDAddon")) + if (addon.getContributionURI().contains("ui.workbench.addons.dndaddon.DnDAddon")) //$NON-NLS-1$ return; } - // Insert the addon into the system - MAddon dndAddon = ApplicationFactoryImpl.eINSTANCE.createAddon(); + // adds the add-on to the application model + MAddon dndAddon = modelService.createModelElement(MAddon.class); dndAddon.setElementId("DnDAddon"); //$NON-NLS-1$ dndAddon.setContributionURI("bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.dndaddon.DnDAddon"); //$NON-NLS-1$ app.getAddons().add(dndAddon); 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 bd0113ae650..339d2656b10 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 IBM Corporation and others. + * Copyright (c) 2013, 2014 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 429421 *******************************************************************************/ package org.eclipse.e4.ui.workbench.addons.swt; @@ -14,21 +15,24 @@ import java.util.List; import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.e4.ui.model.application.impl.ApplicationFactoryImpl; +import org.eclipse.e4.ui.workbench.modeling.EModelService; +/** + * Model processors which adds the MinMax add-on to the application model + */ public class MinMaxProcessor { @Execute - void addMinMaxAddon(MApplication app) { + void addMinMaxAddon(MApplication app, EModelService modelService) { List<MAddon> addons = app.getAddons(); - // Prevent multiple copies + // prevent multiple copies for (MAddon addon : addons) { - if (addon.getContributionURI().contains("ui.workbench.addons.minmax.MinMaxAddon")) + if (addon.getContributionURI().contains("ui.workbench.addons.minmax.MinMaxAddon")) //$NON-NLS-1$ return; } - // Insert the addon into the system - MAddon minMaxAddon = ApplicationFactoryImpl.eINSTANCE.createAddon(); + // add the add-on to the application model + MAddon minMaxAddon = modelService.createModelElement(MAddon.class); minMaxAddon.setElementId("MinMaxAddon"); //$NON-NLS-1$ minMaxAddon .setContributionURI("bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon"); //$NON-NLS-1$ 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 fefbf87a63a..c0f6a24d566 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 IBM Corporation and others. + * Copyright (c) 2013, 2014 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 429421 *******************************************************************************/ package org.eclipse.e4.ui.workbench.addons.swt; @@ -14,22 +15,26 @@ import java.util.List; import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.model.application.MAddon; import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.e4.ui.model.application.impl.ApplicationFactoryImpl; +import org.eclipse.e4.ui.workbench.modeling.EModelService; + +/** + * Model processors which adds the Splitter add-on to the application model + */ public class SplitterProcessor { @Execute - void addSplitterAddon(MApplication app) { + void addSplitterAddon(MApplication app, EModelService modelService) { List<MAddon> addons = app.getAddons(); - // Prevent multiple copies + // prevent multiple copies for (MAddon addon : addons) { if (addon.getContributionURI().contains( - "ui.workbench.addons.splitteraddon.SplitterAddon")) + "ui.workbench.addons.splitteraddon.SplitterAddon")) //$NON-NLS-1$ return; } - // Insert the addon into the system - MAddon splitterAddon = ApplicationFactoryImpl.eINSTANCE.createAddon(); + // adds the add-on to the application model + MAddon splitterAddon = modelService.createModelElement(MAddon.class); splitterAddon.setElementId("SplitterAddon"); //$NON-NLS-1$ splitterAddon .setContributionURI("bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.splitteraddon.SplitterAddon"); //$NON-NLS-1$ |
