use of org.eclipse.gef.requests.ChangeBoundsRequest in project yamcs-studio by yamcs.
the class ArrayLayoutEditPolicy method getAddCommand.
/* Override super method because array widget only allows adding one child.
* (non-Javadoc)
* @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getAddCommand(org.eclipse.gef.Request)
*/
@Override
protected Command getAddCommand(Request generic) {
ChangeBoundsRequest request = (ChangeBoundsRequest) generic;
List<?> editParts = request.getEditParts();
CompoundCommand command = new CompoundCommand();
// $NON-NLS-1$
command.setDebugLabel("Add in ConstrainedLayoutEditPolicy");
GraphicalEditPart child;
if (editParts.size() > 0) {
child = (GraphicalEditPart) editParts.get(0);
command.add(createAddCommand(request, child, translateToModelConstraint(getConstraintFor(request, child))));
}
return command.unwrap();
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project archi by archimatetool.
the class ArchimateContainerLayoutPolicy method getAddCommand.
// Over-ride this method to add a sub-command for nested connections
@Override
protected Command getAddCommand(Request generic) {
Object parent = getHost().getModel();
ChangeBoundsRequest request = (ChangeBoundsRequest) generic;
CompoundCommand command = new CompoundCommand();
// Add relations/connections between parent and child if Prefs set and if parent is an Archimate object
boolean doAddNestedConnections = ConnectionPreferences.createRelationWhenMovingElement() && parent instanceof IDiagramModelArchimateObject;
List<IDiagramModelArchimateObject> childObjectsForNewConnections = new ArrayList<IDiagramModelArchimateObject>();
// Delete connections between parent and child if Prefs set and if parent is an Archimate object
boolean doDeleteNestedConnections = ConnectionPreferences.useNestedConnections();
List<IDiagramModelArchimateObject> childObjectsForDeletedConnections = new ArrayList<IDiagramModelArchimateObject>();
for (Object editPart : request.getEditParts()) {
GraphicalEditPart child = (GraphicalEditPart) editPart;
AddObjectCommand addCommand = createAddCommand(request, child, translateToModelConstraint(getConstraintFor(request, child)));
command.add(addCommand);
// If we use nested connections, and child is an Archimate diagram object add it to the list
if (doAddNestedConnections && addCommand.child instanceof IDiagramModelArchimateObject) {
childObjectsForNewConnections.add((IDiagramModelArchimateObject) addCommand.child);
}
// If we need to delete some nested connections
if (doDeleteNestedConnections && addCommand.child instanceof IDiagramModelArchimateObject) {
childObjectsForDeletedConnections.add((IDiagramModelArchimateObject) addCommand.child);
}
}
// We have some child objects for deletion connections
if (!childObjectsForDeletedConnections.isEmpty()) {
Command cmd = new DeleteNestedConnectionsCommand((IDiagramModelArchimateObject) parent, childObjectsForDeletedConnections);
command.add(cmd);
}
// We have some child objects so add the sub command
if (!childObjectsForNewConnections.isEmpty()) {
Command cmd = new CreateNestedArchimateConnectionsWithDialogCommand((IDiagramModelArchimateObject) parent, childObjectsForNewConnections);
command.add(cmd);
}
return command.unwrap();
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.
the class WholeFlowLayoutEditPolicy method getCloneCommand.
protected Command getCloneCommand(ChangeBoundsRequest request) {
String reqType = request.getType() == WholeDragEditPartsTracker.REQ_SHARE ? PartRequest.SHARE_CHILD : PartRequest.CLONE_CHILD;
CompoundCommand command = new CompoundCommand();
List<?> editParts = ((ChangeBoundsRequest) request).getEditParts();
EditPart insertionReference = getInsertionReference(request);
for (int i = 0; i < editParts.size(); i++) {
EditPart child = (EditPart) editParts.get(i);
command.add(createCloneChildCommand(reqType, child, insertionReference));
}
return command.unwrap();
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.
the class WholeTreeLayoutEditPolicy method getCloneCommand.
protected Command getCloneCommand(ChangeBoundsRequest request) {
String reqType = request.getType() == WholeDragEditPartsTracker.REQ_SHARE ? PartRequest.SHARE_CHILD : PartRequest.CLONE_CHILD;
CompoundCommand command = new CompoundCommand();
List editParts = ((ChangeBoundsRequest) request).getEditParts();
EditPart insertionReference = getInsertionReference(request);
for (int i = 0; i < editParts.size(); i++) {
EditPart child = (EditPart) editParts.get(i);
command.add(createCloneChildCommand(reqType, child, insertionReference));
}
return command.unwrap();
}
use of org.eclipse.gef.requests.ChangeBoundsRequest in project statecharts by Yakindu.
the class RegionCompartmentEditPart method createDefaultEditPolicies.
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CompartmentCreationEditPolicy());
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new RegionCompartmentCanonicalEditPolicy());
installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy() {
@Override
protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
// Remove dithering connection anchors
CompoundCommand result = new CompoundCommand();
result.add(super.getResizeChildrenCommand(request));
AdjustIdentityAnchorCommand command = new AdjustIdentityAnchorCommand(TransactionUtil.getEditingDomain(resolveSemanticElement()), request);
result.add(new ICommandProxy(command));
return result;
}
});
// Removes the collapse expand handler
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableEditPolicyEx());
installEditPolicy(EditPolicyRoles.SNAP_FEEDBACK_ROLE, new SimpleSnapFeedbackPolicy());
}
Aggregations