diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/LayoutedConnectionEditPartBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/LayoutedConnectionEditPartBase.java index 72f6a78c2d2ebc1c567f492602487927e5c01359..bbe163aabc261a45b2ab742337c0b1c5e07d94a8 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/LayoutedConnectionEditPartBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/LayoutedConnectionEditPartBase.java @@ -22,6 +22,7 @@ import java.util.List; import org.eclipse.draw2d.AbsoluteBendpoint; import org.eclipse.draw2d.BendpointConnectionRouter; +import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.MidpointLocator; @@ -32,6 +33,7 @@ import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.util.EContentAdapter; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; +import org.eclipse.swt.graphics.Color; import org.fortiss.tooling.base.layout.DefaultLayoutConstants; import org.fortiss.tooling.base.model.base.ConnectionSegmentBase; import org.fortiss.tooling.base.model.layout.LayoutPackage; @@ -61,6 +63,9 @@ public abstract class LayoutedConnectionEditPartBase<T extends ConnectionSegment /** The label drawn next to the connection. */ protected final Label relationshipLabel = new Label(modelElement.getName()); + /** The simulation value label drawn in highlighted color. */ + private final Label simulationLabel = new Label(""); + /** The adapter used for dealing with changes of the */ // TODO (FH): check for collision with full refresh adapter of super class ! protected final Adapter layoutChanged = new EContentAdapter() { @@ -83,6 +88,7 @@ public abstract class LayoutedConnectionEditPartBase<T extends ConnectionSegment /** Constructor. */ protected LayoutedConnectionEditPartBase(T modelElement) { super(modelElement); + simulationLabel.setForegroundColor(getSimulationLabelColor()); } /** {@inheritDoc} */ @@ -127,6 +133,23 @@ public abstract class LayoutedConnectionEditPartBase<T extends ConnectionSegment }; connection.add(relationshipLabel, mpl); + // Update simulation label + if (connection.getChildren().contains(simulationLabel)) { + connection.remove(simulationLabel); + } + if (!"".equals(simulationLabel.getText())) { + mpl = new MidpointLocator(connection, size / 2) { + @Override + protected org.eclipse.draw2d.geometry.Point getReferencePoint() { + org.eclipse.draw2d.geometry.Point p = super + .getReferencePoint(); + p.y += 2 * DefaultLayoutConstants.DEFAULT_GRID_SIZE; + return p; + } + }; + connection.add(simulationLabel, mpl); + } + getConnectionFigure().setRoutingConstraint(figureConstraint); } @@ -166,4 +189,15 @@ public abstract class LayoutedConnectionEditPartBase<T extends ConnectionSegment protected void refreshVisuals() { refreshBendpoints(); } + + /** Sets the simulation value label to the given value. */ + public void setSimulationValue(String value) { + simulationLabel.setText(value); + refreshVisuals(); + } + + /** Returns the simulation label color. */ + protected Color getSimulationLabelColor() { + return ColorConstants.red; + } }