Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2014-07-17 16:08:08 -0400
committerBob Brodt2014-07-17 16:08:08 -0400
commit04e563def6a9d7a21444a365a5b710c48c634f3a (patch)
treedf0c798873103d9cce0c5d0f528900291868031c
parent231b46442233a32ac155b8e806fc3ad00b08fe73 (diff)
downloadorg.eclipse.bpmn2-modeler-04e563def6a9d7a21444a365a5b710c48c634f3a.tar.gz
org.eclipse.bpmn2-modeler-04e563def6a9d7a21444a365a5b710c48c634f3a.tar.xz
org.eclipse.bpmn2-modeler-04e563def6a9d7a21444a365a5b710c48c634f3a.zip
Added Definitions.exporter and exporterVersion.
Added code to allow insertion of a comment at beginning of document during save. This COULD be used to store diagram origin offset information, for example. See Bug 438604 - Offset in x,y coordinates between *.bpmn and exported Image.
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java52
1 files changed, 46 insertions, 6 deletions
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
index bfe369c4..7b6ffdf8 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
@@ -65,6 +65,7 @@ import org.eclipse.bpmn2.util.XmlExtendedMetadata;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.dd.dc.Bounds;
import org.eclipse.dd.dc.DcFactory;
@@ -93,6 +94,7 @@ import org.eclipse.emf.ecore.util.EObjectWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.XMLLoad;
import org.eclipse.emf.ecore.xmi.XMLResource;
@@ -101,6 +103,7 @@ import org.eclipse.emf.ecore.xmi.impl.ElementHandlerImpl;
import org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl;
import org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl;
import org.eclipse.emf.ecore.xmi.impl.XMLString;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
@@ -957,6 +960,38 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
}
doc = createXMLString();
+
+ if (contents.size()>0 && contents.get(0) instanceof Bpmn2ModelerDocumentRootImpl) {
+ Bpmn2ModelerDocumentRootImpl documentRoot = (Bpmn2ModelerDocumentRootImpl)contents.get(0);
+ Definitions definitions = ModelUtil.getDefinitions(helper.getResource());
+ try {
+ documentRoot.setDeliver(false);
+ documentRoot.eSetDeliver(false);
+ FeatureMap featureMap = documentRoot.getMixed();
+ if (featureMap.size()>0) {
+ // insert a comment before the Definitions node
+ String comment = " origin at X="+(minX<0 ? minX : 0)+
+ " Y="+(minY<0 ? minY : 0)+" ";
+ if (featureMap.get(0).getEStructuralFeature() != XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT) {
+ featureMap.add(0,XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT, comment);
+ }
+ else {
+ FeatureMap.Entry e = FeatureMapUtil.createEntry(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT, comment);
+ featureMap.set(0, e);
+ }
+ }
+ definitions.eSetDeliver(false);
+ definitions.setExporter(Activator.PLUGIN_ID);
+ String version = Platform.getBundle(Activator.PLUGIN_ID).getHeaders().get("Bundle-Version");
+ version = version.replaceAll(".qualifier", "");
+ definitions.setExporterVersion(version);
+ }
+ finally {
+ documentRoot.setDeliver(true);
+ documentRoot.eSetDeliver(true);
+ definitions.eSetDeliver(true);
+ }
+ }
}
protected XMLString createXMLString() {
@@ -977,13 +1012,18 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
if (contents.size()>0 && contents.get(0) instanceof Bpmn2ModelerDocumentRootImpl) {
documentRoot = (Bpmn2ModelerDocumentRootImpl)contents.get(0);
documentRoot.setDeliver(false);
+ documentRoot.eSetDeliver(false);
}
-
- super.endSave(contents);
-
- if (documentRoot!=null) {
- documentRoot.setDeliver(true);
- }
+
+ try {
+ super.endSave(contents);
+ }
+ finally {
+ if (documentRoot!=null) {
+ documentRoot.setDeliver(true);
+ documentRoot.eSetDeliver(true);
+ }
+ }
}
@Override

Back to the top