use of org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest in project statecharts by Yakindu.
the class CreateTransitionCommand method doExecuteWithResult.
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
Vertex source = (Vertex) getRequest().getSource();
Vertex target = (Vertex) getRequest().getTarget();
if (source != null && target != null) {
Transition transition = SGraphFactory.eINSTANCE.createTransition();
source.getOutgoingTransitions().add(transition);
transition.setSource(source);
transition.setTarget(target);
source.getOutgoingTransitions().add(transition);
target.getIncomingTransitions().add(transition);
((CreateElementRequest) getRequest()).setNewElement(transition);
}
return CommandResult.newOKCommandResult();
}
use of org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest 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