Java Code Examples for org.eclipse.emf.common.command.CompoundCommand#append()
The following examples show how to use
org.eclipse.emf.common.command.CompoundCommand#append() .
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: RefactorParametersOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void refactorReferencedExpressions(final EditingDomain editingDomain, final CompoundCommand cc) { final List<Expression> expressions = ModelHelper.getAllItemsOfType(process, ExpressionPackage.Literals.EXPRESSION); for (final Expression exp : expressions) { for (final ParameterRefactorPair pairToRefactor : pairsToRefactor) { if (ExpressionConstants.PARAMETER_TYPE.equals(exp.getType()) && pairToRefactor.getOldValueName().equals(exp.getName())) { cc.append(SetCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__NAME, pairToRefactor.getNewValueName())); cc.append(SetCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__CONTENT, pairToRefactor.getNewValueName())); cc.append(SetCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE, pairToRefactor.getNewValue() .getTypeClassname())); updateDependencies(cc, pairToRefactor, exp); } } } }
Example 2
Source File: RefactorDataOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void updateDataInListsOfData(final CompoundCommand cc) { final List<Data> data = ModelHelper.getAllItemsOfType(dataContainer, ProcessPackage.Literals.DATA); for (final DataRefactorPair pairToRefactor : pairsToRefactor) { for (final Data d : data) { if (!d.equals(pairToRefactor.getNewValue()) && d.getName().equals(pairToRefactor.getOldValue().getName())) { final Data copy = EcoreUtil.copy(pairToRefactor.getNewValue()); final EObject container = d.eContainer(); final EReference eContainmentFeature = d.eContainmentFeature(); if (container != null && container.eGet(eContainmentFeature) instanceof Collection<?>) { final List<?> dataList = (List<?>) container.eGet(eContainmentFeature); final int index = dataList.indexOf(d); cc.append(RemoveCommand.create(getEditingDomain(), container, eContainmentFeature, d)); cc.append(AddCommand.create(getEditingDomain(), container, eContainmentFeature, copy, index)); } else if (container != null && container.eGet(eContainmentFeature) instanceof Data) { cc.append(SetCommand.create(getEditingDomain(), container, eContainmentFeature, copy)); } } } } }
Example 3
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 4
Source File: ConnectionCommands.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Removes a connection from the model. * * @param model the {@link GModel} from which the connection should be removed * @param connection the {@link GConnection} to be removed * @return the newly-executed {@link CompoundCommand} that removed the connection */ public static CompoundCommand removeConnection(final GModel model, final GConnection connection) { final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model); if (editingDomain != null) { final CompoundCommand command = new CompoundCommand(); final GConnector source = connection.getSource(); final GConnector target = connection.getTarget(); command.append(RemoveCommand.create(editingDomain, model, CONNECTIONS, connection)); command.append(RemoveCommand.create(editingDomain, source, CONNECTOR_CONNECTIONS, connection)); command.append(RemoveCommand.create(editingDomain, target, CONNECTOR_CONNECTIONS, connection)); if (command.canExecute()) { editingDomain.getCommandStack().execute(command); } return command; } else { return null; } }
Example 5
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 6
Source File: RefactorDataOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void removeAllDataReferences(final CompoundCommand cc, final DataRefactorPair pairToRefactor) { final List<Expression> expressions = retrieveExpressionsInTheContainer(pairToRefactor); for (final Expression exp : expressions) { if (ExpressionConstants.VARIABLE_TYPE.equals(exp.getType()) && exp.getName().equals(pairToRefactor.getOldValue().getName())) { // update name and content cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__NAME, "")); cc.append( SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__CONTENT, "")); // update return type cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE, String.class.getName())); cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__TYPE, ExpressionConstants.CONSTANT_TYPE)); // update referenced data cc.append(RemoveCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS, exp.getReferencedElements())); } } }
Example 7
Source File: RemoveParametersOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void deleteAllReferencesToParameter(final EditingDomain editingDomain, final Parameter parameter, final CompoundCommand cc) { final List<Expression> expressions = ModelHelper.getAllItemsOfType(process, ExpressionPackage.Literals.EXPRESSION); for (final Expression exp : expressions) { if (ExpressionConstants.PARAMETER_TYPE.equals(exp.getType()) && exp.getName().equals(parameter.getName())) { // update name and content cc.append(SetCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__NAME, "")); cc.append(SetCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__CONTENT, "")); // update return type cc.append(SetCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE, String.class.getName())); cc.append(SetCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__TYPE, ExpressionConstants.CONSTANT_TYPE)); // update referenced parameter cc.append(RemoveCommand.create(editingDomain, exp, ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS, exp.getReferencedElements())); } } }
Example 8
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 9
Source File: ReadOnlyExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private String updateOperatorType(final CompoundCommand cc, final Operator operator, final Expression storageExpression) { final String newOperatorType = getNewOperatorTypeFor(operator, storageExpression); if (!operator.getType().equals(newOperatorType)) { cc.append(SetCommand.create(getEditingDomain(), operator, ExpressionPackage.Literals.OPERATOR__TYPE, newOperatorType)); } return newOperatorType; }
Example 10
Source File: ParameterDescriptionEditingSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void setValue(final Object element, final Object value) { if(element != null && value != null && transactionalEditingDomain != null){ final AbstractProcess process = (AbstractProcess) ((EObject)element).eContainer() ; if(process != null){ final CompoundCommand cc = new CompoundCommand() ; cc.append(SetCommand.create(transactionalEditingDomain, element, ParameterPackage.Literals.PARAMETER__DESCRIPTION, value)) ; transactionalEditingDomain.getCommandStack().execute(cc) ; getViewer().refresh() ; } } }
Example 11
Source File: ConnectorWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected CompoundCommand createPerformFinishCommandOnCreation( final EditingDomain editingDomain) { final CompoundCommand cc = new CompoundCommand("Add Connector"); cc.append(AddCommand.create(editingDomain, container, connectorContainmentFeature, connectorWorkingCopy)); return cc; }
Example 12
Source File: RefactorDocumentOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void updateDocumentInExpression(final CompoundCommand cc, final DocumentRefactorPair pairToRefactor, final Document newValue, final Expression exp) { if (isMatchingDocumentExpression(pairToRefactor, exp)) { // update name and content cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__NAME, newValue.getName())); cc.append(SetCommand.create(getEditingDomain(), exp, ExpressionPackage.Literals.EXPRESSION__CONTENT, newValue.getName())); updateReturnType(cc, newValue, exp); updateDependencies(cc, pairToRefactor, exp); } }
Example 13
Source File: RemoveParametersOperation.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.removeParameters, IProgressMonitor.UNKNOWN); for (final ParameterRefactorPair pairToRefactor : pairsToRefactor) { deleteAllReferencesToParameter(getEditingDomain(), pairToRefactor.getOldValue(), compoundCommand); 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 localeConfigurationWorkingCopy = null; if (file != null) { localeConfiguration = file.getContent(); localeConfigurationWorkingCopy = EcoreUtil.copy(localeConfiguration); } if (localeConfiguration != null) { for (final Parameter configParameter : localeConfiguration.getParameters()) { if (configParameter.getName().equals(pairToRefactor.getOldValueName())) { compoundCommand.append(new RemoveCommand(getEditingDomain(), localeConfiguration, ConfigurationPackage.Literals.CONFIGURATION__PARAMETERS, configParameter)); } } compoundCommand.append(new SaveConfigurationEMFCommand(file, localeConfigurationWorkingCopy, localeConfiguration)); } compoundCommand.append(DeleteCommand.create(getEditingDomain(), pairToRefactor.getOldValue())); } return compoundCommand; }
Example 14
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 15
Source File: AbstractGroovyScriptConfigurationSynchronizer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void removeDeletedPackage(Configuration configuration, GroovyRepositoryStore store, CompoundCommand cc, EditingDomain editingDomain) { IFolder srcFolder = store.getResource(); FragmentContainer container = getContainer(configuration); for (Fragment f : container.getFragments()) { IResource member = srcFolder.findMember(Path.fromOSString(f.getValue())); if (member == null || !member.exists()) { cc.append(RemoveCommand.create(editingDomain, container, ConfigurationPackage.Literals.FRAGMENT_CONTAINER__FRAGMENTS, f)); } } }
Example 16
Source File: ContractInputGenerationWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void createDocumentUpdateOperation(Document document, ContractInput input, CompoundCommand cc) { Operation operation = new DocumentUpdateOperationBuilder(input, document).toOperation(); cc.append(AddCommand.create(editingDomain, contractContainer, ProcessPackage.Literals.OPERATION_CONTAINER__OPERATIONS, operation)); infoDialogFactory.openUpdateDocumentOperationWarning(document.getName(), getShell()); }
Example 17
Source File: Commands.java From graph-editor with Eclipse Public License 1.0 | 5 votes |
/** * Updates the model's layout values to match those in the skin instances. * * <p> * This method adds set operations to the given compound command but does <b>not</b> execute it. * </p> * * @param command a {@link CompoundCommand} to which the set commands will be added * @param model the {@link GModel} whose layout values should be updated * @param skinLookup the {@link SkinLookup} in use for this graph editor instance */ public static void updateLayoutValues(final CompoundCommand command, final GModel model, final SkinLookup skinLookup) { final EditingDomain editingDomain = getEditingDomain(model); if (editingDomain != null) { for (final GNode node : model.getNodes()) { final Region nodeRegion = skinLookup.lookupNode(node).getRoot(); command.append(SetCommand.create(editingDomain, node, NODE_X, nodeRegion.getLayoutX())); command.append(SetCommand.create(editingDomain, node, NODE_Y, nodeRegion.getLayoutY())); command.append(SetCommand.create(editingDomain, node, NODE_WIDTH, nodeRegion.getWidth())); command.append(SetCommand.create(editingDomain, node, NODE_HEIGHT, nodeRegion.getHeight())); } for (final GConnection connection : model.getConnections()) { for (final GJoint joint : connection.getJoints()) { final GJointSkin jointSkin = skinLookup.lookupJoint(joint); final Region jointRegion = jointSkin.getRoot(); final double x = jointRegion.getLayoutX() + jointSkin.getWidth() / 2; final double y = jointRegion.getLayoutY() + jointSkin.getHeight() / 2; command.append(SetCommand.create(editingDomain, joint, JOINT_X, x)); command.append(SetCommand.create(editingDomain, joint, JOINT_Y, y)); } } } }
Example 18
Source File: ContractInputController.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void remove(final ColumnViewer viewer) { final IObservableValue contractObservable = (IObservableValue) viewer.getInput(); final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); final List<?> selectedInput = selection.toList(); Contract contract = (Contract) contractObservable.getValue(); if (openConfirmation(selectedInput)) { final RefactorContractInputOperation refactorOperation = newRefactorOperation(contract); final TransactionalEditingDomain editingDomain = editingDomain(contract); refactorOperation.setEditingDomain(editingDomain); refactorOperation.setAskConfirmation(shouldAskConfirmation()); final CompoundCommand compoundCommand = refactorOperation.getCompoundCommand(); for (final Object input : selectedInput) { final ContractInput contractInput = (ContractInput) input; contract = ModelHelper.getFirstContainerOfType(contractInput, Contract.class); //Parent input has been removed in current selection if (contract == null) { continue; } refactorOperation.addItemToRefactor(null, contractInput); compoundCommand.append(DeleteCommand.create(editingDomain, contractInput)); final Collection<ContractConstraint> constraintsReferencingInput = constraintsReferencingSingleInput(contract, contractInput); if (!constraintsReferencingInput.isEmpty()) { compoundCommand.append(DeleteCommand.create(editingDomain, constraintsReferencingInput)); } } try { if (refactorOperation.canExecute()) { progressService.run(true, true, refactorOperation); } } catch (final InvocationTargetException | InterruptedException e) { BonitaStudioLog.error("Failed to remove contract input.", e); openErrorDialog(e); } } }
Example 19
Source File: TestDeployCommand.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * used to check fix 2204 * * @throws Exception */ @Test public void testDeployAfterRenamedOfParentProcess() throws Exception { /* Import a base process for the test */ final ProcessDiagramEditor processEditor = importBos("ProcessForTestBug2204.bos"); final MainProcess mainProcess = (MainProcess) processEditor.getDiagramEditPart().resolveSemanticElement(); /* Run a first time */ final AbstractProcess selectedProcess = (AbstractProcess) mainProcess.getElements().get(0); final RunProcessCommand runProcessCommand = new RunProcessCommand(true); runProcessCommand.execute(ProcessSelector.createExecutionEvent(selectedProcess)); /* Rename the parent */ final Pool parentProcess = (Pool) mainProcess.getElements().get(0); TransactionalEditingDomain domain = GMFEditingDomainFactory.getInstance() .getEditingDomain(parentProcess.eResource().getResourceSet()); if (domain == null) { domain = TransactionUtil.getEditingDomain(parentProcess); } if (domain == null) { domain = GMFEditingDomainFactory.getInstance().createEditingDomain(); } final CompoundCommand cc = new CompoundCommand(); cc.append(SetCommand.create(domain, parentProcess, ProcessPackage.eINSTANCE.getElement_Name(), "ParentRenamed")); domain.getCommandStack().execute(cc); processEditor.doSave(Repository.NULL_PROGRESS_MONITOR); /* Retry to deploy */ runProcessCommand.execute(null); APISession session = null; try { session = BOSEngineManager.getInstance().loginDefaultTenant(Repository.NULL_PROGRESS_MONITOR); final ProcessManagementAPI processAPI = BOSEngineManager.getInstance().getProcessAPI(session); final int nbProcess = (int) processAPI.getNumberOfProcessDeploymentInfos(); final List<ProcessDeploymentInfo> infos = processAPI.getProcessDeploymentInfos(0, nbProcess, ProcessDeploymentInfoCriterion.DEFAULT); boolean found = false; for (final ProcessDeploymentInfo info : infos) { if (info.getName().equals(parentProcess.getName()) && info.getVersion().equals(parentProcess.getVersion())) { found = true; } } assertTrue("Process not found", found); } catch (final Exception e) { fail(); } finally { if (session != null) { BOSEngineManager.getInstance().logoutDefaultTenant(session); } } }
Example 20
Source File: ReadOnlyExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected void appendCommandToScriptType(final CompoundCommand cc, final Expression right) { cc.append( SetCommand.create(getEditingDomain(), right, ExpressionPackage.Literals.EXPRESSION__TYPE, ExpressionConstants.SCRIPT_TYPE)); cc.append( SetCommand.create(getEditingDomain(), right, ExpressionPackage.Literals.EXPRESSION__INTERPRETER, ExpressionConstants.GROOVY)); }