Search in sources :

Example 1 with Handle

use of org.eclipse.gef.Handle in project yamcs-studio by yamcs.

the class GraphicalFeedbackChildEditPolicy method createSelectionHandles.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected List<?> createSelectionHandles() {
    // get default handles
    List<Handle> handleList = super.createSelectionHandles();
    // add contributed handles
    GraphicalEditPart hostEP = (GraphicalEditPart) getHost();
    List<Handle> contributedHandles = feedbackFactory.createCustomHandles(hostEP);
    if (contributedHandles != null) {
        handleList.addAll(contributedHandles);
    }
    if (hostEP.getModel() instanceof IPVWidgetModel && ((AbstractWidgetModel) (hostEP.getModel())).getProperty(IPVWidgetModel.PROP_PVNAME).isVisibleInPropSheet()) {
        handleList.add(new PVWidgetSelectionHandle((GraphicalEditPart) hostEP));
    }
    return handleList;
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) IPVWidgetModel(org.csstudio.opibuilder.model.IPVWidgetModel) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Handle(org.eclipse.gef.Handle)

Example 2 with Handle

use of org.eclipse.gef.Handle in project yamcs-studio by yamcs.

the class AbstractPolyFeedbackFactory method createCustomHandles.

/**
 * {@inheritDoc}
 */
@Override
public final List<Handle> createCustomHandles(final GraphicalEditPart hostEP) {
    assert hostEP != null;
    // $NON-NLS-1$
    assert hostEP.getModel() instanceof AbstractPolyModel : "hostEP.getModel() instanceof AbstractPolyModel";
    // create some custom handles, which enable the user to drag arround
    // single points of the polyline
    List<Handle> handles = new ArrayList<Handle>();
    AbstractPolyModel abstractPolyElement = (AbstractPolyModel) hostEP.getModel();
    int pointCount = abstractPolyElement.getPoints().size();
    for (int i = 0; i < pointCount; i++) {
        PolyPointHandle myHandle = new PolyPointHandle(hostEP, i);
        handles.add(myHandle);
    }
    return handles;
}
Also used : AbstractPolyModel(org.csstudio.opibuilder.widgets.model.AbstractPolyModel) ArrayList(java.util.ArrayList) Handle(org.eclipse.gef.Handle)

Example 3 with Handle

use of org.eclipse.gef.Handle in project whole by wholeplatform.

the class WholeNonResizableEditPolicy method createSelectionHandles.

@Override
protected List<?> createSelectionHandles() {
    final GraphicalEditPart host = (GraphicalEditPart) getHost();
    final DragTracker tracker = new SelectEditPartTracker(host);
    final Cursor cursor = SharedCursors.ARROW;
    final MoveHandle moveHandle = new MoveHandle(host) {

        @Override
        protected void initialize() {
            setOpaque(false);
            setBorder(new LineBorder(ColorConstants.gray, 1));
            setCursor(cursor);
            setDragTracker(tracker);
        }
    };
    final List<Handle> handles = new ArrayList<Handle>(5);
    handles.add(moveHandle);
    if (isDragAllowed()) {
        handles.add(createHandle(host, PositionConstants.SOUTH_EAST, tracker, cursor));
        handles.add(createHandle(host, PositionConstants.SOUTH_WEST, tracker, cursor));
        handles.add(createHandle(host, PositionConstants.NORTH_WEST, tracker, cursor));
        handles.add(createHandle(host, PositionConstants.NORTH_EAST, tracker, cursor));
    }
    return handles;
}
Also used : DragTracker(org.eclipse.gef.DragTracker) MoveHandle(org.eclipse.gef.handles.MoveHandle) LineBorder(org.eclipse.draw2d.LineBorder) ArrayList(java.util.ArrayList) SelectEditPartTracker(org.eclipse.gef.tools.SelectEditPartTracker) Cursor(org.eclipse.swt.graphics.Cursor) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Handle(org.eclipse.gef.Handle) ResizeHandle(org.eclipse.gef.handles.ResizeHandle) AbstractHandle(org.eclipse.gef.handles.AbstractHandle) MoveHandle(org.eclipse.gef.handles.MoveHandle)

Example 4 with Handle

use of org.eclipse.gef.Handle 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)

Example 5 with Handle

use of org.eclipse.gef.Handle in project whole by wholeplatform.

the class WholeResizableEditPolicy method createSelectionHandles.

protected List<?> createSelectionHandles() {
    final GraphicalEditPart host = (GraphicalEditPart) getHost();
    final int directions = getResizeDirections() != -1 ? getResizeDirections() : PositionConstants.EAST + PositionConstants.SOUTH + PositionConstants.WEST + PositionConstants.NORTH;
    final MoveHandle moveHandle = new MoveHandle(host) {

        @Override
        protected void initialize() {
            setOpaque(false);
            setBorder(new LineBorder(ColorConstants.gray, 1));
            setCursor(Cursors.SIZEALL);
        }
    };
    final List<Handle> handles = new ArrayList<Handle>(9);
    handles.add(moveHandle);
    handles.add(createHandle(host, PositionConstants.EAST, (directions & PositionConstants.EAST) != 0));
    handles.add(createHandle(host, PositionConstants.SOUTH_EAST, (directions & PositionConstants.SOUTH_EAST) != 0));
    handles.add(createHandle(host, PositionConstants.SOUTH, (directions & PositionConstants.SOUTH) != 0));
    handles.add(createHandle(host, PositionConstants.SOUTH_WEST, (directions & PositionConstants.SOUTH_WEST) != 0));
    handles.add(createHandle(host, PositionConstants.WEST, (directions & PositionConstants.WEST) != 0));
    handles.add(createHandle(host, PositionConstants.NORTH_WEST, (directions & PositionConstants.NORTH_WEST) != 0));
    handles.add(createHandle(host, PositionConstants.NORTH, (directions & PositionConstants.NORTH) != 0));
    handles.add(createHandle(host, PositionConstants.NORTH_EAST, (directions & PositionConstants.NORTH_EAST) != 0));
    return handles;
}
Also used : MoveHandle(org.eclipse.gef.handles.MoveHandle) LineBorder(org.eclipse.draw2d.LineBorder) ArrayList(java.util.ArrayList) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Handle(org.eclipse.gef.Handle) ResizeHandle(org.eclipse.gef.handles.ResizeHandle) AbstractHandle(org.eclipse.gef.handles.AbstractHandle) MoveHandle(org.eclipse.gef.handles.MoveHandle)

Aggregations

Handle (org.eclipse.gef.Handle)5 ArrayList (java.util.ArrayList)3 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)3 AbstractHandle (org.eclipse.gef.handles.AbstractHandle)3 LineBorder (org.eclipse.draw2d.LineBorder)2 MoveHandle (org.eclipse.gef.handles.MoveHandle)2 ResizeHandle (org.eclipse.gef.handles.ResizeHandle)2 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 IPVWidgetModel (org.csstudio.opibuilder.model.IPVWidgetModel)1 AbstractPolyModel (org.csstudio.opibuilder.widgets.model.AbstractPolyModel)1 DragTracker (org.eclipse.gef.DragTracker)1 SelectEditPartTracker (org.eclipse.gef.tools.SelectEditPartTracker)1 NonResizableLabelEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy)1 DragEditPartsTrackerEx (org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx)1 Cursor (org.eclipse.swt.graphics.Cursor)1 ContextSensitiveHelpPolicy (org.yakindu.sct.ui.editor.policies.ContextSensitiveHelpPolicy)1 TransitionExpressionComponentEditPolicy (org.yakindu.sct.ui.editor.policies.TransitionExpressionComponentEditPolicy)1