Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2014-07-17 10:10:12 -0400
committerBob Brodt2014-07-17 10:10:12 -0400
commit6ddeac20cec050b9617ceb2601652c8d7b66750c (patch)
tree88419ea62873ca6bc40c06ac9c88fd91b192fe19
parentc94f7dcae2e78397d0e10df446885d05dc9c09d7 (diff)
downloadorg.eclipse.bpmn2-modeler-6ddeac20cec050b9617ceb2601652c8d7b66750c.tar.gz
org.eclipse.bpmn2-modeler-6ddeac20cec050b9617ceb2601652c8d7b66750c.tar.xz
org.eclipse.bpmn2-modeler-6ddeac20cec050b9617ceb2601652c8d7b66750c.zip
Obey the "Save BPMNLabel" user preference on save.
Fix rounding error in font size.
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java23
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java26
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/EFontConversionDelegate.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/StyleChangeAdapter.java23
4 files changed, 36 insertions, 37 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 041c4922..bfe369c4 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
@@ -872,6 +872,7 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
protected float minY = Float.MAX_VALUE;
protected int lineNum = 1;
protected int lineOffset = 0;
+ protected Bpmn2Preferences preferences;
@SuppressWarnings("serial")
protected class Bpmn2ModelerXMLString extends XMLString {
@@ -926,6 +927,7 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
public Bpmn2ModelerXMLSave(XMLHelper helper) {
super(helper);
helper.getPrefixToNamespaceMap().clear();
+ preferences = Bpmn2Preferences.getInstance(helper.getResource());
}
@Override
@@ -1176,17 +1178,24 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
}
}
+ if (o instanceof BPMNLabel) {
+ if (!preferences.getSaveBPMNLabels())
+ return;
+ }
+
if (o instanceof BPMNLabelStyle) {
// is anyone still using this BPMNLabelStyle?
// if not, get rid of it.
boolean save = false;
- Definitions definitions = ModelUtil.getDefinitions(o);
- TreeIterator<EObject> iter = definitions.eAllContents();
- while (iter.hasNext()) {
- EObject eo = iter.next();
- if (eo instanceof BPMNLabel) {
- if (((BPMNLabel)eo).getLabelStyle() == o)
- save = true;
+ if (preferences.getSaveBPMNLabels()) {
+ Definitions definitions = ModelUtil.getDefinitions(o);
+ TreeIterator<EObject> iter = definitions.eAllContents();
+ while (iter.hasNext()) {
+ EObject eo = iter.next();
+ if (eo instanceof BPMNLabel) {
+ if (((BPMNLabel)eo).getLabelStyle() == o)
+ save = true;
+ }
}
}
if (!save)
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
index c2f72f7d..873c36fb 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java
@@ -560,19 +560,6 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
return new FontData(f.getName(), f.getSize(), style);
}
- /**
- * @param font
- * @return
- */
- private static Object fontToFontData(org.eclipse.dd.dc.Font f) {
- int style = 0;
- if (f.isIsItalic())
- style |= SWT.ITALIC;
- if (f.isIsBold())
- style |= SWT.BOLD;
- return new FontData(f.getName(), (int)f.getSize(), style);
- }
-
public static Font fontDataToFont(FontData fd) {
Font f = StylesFactory.eINSTANCE.createFont();
f.eSet(StylesPackage.eINSTANCE.getFont_Name(),fd.getName());
@@ -610,7 +597,7 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
Font ret = null;
try {
String name = bpmnFont.getName();
- int height = (int)bpmnFont.getSize();
+ int height = Math.round(bpmnFont.getSize());
boolean italic = bpmnFont.isIsItalic();
boolean bold = bpmnFont.isIsBold();
ret = Graphiti.getGaService().manageFont(diagram, name, height, italic, bold);
@@ -1016,15 +1003,4 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
preferences.setShapeStyle(element,ss);
}
}
-
- public static boolean isDirty(BaseElement element) {
- if (element==null)
- return false;
- Bpmn2Preferences preferences = Bpmn2Preferences.getInstance(element);
- ShapeStyle ssDefault = preferences.getShapeStyle(element);
- ShapeStyle ssElement = getShapeStyle(element);
- String defaultString = ssDefault.toString();
- String elementString = ssElement.toString();
- return !defaultString.equals(elementString);
- }
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/EFontConversionDelegate.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/EFontConversionDelegate.java
index 7fa40fde..d41f3fa6 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/EFontConversionDelegate.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/EFontConversionDelegate.java
@@ -199,6 +199,7 @@ public class EFontConversionDelegate extends DefaultConversionDelegate {
private void setSelectedFont(FontData fd) {
+ fd.setHeight( Math.round(fd.getHeight()) );
FontData[] bestFont = JFaceResources.getFontRegistry().filterData(
new FontData[]{fd}, previewLabel.getDisplay());
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/StyleChangeAdapter.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/StyleChangeAdapter.java
index 9bd92f38..109e5b7e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/StyleChangeAdapter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/StyleChangeAdapter.java
@@ -108,9 +108,7 @@ public class StyleChangeAdapter extends AdapterImpl implements IExtensionValueAd
// or line Routing Style which will be handled by the appropriate Update Features.
if (!(newValue instanceof EEnumLiteral)) {
StyleUtil.applyStyle(ga, businessObject, ss);
- Bpmn2Preferences prefs = Bpmn2Preferences.getInstance(businessObject);
- if (prefs.getSaveBPMNLabels())
- DIUtils.getOrCreateDILabelStyle(businessObject, ss);
+ DIUtils.getOrCreateDILabelStyle(businessObject, ss);
}
// also apply the style to Label
@@ -130,11 +128,26 @@ public class StyleChangeAdapter extends AdapterImpl implements IExtensionValueAd
public boolean shouldSaveElement(EObject o) {
if (ShapeStyle.isStyleObject(o)) {
// this is the "style" object
- return ShapeStyle.isDirty(businessObject);
+ if (businessObject==null) {
+ // which hasn't been attached to anything yet
+ return false;
+ }
+ Bpmn2Preferences preferences = Bpmn2Preferences.getInstance(businessObject);
+ ShapeStyle ssDefault = preferences.getShapeStyle(businessObject);
+ ShapeStyle ssElement = ShapeStyle.getShapeStyle(businessObject);
+ // if the font is the only thing that changed AND if we're serializing
+ // label fonts as BPMNLabelStyle elements, then don't save this empty
+ // <style> object.
+ if (preferences.getSaveBPMNLabels()) {
+ ssElement.setLabelFont( ssDefault.getLabelFont() );
+ }
+ String defaultString = ssDefault.toString();
+ String elementString = ssElement.toString();
+ return !defaultString.equals(elementString);
}
return true;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.bpmn2.modeler.core.adapters.IExtensionValueAdapter#shouldSaveFeature(org.eclipse.emf.ecore.EStructuralFeature)
*/

Back to the top