use of org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest in project statecharts by Yakindu.
the class TreeLayoutEditPolicy method getCreateCommand.
@Override
protected Command getCreateCommand(CreateRequest request) {
final CompoundCommand cmd = new CompoundCommand();
cmd.add(super.getCreateCommand(request));
if (request instanceof CreateViewAndElementRequest) {
final CreateViewAndElementRequest req = (CreateViewAndElementRequest) request;
if (shouldUpdateAnnotationsOnCreation(req)) {
cmd.add(new ICommandProxy(new UpdateAnnotationsOnCreationCommand(getHost().getEditingDomain(), req)));
}
}
return cmd;
}
use of org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest 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;
}
Aggregations