Bug 391523 - Revise getSelectionInfo...() in IToolBehaviorProvider
* use of handle colors provided by IShapeSelectionInfo
Change-Id: I486c5bd7c3afe055400fe377e761b82d3e67311b
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFCornerHandle.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFCornerHandle.java
index 7b90094..73fac43 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFCornerHandle.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFCornerHandle.java
@@ -28,8 +28,11 @@
import org.eclipse.gef.handles.AbstractHandle;
import org.eclipse.gef.tools.DragEditPartsTracker;
import org.eclipse.gef.tools.ResizeTracker;
+import org.eclipse.graphiti.tb.IShapeSelectionInfo;
import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal;
import org.eclipse.graphiti.ui.internal.figures.GFFigureUtil;
+import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation;
+import org.eclipse.graphiti.util.IColorConstant;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Color;
@@ -116,6 +119,11 @@
private boolean movable;
/**
+ * the selection info, e.g. handle colors
+ */
+ private IShapeSelectionInfo shapeSelectionInfo;
+
+ /**
* Creates a new GFCornerHandle.
*
* @param owner
@@ -133,12 +141,14 @@
* @param movable
* Indicates, if moving the shape edit-part via this handle is
* supported.
+ * @param shapeSelectionInfo
*/
public GFCornerHandle(GraphicalEditPart owner, IConfigurationProviderInternal configurationProvider, int location,
- int supportedResizeDirections, boolean movable) {
+ int supportedResizeDirections, boolean movable, IShapeSelectionInfo shapeSelectionInfo) {
this.configurationProvider = configurationProvider;
this.resizeDirection = supportedResizeDirections & location;
this.movable = movable;
+ this.shapeSelectionInfo = shapeSelectionInfo;
setOwner(owner);
setLocator(new ZoomingRelativeHandleLocator(owner.getFigure(), configurationProvider, location,
@@ -159,6 +169,13 @@
* @return the fG_COLOR_PRIMARY_RESIZABLE
*/
public Color getFG_COLOR_PRIMARY_RESIZABLE() {
+ if (shapeSelectionInfo != null) {
+ IColorConstant color = shapeSelectionInfo.getPrimarySelectionHandleForegroundColor();
+ if (color != null) {
+ Color swtColor = DataTypeTransformation.toSwtColor(configurationProvider.getResourceRegistry(), color);
+ return swtColor;
+ }
+ }
if (FG_COLOR_PRIMARY_RESIZABLE == null || FG_COLOR_PRIMARY_RESIZABLE.isDisposed())
FG_COLOR_PRIMARY_RESIZABLE = configurationProvider.getResourceRegistry().getSwtColor("f17d00"); //$NON-NLS-1$
return FG_COLOR_PRIMARY_RESIZABLE;
@@ -168,6 +185,13 @@
* @return the fG_COLOR_SECONDARY_RESIZABLE
*/
public Color getFG_COLOR_SECONDARY_RESIZABLE() {
+ if (shapeSelectionInfo != null) {
+ IColorConstant color = shapeSelectionInfo.getSecondarySelectionHandleForegroundColor();
+ if (color != null) {
+ Color swtColor = DataTypeTransformation.toSwtColor(configurationProvider.getResourceRegistry(), color);
+ return swtColor;
+ }
+ }
if (FG_COLOR_SECONDARY_RESIZABLE == null || FG_COLOR_SECONDARY_RESIZABLE.isDisposed())
FG_COLOR_SECONDARY_RESIZABLE = configurationProvider.getResourceRegistry().getSwtColor("f17d00"); //$NON-NLS-1$
return FG_COLOR_SECONDARY_RESIZABLE;
@@ -186,6 +210,13 @@
* @return the bG_COLOR_PRIMARY_RESIZABLE
*/
public Color getBG_COLOR_PRIMARY_RESIZABLE() {
+ if (shapeSelectionInfo != null) {
+ IColorConstant color = shapeSelectionInfo.getPrimarySelectionHandleBackgroundColor();
+ if (color != null) {
+ Color swtColor = DataTypeTransformation.toSwtColor(configurationProvider.getResourceRegistry(), color);
+ return swtColor;
+ }
+ }
if (BG_COLOR_PRIMARY_RESIZABLE == null || BG_COLOR_PRIMARY_RESIZABLE.isDisposed())
BG_COLOR_PRIMARY_RESIZABLE = configurationProvider.getResourceRegistry().getSwtColor("ff8400"); //$NON-NLS-1$
return BG_COLOR_PRIMARY_RESIZABLE;
@@ -195,6 +226,13 @@
* @return the bG_COLOR_SECONDARY_RESIZABLE
*/
public Color getBG_COLOR_SECONDARY_RESIZABLE() {
+ if (shapeSelectionInfo != null) {
+ IColorConstant color = shapeSelectionInfo.getSecondarySelectionHandleBackgroundColor();
+ if (color != null) {
+ Color swtColor = DataTypeTransformation.toSwtColor(configurationProvider.getResourceRegistry(), color);
+ return swtColor;
+ }
+ }
if (BG_COLOR_SECONDARY_RESIZABLE == null || BG_COLOR_SECONDARY_RESIZABLE.isDisposed())
BG_COLOR_SECONDARY_RESIZABLE = configurationProvider.getResourceRegistry().getSwtColor("ffffff"); //$NON-NLS-1$
return BG_COLOR_SECONDARY_RESIZABLE;
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFHandleHelper.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFHandleHelper.java
index aec6c9a..a49d4df 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFHandleHelper.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFHandleHelper.java
@@ -10,6 +10,7 @@
* Contributors:
* SAP AG - initial API, implementation and documentation
* mwenz - Bug 346487 - No selection feedback for non-resizable diagram nodes
+ * mgorning - Bug 391523 - Revise getSelectionInfo...() in IToolBehaviorProvider
*
* </copyright>
*
@@ -22,6 +23,10 @@
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.handles.AbstractHandle;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.tb.IShapeSelectionInfo;
+import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal;
import org.eclipse.graphiti.ui.platform.IConfigurationProvider;
@@ -70,25 +75,38 @@
int supportedResizeDirections, boolean movable, boolean resizeAllowed) {
List<AbstractHandle> list = new ArrayList<AbstractHandle>();
- list.add(new GFSurroundingHandle(owner, cp, PositionConstants.NSEW, movable));
+ IShapeSelectionInfo si = null;
+ IToolBehaviorProvider tbp = cp.getDiagramTypeProvider().getCurrentToolBehaviorProvider();
+ Object model = owner.getModel();
+ if (model instanceof Shape) {
+ si = tbp.getSelectionInfoForShape((Shape) model);
+ } else if (model instanceof Anchor) {
+ si = tbp.getSelectionInfoForAnchor((Anchor) model);
+ }
+
+ list.add(new GFSurroundingHandle(owner, cp, PositionConstants.NSEW, movable, si));
if (resizeAllowed) {
if ((PositionConstants.NORTH_EAST & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.NORTH_EAST, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.NORTH_EAST, supportedResizeDirections,
+ movable, si));
if ((PositionConstants.SOUTH_EAST & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.SOUTH_EAST, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.SOUTH_EAST, supportedResizeDirections,
+ movable, si));
if ((PositionConstants.SOUTH_WEST & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.SOUTH_WEST, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.SOUTH_WEST, supportedResizeDirections,
+ movable, si));
if ((PositionConstants.NORTH_WEST & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.NORTH_WEST, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.NORTH_WEST, supportedResizeDirections,
+ movable, si));
if ((PositionConstants.NORTH & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.NORTH, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.NORTH, supportedResizeDirections, movable, si));
if ((PositionConstants.EAST & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.EAST, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.EAST, supportedResizeDirections, movable, si));
if ((PositionConstants.SOUTH & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.SOUTH, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.SOUTH, supportedResizeDirections, movable, si));
if ((PositionConstants.WEST & supportedResizeDirections) != 0)
- list.add(new GFCornerHandle(owner, cp, PositionConstants.WEST, supportedResizeDirections, movable));
+ list.add(new GFCornerHandle(owner, cp, PositionConstants.WEST, supportedResizeDirections, movable, si));
}
return list;
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java
index d5dbfac..5511aa5 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java
@@ -10,6 +10,7 @@
* Contributors:
* SAP AG - initial API, implementation and documentation
* mgorning - Bug 365172 - Shape Selection Info Solid Line
+ * mgorning - Bug 391523 - Revise getSelectionInfo...() in IToolBehaviorProvider
*
* </copyright>
*
@@ -28,12 +29,9 @@
import org.eclipse.gef.handles.AbstractHandle;
import org.eclipse.gef.tools.DragEditPartsTracker;
import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
-import org.eclipse.graphiti.mm.pictograms.Shape;
-import org.eclipse.graphiti.tb.ISelectionInfo;
-import org.eclipse.graphiti.tb.IToolBehaviorProvider;
+import org.eclipse.graphiti.tb.IShapeSelectionInfo;
import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal;
import org.eclipse.graphiti.ui.internal.figures.GFFigureUtil;
-import org.eclipse.graphiti.ui.internal.parts.ShapeEditPart;
import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
@@ -105,7 +103,7 @@
*/
private boolean movable;
- private ISelectionInfo selectionInfoForShape = null;
+ private IShapeSelectionInfo shapeSelectionInfo = null;
/**
* Creates a new GFSurroundingHandle.
@@ -121,18 +119,14 @@
* @param movable
* Indicates, if moving the owner edit-part via this handle is
* supported.
+ * @param shapeSelectionInfo
*/
public GFSurroundingHandle(GraphicalEditPart owner, IConfigurationProviderInternal configurationProvider,
- int supportedResizeDirections, boolean movable) {
+ int supportedResizeDirections, boolean movable, IShapeSelectionInfo shapeSelectionInfo) {
this.configurationProvider = configurationProvider;
this.supportedResizeDirections = supportedResizeDirections;
this.movable = movable;
-
- if (owner instanceof ShapeEditPart && owner.getModel() instanceof Shape) {
- Shape shape = (Shape) owner.getModel();
- IToolBehaviorProvider tbp = configurationProvider.getDiagramTypeProvider().getCurrentToolBehaviorProvider();
- selectionInfoForShape = tbp.getSelectionInfoForShape(shape);
- }
+ this.shapeSelectionInfo = shapeSelectionInfo;
setOwner(owner);
setLocator(new ZoomingInsetsHandleLocator(owner.getFigure(), configurationProvider, HANDLE_INSETS));
@@ -229,8 +223,8 @@
fg = getFG_COLOR_NOT_RESIZABLE();
}
- if (selectionInfoForShape != null) {
- LineStyle lineStyle = selectionInfoForShape.getLineStyle();
+ if (shapeSelectionInfo != null) {
+ LineStyle lineStyle = shapeSelectionInfo.getLineStyle();
int draw2dLineStyle = DataTypeTransformation.toDraw2dLineStyle(lineStyle);
g.setLineStyle(draw2dLineStyle);
} else {