/** * Builds the command which will execute the user-tasks specified operations to reorder an event. * * @param sequenceDDiagram the DRepresentation to use for the ModelOperations * @param reorderTool the user-defined reordering tool. * @param event the semantic element of the event which was moved. * @param startingEndPredecessor the event end immediately preceding the reordered event's * starting end after the move. * @param finishingEndPredecessor the event end immediately preceding the reordered event's * finishing end after the move. * @return a command which executes the user-specified operations with the appropriate variables * set. */ public static SiriusCommand buildReorderCommand( SequenceDDiagram sequenceDDiagram, ReorderTool reorderTool, EObject event, EventEnd startingEndPredecessor, EventEnd finishingEndPredecessor) { ModelAccessor modelAccessor = SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(event); TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(event); SiriusCommand result = new SiriusCommand(domain, new IdentifiedElementQuery(reorderTool).getLabel()); if (reorderTool.getOnEventMovedOperation().getFirstModelOperations() != null) { result .getTasks() .add( ToolCommandBuilder.buildVariablesInitializationTask( reorderTool, event, startingEndPredecessor, finishingEndPredecessor)); TaskHelper taskHelper = new TaskHelper(modelAccessor, new EMFCommandFactoryUI()); result .getTasks() .add( taskHelper.buildTaskFromModelOperation( sequenceDDiagram, event, reorderTool.getOnEventMovedOperation().getFirstModelOperations())); } return result; }
private static InitInterpreterVariablesTask buildVariablesInitializationTask( ReorderTool reorderTool, EObject event, EventEnd startingEndPredecessor, EventEnd finishingEndPredecessor) { Map<AbstractVariable, Object> variables = Maps.newHashMap(); variables.put(reorderTool.getStartingEndPredecessorAfter(), startingEndPredecessor); variables.put(reorderTool.getFinishingEndPredecessorAfter(), finishingEndPredecessor); return new InitInterpreterVariablesTask(variables, InterpreterUtil.getInterpreter(event), null); }