Search in sources :

Example 1 with AbstractHandle

use of org.eclipse.gef.handles.AbstractHandle in project whole by wholeplatform.

the class WholeNonResizableEditPolicy method showTargetFeedback.

@Override
public void showTargetFeedback(Request request) {
    if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_CLONE) || request.getType().equals(RequestConstants.REQ_ADD))
        if (targetFeedback == null) {
            targetFeedback = new AbstractHandle((GraphicalEditPart) getHost(), new Locator() {

                public void relocate(IFigure target) {
                    IFigure figure = getHostFigure();
                    Rectangle r;
                    if (figure instanceof HandleBounds)
                        r = ((HandleBounds) figure).getHandleBounds().getCopy();
                    else
                        r = getHostFigure().getBounds().getResized(-1, -1);
                    getHostFigure().translateToAbsolute(r);
                    target.translateToRelative(r);
                    target.setBounds(r.expand(5, 5).resize(1, 1));
                }
            }) {

                {
                    setBorder(new LineBorder(ColorConstants.lightGray, 1));
                }

                protected DragTracker createDragTracker() {
                    return null;
                }
            };
            addFeedback(targetFeedback);
        }
}
Also used : Locator(org.eclipse.draw2d.Locator) HandleBounds(org.eclipse.gef.handles.HandleBounds) LineBorder(org.eclipse.draw2d.LineBorder) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractHandle(org.eclipse.gef.handles.AbstractHandle) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with AbstractHandle

use of org.eclipse.gef.handles.AbstractHandle in project whole by wholeplatform.

the class WholeResizableEditPolicy method showTargetFeedback.

@Override
public void showTargetFeedback(Request request) {
    if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_CLONE) || request.getType().equals(RequestConstants.REQ_ADD))
        if (targetFeedback == null) {
            targetFeedback = new AbstractHandle((GraphicalEditPart) getHost(), new Locator() {

                public void relocate(IFigure target) {
                    IFigure figure = getHostFigure();
                    Rectangle r;
                    if (figure instanceof HandleBounds)
                        r = ((HandleBounds) figure).getHandleBounds().getCopy();
                    else
                        r = getHostFigure().getBounds().getResized(-1, -1);
                    getHostFigure().translateToAbsolute(r);
                    target.translateToRelative(r);
                    target.setBounds(r.expand(5, 5).resize(1, 1));
                }
            }) {

                {
                    setBorder(new LineBorder(ColorConstants.lightGray, 1));
                }

                protected DragTracker createDragTracker() {
                    return null;
                }
            };
            addFeedback(targetFeedback);
        }
}
Also used : Locator(org.eclipse.draw2d.Locator) HandleBounds(org.eclipse.gef.handles.HandleBounds) LineBorder(org.eclipse.draw2d.LineBorder) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractHandle(org.eclipse.gef.handles.AbstractHandle) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with AbstractHandle

use of org.eclipse.gef.handles.AbstractHandle in project statecharts by Yakindu.

the class TransitionExpressionEditPart method createDefaultEditPolicies.

@Override
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicy.COMPONENT_ROLE, new TransitionExpressionComponentEditPolicy());
    installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ContextSensitiveHelpPolicy(HelpContextIds.SC_PROPERTIES_TRANSITION_EXPRESSION));
    // BUGFIX:
    // https://code.google.com/a/eclipselabs.org/p/yakindu/issues/detail?id=26
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableLabelEditPolicy() {

        @Override
        protected void replaceHandleDragEditPartsTracker(Handle handle) {
            if (handle instanceof AbstractHandle) {
                AbstractHandle h = (AbstractHandle) handle;
                h.setDragTracker(new DragEditPartsTrackerEx(getHost()) {

                    protected boolean isMove() {
                        return true;
                    }
                });
            }
        }
    });
}
Also used : DragEditPartsTrackerEx(org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx) TransitionExpressionComponentEditPolicy(org.yakindu.sct.ui.editor.policies.TransitionExpressionComponentEditPolicy) ContextSensitiveHelpPolicy(org.yakindu.sct.ui.editor.policies.ContextSensitiveHelpPolicy) AbstractHandle(org.eclipse.gef.handles.AbstractHandle) NonResizableLabelEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy) Handle(org.eclipse.gef.Handle) AbstractHandle(org.eclipse.gef.handles.AbstractHandle)

Aggregations

AbstractHandle (org.eclipse.gef.handles.AbstractHandle)3 IFigure (org.eclipse.draw2d.IFigure)2 LineBorder (org.eclipse.draw2d.LineBorder)2 Locator (org.eclipse.draw2d.Locator)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 HandleBounds (org.eclipse.gef.handles.HandleBounds)2 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)1 Handle (org.eclipse.gef.Handle)1 NonResizableLabelEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy)1 DragEditPartsTrackerEx (org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx)1 ContextSensitiveHelpPolicy (org.yakindu.sct.ui.editor.policies.ContextSensitiveHelpPolicy)1 TransitionExpressionComponentEditPolicy (org.yakindu.sct.ui.editor.policies.TransitionExpressionComponentEditPolicy)1