Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2018-02-16 12:18:24 +0000
committervincent lorenzo2018-02-27 14:42:36 +0000
commitcff5c9af3804ec54a7565d9f527a0039147589d2 (patch)
tree200e8f19d3c9bf5d6d9d4554e5c82a6203a90bd3 /plugins/infra
parent2254db96aee5eebb8d4df751760216ca06c87f11 (diff)
downloadorg.eclipse.papyrus-cff5c9af3804ec54a7565d9f527a0039147589d2.tar.gz
org.eclipse.papyrus-cff5c9af3804ec54a7565d9f527a0039147589d2.tar.xz
org.eclipse.papyrus-cff5c9af3804ec54a7565d9f527a0039147589d2.zip
Bug 531270: [EMF][Expressions]Papyrus must provide a common way to save and load all Papyrus EMF models with the same options
Change-Id: I49305997e6e80c4ef7e3fb32bb364a2d20d1dd0c Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins/infra')
-rwxr-xr-xplugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/META-INF/MANIFEST.MF3
-rwxr-xr-xplugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/src/org/eclipse/papyrus/infra/emf/expressions/util/custom/ExpressionsResource.java76
2 files changed, 5 insertions, 74 deletions
diff --git a/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/META-INF/MANIFEST.MF b/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/META-INF/MANIFEST.MF
index cb78dded60c..d31809754d7 100755
--- a/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/META-INF/MANIFEST.MF
+++ b/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@ Export-Package: org.eclipse.papyrus.infra.emf.expressions,
org.eclipse.papyrus.infra.emf.expressions.utils
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)";resolution:=optional;x-installation:=greedy,
org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)",
- org.eclipse.emf.ecore.xmi;bundle-version="[2.12.0,3.0.0)"
+ org.eclipse.emf.ecore.xmi;bundle-version="[2.12.0,3.0.0)",
+ org.eclipse.papyrus.emf;bundle-version="[1.0.0,2.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-Description: %Bundle-Description
diff --git a/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/src/org/eclipse/papyrus/infra/emf/expressions/util/custom/ExpressionsResource.java b/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/src/org/eclipse/papyrus/infra/emf/expressions/util/custom/ExpressionsResource.java
index 24a56d44303..2891e2fe747 100755
--- a/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/src/org/eclipse/papyrus/infra/emf/expressions/util/custom/ExpressionsResource.java
+++ b/plugins/infra/emf/expressions/org.eclipse.papyrus.infra.emf.expressions/src/org/eclipse/papyrus/infra/emf/expressions/util/custom/ExpressionsResource.java
@@ -12,22 +12,16 @@
*/
package org.eclipse.papyrus.infra.emf.expressions.util.custom;
-import java.io.IOException;
-import java.util.Map;
-
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+import org.eclipse.papyrus.emf.resources.AbstractEMFResource;
/**
*
* We create our own resource to manage the save options with (I hope) no doubt.
- * The goal is to avoid formatting trouble between editors
+ * The goal is to avoid formatting trouble between editors, to use ID, and to save default values, as provided by the super class
*
*/
-public class ExpressionsResource extends XMIResourceImpl {
+public class ExpressionsResource extends AbstractEMFResource {
/**
* The extension for the file owning Expressions
@@ -44,68 +38,4 @@ public class ExpressionsResource extends XMIResourceImpl {
super(uri);
}
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#useUUIDs()
- *
- * @return
- */
-
- @Override
- protected boolean useUUIDs() {
- return true;
- }
-
- @Override
- public 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.xmi.impl.XMLResourceImpl#getDefaultSaveOptions()
- *
- * @return
- */
-
- @Override
- public Map<Object, Object> getDefaultSaveOptions() {
- if (null == this.defaultSaveOptions) {
- Map<Object, Object> options = super.getDefaultSaveOptions();
-
- // idem in Papyrus ModelSet
- options.put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware());
-
-
- // idem in MultiDiagramUtil
- options.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
- options.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
-
- // formating option about the size of the line in the file
- // options.put(XMLResource.OPTION_LINE_WIDTH, 10);
- options.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
-
- }
- return this.defaultSaveOptions;
-
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#getDefaultLoadOptions()
- *
- * @return
- */
-
- @Override
- public Map<Object, Object> getDefaultLoadOptions() {
- if (null == this.defaultLoadOptions) {
- Map<Object, Object> options = super.getDefaultLoadOptions();
- // the same as in Papyrus ModelSet
- options.put(XMLResource.OPTION_DEFER_ATTACHMENT, true);
- options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
- options.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE);
- options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
- options.put(XMLResource.OPTION_USE_PACKAGE_NS_URI_AS_LOCATION, Boolean.FALSE);
- }
- return this.defaultLoadOptions;
- }
-
}

Back to the top