Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2015-06-10 08:19:18 +0000
committerCamille Letavernier2015-06-10 08:19:18 +0000
commit6030e90279aab8cd1d5b92e166065fb3d1144555 (patch)
tree54ee528e5c82442b7d872a6da4d5e6e68fc045b9
parent0b0763723117d2c15ff1c34953808798145997a5 (diff)
downloadorg.eclipse.papyrus-6030e90279aab8cd1d5b92e166065fb3d1144555.tar.gz
org.eclipse.papyrus-6030e90279aab8cd1d5b92e166065fb3d1144555.tar.xz
org.eclipse.papyrus-6030e90279aab8cd1d5b92e166065fb3d1144555.zip
Bug 469630 - Must add named style change listener to Edit Part.
Change-Id: I5af5a9fd44faf8437ed74106d299b8efc44a4e7c Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/databinding/custom/AbstractCustomStyleObservableValue.java11
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java96
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java42
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java139
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java112
5 files changed, 387 insertions, 13 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/databinding/custom/AbstractCustomStyleObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/databinding/custom/AbstractCustomStyleObservableValue.java
index f385593ad2c..52712763b5f 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/databinding/custom/AbstractCustomStyleObservableValue.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/databinding/custom/AbstractCustomStyleObservableValue.java
@@ -117,9 +117,14 @@ public abstract class AbstractCustomStyleObservableValue extends AbstractObserva
@Override
public void dispose() {
- source.eAdapters().remove(listener);
- listener.dispose();
- listener = null;
+ if (isDisposed()) {
+ return;
+ }
+ if (listener != null) {
+ source.eAdapters().remove(listener);
+ listener.dispose();
+ listener = null;
+ }
super.dispose();
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java
index c814d432191..ad3536eaa08 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/PapyrusLabelEditPart.java
@@ -15,6 +15,9 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.editpart;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.resources.IResource;
import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.IFigure;
@@ -22,6 +25,7 @@ import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
@@ -34,6 +38,10 @@ import org.eclipse.gmf.runtime.diagram.ui.internal.figures.ResizableLabelLocator
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.BorderDisplayEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.LabelAlignmentEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.LabelPrimarySelectionEditPolicy;
@@ -60,6 +68,40 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart implements Name
/** The affixed label locator. */
protected IPapyrusBorderItemLocator borderLabelLocator = null;
+ /** The labelConstrained Observable */
+ private IObservableValue labelConstrainedObservable;
+
+ /** The namedStyle Listener */
+ private IChangeListener namedStyleListener = new IChangeListener() {
+
+ @Override
+ public void handleChange(ChangeEvent event) {
+ refresh();
+
+ }
+
+ };
+
+ /** The position Observable */
+ private IObservableValue positionObservable;
+
+ /** The labelOffsetX Observable */
+ private IObservableValue labelOffsetXObservable;
+
+ /** The labelOffsety Observable */
+ private IObservableValue labelOffsetYObservable;
+
+ /** The leftMargin Observable */
+ private IObservableValue leftMarginObservable;
+
+ /** The rightMargin Observable */
+ private IObservableValue rightMarginObservable;
+
+ /** The topMargin Observable */
+ private IObservableValue topMarginObservable;
+
+ /** The bottomMargin Observable */
+ private IObservableValue bottomMarginObservable;
public PapyrusLabelEditPart(View view) {
super(view);
@@ -280,6 +322,58 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart implements Name
}
/**
+ * Adds listener to handle named Style modifications.
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+
+ View view = (View) getModel();
+ EditingDomain domain = EMFHelper.resolveEditingDomain(view);
+
+ labelConstrainedObservable = new CustomBooleanStyleObservableValue(view, domain, LABEL_CONSTRAINED);
+ labelConstrainedObservable.addChangeListener(namedStyleListener);
+
+ positionObservable = new CustomStringStyleObservableValue(view, domain, POSITION);
+ positionObservable.addChangeListener(namedStyleListener);
+
+ labelOffsetXObservable = new CustomIntStyleObservableValue(view, domain, LABEL_OFFSET_X);
+ labelOffsetXObservable.addChangeListener(namedStyleListener);
+
+ labelOffsetYObservable = new CustomIntStyleObservableValue(view, domain, LABEL_OFFSET_Y);
+ labelOffsetYObservable.addChangeListener(namedStyleListener);
+
+ leftMarginObservable = new CustomIntStyleObservableValue(view, domain, LEFT_MARGIN_PROPERTY);
+ leftMarginObservable.addChangeListener(namedStyleListener);
+
+ rightMarginObservable = new CustomIntStyleObservableValue(view, domain, RIGHT_MARGIN_PROPERTY);
+ rightMarginObservable.addChangeListener(namedStyleListener);
+
+ topMarginObservable = new CustomIntStyleObservableValue(view, domain, TOP_MARGIN_PROPERTY);
+ topMarginObservable.addChangeListener(namedStyleListener);
+
+ bottomMarginObservable = new CustomIntStyleObservableValue(view, domain, BOTTOM_MARGIN_PROPERTY);
+ bottomMarginObservable.addChangeListener(namedStyleListener);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#removeNotationalListeners()
+ *
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ labelConstrainedObservable.dispose();
+ positionObservable.dispose();
+ labelOffsetXObservable.dispose();
+ labelOffsetYObservable.dispose();
+ leftMarginObservable.dispose();
+ rightMarginObservable.dispose();
+ topMarginObservable.dispose();
+ bottomMarginObservable.dispose();
+ }
+
+ /**
* Gets the default label offset y.
*
* @return the default label offset y
@@ -355,7 +449,7 @@ public abstract class PapyrusLabelEditPart extends LabelEditPart implements Name
}
}
}
-
+
/**
* Workaround for bug #465611, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=465611
*/
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
index c2aa9b1839b..08c0403b6e0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/FloatingLabelEditPart.java
@@ -8,11 +8,16 @@
*
* Contributors:
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
@@ -28,6 +33,19 @@ public class FloatingLabelEditPart extends PapyrusLabelEditPart implements Named
/** The Constant DEFAULT_LABEL_DISPLAYED. */
private static final boolean DEFAULT_LABEL_DISPLAYED = false;
+ /** The isLabelDisplayed Observable */
+ private IObservableValue labelDisplayedObservable;
+
+ /** The namedStyle Listener */
+ private IChangeListener namedStyleListener = new IChangeListener() {
+
+ @Override
+ public void handleChange(ChangeEvent event) {
+ refresh();
+ }
+
+ };
+
/**
* Instantiates a new floating label edit part.
*
@@ -71,4 +89,26 @@ public class FloatingLabelEditPart extends PapyrusLabelEditPart implements Named
return DEFAULT_LABEL_DISPLAYED;
}
+ /**
+ * Adds listener to handle named Style modifications.
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+
+ labelDisplayedObservable = new CustomBooleanStyleObservableValue((View) getModel(), EMFHelper.resolveEditingDomain(getModel()), DISPLAY_FLOATING_LABEL);
+ labelDisplayedObservable.addChangeListener(namedStyleListener);
+
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#removeNotationalListeners()
+ *
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ labelDisplayedObservable.dispose();
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java
index cf2a047607c..5a0fb051bc6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java
@@ -1,8 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2015 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:
+ * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation
+ *
+ *****************************************************************************/
+
+
package org.eclipse.papyrus.uml.diagram.common.editparts;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.draw2d.Graphics;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.PapyrusRoundedEditPartHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
@@ -12,7 +36,10 @@ import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEd
import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
-public abstract class RoundedBorderNamedElementEditPart extends BorderNamedElementEditPart {
+/**
+ * The Class RoundedBorderNamedElementEditPart.
+ */
+public abstract class RoundedBorderNamedElementEditPart extends BorderNamedElementEditPart implements NamedStyleProperties {
/** The Constant DEFAULT_BORDER_STYLE. */
private static final int DEFAULT_BORDER_STYLE = Graphics.LINE_SOLID;
@@ -23,6 +50,7 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
/** The Constant DEFAULT_CORNER_WIDTH. */
private static final int DEFAULT_CORNER_WIDTH = 0;
+ /** The Constant DEFAULT_CUTOM_DASH. */
private static final int[] DEFAULT_CUTOM_DASH = new int[] { 5, 5 };
/** The Constant DEFAULT_FLOATING_LABEL_OFFSET_HEIGHT. */
@@ -37,16 +65,52 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
/** The Constant DEFAULT_IS_OVAL. */
private static final boolean DEFAULT_IS_OVAL = false;
+ /** The Constant DEFAULT_USE_ORIGINAL_COLORS. */
private static final boolean DEFAULT_USE_ORIGINAL_COLORS = true;
+ /** The Constant DEFAULT_HAS_HEADER. */
private static final boolean DEFAULT_HAS_HEADER = false;
+ /** The Constant DEFAULT_PORT_POSITION_VALUE. */
private static final String DEFAULT_PORT_POSITION_VALUE = PortPositionEnum.ONLINE.toString();
+ /** the namedStyle Listener */
+ IChangeListener namedStyleListener = new IChangeListener() {
+
+ @Override
+ public void handleChange(ChangeEvent event) {
+ refresh();
+
+ }
+
+ };
+
+ /** The ovalObservable */
+ private IObservableValue ovalObservable;
+
+ /** The radius height Observable */
+ private IObservableValue radiusObservableHeight;
+
+ /** The radius width Observable */
+ private IObservableValue radiusObservableWidth;
+
+ /** The customDash Observable */
+ private IObservableList customDashObservable;
+
+ /** The shadowWidth Observable */
+ private IObservableValue shadowWidthObservable;
+
+ /** The shadowColor Observable */
+ private IObservableValue shadowColorObservable;
+
+ /** The port position Observable */
+ private IObservableValue positionObservable;
+
/**
* Constructor.
*
* @param view
+ * the view
*/
public RoundedBorderNamedElementEditPart(View view) {
super(view);
@@ -54,8 +118,9 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
/**
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#createDefaultEditPolicies()
+ * Creates the default edit policies.
*
+ * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#createDefaultEditPolicies()
*/
@Override
protected void createDefaultEditPolicies() {
@@ -92,6 +157,11 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
return DEFAULT_CORNER_WIDTH;
}
+ /**
+ * Gets the default cutom dash.
+ *
+ * @return the default cutom dash
+ */
private int[] getDefaultCutomDash() {
return DEFAULT_CUTOM_DASH;
}
@@ -133,7 +203,9 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
}
/**
- * @return
+ * Gets the default use original colors.
+ *
+ * @return the default use original colors
*/
private boolean getDefaultUseOriginalColors() {
return DEFAULT_USE_ORIGINAL_COLORS;
@@ -148,15 +220,62 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
protected void refreshVisuals() {
PapyrusRoundedEditPartHelper.refreshRadius(this, getDefaultCornerWidth(), getDefaultCornerHeight());
PapyrusRoundedEditPartHelper.refreshOval(this, getDefaultIsOvalValue());
- PapyrusRoundedEditPartHelper.refreshFloatingName(this, getDefaultIsFloatingNameConstrained(), getDefaultFloatingLabelOffsetWidth(), getDefaultFloatingLabelOffsetHeight());
PapyrusRoundedEditPartHelper.refreshBorderStyle(this, getDefaultBorderStyle(), getDefaultCutomDash());
- PapyrusRoundedEditPartHelper.refreshHasHeader(this, getDefaultHasHeader());
PapyrusRoundedEditPartHelper.refreshShadowColor(this, getDefaultShadowColor());
refreshPortPosition();
super.refreshVisuals();
}
/**
+ * Adds listener to handle named Style modifications.
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+
+ View view = (View) getModel();
+ EditingDomain domain = EMFHelper.resolveEditingDomain(view);
+
+ radiusObservableWidth = new CustomIntStyleObservableValue(view, domain, RADIUS_WIDTH);
+ radiusObservableWidth.addChangeListener(namedStyleListener);
+
+ radiusObservableHeight = new CustomIntStyleObservableValue(view, domain, RADIUS_HEIGHT);
+ radiusObservableHeight.addChangeListener(namedStyleListener);
+
+ ovalObservable = new CustomBooleanStyleObservableValue(view, domain, IS_OVAL);
+ ovalObservable.addChangeListener(namedStyleListener);
+
+ customDashObservable = new CustomStringStyleObservableList(view, domain, LINE_CUSTOM_VALUE);
+ customDashObservable.addChangeListener(namedStyleListener);
+
+ shadowWidthObservable = new CustomIntStyleObservableValue(view, domain, SHADOW_WIDTH);
+ shadowWidthObservable.addChangeListener(namedStyleListener);
+
+ shadowColorObservable = new CustomStringStyleObservableValue(view, domain, SHADOW_COLOR);
+ shadowColorObservable.addChangeListener(namedStyleListener);
+
+ positionObservable = new CustomStringStyleObservableValue(view, domain, PORT_POSITION);
+ positionObservable.addChangeListener(namedStyleListener);
+
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#removeNotationalListeners()
+ *
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ radiusObservableWidth.dispose();
+ radiusObservableHeight.dispose();
+ ovalObservable.dispose();
+ customDashObservable.dispose();
+ shadowWidthObservable.dispose();
+ shadowColorObservable.dispose();
+ positionObservable.dispose();
+ }
+
+ /**
* Gets the default shadow color.
*
* @return the default shadow color
@@ -167,7 +286,7 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
}
/**
- * Refresh the port position
+ * Refresh the port position.
*/
private void refreshPortPosition() {
if (getPrimaryShape() instanceof IRoundedRectangleFigure) {
@@ -178,7 +297,7 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
if (constraint instanceof PortPositionLocator) {
PortPositionLocator portLocator = (PortPositionLocator) constraint;
- String position = NotationUtils.getStringValue((View) getModel(), NamedStyleProperties.PORT_POSITION, getDefaultPortPosition());
+ String position = NotationUtils.getStringValue((View) getModel(), PORT_POSITION, getDefaultPortPosition());
portLocator.setPortPosition(position);
}
}
@@ -188,13 +307,17 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme
/**
* get the default Port Position(can be inside, outside or onLine).
+ *
+ * @return the default port position
*/
protected String getDefaultPortPosition() {
return DEFAULT_PORT_POSITION_VALUE;
}
/**
- * @return
+ * Gets the default has header.
+ *
+ * @return the default has header
*/
protected boolean getDefaultHasHeader() {
return DEFAULT_HAS_HEADER;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
index b2792b0ac6b..372c68a6ee8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedCompartmentEditPart.java
@@ -13,8 +13,18 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.draw2d.Graphics;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.PapyrusRoundedEditPartHelper;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
@@ -58,6 +68,47 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
/** The Constant DEFAULT_SHADOW_WIDTH. */
private static final int DEFAULT_SHADOW_WIDTH = 4;
+ /** The namedStyle Listener */
+ private IChangeListener namedStyleListener = new IChangeListener() {
+
+ @Override
+ public void handleChange(ChangeEvent event) {
+ refresh();
+
+ }
+
+ };
+
+ /** The oval Observable */
+ private IObservableValue ovalObservable;
+
+ /** The borderStyle Observable */
+ private IObservableValue borderStyleObservable;
+
+ /** The hasHeader Observable */
+ private IObservableValue hasHeaderObservable;
+
+ /** The radiusHeight Observable */
+ private IObservableValue radiusObservableHeight;
+
+ /** The radiusWidth Observable */
+ private IObservableValue radiusObservableWidth;
+
+ /** The customDash Observable */
+ private IObservableList customDashObservable;
+
+ /** The isPackage Observable */
+ private IObservableValue isPackageObservable;
+
+ /** The shadowWidth Observable */
+ private IObservableValue shadowWidthObservable;
+
+ /** The shadowColor Observable */
+ private IObservableValue shadowColorObservable;
+
+ /** The alignment Observable */
+ private IObservableValue alignmentObservable;
+
/**
* Instantiates a new rounded compartment edit part.
*
@@ -99,6 +150,67 @@ public abstract class RoundedCompartmentEditPart extends NamedElementEditPart {
super.refreshVisuals();
}
+
+ /**
+ * Adds listener to handle named Style modifications.
+ */
+ @Override
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+
+ View view = (View) getModel();
+ EditingDomain domain = EMFHelper.resolveEditingDomain(view);
+
+ radiusObservableWidth = new CustomIntStyleObservableValue(view, domain, RADIUS_WIDTH);
+ radiusObservableWidth.addChangeListener(namedStyleListener);
+
+ radiusObservableHeight = new CustomIntStyleObservableValue(view, domain, RADIUS_HEIGHT);
+ radiusObservableHeight.addChangeListener(namedStyleListener);
+
+ ovalObservable = new CustomBooleanStyleObservableValue(view, domain, IS_OVAL);
+ ovalObservable.addChangeListener(namedStyleListener);
+
+ borderStyleObservable = new CustomStringStyleObservableValue(view, domain, BORDER_STYLE);
+ borderStyleObservable.addChangeListener(namedStyleListener);
+
+ customDashObservable = new CustomStringStyleObservableList(view, domain, LINE_CUSTOM_VALUE);
+ customDashObservable.addChangeListener(namedStyleListener);
+
+ hasHeaderObservable = new CustomBooleanStyleObservableValue(view, domain, DISPLAY_HEADER);
+ hasHeaderObservable.addChangeListener(namedStyleListener);
+
+ isPackageObservable = new CustomBooleanStyleObservableValue(view, domain, IS_PACKAGE);
+ isPackageObservable.addChangeListener(namedStyleListener);
+
+ shadowWidthObservable = new CustomIntStyleObservableValue(view, domain, SHADOW_WIDTH);
+ shadowWidthObservable.addChangeListener(namedStyleListener);
+
+ shadowColorObservable = new CustomStringStyleObservableValue(view, domain, SHADOW_COLOR);
+ shadowColorObservable.addChangeListener(namedStyleListener);
+
+ alignmentObservable = new CustomStringStyleObservableValue(view, domain, TEXT_ALIGNMENT);
+ alignmentObservable.addChangeListener(namedStyleListener);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#removeNotationalListeners()
+ *
+ */
+ @Override
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ radiusObservableWidth.dispose();
+ radiusObservableHeight.dispose();
+ ovalObservable.dispose();
+ borderStyleObservable.dispose();
+ customDashObservable.dispose();
+ hasHeaderObservable.dispose();
+ isPackageObservable.dispose();
+ shadowWidthObservable.dispose();
+ shadowColorObservable.dispose();
+ alignmentObservable.dispose();
+ }
+
/**
* Gets the default shadow color.
*

Back to the top