Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaged Elaasar2018-04-04 19:16:09 -0400
committerQuentin Le Menez2018-05-31 15:48:16 -0400
commit83a61595154affeb0085144c21df270f0923e705 (patch)
tree2633b7a815dc701dd153f3a875ffa14eb1a87af3 /plugins/emf
parent5b741694e83316ae55fccfa5b950e636d47d4a87 (diff)
downloadorg.eclipse.papyrus-83a61595154affeb0085144c21df270f0923e705.tar.gz
org.eclipse.papyrus-83a61595154affeb0085144c21df270f0923e705.tar.xz
org.eclipse.papyrus-83a61595154affeb0085144c21df270f0923e705.zip
Bug 532101: [AFViewpoints] Make AF editor faster
Bug 532104: [AFViewpoints] Transform your Workspace reference to platform reference - Simplified the AF model wizard by defaulting the root to be Architecture Domain. - Extended the Load Resource action in the AF editor to allow loading AF models from the running platfom. - Added a Resolve All action that can be used on any object in the editor to quickly resolve related references. This can be used on a loaded AF model (from workspace or running platform) to also load its dependencies like elementtypeconfigurtion and palleteconfiguration files. - Made the architecture, elementtypesetconfigurtion, nattableconfiguration, and paletteconfiguration resources extend of a common base class that supports default load/save options. This base class also makes the cross references persist using platform:/platform URIs but upon load, they may resolve to platform:/resource if the resource is available in the workspace. - Refactored uml.architecture, all the elementtypeconfiguration, all palletteconfiguration, and all nattableconfiguration models by changing their cross references to platform:/plugin URI format. - Fixed PasteEObjectConfigurationItemProvider to make the containment reference axisIdentifier show in the editor/property sheet as a containment reference (was necessary to convert its cross references properly) Change-Id: I69b82f53670cbb81e9117ce82c61d7c898080c93 Signed-off-by: Maged Elaasar <melaasar@gmail.com>
Diffstat (limited to 'plugins/emf')
-rwxr-xr-xplugins/emf/org.eclipse.papyrus.emf/META-INF/MANIFEST.MF1
-rwxr-xr-xplugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResource.java17
-rw-r--r--plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResourceWithUUID.java52
-rwxr-xr-xplugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/LoadAndSaveOptionsUtils.java46
4 files changed, 106 insertions, 10 deletions
diff --git a/plugins/emf/org.eclipse.papyrus.emf/META-INF/MANIFEST.MF b/plugins/emf/org.eclipse.papyrus.emf/META-INF/MANIFEST.MF
index f4f59134439..994a37108a9 100755
--- a/plugins/emf/org.eclipse.papyrus.emf/META-INF/MANIFEST.MF
+++ b/plugins/emf/org.eclipse.papyrus.emf/META-INF/MANIFEST.MF
@@ -7,6 +7,7 @@ Bundle-Activator: org.eclipse.papyrus.emf.Activator
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
+ org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)",
org.eclipse.emf.ecore;bundle-version="[2.14.0,3.0.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.14.0,3.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResource.java b/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResource.java
index 964fd4c1a66..7f7d1d9ac5f 100755
--- a/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResource.java
+++ b/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResource.java
@@ -43,26 +43,27 @@ public abstract class AbstractEMFResource extends XMIResourceImpl {
}
/**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#useUUIDs()
+ *
+ * @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#save(java.util.Map)
*
- * @return
+ * @param options
+ * @throws IOException
*/
-
@Override
- protected boolean useUUIDs() {
- return true;
+ public final void save(Map<?, ?> options) throws IOException {
+ super.save(getDefaultSaveOptions());// we bypass the options argument to avoid changes between editors (ExpressionEditor, Ecore Sample Reflexive Editor and Ecore Editor
}
/**
*
- * @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#save(java.util.Map)
+ * @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#load(java.util.Map)
*
* @param options
* @throws IOException
*/
@Override
- public final void save(Map<?, ?> options) throws IOException {
- super.save(getDefaultSaveOptions());// we bypass the options argument to avoid changes between editors (ExpressionEditor, Ecore Sample Reflexive Editor and Ecore Editor
+ public final void load(Map<?, ?> options) throws IOException {
+ super.load(getDefaultLoadOptions());// we bypass the options argument to avoid changes between editors (ExpressionEditor, Ecore Sample Reflexive Editor and Ecore Editor
}
/**
diff --git a/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResourceWithUUID.java b/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResourceWithUUID.java
new file mode 100644
index 00000000000..e589fa0ca1a
--- /dev/null
+++ b/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/AbstractEMFResourceWithUUID.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent LORENZO (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.emf.resources;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * @author Vincent LORENZO
+ * Abstract XMI Resource to extends for EMF model Resource. The goal is to provides the same options (save and load) for the Papyrus EMF models:
+ * <ul>
+ * <li>use ID, instead of position to reference element</li>
+ * <li>common formating rules (ignoring the options given by the editors)</li>
+ * <li>encoding : UTF-8</li>
+ * <li>default values are saved (allow to prevent troubles when default value changed)</li>
+ * <li>...</li>
+ * </ul>
+ */
+public abstract class AbstractEMFResourceWithUUID extends AbstractEMFResource {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param uri
+ */
+ public AbstractEMFResourceWithUUID(final URI uri) {
+ super(uri);
+ }
+
+ /**
+ * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#useUUIDs()
+ *
+ * @return
+ */
+
+ @Override
+ protected boolean useUUIDs() {
+ return true;
+ }
+
+}
diff --git a/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/LoadAndSaveOptionsUtils.java b/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/LoadAndSaveOptionsUtils.java
index 351a95d306d..eafcc90b74d 100755
--- a/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/LoadAndSaveOptionsUtils.java
+++ b/plugins/emf/org.eclipse.papyrus.emf/src/org/eclipse/papyrus/emf/resources/LoadAndSaveOptionsUtils.java
@@ -16,6 +16,9 @@ package org.eclipse.papyrus.emf.resources;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.XMLResource;
@@ -43,7 +46,7 @@ public final class LoadAndSaveOptionsUtils {
// create the save options
SAVE_OPTIONS = new HashMap<Object, Object>();
// idem in Papyrus ModelSet
- SAVE_OPTIONS.put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware());
+ SAVE_OPTIONS.put(XMLResource.OPTION_URI_HANDLER, new PapyrusURIHandler());
// idem in MultiDiagramUtil
@@ -67,7 +70,9 @@ public final class LoadAndSaveOptionsUtils {
LOAD_OPTIONS.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE);
LOAD_OPTIONS.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
LOAD_OPTIONS.put(XMLResource.OPTION_USE_PACKAGE_NS_URI_AS_LOCATION, Boolean.FALSE);
- }
+ // idem in Papyrus ModelSet
+ LOAD_OPTIONS.put(XMLResource.OPTION_URI_HANDLER, new PapyrusURIHandler());
+}
/**
* Constructor.
@@ -94,4 +99,41 @@ public final class LoadAndSaveOptionsUtils {
public static final Map<Object, Object> getSaveOptions() {
return new HashMap<Object, Object>(SAVE_OPTIONS);// we create a copy, to avoid non wanted changes
}
+
+ /**
+ * A URI handler that converts all platform:/resource URIs on save to platform:/plugin format
+ * and loads them back as either platform:/resource (if they exist in the workspace) or
+ * platform:/plugin (if they do not).
+ */
+ protected static class PapyrusURIHandler extends URIHandlerImpl.PlatformSchemeAware {
+
+ @Override
+ public URI deresolve(URI uri) {
+ // Convert all platform:/resource URIs to platform:/plugin format on save
+ if (uri.isPlatformResource()) {
+ String platformString = uri.toPlatformString(true);
+ String fragment = uri.fragment();
+ URI pluginURI = URI.createPlatformPluginURI(platformString, true);
+ pluginURI = pluginURI.appendFragment(fragment);
+ return pluginURI;
+ }
+ return super.deresolve(uri);
+ }
+
+ @Override
+ public URI resolve(URI uri) {
+ // Convert platform:/plugin URIs to platform:/resource format on load if the resource exists in the workspace
+ if (uri.isPlatformPlugin()) {
+ String platformString = uri.toPlatformString(true);
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(platformString);
+ if (resource != null) {
+ String fragment = uri.fragment();
+ URI resourceURI = URI.createPlatformResourceURI(platformString, true);
+ resourceURI = resourceURI.appendFragment(fragment);
+ return resourceURI;
+ }
+ }
+ return super.resolve(uri);
+ }
+ }
}

Back to the top