Search in sources :

Example 1 with EditPolicy

use of org.eclipse.gef.EditPolicy in project Palladio-Editors-Sirius by PalladioSimulator.

the class AbstractRotatableImageEditPart method getPrimaryDragEditPolicy.

/**
 * @generated
 */
public EditPolicy getPrimaryDragEditPolicy() {
    EditPolicy result = super.getPrimaryDragEditPolicy();
    if (result instanceof ResizableEditPolicy) {
        ResizableEditPolicy ep = (ResizableEditPolicy) result;
        ep.setResizeDirections(PositionConstants.NONE);
    }
    return result;
}
Also used : ResizableEditPolicy(org.eclipse.gef.editpolicies.ResizableEditPolicy) NonResizableEditPolicy(org.eclipse.gef.editpolicies.NonResizableEditPolicy) LayoutEditPolicy(org.eclipse.gef.editpolicies.LayoutEditPolicy) EditPolicy(org.eclipse.gef.EditPolicy) ResizableEditPolicy(org.eclipse.gef.editpolicies.ResizableEditPolicy) NonResizableEditPolicy(org.eclipse.gef.editpolicies.NonResizableEditPolicy)

Example 2 with EditPolicy

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

the class TextualSelectionTool method mouseDown.

@Override
public void mouseDown(MouseEvent e, EditPartViewer viewer) {
    super.mouseDown(e, viewer);
    EditPart targetEditPart = getTargetEditPart();
    if (targetEditPart == null || e.button != 1)
        return;
    EditPolicy editPolicy = targetEditPart.getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
    if (editPolicy instanceof TextualHilightEditPolicy)
        performSelectionLocationUpdate((TextualHilightEditPolicy) editPolicy);
}
Also used : EditPart(org.eclipse.gef.EditPart) TextualHilightEditPolicy(org.whole.lang.ui.editpolicies.TextualHilightEditPolicy) EditPolicy(org.eclipse.gef.EditPolicy) TextualHilightEditPolicy(org.whole.lang.ui.editpolicies.TextualHilightEditPolicy)

Example 3 with EditPolicy

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

the class FreeformRootPart method createEditPolicies.

protected void createEditPolicies() {
    installEditPolicy(EditPolicy.CONTAINER_ROLE, new WholeContainerEditPolicy(getCommandFactory()));
    installEditPolicy(EditPolicy.COMPONENT_ROLE, new WholeComponentEditPolicy(getCommandFactory()));
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new WholeFreeformLayoutEditPolicy((XYLayout) getContentPane().getLayoutManager(), getCommandFactory()) {

        @Override
        protected EditPolicy createChildEditPolicy(EditPart child) {
            return new WholeNonResizableEditPolicy();
        }

        @Override
        protected Command getCreateCommand(CreateRequest request) {
            // FIXME
            return super.getCreateCommand(request);
        }
    });
    installEditPolicy("Snap Feedback", new SnapFeedbackPolicy());
}
Also used : WholeContainerEditPolicy(org.whole.lang.ui.editpolicies.WholeContainerEditPolicy) WholeComponentEditPolicy(org.whole.lang.ui.editpolicies.WholeComponentEditPolicy) WholeFreeformLayoutEditPolicy(org.whole.lang.ui.editpolicies.WholeFreeformLayoutEditPolicy) Command(org.eclipse.gef.commands.Command) WholeNonResizableEditPolicy(org.whole.lang.ui.editpolicies.WholeNonResizableEditPolicy) CreateRequest(org.eclipse.gef.requests.CreateRequest) EditPart(org.eclipse.gef.EditPart) EntityXYLayout(org.whole.lang.ui.layout.EntityXYLayout) XYLayout(org.eclipse.draw2d.XYLayout) WholeContainerEditPolicy(org.whole.lang.ui.editpolicies.WholeContainerEditPolicy) WholeNonResizableEditPolicy(org.whole.lang.ui.editpolicies.WholeNonResizableEditPolicy) WholeFreeformLayoutEditPolicy(org.whole.lang.ui.editpolicies.WholeFreeformLayoutEditPolicy) WholeComponentEditPolicy(org.whole.lang.ui.editpolicies.WholeComponentEditPolicy) EditPolicy(org.eclipse.gef.EditPolicy) SnapFeedbackPolicy(org.eclipse.gef.editpolicies.SnapFeedbackPolicy)

Example 4 with EditPolicy

use of org.eclipse.gef.EditPolicy in project dbeaver by serge-rider.

the class ExtendedDirectEditManager method commit.

/**
 * Commits the current value of the cell editor by getting a {@link Command}
 * from the source edit part and executing it via the {@link CommandStack}.
 * Finally, {@link #bringDown()}is called to perform and necessary cleanup.
 */
