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

finished review of tooling.base.ui

refs 311
parent dbbcd51a
No related branches found
No related tags found
No related merge requests found
Showing
with 89 additions and 78 deletions
......@@ -32,7 +32,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase;
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: 3386CF920FA51BB64D0B8035BB9EB721
* @ConQAT.Rating RED Hash: 658C6CE7721FC82AA7DF76FC0A1CE6F0
*/
public abstract class PropertySectionWithCopyPasteBase<T extends IModelElementSpecification>
extends PropertySectionBase implements SelectionListener {
......@@ -61,6 +61,8 @@ public abstract class PropertySectionWithCopyPasteBase<T extends IModelElementSp
createFormEntry(copyPasteComposite, "Clipboard");
}
// TODO @review CD: why not use SelectionAdapter and thus save the empty
// method?
/** {@inheritDoc} */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
......
......@@ -29,7 +29,7 @@ import org.eclipse.jface.viewers.TableViewer;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: A39EE0F9184DD86FD5FC5D46A164976A
* @ConQAT.Rating GREEN Hash: 0E48EDEDD7575A54341D6BE6926F0792
*/
public abstract class CheckBoxEditingSupport extends EditingSupport {
......
......@@ -38,8 +38,13 @@ import org.eclipse.swt.widgets.Shell;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: BDA0B84E86A88AC31CFF2B2C1B367A98
* @ConQAT.Rating RED Hash: 74220EAB8C4432DC0ABDACC754751490
*/
// TODO @review CD: Very interesting, but is this really necessary? Don't SWT
// checkboxes work as good or even better? During testing these checkboxes seem
// to react slower and additionally they have an ugly gray background.
public abstract class CheckBoxLabelProvider extends ColumnLabelProvider {
/** {@link JFaceResources} id for checked image. */
private static final String CHECKED_KEY = "CHECKED";
......
......@@ -33,8 +33,11 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3F8CFB07632A14D29A38168BB1D15D76
* @ConQAT.Rating RED Hash: 358A7180C7CC44420271B76CD80E8450
*/
// TODO @review CD: Imprecise class name. I expected elements with error/warning
// decorations rather than simply an icon.
public class DecoratedIconNameLabelProvider implements IStyledLabelProvider {
/** {@inheritDoc} */
@Override
......
......@@ -26,7 +26,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 4F5DBBB7032E0A60CA00568B358750A4
* @ConQAT.Rating GREEN Hash: 2CF844E52ABEFC0EF8EF0A639EA10D5F
*/
public class ActionUtils {
......
......@@ -40,7 +40,7 @@ import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 9BDB7D27FC9B1917E41C3DFD44C0FF23
* @ConQAT.Rating GREEN Hash: 6A74D01004722B0E1A9FA610890C601B
*/
public final class EllipseLayoutUtils {
/**
......
......@@ -17,16 +17,40 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.utils;
import static org.eclipse.gef.EditPart.SELECTED_NONE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.CONNECTION_POINTS;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.CONNECTOR_ANGLE;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.CONNECTOR_OFFSET;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.CONNECTOR_POSITION;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.NODE_DIMENSION;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.NODE_POSITION;
import static org.fortiss.tooling.base.model.layout.EOrientation.NORTH;
import static org.fortiss.tooling.base.utils.AngleUtils.getAngle;
import static org.fortiss.tooling.base.utils.AngleUtils.setAngle;
import static org.fortiss.tooling.base.utils.DimensionUtils.getDimension;
import static org.fortiss.tooling.base.utils.DimensionUtils.setDimension;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createAngle;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createOffsetOrientation;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoints;
import static org.fortiss.tooling.base.utils.OffsetOrientationUtils.getOffsetOrientation;
import static org.fortiss.tooling.base.utils.OffsetOrientationUtils.setOffsetOrientation;
import static org.fortiss.tooling.base.utils.PointUtils.getPosition;
import static org.fortiss.tooling.base.utils.PointUtils.setPoint;
import static org.fortiss.tooling.base.utils.PointsUtils.getPoints;
import static org.fortiss.tooling.base.utils.PointsUtils.setPoints;
import java.util.List;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gef.EditPart;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.layout.LayoutKeyConstants;
import org.fortiss.tooling.base.model.layout.Angle;
import org.fortiss.tooling.base.model.layout.Dimension;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.base.model.layout.ILayoutData;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Offset;
......@@ -36,12 +60,7 @@ import org.fortiss.tooling.base.model.layout.Points;
import org.fortiss.tooling.base.ui.editpart.ConnectionEditPartBase;
import org.fortiss.tooling.base.ui.editpart.ConnectorEditPartBase;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.utils.AngleUtils;
import org.fortiss.tooling.base.utils.DimensionUtils;
import org.fortiss.tooling.base.utils.LayoutModelElementFactory;
import org.fortiss.tooling.base.utils.OffsetOrientationUtils;
import org.fortiss.tooling.base.utils.PointUtils;
import org.fortiss.tooling.base.utils.PointsUtils;
/**
* Utility methods for {@link ILayoutedModelElement} and {@link ILayoutData}.
......@@ -56,7 +75,7 @@ import org.fortiss.tooling.base.utils.PointsUtils;
* @author hummel
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 2AC0495B10FD6EC5AF6DC8480D0BB126
* @ConQAT.Rating GREEN Hash: BA085FEB69C66332C246D33F24D7D240
*/
public class LayoutDataUtils {
......@@ -79,14 +98,13 @@ public class LayoutDataUtils {
/** Returns the position of the given layouted node. */
public static Point getNodePosition(ILayoutedModelElement layouted) {
return PointUtils.getPosition(layouted,
LayoutKeyConstants.NODE_POSITION);
return getPosition(layouted, NODE_POSITION);
}
/** Sets the layouted node's position. */
public static void setNodePosition(ILayoutedModelElement layouted, int x,
int y) {
PointUtils.setPoint(layouted, LayoutKeyConstants.NODE_POSITION, x, y);
setPoint(layouted, NODE_POSITION, x, y);
}
/**
......@@ -94,14 +112,12 @@ public class LayoutDataUtils {
* the given element a new dimension with the default size is returned.
*/
public static Dimension getNodeSize(ILayoutedModelElement layouted) {
Dimension size = DimensionUtils.getDimension(layouted,
LayoutKeyConstants.NODE_DIMENSION);
Dimension size = getDimension(layouted, NODE_DIMENSION);
if (size == null) {
Dimension result = LayoutModelElementFactory.createDimension(
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH,
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT,
LayoutKeyConstants.NODE_DIMENSION);
DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT,
NODE_DIMENSION);
return result;
}
return EcoreUtil.copy(size);
......@@ -109,24 +125,23 @@ public class LayoutDataUtils {
/** Sets the layouted node's size. */
public static void setNodeSize(ILayoutedModelElement layouted, int w, int h) {
DimensionUtils.setDimension(layouted,
LayoutKeyConstants.NODE_DIMENSION, w, h);
setDimension(layouted, NODE_DIMENSION, w, h);
}
/** Moves the given node. */
public static void moveNode(ILayoutedModelElement layouted, int dx, int dy) {
Point p = LayoutDataUtils.getNodePosition(layouted);
LayoutDataUtils.setNodePosition(layouted, p.getX() + dx, p.getY() + dy);
Point p = getNodePosition(layouted);
setNodePosition(layouted, p.getX() + dx, p.getY() + dy);
}
/** Moves and resizes the given node. */
public static void moveAndResizeNode(ILayoutedModelElement layouted,
int dx, int dy, int dw, int dh, int minWidth, int minHeight) {
Point pos = LayoutDataUtils.getNodePosition(layouted);
Point pos = getNodePosition(layouted);
int posX = pos.getX() + dx;
int posY = pos.getY() + dy;
Dimension dim = LayoutDataUtils.getNodeSize(layouted);
Dimension dim = getNodeSize(layouted);
int dimW = dim.getWidth() + dw;
int dimH = dim.getHeight() + dh;
......@@ -144,32 +159,29 @@ public class LayoutDataUtils {
dimH = minHeight;
}
LayoutDataUtils.setNodePosition(layouted, posX, posY);
LayoutDataUtils.setNodeSize(layouted, dimW, dimH);
setNodePosition(layouted, posX, posY);
setNodeSize(layouted, dimW, dimH);
}
/** Returns the layouted connector's position. */
public static Point getConnectorPosition(ILayoutedModelElement layouted) {
return PointUtils.getPosition(layouted,
LayoutKeyConstants.CONNECTOR_POSITION);
return getPosition(layouted, CONNECTOR_POSITION);
}
/** Sets the layouted connector's position. */
public static void setConnectorPosition(ILayoutedModelElement layouted,
int x, int y) {
PointUtils.setPoint(layouted, LayoutKeyConstants.CONNECTOR_POSITION, x,
y);
setPoint(layouted, CONNECTOR_POSITION, x, y);
}
/** Returns the layouted connector's orientation. */
public static OffsetOrientation getConnectorOffsetOrientation(
ILayoutedModelElement layouted) {
OffsetOrientation oo = OffsetOrientationUtils.getOffsetOrientation(
layouted, LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION);
OffsetOrientation oo = getOffsetOrientation(layouted,
CONNECTOR_OFFSET_ORIENTATION);
if (oo == null) {
return LayoutModelElementFactory.createOffsetOrientation(0,
EOrientation.NORTH,
LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION);
return createOffsetOrientation(0, NORTH,
CONNECTOR_OFFSET_ORIENTATION);
}
return oo;
}
......@@ -177,18 +189,16 @@ public class LayoutDataUtils {
/** Sets the layouted connector's offset and orientation. */
public static void setConnectorOffsetOrientation(
ILayoutedModelElement layouted, OffsetOrientation orientation) {
OffsetOrientationUtils.setOffsetOrientation(layouted,
LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION,
setOffsetOrientation(layouted, CONNECTOR_OFFSET_ORIENTATION,
orientation.getOffset(), orientation.getOrientation());
}
/** Returns the layouted connector's offset. */
public static Offset getConnectorOffset(ILayoutedModelElement layouted) {
OffsetOrientation offset = OffsetOrientationUtils.getOffsetOrientation(
layouted, LayoutKeyConstants.CONNECTOR_OFFSET);
OffsetOrientation offset = getOffsetOrientation(layouted,
CONNECTOR_OFFSET);
if (offset == null) {
return LayoutModelElementFactory.createOffsetOrientation(0,
EOrientation.NORTH, LayoutKeyConstants.CONNECTOR_OFFSET);
return createOffsetOrientation(0, NORTH, CONNECTOR_OFFSET);
}
return offset;
}
......@@ -196,17 +206,14 @@ public class LayoutDataUtils {
/** Sets the layouted connector's angle. */
public static void setConnectorAngle(ILayoutedModelElement layouted,
double angle) {
AngleUtils
.setAngle(layouted, LayoutKeyConstants.CONNECTOR_ANGLE, angle);
setAngle(layouted, CONNECTOR_ANGLE, angle);
}
/** Returns the layouted connector's angle. */
public static Angle getConnectorAngle(ILayoutedModelElement layouted) {
Angle angle = AngleUtils.getAngle(layouted,
LayoutKeyConstants.CONNECTOR_ANGLE);
Angle angle = getAngle(layouted, CONNECTOR_ANGLE);
if (angle == null) {
return LayoutModelElementFactory.createAngle(0.0,
LayoutKeyConstants.CONNECTOR_ANGLE);
return createAngle(0.0, CONNECTOR_ANGLE);
}
return angle;
}
......@@ -219,7 +226,7 @@ public class LayoutDataUtils {
/** Return the absolute position for a given offset, orientation and insets. */
public static Point getAbsolute(OffsetOrientation oo, Dimension parentSize,
int parentInsets) {
Point pos = LayoutModelElementFactory.createPoint(0, 0, null);
Point pos = createPoint(0, 0, null);
int offsetValue = oo.getOffset();
switch (oo.getOrientation()) {
case NORTH:
......@@ -244,43 +251,38 @@ public class LayoutDataUtils {
/** Returns the {@link Points} layout data object for the given connection. */
public static Points getConnectionPoints(ILayoutedModelElement lobject) {
return PointsUtils.getPoints(lobject,
LayoutKeyConstants.CONNECTION_POINTS);
return getPoints(lobject, CONNECTION_POINTS);
}
/** Adds the given x/y point to the layout data of the given element. */
public static void addConnectionPoint(ILayoutedModelElement lobject,
int index, int x, int y) {
Points existingPoints = getConnectionPoints(lobject);
Point newPoint = LayoutModelElementFactory.createPoint(x, y, null);
Point newPoint = createPoint(x, y, null);
existingPoints.getPointsList().add(index, newPoint);
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
existingPoints);
setPoints(lobject, CONNECTION_POINTS, existingPoints);
}
/** Changes the point of the layout data at the given index. */
public static void changeConnectionPoint(ILayoutedModelElement lobject,
int index, int x, int y) {
Points pts = getConnectionPoints(lobject);
Point np = LayoutModelElementFactory.createPoint(x, y, null);
Point np = createPoint(x, y, null);
pts.getPointsList().set(index, np);
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
pts);
setPoints(lobject, CONNECTION_POINTS, pts);
}
/** Changes all the point layout data of the given element. */
public static void changeAllConnectionPoints(ILayoutedModelElement lobject,
int dx, int dy) {
Points pts = getConnectionPoints(lobject);
Points newPoints = LayoutModelElementFactory.createPoints(null);
Points newPoints = createPoints(null);
if (pts != null) {
for (Point p : pts.getPointsList()) {
Point np = LayoutModelElementFactory.createPoint(p.getX() + dx,
p.getY() + dy, null);
Point np = createPoint(p.getX() + dx, p.getY() + dy, null);
newPoints.getPointsList().add(np);
}
PointsUtils.setPoints(lobject,
LayoutKeyConstants.CONNECTION_POINTS, newPoints);
setPoints(lobject, CONNECTION_POINTS, newPoints);
}
}
......@@ -292,8 +294,7 @@ public class LayoutDataUtils {
int index) {
Points pts = getConnectionPoints(lobject);
pts.getPointsList().remove(index);
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
pts);
setPoints(lobject, CONNECTION_POINTS, pts);
}
......@@ -320,8 +321,8 @@ public class LayoutDataUtils {
// IF two states where selected, OR IF the 'connection' is a
// self-transition, THEN move also the bendpoints of the
// connections between these states.
if ((connection.getTarget().getSelected() != EditPart.SELECTED_NONE)
|| (connection.getTarget().getParent().getSelected() != EditPart.SELECTED_NONE)) {
if ((connection.getTarget().getSelected() != SELECTED_NONE)
|| (connection.getTarget().getParent().getSelected() != SELECTED_NONE)) {
changeAllConnectionPoints(connection.getModel(), deltaX,
deltaY);
}
......@@ -338,8 +339,8 @@ public class LayoutDataUtils {
if (parts.size() == 1 && parts.get(0) instanceof ElementEditPartBase) {
ElementEditPartBase element = (ElementEditPartBase) parts.get(0);
Point partPos = PointUtils.getPosition(layouted, "pos");
Dimension partDim = DimensionUtils.getDimension(layouted, "dim");
Point partPos = getPosition(layouted, "pos");
Dimension partDim = getDimension(layouted, "dim");
for (ConnectorEditPartBase connector : (List<ConnectorEditPartBase>) element
.getChildren()) {
......@@ -347,9 +348,9 @@ public class LayoutDataUtils {
.getSourceConnections()) {
// IF it is a self-transition/self-channel, THEN move also
// the bendpoints of the connections/channels.
if ((connection.getTarget().getParent().getSelected() != EditPart.SELECTED_NONE)
if ((connection.getTarget().getParent().getSelected() != SELECTED_NONE)
&& (connection.getSource().getParent()
.getSelected() != EditPart.SELECTED_NONE)) {
.getSelected() != SELECTED_NONE)) {
// get list of all bendpoints of the connections
Points points = getConnectionPoints(connection
......
......@@ -52,7 +52,7 @@ import org.fortiss.tooling.base.ui.dnd.gef.ElementDropContext;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 80F0CE6BDF08AD19CD6F1A664995CE02
* @ConQAT.Rating GREEN Hash: 4AC211E8ED3669B184AEB530916A8A5C
*/
public class RectangleLayoutUtils {
......@@ -164,9 +164,8 @@ public class RectangleLayoutUtils {
// do border clamping
org.fortiss.tooling.base.model.layout.Dimension nd = getNodeSize(container);
Dimension d = new Dimension(nd.getWidth(), nd.getHeight());
OffsetOrientation orient = RectangleLayoutUtils
.calculateRectangleBorderOrientation(position, d,
DEFAULT_SHAPE_INSETS);
OffsetOrientation orient = calculateRectangleBorderOrientation(
position, d, DEFAULT_SHAPE_INSETS);
// snap to grid and store the value in the model
orient.setOffset(snapToGrid(orient.getOffset()));
setConnectorOffsetOrientation(layouted, orient);
......
......@@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.Composite;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: D72A875CBFB2BC8DFAB51FCCEE910F0A
* @ConQAT.Rating GREEN Hash: 877B1F139CCBFED05771E43F31FA489F
*/
public class TableViewerUtils {
......@@ -108,6 +108,7 @@ public class TableViewerUtils {
CellEditor ce = new TextCellEditor(parent);
ce.setValidator(new ICellEditorValidator() {
/** {@inheritDoc} */
@Override
public String isValid(Object value) {
try {
......
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