org.eclipse.emf.common.command.CompoundCommand Java Examples
The following examples show how to use
org.eclipse.emf.common.command.CompoundCommand.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActorMappingConfigurationSynchronizer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void removeDeletedActors(Configuration configuration, AbstractProcess process, EditingDomain editingDomain, CompoundCommand cc) { ActorMappingsType mappings = configuration.getActorMappings() ; if(mappings != null){ int removed = 0; for(ActorMapping mapping : mappings.getActorMapping()){ String actorName = mapping.getName() ; boolean exists = false ; for(Actor actor : process.getActors()){ if(actor.getName().equals(actorName)){ exists = true ; break ; } } if(!exists){ removed++; cc.append(RemoveCommand.create(editingDomain, mappings, ActorMappingPackage.Literals.ACTOR_MAPPINGS_TYPE__ACTOR_MAPPING, mapping)) ; } } if(removed > 0 ){ if(mappings.getActorMapping().size() == removed + added){ cc.append(SetCommand.create(editingDomain, configuration, ConfigurationPackage.Literals.CONFIGURATION__ACTOR_MAPPINGS, null )) ; } } } }
Example #2
Source File: DeleteHandler.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void removeMessage(final MessageFlow flow) { final MainProcess diagram = ModelHelper.getMainProcess(flow); Assert.isNotNull(diagram); final AbstractCatchMessageEvent catchEvent = flow.getTarget(); final ThrowMessageEvent thowEvent = flow.getSource(); final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(diagram); Assert.isNotNull(domain); final CompoundCommand cc = new CompoundCommand(); if (flow.getSource() != null) { final List<Message> messages = flow.getSource().getEvents(); for (final Message message : messages) { if (flow.getName().equals(message.getName())) { cc.append(DeleteCommand.create(domain, message)); break; } } } cc.append(SetCommand.create(domain, catchEvent, ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT, null)); domain.getCommandStack().execute(cc); }
Example #3
Source File: ReadOnlyExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void updateRightOperand(final CompoundCommand cc, final Operation action, final String newOperatorType, final Expression newLeftOperand) { final Expression right = action.getRightOperand(); //final Expression newLeftOperand = action.getLeftOperand(); if (newLeftOperand != null && right != null) { if (ExpressionConstants.ASSIGNMENT_OPERATOR.equals(newOperatorType) && !newLeftOperand.getReturnType().equals(right.getReturnType())) { if (ExpressionConstants.CONSTANT_TYPE.equals(right.getType()) && isPrimitiveType(newLeftOperand.getReturnType())) { appendCommandToSetReturnType(cc, right, newLeftOperand.getReturnType()); } else if (DocumentValue.class.getName().equals(right.getReturnType())) { appendCommandToSetReturnType(cc, right, DocumentValue.class.getName()); } } else if (canSwitchToDocumentValueWithGroovyScript(newOperatorType, right)) { appendCommandToSetReturnType(cc, right, DocumentValue.class.getName()); appendCommandToScriptType(cc, right); } else if (canSwitchToListWithGroovyScript(newOperatorType, right)) { appendCommandToSetReturnType(cc, right, List.class.getName()); appendCommandToScriptType(cc, right); } } }
Example #4
Source File: ExpressionScriptContrainer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public CompoundCommand updateDependencies(final TransactionalEditingDomain editingDomain, final List<? extends RefactorPair<? extends EObject, ? extends EObject>> pairsToRefactor) { final CompoundCommand compoundCommand = new CompoundCommand(); final Expression expression = getModelElement(); for (final EObject dep : expression.getReferencedElements()) { for (final RefactorPair<? extends EObject, ? extends EObject> pair : pairsToRefactor) { final String oldValueName = pair.getOldValueName(); final EClass eClass = pair.getOldValue().eClass(); if (eClass.equals(dep.eClass()) && oldValueName.equals(dependencyName(dep))) { EMFModelUpdater<EObject> updater = new EMFModelUpdater<>().from(dep); updater.editWorkingCopy(ExpressionHelper.createDependencyFromEObject(pair.getNewValue())); compoundCommand.append(updater.createUpdateCommand(editingDomain)); } } } return compoundCommand; }
Example #5
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void proposalAccepted(final IContentProposal proposal) { final int proposalAcceptanceStyle = autoCompletion.getContentProposalAdapter().getProposalAcceptanceStyle(); if (proposalAcceptanceStyle == ContentProposalAdapter.PROPOSAL_REPLACE) { final Expression selectedExpression = getSelectedExpression(); final CompoundCommand cc = new CompoundCommand("Update Expression (and potential side components)"); final ExpressionProposal prop = (ExpressionProposal) proposal; final Expression copy = EcoreUtil.copy((Expression) prop.getExpression()); copy.setReturnTypeFixed(selectedExpression.isReturnTypeFixed()); sideModificationOnProposalAccepted(cc, copy); updateSelection(cc, copy); fireSelectionChanged(new SelectionChangedEvent(ExpressionViewer.this, new StructuredSelection(selectedExpression))); validate(); } }
Example #6
Source File: ReadOnlyExpressionViewerTest.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Test public void testUpdateRightOperandWithDocumentMultiple() { doCallRealMethod().when(roew).updateRightOperand(any(CompoundCommand.class), any(Operation.class), any(String.class), any(Expression.class)); final Operation operation = createEmptyOperation(); final Expression newLeftOperand = ExpressionFactory.eINSTANCE.createExpression(); final Document documentReferenced = ProcessFactory.eINSTANCE.createDocument(); documentReferenced.setMultiple(true); newLeftOperand.getReferencedElements().add(documentReferenced); operation.setLeftOperand(newLeftOperand); roew.updateRightOperand(new CompoundCommand(), operation, ExpressionConstants.SET_LIST_DOCUMENT_OPERATOR, newLeftOperand); verify(roew).appendCommandToSetReturnType(any(CompoundCommand.class), any(Expression.class), eq(List.class.getName())); }
Example #7
Source File: ExpressionScriptContrainer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public CompoundCommand removeDependencies(final TransactionalEditingDomain editingDomain, final List<? extends RefactorPair<? extends EObject, ? extends EObject>> pairsToRefactor) { final CompoundCommand compoundCommand = new CompoundCommand(); final Expression expression = getModelElement(); for (final EObject dep : expression.getReferencedElements()) { for (final RefactorPair<?, ? extends EObject> pair : pairsToRefactor) { final String oldValueName = pair.getOldValueName(); final EClass eClass = pair.getOldValue().eClass(); if (eClass.equals(dep.eClass()) && oldValueName.equals(dependencyName(dep))) { final Command removeCmd = RemoveCommand.create(editingDomain, expression, ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS, dep); if (!compoundCommand.getCommandList().contains(removeCmd)) { compoundCommand.append(removeCmd); } } } } return compoundCommand; }
Example #8
Source File: JointCommands.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Removes any existing joints from the connection and creates a new set of joints at the given positions. * * <p> * This is executed as a single compound command and is therefore a single element in the undo-redo stack. * </p> * * @param positions a list of {@link Point2D} instances speciying the x and y positions of the new joints * @param connection the connection in which the joints will be set */ public static void setNewJoints(final List<Point2D> positions, final GConnection connection) { final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(connection); final CompoundCommand command = new CompoundCommand(); command.append(RemoveCommand.create(editingDomain, connection, JOINTS, connection.getJoints())); for (final Point2D position : positions) { final GJoint newJoint = GraphFactory.eINSTANCE.createGJoint(); newJoint.setX(position.getX()); newJoint.setY(position.getY()); command.append(AddCommand.create(editingDomain, connection, JOINTS, newJoint)); } if (command.canExecute()) { editingDomain.getCommandStack().execute(command); } }
Example #9
Source File: AbstractConnectorConfigurationSynchronizer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void removeConnectorDependencies(final Configuration configuration, final String implementationId, final CompoundCommand cc, final EditingDomain editingDomain) { final FragmentContainer container = getContainer(configuration); Assert.isNotNull(container); FragmentContainer toRemove = null; for (final FragmentContainer fc : container.getChildren()) { if (fc.getId().equals(implementationId)) { toRemove = fc; } } if (toRemove != null) { editingDomain.getCommandStack().execute( RemoveCommand.create(editingDomain, container, ConfigurationPackage.Literals.FRAGMENT_CONTAINER__CHILDREN, toRemove)); } }
Example #10
Source File: ConstraintExpressionScriptContainer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public CompoundCommand removeDependencies(final TransactionalEditingDomain editingDomain, final List<? extends RefactorPair<? extends EObject, ? extends EObject>> pairsToRefactor) { final CompoundCommand compoundCommand = new CompoundCommand(); final ContractConstraint constraint = getModelElement(); for (final String inputName : constraint.getInputNames()) { for (final RefactorPair<? extends EObject, ? extends EObject> pair : pairsToRefactor) { final String oldValueName = pair.getOldValueName(); if (oldValueName.equals(inputName)) { compoundCommand.append(RemoveCommand.create(editingDomain, constraint, ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES, inputName)); } } } return compoundCommand; }
Example #11
Source File: ConnectorDragManager.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Adds a new connection to the model. * * <p> * This will trigger the model listener and cause everything to be reinitialized. * </p> * * @param source the source {@link GConnector} for the new connection * @param target the target {@link GConnector} for the new connection */ private void addConnection(final GConnector source, final GConnector target) { final String connectionType = validator.createConnectionType(source, target); final String jointType = validator.createJointType(source, target); final List<Point2D> jointPositions = skinLookup.lookupTail(source).allocateJointPositions(); final List<GJoint> joints = new ArrayList<>(); for (final Point2D position : jointPositions) { final GJoint joint = GraphFactory.eINSTANCE.createGJoint(); joint.setX(position.getX()); joint.setY(position.getY()); joint.setType(jointType); joints.add(joint); } final CompoundCommand command = ConnectionCommands.addConnection(model, source, target, connectionType, joints); // Notify the event manager so additional commands may be appended to this compound command. final GConnection addedConnection = model.getConnections().get(model.getConnections().size() - 1); connectionEventManager.notifyConnectionAdded(addedConnection, command); }
Example #12
Source File: SelectionCopier.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Pastes the most-recently-copied selection. * * <p> * After the paste operation, the newly-pasted elements will be selected. * </p> * * @param consumer a consumer to allow custom commands to be appended to the paste command * @return the list of new {@link GNode} instances created by the paste operation */ public List<GNode> paste(final BiConsumer<List<GNode>, CompoundCommand> consumer) { selectionCreator.deselectAll(); final List<GNode> pastedNodes = new ArrayList<>(); final List<GConnection> pastedConnections = new ArrayList<>(); preparePastedElements(pastedNodes, pastedConnections); addPasteOffset(pastedNodes, pastedConnections); checkWithinBounds(pastedNodes, pastedConnections); addPastedElements(pastedNodes, pastedConnections, consumer); for (final GNode pastedNode : pastedNodes) { skinLookup.lookupNode(pastedNode).setSelected(true); } for (final GConnection pastedConnection : pastedConnections) { for (final GJoint pastedJoint : pastedConnection.getJoints()) { skinLookup.lookupJoint(pastedJoint).setSelected(true); } } return pastedNodes; }
Example #13
Source File: RefactorDataOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void updateDataReferenceInVariableExpression(final CompoundCommand cc, final DataRefactorPair pairToRefactor, final Expression exp) { if (isReturnFixedOnExpressionWithUpdatedType(pairToRefactor, exp)) { cc.append(clearExpression(exp, getEditingDomain())); setAskConfirmation(true); } else { // update name and content final Data newValue = pairToRefactor.getNewValue(); final String newValueName = newValue.getName(); cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__NAME, newValueName)); cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__CONTENT, newValueName)); // update return type cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE, DataUtil.getTechnicalTypeFor(newValue))); } }
Example #14
Source File: RefactorActorMappingsOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private Command refactorGroup(Group oldGroup, Group newGroup, Configuration configuration, EditingDomain editingDomain) { CompoundCommand cc = new CompoundCommand(); for (ActorMapping ac : configuration.getActorMappings().getActorMapping()) { final Groups groups = ac.getGroups(); if (groups != null) { if (groups.getGroup().contains(GroupContentProvider.getGroupPath(oldGroup))) { cc.appendIfCanExecute(RemoveCommand.create(editingDomain, groups, ActorMappingPackage.Literals.GROUPS__GROUP, GroupContentProvider.getGroupPath(oldGroup))); cc.appendIfCanExecute(AddCommand.create(editingDomain, groups, ActorMappingPackage.Literals.GROUPS__GROUP, GroupContentProvider.getGroupPath(newGroup))); // cc.append(new ReplaceCommand(editingDomain, groups.getGroup(), GroupContentProvider.getGroupPath(oldGroup), // GroupContentProvider.getGroupPath(newGroup))); } } } return cc; }
Example #15
Source File: RefactorActorMappingsOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private Command refactorUsername(final User oldUser, final User newUser, final Configuration configuration, EditingDomain editingDomain) { CompoundCommand cc = new CompoundCommand(); for (ActorMapping ac : configuration.getActorMappings().getActorMapping()) { final Users users = ac.getUsers(); if (users != null) { if (users.getUser().contains(oldUser.getUserName())) { cc.appendIfCanExecute(RemoveCommand.create(editingDomain, users, ActorMappingPackage.Literals.USERS__USER, oldUser.getUserName())); cc.appendIfCanExecute(AddCommand.create(editingDomain, users, ActorMappingPackage.Literals.USERS__USER, newUser.getUserName())); } } } if (Objects.equals(configuration.getUsername(), oldUser.getUserName())) { cc.appendIfCanExecute(SetCommand.create(editingDomain, configuration, ConfigurationPackage.Literals.CONFIGURATION__USERNAME, newUser.getUserName())); } return cc; }
Example #16
Source File: RefactorActorMappingsOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private Command refactorMembership(final Group oldGroup, final Group newGroup, final Configuration configuration, EditingDomain editingDomain) { CompoundCommand cc = new CompoundCommand(); for (ActorMapping ac : configuration.getActorMappings().getActorMapping()) { final Membership memberships = ac.getMemberships(); if (memberships != null) { for (final MembershipType membershipType : memberships.getMembership()) { if (membershipType.getGroup().equals(GroupContentProvider.getGroupPath(oldGroup))) { cc.appendIfCanExecute(SetCommand.create(editingDomain, membershipType, ActorMappingPackage.Literals.MEMBERSHIP_TYPE__GROUP, GroupContentProvider.getGroupPath(newGroup))); } } } } return cc; }
Example #17
Source File: RefactorActorMappingsOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private Command refactorUsername( final org.bonitasoft.studio.actors.model.organization.Membership oldMembership, final org.bonitasoft.studio.actors.model.organization.Membership newMembership, final Configuration configuration, EditingDomain editingDomain) { CompoundCommand cc = new CompoundCommand(); for (ActorMapping ac : configuration.getActorMappings().getActorMapping()) { final Users users = ac.getUsers(); if (users != null) { if (users.getUser().contains(oldMembership.getUserName())) { cc.appendIfCanExecute(new ReplaceCommand(editingDomain, users.getUser(), oldMembership.getUserName(), newMembership.getUserName())); } } } return cc; }
Example #18
Source File: RefactorContractInputOperationTest.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Test public void should_not_refactor_input_with_same_name_in_another_contract_container() throws Exception { final Pool process = aPool().havingContract(aContract().havingInput(aContractInput().withName("myInput"))) .havingData(aData().withName("aTextData") .havingDefaultValue(ExpressionHelper .createContractInputExpression(aContractInput().withName("myInput").build()))) .havingElements(aTask().havingContract(aContract().havingInput(aContractInput().withName("myInput"))) .havingData(aData().withName("aTextData") .havingDefaultValue(ExpressionHelper .createContractInputExpression(aContractInput().withName("myInput").build())))) .build(); final RefactorContractInputOperation refactorOperation = new RefactorContractInputOperation(process, scriptRefactorOperationFactory, RefactoringOperationType.UPDATE); refactorOperation.setEditingDomain(domain); final ContractInput processInput = process.getContract().getInputs().get(0); final ContractInput newInput = EcoreUtil.copy(processInput); newInput.setName("newName"); refactorOperation.addItemToRefactor(newInput, processInput); CompoundCommand cc = new CompoundCommand(); cc = refactorOperation.doBuildCompoundCommand(cc, monitor); assertThat(cc.getCommandList()).hasSize(1); }
Example #19
Source File: ContractInputGenerationWizard.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected CompoundCommand createCommand(final RootContractInputGenerator contractInputGenerator, final BusinessObjectData data, List<ContractConstraint> constraints) { final CompoundCommand cc = new CompoundCommand(); cc.append(AddCommand.create(editingDomain, contractContainer.getContract(), ProcessPackage.Literals.CONTRACT__INPUTS, contractInputGenerator.getRootContractInput())); cc.append(SetCommand.create(editingDomain, contractContainer.getContract(), ProcessPackage.Literals.CONTRACT__CONSTRAINTS, constraints)); if (contractContainer instanceof OperationContainer && generationOptions.isAutoGeneratedScript()) { cc.appendIfCanExecute(AddCommand.create(editingDomain, contractContainer, ProcessPackage.Literals.OPERATION_CONTAINER__OPERATIONS, contractInputGenerator.getMappingOperations())); } if (contractContainer instanceof Pool && generationOptions.isAutoGeneratedScript()) { cc.appendIfCanExecute(SetCommand.create(editingDomain, data, ProcessPackage.Literals.DATA__DEFAULT_VALUE, contractInputGenerator.getInitialValueExpression())); } return cc; }
Example #20
Source File: SelectionCopier.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Adds the pasted elements to the graph editor via a single EMF command. * * @param pastedNodes the pasted nodes to be added * @param pastedConnections the pasted connections to be added * @param consumer a consumer to allow custom commands to be appended to the paste command */ private void addPastedElements(final List<GNode> pastedNodes, final List<GConnection> pastedConnections, final BiConsumer<List<GNode>, CompoundCommand> consumer) { final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model); final CompoundCommand command = new CompoundCommand(); for (final GNode pastedNode : pastedNodes) { command.append(AddCommand.create(editingDomain, model, NODES, pastedNode)); } for (final GConnection pastedConnection : pastedConnections) { command.append(AddCommand.create(editingDomain, model, CONNECTIONS, pastedConnection)); } if (command.canExecute()) { editingDomain.getCommandStack().execute(command); } if (consumer != null) { consumer.accept(pastedNodes, command); } }
Example #21
Source File: ContractInputGenerationWizard.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private IRunnableWithProgress buildContractOperationFromDocument(Document document) { return monitor -> { monitor.beginTask("", IProgressMonitor.UNKNOWN); ContractInput input = createDocumentContractInput(document); CompoundCommand cc = new CompoundCommand(); cc.append(AddCommand.create(editingDomain, contractContainer.getContract(), ProcessPackage.Literals.CONTRACT__INPUTS, input)); if (contractContainer instanceof Task) { createDocumentUpdateOperation(document, input, cc); } else { cc.append(SetCommand.create(editingDomain, document, ProcessPackage.Literals.DOCUMENT__DOCUMENT_TYPE, DocumentType.CONTRACT)); cc.append( SetCommand.create(editingDomain, document, ProcessPackage.Literals.DOCUMENT__CONTRACT_INPUT, input)); } editingDomain.getCommandStack().execute(cc); }; }
Example #22
Source File: ReadOnlyExpressionViewerTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void testUpdateRightOperandWithBooleanPrimitiveType() { doCallRealMethod().when(roew).updateRightOperand(any(CompoundCommand.class), any(Operation.class), any(String.class), any(Expression.class)); final Operation operation = createOperationWithEmptyConstantRightOperand(); final Expression newLeftOperand = ExpressionFactory.eINSTANCE.createExpression(); newLeftOperand.setReturnType(Boolean.class.getName()); operation.setLeftOperand(newLeftOperand); roew.updateRightOperand(new CompoundCommand(), operation, ExpressionConstants.ASSIGNMENT_OPERATOR, newLeftOperand); verify(roew).appendCommandToSetReturnType(any(CompoundCommand.class), any(Expression.class), eq(Boolean.class.getName())); }
Example #23
Source File: ConnectorWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected CompoundCommand createPerformFinishCommandOnEdition( final EditingDomain editingDomain) { final List<?> connectorsList = (List<?>) container .eGet(connectorContainmentFeature); final int index = connectorsList.indexOf(originalConnector); final CompoundCommand cc = new CompoundCommand("Update Connector"); cc.append(RemoveCommand.create(editingDomain, container, connectorContainmentFeature, originalConnector)); cc.append(AddCommand.create(editingDomain, container, connectorContainmentFeature, connectorWorkingCopy, index)); return cc; }
Example #24
Source File: ReadOnlyExpressionViewerTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void testUpdateRightOperandWithDocumentFromDocumentAndClearedExpression() { doCallRealMethod().when(roew).updateRightOperand(any(CompoundCommand.class), any(Operation.class), any(String.class), any(Expression.class)); final Operation operation = createEmptyOperation(); final Expression newLeftOperand = ExpressionFactory.eINSTANCE.createExpression(); newLeftOperand.setReturnType(String.class.getName()); operation.setLeftOperand(newLeftOperand); roew.updateRightOperand(new CompoundCommand(), operation, ExpressionConstants.SET_DOCUMENT_OPERATOR, newLeftOperand); verify(roew).appendCommandToSetReturnType(any(CompoundCommand.class), any(Expression.class), eq(DocumentValue.class.getName())); }
Example #25
Source File: RefactorDocumentOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected CompoundCommand doBuildCompoundCommand(final CompoundCommand compoundCommand, final IProgressMonitor monitor) { final CompoundCommand deleteCommands = new CompoundCommand( "Compound commands containing all delete operations to do at last step"); for (final DocumentRefactorPair pairToRefactor : pairsToRefactor) { doExecute(compoundCommand, deleteCommands, pairToRefactor); } compoundCommand.appendIfCanExecute(deleteCommands); return compoundCommand; }
Example #26
Source File: AdditionalResourcesConfigurationSyncronizer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void addNewAdditionalResources(Configuration configuration, Pool pool, EditingDomain editingDomain, CompoundCommand cc) { pool.getAdditionalResources().stream() .filter(additionalResource -> configuration.getAdditionalResources().stream() .noneMatch(anAdditionalResource -> Objects.equals(additionalResource.getName(), anAdditionalResource.getBarPath()))) .forEach(additionalResource -> { Resource newAdditionalResource = ConfigurationFactory.eINSTANCE.createResource(); newAdditionalResource.setBarPath(additionalResource.getName()); Command command = createAddCommand(editingDomain, configuration, newAdditionalResource); cc.append(command); }); }
Example #27
Source File: AbstractRefactorOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected CompoundCommand buildCompoundCommand(final IProgressMonitor monitor) throws InterruptedException, InvocationTargetException { if (canExecute()) { updateReferencesInScripts(monitor); } if (canExecute()) { compoundCommand = doBuildCompoundCommand(compoundCommand, monitor); } return compoundCommand; }
Example #28
Source File: RefactorActorOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected CompoundCommand doBuildCompoundCommand(final CompoundCommand compoundCommand, final IProgressMonitor monitor) { monitor.beginTask(Messages.updateActorReferences, IProgressMonitor.UNKNOWN); final String id = ModelHelper.getEObjectID(process); final String fileName = id + ".conf"; final ProcessConfigurationRepositoryStore processConfStore = RepositoryManager.getInstance().getCurrentRepository() .getRepositoryStore(ProcessConfigurationRepositoryStore.class); final ProcessConfigurationFileStore file = processConfStore.getChild(fileName, true); Configuration localeConfiguration = null; Configuration localConfigurationCopy = null; if (file != null) { localeConfiguration = file.getContent(); localConfigurationCopy = EcoreUtil.copy(localeConfiguration); } final List<Configuration> configurations = new ArrayList<Configuration>(); if (localeConfiguration != null) { configurations.add(localeConfiguration); } configurations.addAll(process.getConfigurations()); for (final ActorRefactorPair pairToRefactor : pairsToRefactor) { final Actor actor = pairToRefactor.getOldValue(); for (final Configuration configuration : configurations) { if (configuration.getActorMappings() != null) { final List<ActorMapping> actorMappings = configuration.getActorMappings().getActorMapping(); for (final ActorMapping actorMapping : actorMappings) { if (actorMapping.getName().equals(actor.getName())) { compoundCommand.append(SetCommand.create(getEditingDomain(), actorMapping, ActorMappingPackage.Literals.ACTOR_MAPPING__NAME, pairToRefactor.getNewValueName())); } } if (localeConfiguration != null) { compoundCommand.append(new SaveConfigurationEMFCommand(file, localConfigurationCopy, localeConfiguration)); } } } compoundCommand.append(SetCommand.create(getEditingDomain(), actor, ProcessPackage.Literals.ELEMENT__NAME, pairToRefactor.getNewValueName())); } return compoundCommand; }
Example #29
Source File: CompoundHandler.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public CompoundHandler ( final EditingDomain domain ) { this.domain = domain; this.command = new CompoundCommand () { @Override public Collection<?> getAffectedObjects () { // we do this in order to prevent the "Add" command to jump "somewhere" return Collections.EMPTY_LIST; } }; }
Example #30
Source File: ScriptContainer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public CompoundCommand applyUpdate(final EditingDomain editingDomain) { final CompoundCommand compoundCommand = new CompoundCommand(); if (scriptHasChanged()) { compoundCommand.append(SetCommand.create(editingDomain, modelElement, scriptFeature, newScript)); } return compoundCommand; }