Skip to content
Snippets Groups Projects
Commit 3d0dc67f authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

fixes moving outside the figure

refs 2346
parent d0143c52
No related branches found
No related tags found
No related merge requests found
......@@ -38,11 +38,14 @@ import org.eclipse.gef.KeyHandler;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.fortiss.tooling.base.model.layout.Angle;
import org.fortiss.tooling.base.model.layout.Dimension;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.LayoutFactory;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.ui.editpart.PositionedEditPartBase;
import org.fortiss.tooling.base.ui.editpart.StickyConnectorEditPartBase;
import org.fortiss.tooling.base.utils.LayoutDataUtils;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
......@@ -57,7 +60,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 574C2BF5E507B24ED6AC4D09E6EEDFD3
* @ConQAT.Rating YELLOW Hash: 60245690315B7D65B464ADC89AC541B9
*/
public class DiagramKeyHandler extends KeyHandler {
......@@ -155,15 +158,27 @@ public class DiagramKeyHandler extends KeyHandler {
OffsetOrientation oo =
getOffsetOrientation(ep.getModel(), CONNECTOR_OFFSET_ORIENTATION);
if(oo != null) {
Dimension containerDim = LayoutFactory.eINSTANCE.createDimension();
if(ep.getModel().eContainer() instanceof ILayoutedModelElement) {
ILayoutedModelElement layoutedContainer =
(ILayoutedModelElement)ep.getModel().eContainer();
containerDim = LayoutDataUtils.getNodeSize(layoutedContainer);
}
if((oo.getOrientation() == EOrientation.EAST || oo.getOrientation() == EOrientation.WEST) &&
(event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP)) {
setStickyConnectorLayoutData(ep.getModel(), oo.getOrientation(),
oo.getOffset() + scrollCoeff.y);
int newY = oo.getOffset() + scrollCoeff.y;
if(newY >= 0 && newY < containerDim.getHeight() - DEFAULT_GRID_SIZE) {
setStickyConnectorLayoutData(ep.getModel(),
oo.getOrientation(), newY);
}
} else if((oo.getOrientation() == EOrientation.NORTH || oo
.getOrientation() == EOrientation.SOUTH) &&
(event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT)) {
setStickyConnectorLayoutData(ep.getModel(), oo.getOrientation(),
oo.getOffset() + scrollCoeff.x);
int newX = oo.getOffset() + scrollCoeff.x;
if(newX >= 0 && newX < containerDim.getWidth() - DEFAULT_GRID_SIZE) {
setStickyConnectorLayoutData(ep.getModel(),
oo.getOrientation(), newX);
}
}
} else {
Angle angle = getConnectorAngle(ep.getModel());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment