Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[376] Remove code now accessible as APIs in GEF #377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,71 +347,4 @@ protected boolean updateTargetUnderMouse() {
}
return super.updateTargetUnderMouse();
}

/**
* Return true if a move is currently in progress with arrow key, false otherwise.
*
* @return true if a move is currently in progress with arrow key, false otherwise.
*/
public boolean isMoveWithArrowKeysSiriusMode() {
return moveWithArrowKeysSiriusMode;
}

/**
* Set the moveWithArrowKeysSiriusMode.
*
* @param moveWithArrowKeysSiriusMode
* The new mode status
*/
protected void setMoveWithArrowKeysSiriusMode(boolean moveWithArrowKeysSiriusMode) {
this.moveWithArrowKeysSiriusMode = moveWithArrowKeysSiriusMode;
}

/**
* 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;
}
}