use of org.eclipse.gef.editpolicies.ConnectionEditPolicy 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);
}
});
}
use of org.eclipse.gef.editpolicies.ConnectionEditPolicy 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);
}
});
}
use of org.eclipse.gef.editpolicies.ConnectionEditPolicy 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);
}
});
}
Aggregations