Skip to content
Snippets Groups Projects
Commit 0398af76 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

cleanup tooling.base.ui => YELLOW

refs 311
parent 233cf9a9
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
......@@ -37,14 +37,11 @@ import org.fortiss.tooling.kernel.ui.util.DataBindingUtils;
* Decoration is in effect if either {@link #getTextValidator()} or
* {@link #getTextPostConvertValidator()} returns a non-null {@link IValidator}.
*
* @author hoelzlf
* @author $Author: hoelzlf $
* @version $Rev: 1670 $
* @levd.rating RED Rev:
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 06F0B1246D80A923D8D6CC99575F57A5
*/
// TODO (FH): I think we do not need this class anymore
// Only data state editor uses it. Isnt there a part in MIRA
// with cell editing? If so we should use MIRAs version of data binding
public abstract class AbstractDecoratedTextCellDatabindingEditingSupport extends
AbstractTextCellDatabindingEditingSupport {
......
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
......@@ -36,14 +36,10 @@ import org.fortiss.tooling.kernel.ui.util.DataBindingUtils;
* Abstract base class for inline text cell editors using data binding.
*
* @author hoelzlf
* @author $Author: hoelzlf $
* @version $Rev: 5848 $
* @levd.rating RED Rev:
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 4332834DD629BC28D0C0E6C5F3FBEE60
*/
// TODO (FH): I think we do not need this class anymore
// Only data state editor uses it. Isnt there a part in MIRA
// with cell editing? If so we should use MIRAs version of data binding
public abstract class AbstractTextCellDatabindingEditingSupport extends
EditingSupport {
......@@ -151,11 +147,6 @@ public abstract class AbstractTextCellDatabindingEditingSupport extends
* deactivated. This assures that no binding created by
* {@link #createBinding(CellEditor, ViewerCell, CellEditor, DataBindingContext)}
* is left behind in the {@link DataBindingContext}.
*
* @author hoelzlf
* @author $Author: hoelzlf $
* @version $Rev: 5848 $
* @levd.rating RED Rev:
*/
private class ColumnViewerEditorActivationListenerHelper extends
ColumnViewerEditorActivationListener {
......
......@@ -17,37 +17,61 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.utils;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
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.model.layout.EOrientation.EAST;
import static org.fortiss.tooling.base.model.layout.EOrientation.NORTH;
import static org.fortiss.tooling.base.model.layout.EOrientation.SOUTH;
import static org.fortiss.tooling.base.model.layout.EOrientation.WEST;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getAbsolute;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getConnectorOffsetOrientation;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getNodePosition;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getNodeSize;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.setConnectorOffsetOrientation;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.setNodePosition;
import static org.fortiss.tooling.base.ui.utils.SnapToGridUtils.snapToGrid;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createOffsetOrientation;
import java.awt.Polygon;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.ui.dnd.gef.ElementDropContext;
import org.fortiss.tooling.base.utils.LayoutModelElementFactory;
/**
* Utility class for rectangle-shaped edit part layout.
*
* @author wandinger
* @author hummel
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3DAA7FF0B916B47CC06441E6AC6808BC
* @ConQAT.Rating YELLOW Hash: 80F0CE6BDF08AD19CD6F1A664995CE02
*/
public class RectangleLayoutUtils {
/**
* Returns the {@link OffsetOrientation} of the point on the rectangle
* border having a given Point inside the rectangle.
*
* @param source
* the relative coordinates in the rectangle
* @param rectangleSize
* the size of the rectangle
* @param inset
* the inset from each side
* @return the offset and orientation
*/
public static OffsetOrientation calculateRectangleBorderOrientation(
Point source, Dimension rectangleSize, int inset) {
int offset = 0;
EOrientation orientation = EOrientation.NORTH;
EOrientation orientation = NORTH;
// The figure bounds
Rectangle bounds = new Rectangle(0, 0, rectangleSize.width,
......@@ -69,28 +93,37 @@ public class RectangleLayoutUtils {
// Determine in which sector we are and clamp the position accordingly
if (northSector.contains(source.x, source.y)) {
orientation = EOrientation.NORTH;
orientation = NORTH;
offset = (int) (source.x * (1 - (2 * inset) / (double) bounds.width));
}
if (westSector.contains(source.x, source.y)) {
orientation = EOrientation.WEST;
orientation = WEST;
offset = (int) (source.y * (1 - (2 * inset)
/ (double) bounds.height));
}
if (southSector.contains(source.x, source.y)) {
orientation = EOrientation.SOUTH;
orientation = SOUTH;
offset = (int) (source.x * (1 - (2 * inset) / (double) bounds.width));
}
if (eastSector.contains(source.x, source.y)) {
orientation = EOrientation.EAST;
orientation = EAST;
offset = (int) (source.y * (1 - (2 * inset)
/ (double) bounds.height));
}
return LayoutModelElementFactory.createOffsetOrientation(offset,
orientation, null);
return createOffsetOrientation(offset, orientation, null);
}
/** Ensure that the minimum size of a rectangular shape is redeemed. */
/**
* Ensure that the minimum size of a rectangular shape is redeemed.
*
* @param oldSize
* the old size to be adjusted
* @param minimumWidth
* the minimum to be redeemed
* @param minimumHeight
* the minimum height to be redeemed
* @return the new dimensions
*/
public static Dimension clampRectangularShapeSize(Dimension oldSize,
int minimumWidth, int minimumHeight) {
// check for minimum size
......@@ -100,82 +133,115 @@ public class RectangleLayoutUtils {
return newSize;
}
/** Ensure that the minimum size of a rectangular shape is redeemed. */
/**
* Ensure that the minimum size of a rectangular shape is redeemed.
*
* @param oldSize
* the old size to be adjusted
* @return the new dimensions
*/
public static Dimension retainMinimumRectangularShapeSize(Dimension oldSize) {
return clampRectangularShapeSize(oldSize,
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH,
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT);
return clampRectangularShapeSize(oldSize, DEFAULT_SHAPE_MINIMUM_WIDTH,
DEFAULT_SHAPE_MINIMUM_HEIGHT);
}
/** Layouts the given connector within the surrounding rectangle. */
/**
* Layouts the given connector within the surrounding rectangle.
*
* @param layouted
* the connector element
* @param container
* the container of the connector
* @param location
* the location in the rectangle to be used as hint
*/
public static void layoutConnectorInRectangle(
ILayoutedModelElement layouted, ILayoutedModelElement container,
Point location) {
Point position = location.getCopy();
org.fortiss.tooling.base.model.layout.Point np = LayoutDataUtils
.getNodePosition(container);
org.fortiss.tooling.base.model.layout.Point np = getNodePosition(container);
position.translate(-np.getX(), -np.getY());
// do border clamping
org.fortiss.tooling.base.model.layout.Dimension nd = LayoutDataUtils
.getNodeSize(container);
org.fortiss.tooling.base.model.layout.Dimension nd = getNodeSize(container);
Dimension d = new Dimension(nd.getWidth(), nd.getHeight());
OffsetOrientation orient = RectangleLayoutUtils
.calculateRectangleBorderOrientation(position, d,
DefaultLayoutConstants.DEFAULT_SHAPE_INSETS);
DEFAULT_SHAPE_INSETS);
// snap to grid and store the value in the model
orient.setOffset(SnapToGridUtils.snapToGrid(orient.getOffset()));
LayoutDataUtils.setConnectorOffsetOrientation(layouted, orient);
orient.setOffset(snapToGrid(orient.getOffset()));
setConnectorOffsetOrientation(layouted, orient);
}
/** Layouts the given layouted object using the position in the context. */
/**
* Layouts the given layouted object using the position in the context
*
* @param layouted
* the node to be layouted
* @param context
* the location context information to be used
* @param positionOffset
* the offset to adj ust the context location, e.g. grid size
* @param snapToGrid
* snap to grid should be performed or not
*/
public static void layoutNodeInRoot(ILayoutedModelElement layouted,
ElementDropContext context, int positionOffset, boolean snapToGrid) {
layoutNodeInRoot(layouted, context.getPosition(), positionOffset,
snapToGrid);
}
/** Layouts the given layouted object using the position in the context. */
/**
* Layouts the given layouted object using the position in the context.
*
* @param layouted
* the node to be layouted
* @param location
* the location information to be used
* @param positionOffset
* the offset to adjust the location, e.g. grid size
* @param snapToGrid
* snap to grid should be performed or not
*/
public static void layoutNodeInRoot(ILayoutedModelElement layouted,
Point location, int positionOffset, boolean snapToGrid) {
Point position = location.getCopy();
position.translate(-positionOffset, -positionOffset);
if (snapToGrid) {
SnapToGridUtils.snapToGrid(position);
snapToGrid(position);
}
LayoutDataUtils.setNodePosition(layouted, position.x, position.y);
setNodePosition(layouted, position.x, position.y);
}
/** Returns the bounds rectangle of the connector given its parent bounds. */
/**
* Returns the bounds rectangle of the connector given its parent bounds.
*
* @param connector
* the connector with relative positions
* @param parent
* the parent container
* @returns the absolute rectangle
*/
public static Rectangle getAbsoluteConnectorBounds(
ILayoutedModelElement connector, ILayoutedModelElement parent) {
Rectangle result = new Rectangle(0, 0,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE);
Rectangle result = new Rectangle(0, 0, DEFAULT_CONNECTOR_SIZE,
DEFAULT_CONNECTOR_SIZE);
// get orientation
OffsetOrientation orient = LayoutDataUtils
.getConnectorOffsetOrientation(connector);
OffsetOrientation orient = getConnectorOffsetOrientation(connector);
// get parent size
org.fortiss.tooling.base.model.layout.Dimension parentSize = LayoutDataUtils
.getNodeSize(parent);
org.fortiss.tooling.base.model.layout.Point pos = LayoutDataUtils
.getAbsolute(orient, parentSize,
DefaultLayoutConstants.DEFAULT_SHAPE_INSETS);
org.fortiss.tooling.base.model.layout.Dimension parentSize = getNodeSize(parent);
org.fortiss.tooling.base.model.layout.Point pos = getAbsolute(orient,
parentSize, DEFAULT_SHAPE_INSETS);
int relX = pos.getX();
int relY = pos.getY();
org.fortiss.tooling.base.model.layout.Point parentPos = LayoutDataUtils
.getNodePosition(parent);
org.fortiss.tooling.base.model.layout.Point parentPos = getNodePosition(parent);
// fix X coordinate
if (relX > parentSize.getWidth()
- DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE) {
relX = parentSize.getWidth()
- DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
if (relX > parentSize.getWidth() - DEFAULT_CONNECTOR_SIZE) {
relX = parentSize.getWidth() - DEFAULT_CONNECTOR_SIZE;
}
// fix Y coordinate
if (relY > parentSize.getHeight()
- DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE) {
relY = parentSize.getHeight()
- DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
if (relY > parentSize.getHeight() - DEFAULT_CONNECTOR_SIZE) {
relY = parentSize.getHeight() - DEFAULT_CONNECTOR_SIZE;
}
result.x = parentPos.getX() + relX;
......
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