Search in sources :

Example 1 with RelationDeleteCommand

use of org.talend.sqlbuilder.erdiagram.ui.commands.RelationDeleteCommand 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)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Command (org.eclipse.gef.commands.Command)1 ConnectionEditPolicy (org.eclipse.gef.editpolicies.ConnectionEditPolicy)1 ConnectionEndpointEditPolicy (org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy)1 GroupRequest (org.eclipse.gef.requests.GroupRequest)1 RelationDeleteCommand (org.talend.sqlbuilder.erdiagram.ui.commands.RelationDeleteCommand)1 Relation (org.talend.sqlbuilder.erdiagram.ui.nodes.Relation)1