@Override
protected void commit() {
    if (committing)
        return;
    committing = true;
    try {
        // we set the cell editor control to invisible to remove any
        // possible flicker
        getCellEditor().getControl().setVisible(false);
        if (isDirty()) {
            CommandStack stack = getEditPart().getViewer().getEditDomain().getCommandStack();
            EditPolicy editPolicy = getEditPart().getEditPolicy(EditPolicy.DIRECT_EDIT_ROLE);
            Command command;
            if (editPolicy != null) {
                command = editPolicy.getCommand(getDirectEditRequest());
            } else {
                command = getEditPart().getCommand(getDirectEditRequest());
            }
            if (command != null && command.canExecute()) {
                stack.execute(command);
            }
        }
    } finally {
        bringDown();
        committing = false;
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) Command(org.eclipse.gef.commands.Command) EditPolicy(org.eclipse.gef.EditPolicy)

Example 5 with EditPolicy

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

the class WidgetConnectionEditPart method createEditPolicies.

@Override
protected void createEditPolicies() {
    if (getExecutionMode() == ExecutionMode.EDIT_MODE && !getWidgetModel().isLoadedFromLinkedOpi()) {
        // Selection handle edit policy.
        // Makes the connection show a feedback, when selected by the user.
        installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy() {

            private ConnectionRouter originalRouter = null;

            private Object originalConstraint = null;

            @Override
            protected void showConnectionMoveFeedback(ReconnectRequest request) {
                EditPolicy connectionHandlesEditpolicy = getEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE);
                if (connectionHandlesEditpolicy != null && connectionHandlesEditpolicy instanceof ManhattanBendpointEditPolicy) {
                    ((ManhattanBendpointEditPolicy) connectionHandlesEditpolicy).removeSelectionHandles();
                }
                if (getConnection().getConnectionRouter() instanceof FixedPointsConnectionRouter) {
                    originalRouter = getConnection().getConnectionRouter();
                    originalConstraint = originalRouter.getConstraint(getConnection());
                    getConnection().setConnectionRouter(new ManhattanConnectionRouter());
                }
                super.showConnectionMoveFeedback(request);
            }

            @Override
            protected void eraseConnectionMoveFeedback(ReconnectRequest request) {
                if (originalRouter != null) {
                    originalRouter.setConstraint(getConnection(), originalConstraint);
                    getConnection().setConnectionRouter(originalRouter);
                }
                super.eraseConnectionMoveFeedback(request);
            }
        });
        // Allows the removal of the connection model element
        installEditPolicy(EditPolicy.CONNECTION_ROLE, new ConnectionEditPolicy() {

            @Override
            protected Command getDeleteCommand(GroupRequest request) {
                return new ConnectionDeleteCommand(getWidgetModel());
            }
        });
    }
}
Also used : ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) ReconnectRequest(org.eclipse.gef.requests.ReconnectRequest) ManhattanBendpointEditPolicy(org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy) ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) ConnectionDeleteCommand(org.csstudio.opibuilder.commands.ConnectionDeleteCommand) ConnectionDeleteCommand(org.csstudio.opibuilder.commands.ConnectionDeleteCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) ManhattanConnectionRouter(org.eclipse.draw2d.ManhattanConnectionRouter) ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) EditPolicy(org.eclipse.gef.EditPolicy) ManhattanBendpointEditPolicy(org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy) ManhattanConnectionRouter(org.eclipse.draw2d.ManhattanConnectionRouter) ConnectionRouter(org.eclipse.draw2d.ConnectionRouter)

Aggregations

EditPolicy (org.eclipse.gef.EditPolicy)6 EditPart (org.eclipse.gef.EditPart)3 Command (org.eclipse.gef.commands.Command)3 TextualHilightEditPolicy (org.whole.lang.ui.editpolicies.TextualHilightEditPolicy)2 ConnectionDeleteCommand (org.csstudio.opibuilder.commands.ConnectionDeleteCommand)1 ManhattanBendpointEditPolicy (org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy)1 ConnectionRouter (org.eclipse.draw2d.ConnectionRouter)1 ManhattanConnectionRouter (org.eclipse.draw2d.ManhattanConnectionRouter)1 XYLayout (org.eclipse.draw2d.XYLayout)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 ConnectionEditPolicy (org.eclipse.gef.editpolicies.ConnectionEditPolicy)1 ConnectionEndpointEditPolicy (org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy)1 LayoutEditPolicy (org.eclipse.gef.editpolicies.LayoutEditPolicy)1 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)1 ResizableEditPolicy (org.eclipse.gef.editpolicies.ResizableEditPolicy)1 SnapFeedbackPolicy (org.eclipse.gef.editpolicies.SnapFeedbackPolicy)1 CreateRequest (org.eclipse.gef.requests.CreateRequest)1 GroupRequest (org.eclipse.gef.requests.GroupRequest)1 ReconnectRequest (org.eclipse.gef.requests.ReconnectRequest)1 WholeComponentEditPolicy (org.whole.lang.ui.editpolicies.WholeComponentEditPolicy)1