use of org.talend.core.ui.process.IGraphicalNode in project tdi-studio-se by Talend.
the class NodesPasteCommand method computeTheDistance.
private Point computeTheDistance(int index, int firstIndex, Point location) {
Point firstNodeLocation = ((IGraphicalNode) nodePart.getModel()).getLocation();
Point currentNodeLocation = ((IGraphicalNode) nodeParts.get(index).getModel()).getLocation();
int distanceX = firstNodeLocation.x - currentNodeLocation.x;
int distanceY = firstNodeLocation.y - currentNodeLocation.y;
location.x = location.x - distanceX;
location.y = location.y - distanceY;
return location;
}
use of org.talend.core.ui.process.IGraphicalNode in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method createChangeConstraintCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
@Override
public Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
// return a command to move the part to the location given by the constraint
if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof NoteEditPart) {
if (((Note) child.getModel()).isReadOnly()) {
return null;
}
MoveNoteCommand locationCommand = new MoveNoteCommand((Note) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof SubjobContainerPart) {
SubjobContainer sjc = (SubjobContainer) child.getModel();
Point sjcLocation = sjc.getSubjobContainerRectangle().getLocation();
Point translationNeeded = new Point(((Rectangle) constraint).getLocation().x - sjcLocation.x, ((Rectangle) constraint).getLocation().y - sjcLocation.y);
CompoundCommand cc = new CompoundCommand();
for (NodeContainer nc : sjc.getNodeContainers()) {
if (nc.isReadOnly()) {
return null;
}
IGraphicalNode node = nc.getNode();
Point nodeLocation = node.getLocation();
MoveNodeCommand locationCommand = new MoveNodeCommand(nc.getNode(), nodeLocation.getTranslated(translationNeeded));
cc.add(locationCommand);
}
return cc;
}
return null;
}
Aggregations