use of org.talend.designer.core.ui.editor.cmd.MoveNoteCommand 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;
}
use of org.talend.designer.core.ui.editor.cmd.MoveNoteCommand in project tdi-studio-se by Talend.
the class SubjobContainerLayoutEditPolicy method createAddCommand.
// ------------------------------------------------------------------------
// Abstract methods from ConstrainedLayoutEditPolicy
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createAddCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
protected Command createAddCommand(final EditPart child, final Object constraint) {
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 NodeLabelEditPart) {
boolean nodeSelected;
// if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
// nodeSelected = true;
// } else {
nodeSelected = false;
// }
MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
return locationCommand;
} else if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
} else {
return null;
}
}
use of org.talend.designer.core.ui.editor.cmd.MoveNoteCommand in project tdi-studio-se by Talend.
the class SubjobContainerLayoutEditPolicy method createChangeConstraintCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
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 NodeLabelEditPart) {
boolean nodeSelected;
// if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
// nodeSelected = true;
// } else {
nodeSelected = false;
// }
MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
return locationCommand;
} else if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
} else {
return null;
}
}
Aggregations