Skip to content

Commit 0d582ee

Browse files
committed
[GEF] Align handleMove() with GEF CreationTool
The current command should be set before showing the target feedback. Doing so requires an early update of the grid so that the grid-target is up-to-date when calculating the command.
1 parent 4ef3648 commit 0d582ee

8 files changed

Lines changed: 28 additions & 17 deletions

File tree

‎org.eclipse.wb.core/src-gef/org/eclipse/wb/gef/core/tools/AbstractCreationTool.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ protected boolean handleButtonUp(int button) {
7575
protected boolean handleMove() {
7676
updateTargetRequest();
7777
updateTargetUnderMouse();
78-
showTargetFeedback();
7978
setCurrentCommand(getCommand());
79+
showTargetFeedback();
8080
return true;
8181
}
8282

‎org.eclipse.wb.core/src/org/eclipse/wb/core/gef/policy/layout/grid/AbstractGridLayoutEditPolicy.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.eclipse.wb.core.model.broadcast.ObjectEventListener;
2424
import org.eclipse.wb.draw2d.FigureUtils;
2525
import org.eclipse.wb.gef.core.IEditPartViewer;
26+
import org.eclipse.wb.gef.core.requests.PasteRequest;
2627
import org.eclipse.wb.gef.graphical.policies.LayoutEditPolicy;
2728
import org.eclipse.wb.internal.core.DesignerPlugin;
2829
import org.eclipse.wb.internal.draw2d.SemiTransparentFigure;
@@ -35,6 +36,7 @@
3536
import org.eclipse.gef.EditPartListener;
3637
import org.eclipse.gef.EditPolicy;
3738
import org.eclipse.gef.Request;
39+
import org.eclipse.gef.RequestConstants;
3840
import org.eclipse.gef.requests.DropRequest;
3941
import org.eclipse.swt.graphics.Color;
4042

@@ -121,6 +123,15 @@ private void refreshSelectionGrid() {
121123
private static final Color m_badTargetFillColor = new Color(255, 0, 0);
122124
private static final Color m_badTargetBorderColor = new Color(255, 192, 192);
123125

126+
@Override
127+
public EditPart getTargetEditPart(Request request) {
128+
if (RequestConstants.REQ_CREATE.equals(request.getType()) || PasteRequest.REQ_PASTE.equals(request.getType())) {
129+
Point location = PolicyUtils.getAbsoluteLocation(getHost(), (DropRequest) request);
130+
updateGridTarget(location);
131+
}
132+
return super.getTargetEditPart(request);
133+
}
134+
124135
@Override
125136
protected final void showLayoutTargetFeedback(Request request) {
126137
IGridInfo gridInfo = getGridInfo();
@@ -368,5 +379,5 @@ public String toString() {
368379
* @param mouseLocation
369380
* the location of mouse in absolute coordinates.
370381
*/
371-
protected abstract void updateGridTarget(Point mouseLocation) throws Exception;
382+
protected abstract void updateGridTarget(Point mouseLocation);
372383
}

‎org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/gef/policy/forms/layout/grid/TableWrapLayoutEditPolicy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public static int[] getInsertFeedbackParameters(Interval interval,
244244
}
245245

246246
@Override
247-
protected void updateGridTarget(Point mouseLocation) throws Exception {
247+
protected void updateGridTarget(Point mouseLocation) {
248248
m_target = new GridTarget();
249249
// prepare location in model
250250
Point location = mouseLocation.getCopy();

‎org.eclipse.wb.swing.FormLayout/src/org/eclipse/wb/internal/swing/FormLayout/gef/FormLayoutEditPolicy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected void executeEdit() throws Exception {
226226
//
227227
////////////////////////////////////////////////////////////////////////////
228228
@Override
229-
protected void updateGridTarget(Point mouseLocation) throws Exception {
229+
protected void updateGridTarget(Point mouseLocation) {
230230
m_target = new GridTarget();
231231
//
232232
mouseLocation = mouseLocation.getCopy();

‎org.eclipse.wb.swing.MigLayout/src/org/eclipse/wb/internal/swing/MigLayout/gef/MigLayoutEditPolicy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public static int[] getInsertFeedbackParameters(Interval interval,
323323
}
324324

325325
@Override
326-
protected void updateGridTarget(Point mouseLocation) throws Exception {
326+
protected void updateGridTarget(Point mouseLocation) {
327327
m_target = new GridTarget();
328328
// prepare location in model
329329
Point location = mouseLocation.getCopy();

‎org.eclipse.wb.swing/src/org/eclipse/wb/internal/swing/gef/policy/layout/gbl/GridBagLayoutEditPolicy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ protected Command getAddCommand(ChangeBoundsRequest request) {
180180
//
181181
////////////////////////////////////////////////////////////////////////////
182182
@Override
183-
protected void updateGridTarget(Point mouseLocation) throws Exception {
183+
protected void updateGridTarget(Point mouseLocation) {
184184
m_target = new GridTarget();
185185
// prepare location in model
186186
Point location = mouseLocation.getCopy();

‎org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/gef/policy/layout/grid/GridLayoutEditPolicy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public static int[] getInsertFeedbackParameters(Interval interval,
294294
}
295295

296296
@Override
297-
protected void updateGridTarget(Point mouseLocation) throws Exception {
297+
protected void updateGridTarget(Point mouseLocation) {
298298
m_target = new GridTarget();
299299
// prepare location in model
300300
Point location = mouseLocation.getCopy();

‎org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/AbstractCreationToolTest.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public void test_Move_DND() throws Exception {
7676
"getTargetEditPart",
7777
"getTargetEditPart",
7878
"showTargetFeedback",
79-
"showTargetFeedback",
80-
"getCommand"}, m_request);
79+
"getCommand",
80+
"showTargetFeedback"}, m_request);
8181
assertLoggers(expectedLogger, actualLogger);
8282
}
8383
// exit from "editPart" and enter in "childEditPart1"
@@ -92,8 +92,8 @@ public void test_Move_DND() throws Exception {
9292
expectedLogger.log(editPart, "eraseTargetFeedback", m_request);
9393
expectedLogger.log(childEditPart1, new String[]{
9494
"showTargetFeedback",
95-
"showTargetFeedback",
96-
"getCommand"}, m_request);
95+
"getCommand",
96+
"showTargetFeedback"}, m_request);
9797
assertLoggers(expectedLogger, actualLogger);
9898
}
9999
// move into "childEditPart1"
@@ -105,8 +105,8 @@ public void test_Move_DND() throws Exception {
105105
expectedLogger.log(childEditPart1, new String[]{
106106
"getTargetEditPart",
107107
"getTargetEditPart",
108-
"showTargetFeedback",
109-
"getCommand"}, m_request);
108+
"getCommand",
109+
"showTargetFeedback"}, m_request);
110110
assertLoggers(expectedLogger, actualLogger);
111111
}
112112
// start drag process
@@ -184,8 +184,8 @@ public void test_Move_DND_InvalidInput() throws Exception {
184184
"getTargetEditPart",
185185
"getTargetEditPart",
186186
"showTargetFeedback",
187-
"showTargetFeedback",
188-
"getCommand"}, m_request);
187+
"getCommand",
188+
"showTargetFeedback"}, m_request);
189189
assertLoggers(expectedLogger, actualLogger);
190190
}
191191
// click into "editPart" invalid button
@@ -213,8 +213,8 @@ public void test_Move_DND_InvalidInput() throws Exception {
213213
"getTargetEditPart",
214214
"getTargetEditPart",
215215
"showTargetFeedback",
216-
"showTargetFeedback",
217-
"getCommand"}, m_request);
216+
"getCommand",
217+
"showTargetFeedback"}, m_request);
218218
assertLoggers(expectedLogger, actualLogger);
219219
}
220220
// start drag process

0 commit comments

Comments
 (0)