Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2013-04-11 16:53:04 +0000
committerSopot Cela2013-04-11 16:53:04 +0000
commit28d1671bed8f19c1f3e62fc1d1e331552c134f6c (patch)
treeb900d3a0b555fdc663717997ddedd91971c294ec
parent3100214f24bf46276da52d860c4f3722fcf253e7 (diff)
downloadeclipse.platform.ui.tools-28d1671bed8f19c1f3e62fc1d1e331552c134f6c.tar.gz
eclipse.platform.ui.tools-28d1671bed8f19c1f3e62fc1d1e331552c134f6c.tar.xz
eclipse.platform.ui.tools-28d1671bed8f19c1f3e62fc1d1e331552c134f6c.zip
Bug 395371 - Wizard to convert part of the application model to a
fragment
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/OSGI-INF/modelextractor.xml7
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/build.properties5
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java24
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IModelExtractor.java12
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java27
7 files changed, 59 insertions, 19 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF
index ca3b1213..c4ae4d5f 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF
@@ -31,6 +31,6 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
org.eclipse.search;bundle-version="3.7.0",
org.eclipse.text;bundle-version="3.5.100",
org.eclipse.e4.ui.model.workbench;bundle-version="1.0.0"
-Service-Component: OSGI-INF/pdecontributionprovider.xml, OSGI-INF/xmiresourcecontextfunction.xml, OSGI-INF/projectfunction.xml, OSGI-INF/pdee4xmiprovider.xml, OSGI-INF/pdeextensionlookup.xml
+Service-Component: OSGI-INF/pdecontributionprovider.xml, OSGI-INF/xmiresourcecontextfunction.xml, OSGI-INF/projectfunction.xml, OSGI-INF/pdee4xmiprovider.xml, OSGI-INF/pdeextensionlookup.xml, OSGI-INF/modelextractor.xml
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/OSGI-INF/modelextractor.xml b/bundles/org.eclipse.e4.tools.emf.editor3x/OSGI-INF/modelextractor.xml
new file mode 100644
index 00000000..c2dbd85c
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/OSGI-INF/modelextractor.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.e4.tools.emf.editor3x.modelextractor">
+ <implementation class="org.eclipse.e4.tools.emf.editor3x.ModelExtractor"/>
+ <service>
+ <provide interface="org.eclipse.e4.tools.emf.ui.common.IModelExtractor"/>
+ </service>
+</scr:component>
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/build.properties b/bundles/org.eclipse.e4.tools.emf.editor3x/build.properties
index 13160ee8..9fb99e10 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/build.properties
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/build.properties
@@ -1,9 +1,8 @@
output.. = bin/
+source.. = src/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/,\
- OSGI-INF/,\
about.html,\
- OSGI-INF/pdeextensionlookup.xml
-source.. = src/
+ OSGI-INF/
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java
new file mode 100644
index 00000000..ee3f1556
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java
@@ -0,0 +1,24 @@
+package org.eclipse.e4.tools.emf.editor3x;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.internal.tools.wizards.model.ExtractContributionModelWizard;
+import org.eclipse.e4.tools.emf.ui.common.IModelExtractor;
+import org.eclipse.e4.ui.model.application.MApplicationElement;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+@SuppressWarnings("restriction")
+public class ModelExtractor implements IModelExtractor {
+
+ public boolean extract(Shell shell, IProject project,
+ List<MApplicationElement> maes) {
+ ExtractContributionModelWizard extractContributionModelWizard = new ExtractContributionModelWizard(maes);
+ extractContributionModelWizard.setup(project);
+ WizardDialog wizardDialog = new WizardDialog(shell, extractContributionModelWizard);
+ return wizardDialog.open() == WizardDialog.OK;
+ }
+
+
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.emf.ui/META-INF/MANIFEST.MF
index b2aafdb3..a90c35b1 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools.emf.ui/META-INF/MANIFEST.MF
@@ -31,7 +31,6 @@ Require-Bundle: org.eclipse.core.databinding;bundle-version="1.3.0",
org.eclipse.jface.text;bundle-version="3.7.0",
org.eclipse.e4.ui.widgets;bundle-version="0.11.0",
org.eclipse.equinox.preferences;bundle-version="3.4.0",
- org.eclipse.e4.tools;bundle-version="0.12.0",
org.eclipse.e4.ui.workbench.swt;bundle-version="0.10.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.9.0"
Bundle-ActivationPolicy: lazy
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IModelExtractor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IModelExtractor.java
new file mode 100644
index 00000000..c5b840e1
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IModelExtractor.java
@@ -0,0 +1,12 @@
+package org.eclipse.e4.tools.emf.ui.common;
+
+import java.util.List;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.ui.model.application.MApplicationElement;
+import org.eclipse.swt.widgets.Shell;
+
+public interface IModelExtractor {
+
+ boolean extract(Shell shell, IProject project, List<MApplicationElement> maes);
+
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
index 15142485..cd285a87 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -13,6 +13,7 @@
package org.eclipse.e4.tools.emf.ui.internal.common;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -44,13 +45,13 @@ import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.extensions.Preference;
import org.eclipse.e4.core.services.contributions.IContributionFactory;
-import org.eclipse.e4.internal.tools.wizards.model.ExtractContributionModelWizard;
import org.eclipse.e4.tools.emf.ui.common.EStackLayout;
import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator;
import org.eclipse.e4.tools.emf.ui.common.IEditorDescriptor;
import org.eclipse.e4.tools.emf.ui.common.IEditorFeature;
import org.eclipse.e4.tools.emf.ui.common.IEditorFeature.FeatureClass;
import org.eclipse.e4.tools.emf.ui.common.IExtensionLookup;
+import org.eclipse.e4.tools.emf.ui.common.IModelExtractor;
import org.eclipse.e4.tools.emf.ui.common.IModelResource;
import org.eclipse.e4.tools.emf.ui.common.IScriptingSupport;
import org.eclipse.e4.tools.emf.ui.common.ISelectionProviderService;
@@ -202,7 +203,6 @@ import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
@@ -298,6 +298,10 @@ public class ModelEditor {
@Translation
private Messages messages;
+ @Inject
+ @Optional
+ private IModelExtractor modelExtractor;
+
private ObservablesManager obsManager;
private final IResourcePool resourcePool;
@@ -645,7 +649,7 @@ public class ModelEditor {
manager.add(new Separator());
// build the extract action
- if ((!((VirtualEntry<?>) s.getFirstElement()).getList().isEmpty()) && (!isModelFragment()))
+ if ((!((VirtualEntry<?>) s.getFirstElement()).getList().isEmpty()) && (!isModelFragment()) && modelExtractor != null) {
manager.add(new Action(messages.ModelEditor_ExtractFragment, ImageDescriptor.createFromImage(resourcePool.getImageUnchecked(ResourceProvider.IMG_ModelFragments))) {
public void run() {
VirtualEntry<?> ve = (VirtualEntry<?>) s.getFirstElement();
@@ -661,10 +665,8 @@ public class ModelEditor {
while (iterator.hasNext()) {
maes.add((MApplicationElement) iterator.next());
}
- ExtractContributionModelWizard extractContributionModelWizard = new ExtractContributionModelWizard(maes);
- extractContributionModelWizard.setup(project);
- WizardDialog wizardDialog = new WizardDialog(viewer.getControl().getShell(), extractContributionModelWizard);
- if (wizardDialog.open() == WizardDialog.OK) {
+
+ if (modelExtractor.extract(viewer.getControl().getShell(), project, maes)) {
for (MApplicationElement mae : maes) {
Command cmd = DeleteCommand.create(ModelEditor.this.modelProvider.getEditingDomain(), mae);
if (cmd.canExecute()) {
@@ -674,7 +676,7 @@ public class ModelEditor {
}
};
});
-
+ }
} else {
final EObject o = (EObject) s.getFirstElement();
@@ -799,7 +801,7 @@ public class ModelEditor {
}
}
- if ((s.getFirstElement() instanceof MApplicationElement) && (!isModelFragment()) && (!(s.getFirstElement() instanceof MApplication)))
+ if ((s.getFirstElement() instanceof MApplicationElement) && (!isModelFragment()) && (!(s.getFirstElement() instanceof MApplication)) && modelExtractor != null) {
manager.add(new Action(messages.ModelEditor_ExtractFragment, ImageDescriptor.createFromImage(resourcePool.getImageUnchecked(ResourceProvider.IMG_ModelFragments))) {
public void run() {
MApplicationElement oe = (MApplicationElement) s.getFirstElement();
@@ -809,19 +811,16 @@ public class ModelEditor {
MessageDialog.openError(viewer.getControl().getShell(), null, messages.ModelEditor_ExtractFragment_NoParentId);
return;
}
- ExtractContributionModelWizard extractContributionModelWizard = new ExtractContributionModelWizard(oe);
- extractContributionModelWizard.setup(project);
- WizardDialog wizardDialog = new WizardDialog(viewer.getControl().getShell(), extractContributionModelWizard);
- if (wizardDialog.open() == WizardDialog.OK) {
+ if (modelExtractor.extract(viewer.getControl().getShell(), project, Collections.singletonList(oe))) {
Command cmd = DeleteCommand.create(ModelEditor.this.modelProvider.getEditingDomain(), oe);
if (cmd.canExecute()) {
ModelEditor.this.modelProvider.getEditingDomain().getCommandStack().execute(cmd);
}
}
-
};
});
+ }
if (addSeparator) {
manager.add(new Separator());

Back to the top