Search in sources :

Example 1 with GroupRequest

use of org.eclipse.gef.requests.GroupRequest in project tdi-studio-se by Talend.

the class BusinessExtNodeLabelHostLayoutEditPolicy method getCommand.

/**
     * @generated
     */
public Command getCommand(Request request) {
    if (REQ_MOVE_CHILDREN.equals(request.getType())) {
        ChangeBoundsRequest cbRequest = (ChangeBoundsRequest) request;
        List extLabels = getExternalLabels(cbRequest);
        if (!extLabels.isEmpty()) {
            List editParts = cbRequest.getEditParts();
            Command cmd = null;
            if (realLayoutEditPolicy != null && editParts.size() > extLabels.size()) {
                List other = new ArrayList(editParts);
                other.removeAll(extLabels);
                cbRequest.setEditParts(other);
                cmd = realLayoutEditPolicy.getCommand(request);
            }
            cbRequest.setEditParts(extLabels);
            Command extLabelsCmd = getMoveChildrenCommand(request);
            cbRequest.setEditParts(editParts);
            return cmd == null ? extLabelsCmd : cmd.chain(extLabelsCmd);
        }
    }
    if (request instanceof GroupRequest) {
        List extLabels = getExternalLabels((GroupRequest) request);
        if (!extLabels.isEmpty()) {
            return null;
        }
    }
    return realLayoutEditPolicy == null ? null : realLayoutEditPolicy.getCommand(request);
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with GroupRequest

use of org.eclipse.gef.requests.GroupRequest in project tdi-studio-se by Talend.

the class ConnLabelEditPart method createEditPolicies.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
     */
@Override
public void createEditPolicies() {
    installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ConnTextMovePolicy());
    installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ConnTextEditPolicy());
    installEditPolicy(EditPolicy.COMPONENT_ROLE, new ConnectionEditPolicy() {

        @Override
        protected Command getDeleteCommand(GroupRequest request) {
            if (((Connection) getHost().getParent().getModel()).isReadOnly()) {
                return null;
            }
            List<Connection> connectionList = new ArrayList<Connection>();
            for (int i = 0; i < request.getEditParts().size(); i++) {
                if (request.getEditParts().get(i) instanceof ConnLabelEditPart) {
                    connectionList.add(((ConnectionLabel) ((ConnLabelEditPart) request.getEditParts().get(i)).getModel()).getConnection());
                }
            }
            return new ConnectionDeleteCommand(connectionList);
        }
    });
}
Also used : ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) ConnectionDeleteCommand(org.talend.designer.core.ui.editor.cmd.ConnectionDeleteCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) PolylineConnection(org.eclipse.draw2d.PolylineConnection) ConnectionDeleteCommand(org.talend.designer.core.ui.editor.cmd.ConnectionDeleteCommand) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with GroupRequest

use of org.eclipse.gef.requests.GroupRequest in project tdi-studio-se by Talend.

the class ConnectionPart method createEditPolicies.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
     */
@Override
protected void createEditPolicies() {
    // Selection handle edit policy.
    // Makes the connection show a feedback, when selected by the user.
    installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy());
    // Allows the removal of the connection model element
    installEditPolicy(EditPolicy.CONNECTION_ROLE, new ConnectionEditPolicy() {

        @Override
        protected Command getDeleteCommand(GroupRequest request) {
            if (((Connection) getModel()).isReadOnly()) {
                return null;
            }
            List<Connection> connectionList = new ArrayList<Connection>();
            for (int i = 0; i < request.getEditParts().size(); i++) {
                if (request.getEditParts().get(i) instanceof ConnectionPart) {
                    connectionList.add(((Connection) ((ConnectionPart) request.getEditParts().get(i)).getModel()));
                }
            }
            return new ConnectionDeleteCommand(connectionList);
        }
    });
}
Also used : ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) ConnectionDeleteCommand(org.talend.designer.core.ui.editor.cmd.ConnectionDeleteCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) IConnection(org.talend.core.model.process.IConnection) ConnectionDeleteCommand(org.talend.designer.core.ui.editor.cmd.ConnectionDeleteCommand) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with GroupRequest

use of org.eclipse.gef.requests.GroupRequest in project tdi-studio-se by Talend.

the class RelationPart method createEditPolicies.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
     */
@Override
protected void createEditPolicies() {
    // Selection handle edit policy.
    // Makes the connection show a feedback, when selected by the user.
    installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy());
    // Allows the removal of the connection model element
    installEditPolicy(EditPolicy.CONNECTION_ROLE, new ConnectionEditPolicy() {

        protected Command getDeleteCommand(GroupRequest request) {
            List<Relation> connectionList = new ArrayList<Relation>();
            for (int i = 0; i < request.getEditParts().size(); i++) {
                if (request.getEditParts().get(i) instanceof RelationPart) {
                    connectionList.add(((Relation) ((RelationPart) request.getEditParts().get(i)).getModel()));
                }
            }
            return new RelationDeleteCommand(connectionList);
        }
    });
}
Also used : ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) Relation(org.talend.sqlbuilder.erdiagram.ui.nodes.Relation) ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) Command(org.eclipse.gef.commands.Command) RelationDeleteCommand(org.talend.sqlbuilder.erdiagram.ui.commands.RelationDeleteCommand) GroupRequest(org.eclipse.gef.requests.GroupRequest) RelationDeleteCommand(org.talend.sqlbuilder.erdiagram.ui.commands.RelationDeleteCommand) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with GroupRequest

use of org.eclipse.gef.requests.GroupRequest in project tdi-studio-se by Talend.

the class ErDiagramItemDeleteAction method createDeleteCommand.

public Command createDeleteCommand(List objects) {
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
    deleteReq.setEditParts(objects);
    EditPart object = (EditPart) objects.get(0);
    Command cmd = object.getCommand(deleteReq);
    return cmd;
}
Also used : Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) EditPart(org.eclipse.gef.EditPart)

Aggregations

Command (org.eclipse.gef.commands.Command)8 GroupRequest (org.eclipse.gef.requests.GroupRequest)8 ArrayList (java.util.ArrayList)5 List (java.util.List)5 EditPart (org.eclipse.gef.EditPart)3 ConnectionEditPolicy (org.eclipse.gef.editpolicies.ConnectionEditPolicy)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 ConnectionEndpointEditPolicy (org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy)2 ConnectionDeleteCommand (org.talend.designer.core.ui.editor.cmd.ConnectionDeleteCommand)2 Iterator (java.util.Iterator)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 UnexecutableCommand (org.eclipse.gef.commands.UnexecutableCommand)1 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)1 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IConnection (org.talend.core.model.process.IConnection)1 IProcess (org.talend.core.model.process.IProcess)1 IJobletProviderService (org.talend.core.ui.IJobletProviderService)1 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)1