Skip to content

Commit

Permalink
[376] Remove code now accessible as APIs in GEF
Browse files Browse the repository at this point in the history
This commit removes the code duplicated from GEF as it is now available
as API in GEF (through issue
eclipse-gef/gef-classic#426).

Bug: #376
  • Loading branch information
lredor committed Apr 25, 2024
1 parent 06dc15e commit 868617a
Showing 1 changed file with 6 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.tools.internal.ui;

import java.util.Date;

import org.eclipse.core.runtime.Platform;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.PositionConstants;
Expand Down Expand Up @@ -190,24 +188,24 @@ protected boolean handleKeyDown(KeyEvent event) {

// Reproduce the "acceleration behavior" of
// org.eclipse.gef.tools.DragEditPartsTracker.handleKeyDown(KeyEvent) to get the increment to use.
siriusAccStepIncrement();
accStepIncrement();
PrecisionPoint moveDelta;
switch (event.keyCode) {
case SWT.ARROW_DOWN:
moveDelta = new PrecisionPoint(0, siriusAccGetStep());
moveDelta = new PrecisionPoint(0, accGetStep());
break;
case SWT.ARROW_UP:
moveDelta = new PrecisionPoint(0, -siriusAccGetStep());
moveDelta = new PrecisionPoint(0, -accGetStep());
break;
case SWT.ARROW_RIGHT:
int stepping = siriusAccGetStep();
int stepping = accGetStep();
if (isCurrentViewerMirrored2()) {
stepping = -stepping;
}
moveDelta = new PrecisionPoint(stepping, 0);
break;
case SWT.ARROW_LEFT:
int step = -siriusAccGetStep();
int step = -accGetStep();
if (isCurrentViewerMirrored2()) {
step = -step;
}
Expand Down Expand Up @@ -260,7 +258,7 @@ protected boolean handleKeyUp(KeyEvent event) {
}
if (acceptArrowKey(event)) {
moveWithArrowKeysSiriusMode = false;
siriusAccStepReset();
accStepReset();
}
return super.handleKeyUp(event);
}
Expand Down Expand Up @@ -349,52 +347,4 @@ protected boolean updateTargetUnderMouse() {
}
return super.updateTargetUnderMouse();
}

/**
* Method overridden to initialize the cloned field {@link #accessibleBegin}. No longer necessary as soon as GEF
* issue https://github.com/eclipse/gef-classic/issues/426 will be done.
*
* @see org.eclipse.gef.tools.AbstractTool#activate()
*/
@Override
public void activate() {
super.activate();
siriusAccStepReset();
}

/**
* Method cloned from {@link org.eclipse.gef.tools.AbstractTool#.accGetStep()} to have the same behavior here. No
* longer necessary as soon as GEF issue https://github.com/eclipse/gef-classic/issues/426 will be done.
*
* @return the current computed step.
*/
int siriusAccGetStep() {
return accessibleStep;
}

/**
* Method cloned from {@link org.eclipse.gef.tools.AbstractTool#accStepIncrement()} to have the same behavior here.
* No longer necessary as soon as GEF issue https://github.com/eclipse/gef-classic/issues/426 will be done.
*
* @return the current computed step.
*/
void siriusAccStepIncrement() {
if (accessibleBegin == -1) {
accessibleBegin = new Date().getTime();
accessibleStep = 1;
} else {
accessibleStep = 4;
long elapsed = new Date().getTime() - accessibleBegin;
if (elapsed > 1000)
accessibleStep = Math.min(16, (int) (elapsed / 150));
}
}

/**
* Method cloned from {@link org.eclipse.gef.tools.AbstractTool#accStepReset()} to have the same behavior here. No
* longer necessary as soon as GEF issue https://github.com/eclipse/gef-classic/issues/426 will be done.
*/
void siriusAccStepReset() {
accessibleBegin = -1;
}
}

0 comments on commit 868617a

Please sign in to comment.