use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.
the class CompartmentLayoutEditPolicy method getCreateCommand.
@SuppressWarnings("unchecked")
@Override
protected Command getCreateCommand(CreateRequest request) {
if (request instanceof CreateViewAndElementRequest) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
CompositeTransactionalCommand cc = new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label);
Iterator<?> descriptors = ((CreateViewRequest) request).getViewDescriptors().iterator();
while (descriptors.hasNext()) {
CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors.next();
int feedBackIndex = getFeedbackIndexFor(request);
// obtain CreateElementRequest and add initial region feedback
// index to request map. This index is needed to add the
// semantic element at the correct listIndex
CreateElementRequest createElementRequest = (CreateElementRequest) ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter().getAdapter(CreateElementRequest.class);
if (createElementRequest != null) {
createElementRequest.getParameters().put(RequestParameterKeys.RegionFeedbackIndex, feedBackIndex);
}
CreateCommand createCommand = new CompartmentChildCreateCommand(editingDomain, descriptor, (View) (getHost().getModel()), feedBackIndex);
cc.compose(createCommand);
}
return new ICommandProxy(cc.reduce());
}
return null;
}
use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.
the class CompartmentLayoutEditPolicy method createAddCommand.
@Override
protected Command createAddCommand(EditPart child, EditPart after) {
int index = getHost().getChildren().indexOf(after);
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
AddCommand command = new CompartmentAddCommand(editingDomain, new EObjectAdapter((View) getHost().getModel()), new EObjectAdapter((View) child.getModel()), index);
return new ICommandProxy(command);
}
use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.
the class EnlargeContainerEditPolicy method getCommand.
@SuppressWarnings("unchecked")
@Override
public Command getCommand(Request request) {
if (!RequestConstants.REQ_RESIZE.equals(request.getType()) && !RequestConstants.REQ_MOVE.equals(request.getType())) {
return null;
}
if (request instanceof SetPreferredSizeRequest) {
showSourceFeedback(request);
}
ChangeBoundsRequest cbr = (ChangeBoundsRequest) request;
CompoundCommand result = new CompoundCommand();
// Update Bounds of the container hierachy
for (IGraphicalEditPart currentContainer : containerHierachy) {
IFigure figure = currentContainer.getFigure();
SetBoundsCommand boundsCommand = new SetBoundsCommand(getHost().getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(currentContainer.getNotationView()), figure.getBounds());
result.add(new ICommandProxy(boundsCommand));
// Update child bounds of elements that stand in the way...
List<IGraphicalEditPart> children = currentContainer.getParent().getChildren();
for (IGraphicalEditPart childPart : children) {
if (cbr.getEditParts().contains(childPart))
continue;
IFigure childFigure = childPart.getFigure();
if (childPart == currentContainer)
continue;
SetBoundsCommand childBoundsCommand = new SetBoundsCommand(getHost().getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(childPart.getNotationView()), childFigure.getBounds());
result.add(new ICommandProxy(childBoundsCommand));
}
}
return result;
}
use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.
the class InitialPointsConnectionBendpointEditPolicy method getBendpointsChangedCommand.
@Override
protected Command getBendpointsChangedCommand(Connection connection, Edge edge) {
Point ptRef1 = connection.getSourceAnchor().getReferencePoint();
getConnection().translateToRelative(ptRef1);
Point ptRef2 = connection.getTargetAnchor().getReferencePoint();
getConnection().translateToRelative(ptRef2);
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
SetConnectionBendpointsAndLabelCommmand sbbCommand = new SetConnectionBendpointsAndLabelCommmand(editingDomain);
sbbCommand.setEdgeAdapter(new EObjectAdapter(edge));
sbbCommand.setNewPointList(connection.getPoints(), ptRef1, ptRef2);
return new ICommandProxy(sbbCommand);
}
Aggregations