diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/.ratings b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/.ratings index 2cf983ec65faf1888c8f55a04998b4333338edf9..b55c3a0e20198b7452fa013ebb177d679f3f5625 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/.ratings +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/.ratings @@ -1,6 +1,5 @@ - ConnectionEditPartBase.java 53a128af53e251a89a44eda4b85c89ff6c8db5a1 GREEN -ConnectorEditPartBase.java 1e7bf37dff30ee099eadbcfc0193b847aa7d16e3 GREEN +ConnectorEditPartBase.java bc811ad8d69ec19816599755bfa825422a1dc487 YELLOW DiagramEditPartBase.java 7a5305c8dc86f29e05873b28284244328b3e5a20 GREEN ElementEditPartBase.java c2a8f7ca01360eb7866adb34a162d696665ec5f8 GREEN ExtendedLayerRootEditPart.java 1b8206ef963b5b174a02656a5bfc84a2953fe650 GREEN diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/ConnectorEditPartBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/ConnectorEditPartBase.java index 9d869412ae426eaff27dd72a239e4e46bf1b21fb..2d6ceaf93ffc03d95fc76bf6d8b88e24a7cc2285 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/ConnectorEditPartBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/ConnectorEditPartBase.java @@ -38,7 +38,11 @@ import org.eclipse.draw2d.Label; import org.eclipse.draw2d.XYLayout; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.widgets.Display; import org.fortiss.tooling.base.model.element.IConnection; import org.fortiss.tooling.base.model.element.IConnector; import org.fortiss.tooling.base.model.element.IHierarchicElement; @@ -63,6 +67,25 @@ public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IC super(modelElement); } + /** {@link Font} to be used to render the label returned by {@link #getFigureLabel()}. */ + private static Font FIGURE_LABEL_FONT = createFigureLabelFont(); + + /** Helper method to create the font for label returned by {@link #getFigureLabel()}. */ + private static Font createFigureLabelFont() { + final Font defaultFont = JFaceResources.getDefaultFont(); + // There is at least one FontData + final String fontName = defaultFont.getFontData()[0].getName(); + return new Font(Display.getCurrent(), fontName, DEFAULT_CONNECTOR_SIZE / 4, SWT.NORMAL); + } + + /** + * Returns the optional one {@link Character} label to be rendered within the circle + * representing the connector. + */ + protected Character getFigureLabel() { + return null; + } + /** {@inheritDoc} */ @Override protected IFigure createBaseFigure() { @@ -81,6 +104,19 @@ public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IC int oneFourth = DEFAULT_CONNECTOR_SIZE / 4; int half = DEFAULT_CONNECTOR_SIZE / 2; base.add(connector, new Rectangle(oneFourth, oneFourth, half, half)); + + if(getFigureLabel() != null) { + final Label label = new Label(getFigureLabel().toString()); + if(isTarget()) { + label.setForegroundColor(getTargetForegroundColor()); + } else { + label.setForegroundColor(getTargetBackgroundColor()); + } + label.setFont(FIGURE_LABEL_FONT); + + base.add(label, new Rectangle(0, 0, DEFAULT_CONNECTOR_SIZE, DEFAULT_CONNECTOR_SIZE)); + } + return base; }