Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2014-07-16 17:59:06 -0400
committerBob Brodt2014-07-16 17:59:06 -0400
commitc94f7dcae2e78397d0e10df446885d05dc9c09d7 (patch)
tree05cd319c425c12c27529e74e0770ad30824f7bfc
parent0a97863229061d194e0693d1467073c5d4afb8db (diff)
downloadorg.eclipse.bpmn2-modeler-c94f7dcae2e78397d0e10df446885d05dc9c09d7.tar.gz
org.eclipse.bpmn2-modeler-c94f7dcae2e78397d0e10df446885d05dc9c09d7.tar.xz
org.eclipse.bpmn2-modeler-c94f7dcae2e78397d0e10df446885d05dc9c09d7.zip
Added support for BPMNLabelStyle elements
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java90
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/label/UpdateLabelFeature.java1
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java20
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ShapeStyle.java113
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/StyleUtil.java18
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java37
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/StyleChangeAdapter.java29
7 files changed, 239 insertions, 69 deletions
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java
index 54d55f37..dd7f9615 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java
@@ -14,10 +14,8 @@ package org.eclipse.bpmn2.modeler.core.di;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.eclipse.bpmn2.Association;
import org.eclipse.bpmn2.BaseElement;
@@ -31,9 +29,11 @@ import org.eclipse.bpmn2.SequenceFlow;
import org.eclipse.bpmn2.di.BPMNDiagram;
import org.eclipse.bpmn2.di.BPMNEdge;
import org.eclipse.bpmn2.di.BPMNLabel;
+import org.eclipse.bpmn2.di.BPMNLabelStyle;
import org.eclipse.bpmn2.di.BPMNPlane;
import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.di.BpmnDiFactory;
+import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesAdapter;
import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesProvider;
import org.eclipse.bpmn2.modeler.core.preferences.Bpmn2Preferences;
import org.eclipse.bpmn2.modeler.core.preferences.ShapeStyle;
@@ -124,7 +124,7 @@ public class DIUtils {
bounds.setWidth(w);
bounds.setHeight(h);
bpmnShape.setBounds(bounds);
- getOrCreateDILabel(shape, bpmnShape);
+ getOrCreateDILabel(bpmnShape);
Bpmn2Preferences.getInstance(bpmnDiagram.eResource()).applyBPMNDIDefaults(bpmnShape, null);
@@ -236,7 +236,7 @@ public class DIUtils {
point.setY(targetLoc.getY());
bpmnEdge.getWaypoint().add(point);
- getOrCreateDILabel(connection, bpmnEdge);
+ getOrCreateDILabel(bpmnEdge);
DIUtils.addDIElement(bpmnEdge, bpmnDiagram);
ModelUtil.setID(bpmnEdge);
@@ -293,7 +293,7 @@ public class DIUtils {
elements.add(elem);
}
- public static BPMNLabel getOrCreateDILabel(PictogramElement pe, DiagramElement de) {
+ public static BPMNLabel getOrCreateDILabel(DiagramElement de) {
BPMNLabel bpmnLabel = null;
EStructuralFeature feature = de.eClass().getEStructuralFeature("label");
if (feature!=null) {
@@ -313,7 +313,7 @@ public class DIUtils {
}
if (de!=null) {
- BPMNLabel bpmnLabel = getOrCreateDILabel(pe, de);
+ BPMNLabel bpmnLabel = getOrCreateDILabel(de);
if (w==0 && h==0) {
bpmnLabel.setBounds(null);
}
@@ -330,6 +330,74 @@ public class DIUtils {
}
}
+ public static BPMNLabelStyle getDILabelStyle(BaseElement element) {
+ BPMNLabelStyle bpmnStyle = null;
+ DiagramElement de = DIUtils.findDiagramElement(element);
+ if (de instanceof BPMNShape) {
+ BPMNShape bpmnShape = (BPMNShape) de;
+ if (bpmnShape.getLabel() != null) {
+ bpmnStyle = bpmnShape.getLabel().getLabelStyle();
+ }
+ }
+ else if (de instanceof BPMNEdge) {
+ BPMNEdge bpmnEdge = (BPMNEdge) de;
+ if (bpmnEdge.getLabel() != null) {
+ bpmnStyle = bpmnEdge.getLabel().getLabelStyle();
+ }
+ }
+ return bpmnStyle;
+ }
+
+ public static BPMNLabelStyle getOrCreateDILabelStyle(BaseElement element, ShapeStyle ss) {
+ BPMNLabelStyle bpmnStyle = null;
+ DiagramElement de = DIUtils.findDiagramElement(element);
+ BPMNLabel bpmnLabel = getOrCreateDILabel(de);
+ if (bpmnLabel!=null) {
+ BPMNDiagram bpmnDiagram = (BPMNDiagram) de.eContainer().eContainer();
+ for (BPMNLabelStyle ls : bpmnDiagram.getLabelStyle()) {
+ if (ss.equals(ls)) {
+ // found a BPMNLabelStyle that matches the given ShapeStyle
+ // so we can reuse it for this BPMNShape or BPMNEdge object.
+ bpmnStyle = ls;
+ }
+ }
+ if (bpmnStyle==null) {
+ // create a new BPMNLabelStyle and add it to the BPMNDiagram
+ bpmnStyle = BpmnDiFactory.eINSTANCE.createBPMNLabelStyle();
+ bpmnStyle.setFont( ShapeStyle.toBPMNFont(ss.getLabelFont()) );
+ bpmnDiagram.getLabelStyle().add(bpmnStyle);
+ }
+ bpmnLabel.setLabelStyle(bpmnStyle);
+ }
+
+ return bpmnStyle;
+ }
+
+ private static boolean compareDILabelStyle(BPMNLabelStyle ls1, BPMNLabelStyle ls2) {
+ if (ls1==null) {
+ if (ls2==null)
+ return true;
+ return false;
+ }
+ if (ls2==null)
+ return false;
+ org.eclipse.dd.dc.Font f1 = ls1.getFont();
+ org.eclipse.dd.dc.Font f2 = ls2.getFont();
+ if (f1==null) {
+ if (f2==null)
+ return true;
+ return false;
+ }
+ if (f2==null)
+ return false;
+ return f1.getName().equals(f1.getName()) &&
+ f1.getSize() == f2.getSize() &&
+ f1.isIsBold() == f2.isIsBold() &&
+ f1.isIsItalic() == f2.isIsItalic() &&
+ f1.isIsStrikeThrough() == f2.isIsStrikeThrough() &&
+ f1.isIsUnderline() == f2.isIsUnderline();
+ }
+
public static DiagramElement findDiagramElement(List<BPMNDiagram> diagrams, BaseElement bpmnElement) {
for (BPMNDiagram d : diagrams) {
BPMNPlane plane = d.getPlane();
@@ -782,4 +850,14 @@ public class DIUtils {
}
return connections;
}
+
+ public static Diagram getDiagram(BaseElement baseElement) {
+ Resource res = ExtendedPropertiesAdapter.getResource(baseElement);
+ List<PictogramElement> pes = getPictogramElements(res.getResourceSet(), baseElement);
+ if (pes.size()>0) {
+ return Graphiti.getPeService().getDiagramForPictogramElement(pes.get(0));
+ }
+ return null;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/label/UpdateLabelFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/label/UpdateLabelFeature.java
index 7c3c5e18..a1eb86c2 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/label/UpdateLabelFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/label/UpdateLabelFeature.java
@@ -49,7 +49,6 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.ui.services.GraphitiUi;
-import org.eclipse.graphiti.ui.services.IUiLayoutService;
public class UpdateLabelFeature extends AbstractBpmn2UpdateFeature {
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 2111e580..041c4922 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
@@ -41,6 +41,7 @@ import org.eclipse.bpmn2.RootElement;
import org.eclipse.bpmn2.di.BPMNDiagram;
import org.eclipse.bpmn2.di.BPMNEdge;
import org.eclipse.bpmn2.di.BPMNLabel;
+import org.eclipse.bpmn2.di.BPMNLabelStyle;
import org.eclipse.bpmn2.di.BPMNPlane;
import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.di.BpmnDiPackage;
@@ -72,14 +73,12 @@ import org.eclipse.dd.dc.Point;
import org.eclipse.dd.di.DiPackage;
import org.eclipse.dd.di.DiagramElement;
import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EFactory;
@@ -1176,6 +1175,23 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
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 (!save)
+ return;
+ }
float oldX = 0, oldY = 0;
List<Point> oldPoints = null;
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 56910d17..c2f72f7d 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
@@ -13,10 +13,8 @@
package org.eclipse.bpmn2.modeler.core.preferences;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.bpmn2.BaseElement;
+import org.eclipse.bpmn2.di.BPMNLabelStyle;
import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesAdapter;
import org.eclipse.bpmn2.modeler.core.adapters.InsertionAdapter;
import org.eclipse.bpmn2.modeler.core.di.DIUtils;
@@ -27,18 +25,17 @@ import org.eclipse.bpmn2.modeler.core.runtime.TargetRuntime;
import org.eclipse.bpmn2.modeler.core.utils.StyleUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.dd.dc.DcFactory;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.graphiti.mm.algorithms.styles.Font;
import org.eclipse.graphiti.mm.algorithms.styles.StylesFactory;
import org.eclipse.graphiti.mm.algorithms.styles.StylesPackage;
import org.eclipse.graphiti.mm.pictograms.Diagram;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.ColorUtil;
@@ -563,6 +560,19 @@ 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());
@@ -592,7 +602,33 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
}
return ret;
}
+
+ public static Font toGraphitiFont(Diagram diagram, org.eclipse.dd.dc.Font bpmnFont) {
+ if (bpmnFont == null) {
+ return null;
+ }
+ Font ret = null;
+ try {
+ String name = bpmnFont.getName();
+ int height = (int)bpmnFont.getSize();
+ boolean italic = bpmnFont.isIsItalic();
+ boolean bold = bpmnFont.isIsBold();
+ ret = Graphiti.getGaService().manageFont(diagram, name, height, italic, bold);
+ }
+ catch (Exception e) {
+ }
+ return ret;
+ }
+ public static org.eclipse.dd.dc.Font toBPMNFont(Font font) {
+ org.eclipse.dd.dc.Font bpmnFont = DcFactory.eINSTANCE.createFont();
+ bpmnFont.setName(font.getName());
+ bpmnFont.setSize(font.getSize());
+ bpmnFont.setIsBold(font.isBold());
+ bpmnFont.setIsItalic(font.isItalic());
+ return bpmnFont;
+ }
+
/**
* @param pictogramFont
* @return
@@ -799,7 +835,18 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
return style.eGet(f);
return null;
}
-
+
+ private static void setStyleValue(EObject style, String feature, Object value) {
+ try {
+ EStructuralFeature f = style.eClass().getEStructuralFeature(feature);
+ Object oldValue = style.eGet(f);
+ if (value!=null && !value.equals(oldValue))
+ style.eSet(f, value);
+ }
+ catch (Exception e) {
+ }
+ }
+
public Object getStyleValue(BaseElement element, String feature) {
if (STYLE_SHAPE_FOREGROUND.equals(feature))
return colorToRGB(getShapeForeground());
@@ -817,17 +864,6 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
return ShapeStyle.toEENumLiteral(element, getRoutingStyle());
return null;
}
-
- private static void setStyleValue(EObject style, String feature, Object value) {
- try {
- EStructuralFeature f = style.eClass().getEStructuralFeature(feature);
- Object oldValue = style.eGet(f);
- if (value!=null && !value.equals(oldValue))
- style.eSet(f, value);
- }
- catch (Exception e) {
- }
- }
public static boolean isStyleObject(Object object) {
if (object instanceof AnyType) {
@@ -881,12 +917,9 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
if (labelFont!=null) {
// roundabout way to get the Diagram for a Business Object:
// see {@link DIUtils} for details.
- Resource res = ExtendedPropertiesAdapter.getResource(element);
- List<PictogramElement> pes = DIUtils.getPictogramElements(res.getResourceSet(), element);
- if (pes.size()>0) {
- Diagram diagram = Graphiti.getPeService().getDiagramForPictogramElement(pes.get(0));
+ Diagram diagram = DIUtils.getDiagram(element);
+ if (diagram!=null)
ss.setLabelFont(ShapeStyle.toGraphitiFont(diagram, labelFont));
- }
}
else
setStyleValue(style, STYLE_LABEL_FONT, ShapeStyle.toFontData(ss.getLabelFont()));
@@ -903,8 +936,44 @@ public class ShapeStyle extends BaseRuntimeExtensionDescriptor {
style.eSetDeliver(true);
}
+ else {
+ // if this BPMN element has a BPMNShape, and if that BPMNShape has
+ // a BPMNLabelStyle, then get the style attributes from there.
+ BPMNLabelStyle bpmnStyle = DIUtils.getDILabelStyle(element);
+ if (bpmnStyle!=null && bpmnStyle.getFont()!=null) {
+ Diagram diagram = DIUtils.getDiagram(element);
+ if (diagram!=null) {
+ Font f = toGraphitiFont(diagram, bpmnStyle.getFont());
+ ss.setLabelFont(f);
+ }
+ }
+ }
return ss;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ShapeStyle) {
+ return encode(this).equals(encode((ShapeStyle)obj));
+ }
+ if (obj instanceof BPMNLabelStyle) {
+ BPMNLabelStyle ls = (BPMNLabelStyle) obj;
+ ShapeStyle ss = this;
+ org.eclipse.dd.dc.Font f1 = ls.getFont();
+ Font f2 = ss.getLabelFont();
+ if (f1==null) {
+ if (f2==null)
+ return false;
+ }
+ if (f2==null)
+ return false;
+ return f1.getName().equals(f1.getName()) &&
+ f1.getSize() == f2.getSize() &&
+ f1.isIsBold() == f2.isBold() &&
+ f1.isIsItalic() == f2.isItalic();
+ }
+ return super.equals(obj);
+ }
private static Enum fromEENumLiteral(EObject element, EEnumLiteral el) {
try {
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/StyleUtil.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/StyleUtil.java
index 4239e7a0..80ace8ca 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/StyleUtil.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/StyleUtil.java
@@ -16,6 +16,7 @@ import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.modeler.core.preferences.Bpmn2Preferences;
import org.eclipse.bpmn2.modeler.core.preferences.ShapeStyle;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.mm.StyleContainer;
import org.eclipse.graphiti.mm.algorithms.AbstractText;
@@ -31,6 +32,7 @@ import org.eclipse.graphiti.mm.algorithms.styles.StylesPackage;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeService;
@@ -92,6 +94,20 @@ public class StyleUtil {
peService.setPropertyValue(ga, FILL_STYLE, fillStyle.toString());
}
+ public static GraphicsAlgorithm getShapeStyleContainer(PictogramElement pe) {
+ TreeIterator<EObject> childIter = pe.eAllContents();
+ while (childIter.hasNext()) {
+ EObject o = childIter.next();
+ if (o instanceof GraphicsAlgorithm) {
+ GraphicsAlgorithm ga = (GraphicsAlgorithm)o;
+ if (peService.getPropertyValue(ga, Bpmn2Preferences.PREF_SHAPE_STYLE)!=null) {
+ return ga;
+ }
+ }
+ }
+ return null;
+ }
+
public static void applyStyle(GraphicsAlgorithm ga, BaseElement be) {
applyStyle(ga, be, null);
}
@@ -102,7 +118,7 @@ public class StyleUtil {
if (ss==null) {
// fetch ShapeStyle for this BaseElement from the User Preferences
- ss = Bpmn2Preferences.getInstance(be).getShapeStyle(be);
+ ss = ShapeStyle.getShapeStyle(be); //Bpmn2Preferences.getInstance(be).getShapeStyle(be);
}
IColorConstant foreground = ga instanceof AbstractText ? ss.getLabelForeground() : ss.getShapeForeground();
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
index 4c5f6c54..da57fe39 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/BPMN2Editor.java
@@ -1369,31 +1369,22 @@ public class BPMN2Editor extends DiagramEditor implements IPreferenceChangeListe
BaseElement be = BusinessObjectUtil.getFirstElementOfType(pe, BaseElement.class);
// The Business Object class name must match the ShapeStyle type
if (be!=null && be.eClass().getName().equals(name)) {
- // find all of this PE's GraphicsAlgorithrms that have the
- // PREF_SHAPE_STYLE property set - this is the GA to which
- // the ShapeStyle applies.
- TreeIterator<EObject> childIter = pe.eAllContents();
- while (childIter.hasNext()) {
- EObject o = childIter.next();
- if (o instanceof GraphicsAlgorithm) {
- GraphicsAlgorithm ga = (GraphicsAlgorithm)o;
- if (peService.getPropertyValue(ga, Bpmn2Preferences.PREF_SHAPE_STYLE)!=null) {
- // If the ShapeStyle for this BaseElement has already
- // been changed by the user, do not reset it.
- String style = ShapeStyle.encode(ShapeStyle.getShapeStyle(be));
- if (style.equals(event.getNewValue())) {
- StyleUtil.applyStyle(ga, be);
- if (pe instanceof Shape && FeatureSupport.isLabelShape((Shape)pe)) {
- UpdateContext context = new UpdateContext(pe);
- IUpdateFeature feature = fp.getUpdateFeature(context);
- if (feature!=null) {
- feature.update(context);
- }
- }
- }
+ // find this PE's GraphicsAlgorithrms that has the
+ // PREF_SHAPE_STYLE property set - this is the GA to
+ // which the ShapeStyle applies.
+ GraphicsAlgorithm ga = StyleUtil.getShapeStyleContainer(pe);
+ // If the ShapeStyle for this BaseElement has already
+ // been changed by the user, do not reset it.
+ String style = ShapeStyle.encode(ShapeStyle.getShapeStyle(be));
+ if (style.equals(event.getNewValue())) {
+ StyleUtil.applyStyle(ga, be);
+ if (pe instanceof Shape && FeatureSupport.isLabelShape((Shape)pe)) {
+ UpdateContext context = new UpdateContext(pe);
+ IUpdateFeature feature = fp.getUpdateFeature(context);
+ if (feature!=null) {
+ feature.update(context);
}
}
-
}
}
}
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 212a1351..9bd92f38 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
@@ -19,6 +19,7 @@ import org.eclipse.bpmn2.ExtensionAttributeValue;
import org.eclipse.bpmn2.Lane;
import org.eclipse.bpmn2.Participant;
import org.eclipse.bpmn2.modeler.core.adapters.IExtensionValueAdapter;
+import org.eclipse.bpmn2.modeler.core.di.DIUtils;
import org.eclipse.bpmn2.modeler.core.features.GraphitiConstants;
import org.eclipse.bpmn2.modeler.core.preferences.Bpmn2Preferences;
import org.eclipse.bpmn2.modeler.core.preferences.ShapeStyle;
@@ -37,6 +38,7 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.swt.graphics.FontData;
/**
*
@@ -98,25 +100,18 @@ public class StyleChangeAdapter extends AdapterImpl implements IExtensionValueAd
return;
ShapeStyle ss = ShapeStyle.getShapeStyle(businessObject);
- GraphicsAlgorithm ga = null;
- if (businessObject instanceof ChoreographyActivity
- || businessObject instanceof Lane
- || businessObject instanceof Participant) {
- ga = pictogramElement.getGraphicsAlgorithm();
- }
- else if (pictogramElement instanceof ContainerShape && ((ContainerShape)pictogramElement).getChildren().size()>0) {
- Shape shape = ((ContainerShape)pictogramElement).getChildren().get(0);
- ga = shape.getGraphicsAlgorithm();
- }
- else
- ga = pictogramElement.getGraphicsAlgorithm();
+ GraphicsAlgorithm ga = StyleUtil.getShapeStyleContainer(pictogramElement);
if (ga!=null) {
// only certain components, such as color and size apply to the appearance
// of the figure. Other components (of type enum) apply to the Label Position
// or line Routing Style which will be handled by the appropriate Update Features.
- if (!(newValue instanceof EEnumLiteral))
+ if (!(newValue instanceof EEnumLiteral)) {
StyleUtil.applyStyle(ga, businessObject, ss);
+ Bpmn2Preferences prefs = Bpmn2Preferences.getInstance(businessObject);
+ if (prefs.getSaveBPMNLabels())
+ DIUtils.getOrCreateDILabelStyle(businessObject, ss);
+ }
// also apply the style to Label
Shape labelShape = FeatureSupport.getLabelShape(pictogramElement);
@@ -151,7 +146,13 @@ public class StyleChangeAdapter extends AdapterImpl implements IExtensionValueAd
ShapeStyle ss = preferences.getShapeStyle(businessObject);
Object v = ShapeStyle.getStyleValue(o, feature);
if (v!=null) {
- return !v.equals(ss.getStyleValue(businessObject, feature));
+ if (!v.equals(ss.getStyleValue(businessObject, feature))) {
+ if (ShapeStyle.STYLE_LABEL_FONT.equals(feature)) {
+ Bpmn2Preferences prefs = Bpmn2Preferences.getInstance(businessObject);
+ return !prefs.getSaveBPMNLabels();
+ }
+ return true;
+ }
}
return false;
}

Back to the top