Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2014-07-02 09:23:40 +0000
committerLaurent Redor2014-07-04 10:11:30 +0000
commit805c193c509f2f733d0fe4df2feeff0d174d53a7 (patch)
tree97720cbb1bf119e854ecd346de01be0a9090f079
parentccfa161676d84e3cab88cc45893b0ae0f8bbb4d5 (diff)
downloadorg.eclipse.sirius-805c193c509f2f733d0fe4df2feeff0d174d53a7.tar.gz
org.eclipse.sirius-805c193c509f2f733d0fe4df2feeff0d174d53a7.tar.xz
org.eclipse.sirius-805c193c509f2f733d0fe4df2feeff0d174d53a7.zip
[438691] Adapt code to new version of duplicated class
The code of original RubberbandSelectionTool (from org.eclipse.gmf.runtime.diagram.ui.internal.tools) has been changed since the duplication. This commit only reflects these changes. Bug: 438691 Change-Id: I346313c2bb475ec3a6bae52f93ad970d767bbf70 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/diagram/ui/tools/RubberbandSelectionTool.java39
1 files changed, 23 insertions, 16 deletions
diff --git a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/diagram/ui/tools/RubberbandSelectionTool.java b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/diagram/ui/tools/RubberbandSelectionTool.java
index 8ae3d1b471..f56b4bdc0b 100644
--- a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/diagram/ui/tools/RubberbandSelectionTool.java
+++ b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/diagram/ui/tools/RubberbandSelectionTool.java
@@ -21,7 +21,7 @@ import java.util.List;
import java.util.ListIterator;
import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Cursors;
+import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.Graphics;
@@ -30,6 +30,7 @@ import org.eclipse.draw2d.Viewport;
import org.eclipse.draw2d.ViewportUtilities;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.GraphicalEditPart;
@@ -38,6 +39,7 @@ import org.eclipse.gef.KeyHandler;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.SharedCursors;
import org.eclipse.gef.editparts.LayerManager;
import org.eclipse.gef.tools.AbstractTool;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
@@ -117,7 +119,7 @@ public class RubberbandSelectionTool extends AbstractTool {
* Creates a new MarqueeSelectionTool.
*/
public RubberbandSelectionTool() {
- setDefaultCursor(Cursors.CROSS);
+ setDefaultCursor(SharedCursors.CROSS);
setUnloadWhenFinished(false);
}
@@ -125,6 +127,7 @@ public class RubberbandSelectionTool extends AbstractTool {
List newSelections = new ArrayList();
Iterator children = getAllChildren().iterator();
+ Rectangle marqueeBounds = getMarqueeBounds();
int selectionMode = SELECTION_CONTAINED_MODE;
if (feedBackStartLocation != null && feedBackStartLocation.x != getMarqueeBounds().getLeft().x) {
@@ -138,22 +141,26 @@ public class RubberbandSelectionTool extends AbstractTool {
// children who are not visible
while (children.hasNext()) {
EditPart child = (EditPart) children.next();
- if (!child.isSelectable()) {
+ IFigure figure = ((GraphicalEditPart) child).getFigure();
+ if (!child.isSelectable() || child.getTargetEditPart(MARQUEE_REQUEST) != child || !((child instanceof IBorderItemEditPart && isBorderFigureVisible(figure)) || isFigureVisible(figure))) {
continue;
}
- IFigure figure = ((GraphicalEditPart) child).getFigure();
- Rectangle r = figure.getBounds().getCopy();
+ Rectangle r;
+ if (child instanceof ConnectionEditPart) {
+ // RATLC00569348 For connection, get the bounds of connection
+ // points rather than connection figure since the
+ // figure's bounds contain the bounds of all connection children
+ // and would require selection rectangle
+ // to be larger than expected in some cases
+ r = ((Connection) figure).getPoints().getBounds().getCopy();
+ } else {
+ r = figure.getBounds().getCopy();
+ }
figure.translateToAbsolute(r);
-
- Rectangle marqueeBounds = getMarqueeBounds();
getMarqueeFeedbackFigure().translateToRelative(r);
- if (child.getTargetEditPart(MARQUEE_REQUEST) == child) {
- if ((selectionMode == SELECTION_CONTAINED_MODE && marqueeBounds.contains(r.getTopLeft()) && marqueeBounds.contains(r.getBottomRight()))
- || (selectionMode == SELECTION_TOUCHED_MODE && marqueeBounds.intersects(r))) {
- if ((child instanceof IBorderItemEditPart && isBorderFigureVisible(figure)) || isFigureVisible(figure)) {
- newSelections.add(child);
- }
- }
+ if ((selectionMode == SELECTION_CONTAINED_MODE && marqueeBounds.contains(r.getTopLeft()) && marqueeBounds.contains(r.getBottomRight()))
+ || (selectionMode == SELECTION_TOUCHED_MODE && marqueeBounds.intersects(r))) {
+ newSelections.add(child);
}
}
return newSelections;
@@ -489,9 +496,9 @@ public class RubberbandSelectionTool extends AbstractTool {
}
super.setViewer(viewer);
if (viewer instanceof GraphicalViewer) {
- setDefaultCursor(Cursors.CROSS);
+ setDefaultCursor(SharedCursors.CROSS);
} else {
- setDefaultCursor(Cursors.NO);
+ setDefaultCursor(SharedCursors.NO);
}
if (viewer != null) {
weakReference = new WeakReference(viewer);

Back to the top