Search in sources :

Example 1 with CreateViewAndElementRequest

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;
}
Also used : ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CreateViewAndElementRequest(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) UpdateAnnotationsOnCreationCommand(org.yakindu.base.gmf.runtime.treelayout.commands.UpdateAnnotationsOnCreationCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 2 with CreateViewAndElementRequest

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;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) CompartmentChildCreateCommand(org.yakindu.base.gmf.runtime.commands.CompartmentChildCreateCommand) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CompartmentChildCreateCommand(org.yakindu.base.gmf.runtime.commands.CompartmentChildCreateCommand) CreateCommand(org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand) CreateElementRequest(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) CreateViewAndElementRequest(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) CreateViewRequest(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) CompositeTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)

Aggregations

ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)2 CreateViewAndElementRequest (org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 CreateCommand (org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 CreateViewRequest (org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest)1 CompositeTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)1 CreateElementRequest (org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)1 CompartmentChildCreateCommand (org.yakindu.base.gmf.runtime.commands.CompartmentChildCreateCommand)1 UpdateAnnotationsOnCreationCommand (org.yakindu.base.gmf.runtime.treelayout.commands.UpdateAnnotationsOnCreationCommand)1