This repository has been archived by the owner on Jan 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The choice can now be resized with fix aspect ratio
- Loading branch information
1 parent
5a9860e
commit 0962a28
Showing
3 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...ui.editor/src/org/yakindu/sct/ui/editor/policies/FixedAspectRatioResizableEditPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2017 committers of YAKINDU and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* Contributors: | ||
* committers of YAKINDU - initial API and implementation | ||
* | ||
*/ | ||
package org.yakindu.sct.ui.editor.policies; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.draw2d.PositionConstants; | ||
import org.eclipse.gef.DragTracker; | ||
import org.eclipse.gef.EditPartViewer; | ||
import org.eclipse.gef.handles.ResizeHandle; | ||
import org.eclipse.gef.tools.ResizeTracker; | ||
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; | ||
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.MouseEvent; | ||
|
||
/** | ||
* | ||
* @author andreas muelder - Initial contribution and API | ||
* | ||
*/ | ||
public class FixedAspectRatioResizableEditPolicy extends ResizableEditPolicyEx { | ||
|
||
@SuppressWarnings("rawtypes") | ||
protected List createSelectionHandles() { | ||
List list = new ArrayList(); | ||
createMoveHandle(list); | ||
createResizeHandle(list, PositionConstants.SOUTH_EAST); | ||
createResizeHandle(list, PositionConstants.SOUTH_WEST); | ||
createResizeHandle(list, PositionConstants.NORTH_WEST); | ||
createResizeHandle(list, PositionConstants.NORTH_EAST); | ||
return list; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings({ "rawtypes", "unchecked" }) | ||
protected void createResizeHandle(List handles, final int direction) { | ||
handles.add(new ResizeHandle(getHost(), direction) { | ||
@Override | ||
protected DragTracker createDragTracker() { | ||
return new ResizeTracker(getHost(), direction) { | ||
@Override | ||
public void mouseDrag(MouseEvent event, EditPartViewer viewer) { | ||
event.stateMask |= SWT.SHIFT; | ||
super.mouseDrag(event, viewer); | ||
} | ||
}; | ||
}; | ||
}); | ||
} | ||
|
||
@Override | ||
public IGraphicalEditPart getHost() { | ||
return (IGraphicalEditPart) super.getHost(); | ||
} | ||
|
||
} |