Skip to content
Snippets Groups Projects
Commit 4c24265d authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

first steps for the component architecture simulator -- still hacky but some...

first steps for the component architecture simulator -- still hacky but some intermediate results are available
refs 236
parent 7f877835
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment