Skip to content
Snippets Groups Projects
Commit 7b711ac9 authored by Christoph Döbber's avatar Christoph Döbber
Browse files

reviewed part of tooling.base.ui

refs 311
parent 33f98f9e
No related branches found
No related tags found
No related merge requests found
Showing
with 40 additions and 43 deletions
......@@ -18,6 +18,7 @@ $Id$
package org.fortiss.tooling.base.ui.editpart;
import static org.eclipse.draw2d.ColorConstants.red;
import static org.eclipse.draw2d.Graphics.LINE_SOLID;
import static org.eclipse.gef.EditPolicy.COMPONENT_ROLE;
import static org.eclipse.gef.EditPolicy.CONNECTION_BENDPOINTS_ROLE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_GRID_SIZE;
......@@ -28,7 +29,6 @@ import java.util.List;
import org.eclipse.draw2d.AbsoluteBendpoint;
import org.eclipse.draw2d.BendpointConnectionRouter;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.MidpointLocator;
import org.eclipse.draw2d.PolygonDecoration;
......@@ -61,7 +61,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 28E33D2C3C2DF910AEE14C56165E68DC
* @ConQAT.Rating GREEN Hash: 66658DB86881AB1ED2B4CD152E7AF051
*/
public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
extends AbstractConnectionEditPart {
......@@ -135,7 +135,7 @@ public abstract class ConnectionEditPartBase<T extends ConnectionSegmentBase>
// arrow at target end point
connection.setTargetDecoration(new PolygonDecoration());
connection.setLineStyle(Graphics.LINE_SOLID);
connection.setLineStyle(LINE_SOLID);
BendpointConnectionRouter connectionRouter = new BendpointConnectionRouter();
connection.setConnectionRouter(connectionRouter);
......
......@@ -17,6 +17,14 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editpart;
import static org.eclipse.draw2d.ColorConstants.black;
import static org.eclipse.draw2d.ColorConstants.white;
import static org.eclipse.draw2d.PositionConstants.EAST;
import static org.eclipse.draw2d.PositionConstants.LEFT;
import static org.eclipse.draw2d.PositionConstants.TOP;
import static org.eclipse.gef.EditPolicy.COMPONENT_ROLE;
import static org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getNodePosition;
import java.util.ArrayList;
......@@ -24,19 +32,15 @@ import java.util.List;
import org.conqat.lib.commons.collections.CollectionUtils;
import org.eclipse.draw2d.ChopboxAnchor;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.Ellipse;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.swt.graphics.Color;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
......@@ -54,7 +58,7 @@ import org.fortiss.tooling.kernel.model.INamedCommentedElement;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 612D8AAD09A986448B12AFB178EB1DDD
* @ConQAT.Rating GREEN Hash: 16D079AEA83E96E84B22409E8808778B
*/
public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IConnector & INamedCommentedElement>
extends PositionedEditPartBase<T> {
......@@ -79,8 +83,8 @@ public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IC
connector.setForegroundColor(getSourceForegroundColor());
}
int oneFourth = DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 4;
int half = DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2;
int oneFourth = DEFAULT_CONNECTOR_SIZE / 4;
int half = DEFAULT_CONNECTOR_SIZE / 2;
base.add(connector, new Rectangle(oneFourth, oneFourth, half, half));
return base;
}
......@@ -90,8 +94,7 @@ public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IC
protected Rectangle determineBaseFigureBounds() {
Point connectorPos = getNodePosition(getModel());
return new Rectangle(connectorPos.getX(), connectorPos.getY(),
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE);
DEFAULT_CONNECTOR_SIZE, DEFAULT_CONNECTOR_SIZE);
}
/** {@inheritDoc} */
......@@ -99,9 +102,8 @@ public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IC
protected Label createLabelFigure() {
Label nameLabel = new TransparentLabel();
nameLabel.setForegroundColor(getForegroundColor());
nameLabel.setTextAlignment(PositionConstants.LEFT
| PositionConstants.TOP);
nameLabel.setTextPlacement(PositionConstants.EAST);
nameLabel.setTextAlignment(LEFT | TOP);
nameLabel.setTextPlacement(EAST);
return nameLabel;
}
......@@ -149,13 +151,13 @@ public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IC
/** {@inheritDoc} */
@Override
protected Color getForegroundColor() {
return ColorConstants.black;
return black;
}
/** {@inheritDoc} */
@Override
protected Color getBackgroundColor() {
return ColorConstants.white;
return white;
}
/** {@inheritDoc} */
......@@ -229,8 +231,8 @@ public abstract class ConnectorEditPartBase<T extends ILayoutedModelElement & IC
/** {@inheritDoc} */
@Override
protected void createEditPolicies() {
installEditPolicy(EditPolicy.COMPONENT_ROLE, new RemoveEditPolicy());
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
installEditPolicy(COMPONENT_ROLE, new RemoveEditPolicy());
installEditPolicy(GRAPHICAL_NODE_ROLE,
new DirectConnectionAndReconnectionEditPolicy());
}
......
......@@ -17,6 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editpart;
import static org.eclipse.gef.LayerConstants.CONNECTION_LAYER;
import static org.fortiss.tooling.base.ui.utils.SnapToGridUtils.snapToGridAdapter;
import java.util.ArrayList;
......@@ -35,7 +36,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.NodeEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.SnapToHelper;
......@@ -59,7 +59,7 @@ import org.fortiss.tooling.base.ui.layout.IDiagramLayoutConfiguration;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: A8CFB6F38B4ED99A99700905B1921465
* @ConQAT.Rating GREEN Hash: E10FEA16D38EA1452A9EC7367AFC8022
*/
public abstract class DiagramEditPartBase<T extends EObject> extends
GraphicalEditPartBase<T> implements NodeEditPart {
......@@ -94,7 +94,6 @@ public abstract class DiagramEditPartBase<T extends EObject> extends
f.setOpaque(false);
f.setLayoutManager(new XYLayout());
f.setBackgroundColor(ColorConstants.white);
return f;
}
......@@ -159,9 +158,9 @@ public abstract class DiagramEditPartBase<T extends EObject> extends
return result;
}
/** Sets anti-aliasing and the conenction router on connection layer. */
/** Sets anti-aliasing and the connection router on connection layer. */
private void setConnectionRouter() {
ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER);
if (cLayer != null) {
cLayer.setAntialias(SWT.ON);
cLayer.setConnectionRouter(connectionRouter);
......
......@@ -59,7 +59,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 72C4DDDA8A3A00B520E94DCEA1D58075
* @ConQAT.Rating GREEN Hash: 51E7754E9905C1269ABA7D8B4FD50753
*/
public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INamedCommentedElement>
extends PositionedEditPartBase<T> {
......
......@@ -50,7 +50,7 @@ import org.eclipse.gef.editparts.ScalableRootEditPart;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 2E560FF435B9B183DE5682228BE86FB9
* @ConQAT.Rating GREEN Hash: AD8CF87877C4FC3DF66617F4C41072E8
*/
public class ExtendedLayerRootEditPart extends ScalableRootEditPart {
/** The node layer ID. */
......@@ -125,5 +125,4 @@ public class ExtendedLayerRootEditPart extends ScalableRootEditPart {
l.setBackgroundColor(ColorConstants.white);
return l;
}
}
......@@ -30,7 +30,7 @@ import org.fortiss.tooling.kernel.model.INamedCommentedElement;
*
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 14C10973CFA4401F74E7E60CC93AB245
* @ConQAT.Rating GREEN Hash: AF3B6072F290AF3F03F26549AA225F0E
*/
public abstract class FreeConnectorEditPartBase<T extends ILayoutedModelElement & IConnector & INamedCommentedElement>
extends ConnectorEditPartBase<T> {
......
......@@ -36,7 +36,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: E266716B2C92B857E832A4F7E93277CF
* @ConQAT.Rating GREEN Hash: 923DCFE4AFDFE04EC5831959D031495A
*/
public abstract class GraphicalEditPartBase<T extends EObject> extends
AbstractGraphicalEditPart {
......
......@@ -17,6 +17,9 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editpart;
import static org.fortiss.tooling.base.ui.editpart.ExtendedLayerRootEditPart.DECORATION_LAYER;
import static org.fortiss.tooling.base.ui.editpart.ExtendedLayerRootEditPart.LABEL_LAYER;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
......@@ -63,7 +66,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 2D3DCF9F19F2F3F140D4DEDA789661BB
* @ConQAT.Rating GREEN Hash: A7CE6740ADDD2F321FA24E2C5689F3D8
*/
public abstract class PositionedEditPartBase<T extends ILayoutedModelElement>
extends GraphicalEditPartBase<T> implements NodeEditPart {
......@@ -148,14 +151,10 @@ public abstract class PositionedEditPartBase<T extends ILayoutedModelElement>
return new Rectangle();
}
/**
* Returns the foreground color used.
*/
/** Returns the foreground color used. */
protected abstract Color getForegroundColor();
/**
* Returns the background color used.
*/
/** Returns the background color used. */
protected abstract Color getBackgroundColor();
/**
......@@ -198,12 +197,11 @@ public abstract class PositionedEditPartBase<T extends ILayoutedModelElement>
public void addNotify() {
labelFigure = createLabelFigure();
if (labelFigure != null) {
getLayer(ExtendedLayerRootEditPart.LABEL_LAYER).add(labelFigure);
getLayer(LABEL_LAYER).add(labelFigure);
}
decorationFigure = createDecorationFigure();
if (decorationFigure != null) {
getLayer(ExtendedLayerRootEditPart.DECORATION_LAYER).add(
decorationFigure);
getLayer(DECORATION_LAYER).add(decorationFigure);
}
// called last, since it also refreshes label and decoration
super.addNotify();
......@@ -213,11 +211,10 @@ public abstract class PositionedEditPartBase<T extends ILayoutedModelElement>
@Override
public void removeNotify() {
if (labelFigure != null) {
getLayer(ExtendedLayerRootEditPart.LABEL_LAYER).remove(labelFigure);
getLayer(LABEL_LAYER).remove(labelFigure);
}
if (decorationFigure != null) {
getLayer(ExtendedLayerRootEditPart.DECORATION_LAYER).remove(
decorationFigure);
getLayer(DECORATION_LAYER).remove(decorationFigure);
}
super.removeNotify();
}
......
......@@ -34,7 +34,7 @@ import org.fortiss.tooling.kernel.model.INamedCommentedElement;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 6BD53212C477BC4A0E07946A46A1F221
* @ConQAT.Rating GREEN Hash: 49F7C34AF000C6BAFEFCACF201F22DD1
*/
public abstract class StickyConnectorEditPartBase<T extends ILayoutedModelElement & IConnector & INamedCommentedElement>
extends ConnectorEditPartBase<T> {
......
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