org.eclipse.emf.transaction.TransactionalEditingDomain Java Examples
The following examples show how to use
org.eclipse.emf.transaction.TransactionalEditingDomain.
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: BatchValidationHandler.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void addDiagramsToValidate(final BatchValidationOperation validateOperation, final String[] files) throws IOException { final DiagramRepositoryStore store = RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class); for (final String fName : files) { final String fileName = fName.trim(); final DiagramFileStore fileStore = store.getChild(fileName, true); if (fileStore == null) { throw new IOException(fileName + " does not exists in " + store.getResource().getLocation()); } currentDiagramStore = fileStore; fileStore.getContent();//force resource to be loaded final Resource eResource = fileStore.getEMFResource(); final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(eResource); final FindDiagramRunnable runnable = new FindDiagramRunnable(eResource, validateOperation); if (editingDomain != null) { try { editingDomain.runExclusive(runnable); } catch (final InterruptedException e) { BonitaStudioLog.error(e); } } else { runnable.run(); } } }
Example #2
Source File: BatchValidationOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { Assert.isLegal(!diagramsToDiagramEditPart.isEmpty()); buildEditPart(); validationMarkerProvider.clearMarkers(diagramsToDiagramEditPart); for (final Entry<Diagram, DiagramEditPart> entry : diagramsToDiagramEditPart.entrySet()) { final DiagramEditPart diagramEp = entry.getValue(); final Diagram diagram = entry.getKey(); if (diagramEp != null && !monitor.isCanceled()) { monitor.setTaskName(Messages.bind( Messages.validatingProcess, ((MainProcess) diagramEp.resolveSemanticElement()).getName(), ((MainProcess) diagramEp.resolveSemanticElement()).getVersion())); final TransactionalEditingDomain txDomain = TransactionUtil.getEditingDomain(diagram); runWithConstraints(txDomain, () -> validate(diagramEp, diagram, monitor)); monitor.worked(1); } } offscreenEditPartFactory.dispose(); }
Example #3
Source File: DiagramFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSave(final Object content) { final Resource resource = getEMFResource(); final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resource); try { OperationHistoryFactory.getOperationHistory().execute( new SaveDiagramResourceCommand(content, editingDomain, resource), Repository.NULL_PROGRESS_MONITOR, null); } catch (final ExecutionException e1) { BonitaStudioLog.error(e1); } if (content instanceof DiagramDocumentEditor) { ((DiagramDocumentEditor) content).doSave(Repository.NULL_PROGRESS_MONITOR); } try { resource.save(ProcessDiagramEditorUtil.getSaveOptions()); } catch (final IOException e) { BonitaStudioLog.error(e); } }
Example #4
Source File: ProcessValidationProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ public static void runWithConstraints(TransactionalEditingDomain editingDomain, Runnable operation) { if (!DISABLE_VALIDATION) { final Runnable op = operation; Runnable task = new Runnable() { public void run() { try { constraintsActive = true; op.run(); } finally { constraintsActive = false; } } }; if (editingDomain != null) { try { editingDomain.runExclusive(task); } catch (Exception e) { ProcessDiagramEditorPlugin.getInstance().logError("Validation failed", e); //$NON-NLS-1$ } } else { task.run(); } } }
Example #5
Source File: VariableAndOptionPage.java From M2Doc with Eclipse Public License 1.0 | 6 votes |
/** * Edits the given {@link Option}. * * @param genEditingDomain * the {@link TransactionalEditingDomain} * @param gen * the {@link Generation} * @param option * the {@link Option} to edit */ private void editOption(final TransactionalEditingDomain genEditingDomain, final Generation gen, final Option option) { final M2DocOptionDialog dialog = new M2DocOptionDialog(getShell(), gen, option); final int dialogResult = dialog.open(); if (dialogResult == IDialogConstants.OK_ID) { genEditingDomain.getCommandStack().execute(new RecordingCommand(genEditingDomain) { @Override protected void doExecute() { option.setName(dialog.getOptionName()); option.setValue(dialog.getOptionValue()); } }); } }
Example #6
Source File: VariableAndOptionPage.java From M2Doc with Eclipse Public License 1.0 | 6 votes |
/** * Initializes {@link Generation#getDefinitions() variable definition} for the given {@link Generation}. * * @param gen * the {@link Generation} */ private void initializeGenerationVariableDefinition(final Generation gen) { final TemplateCustomProperties properties = templateCustomPropertiesProvider.getTemplateCustomProperties(); ((IQueryEnvironment) queryEnvironment).registerEPackage(EcorePackage.eINSTANCE); ((IQueryEnvironment) queryEnvironment).registerCustomClassMapping( EcorePackage.eINSTANCE.getEStringToStringMapEntry(), EStringToStringMapEntryImpl.class); if (properties != null) { properties.configureQueryEnvironmentWithResult((IQueryEnvironment) queryEnvironment); } final TransactionalEditingDomain generationDomain = TransactionUtil.getEditingDomain(gen); generationDomain.getCommandStack().execute(new RecordingCommand(generationDomain) { @Override protected void doExecute() { GenconfUtils.initializeVariableDefinition(gen, queryEnvironment, properties, getEditingDomain(gen).getResourceSet()); } }); }
Example #7
Source File: ToggleSubRegionLayoutCommand.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { view = unwrap(HandlerUtil.getCurrentSelection(event)); TransactionalEditingDomain editingDomain = TransactionUtil .getEditingDomain(view); ToggleCommand toggleCommand = new ToggleCommand(editingDomain, view); try { OperationHistoryFactory.getOperationHistory().execute( toggleCommand, new NullProgressMonitor(), null); } catch (ExecutionException e) { e.printStackTrace(); } return null; }
Example #8
Source File: ObservableValueWithRefactor.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSetValue(final Object value) { final Object oldValue = eObject.eGet(eStructuralFeature); if (needRefactor(oldValue, value)) { final AbstractRefactorOperation<? extends EObject, ? extends EObject, ? extends RefactorPair<? extends EObject, ? extends EObject>> refactorOperation = refactorOperationFactory .createRefactorOperation((TransactionalEditingDomain) domain, eObject, value); refactorOperation.getCompoundCommand().append(SetCommand.create(domain, eObject, eStructuralFeature, value)); try { progressService.busyCursorWhile(refactorOperation); } catch (InvocationTargetException | InterruptedException e) { BonitaStudioLog.error(String.format("Failed to refactor %s into %s", oldValue, value), e); openErrorDialog(oldValue, value, e); } } else { super.doSetValue(value); } }
Example #9
Source File: CustomCutCommand.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected CommandResult doExecuteWithResult( IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { Clipboard.setToCopyEditParts(toCopyElement); TransactionalEditingDomain domain = (TransactionalEditingDomain) AdapterFactoryEditingDomain.getEditingDomainFor(toCopyElement); domain.getCommandStack().execute(new RecordingCommand(domain) { protected void doExecute() { for (IGraphicalEditPart part : toCopyElement) { EcoreUtil.delete(part.resolveSemanticElement()); } } }); return CommandResult.newOKCommandResult(); }
Example #10
Source File: FixedBendpointEditPolicy.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("restriction") protected Command getBendpointsChangedCommand(ConnectionEditPart part) { Connection connection = part.getConnectionFigure(); Point ptRef1 = connection.getSourceAnchor().getReferencePoint(); connection.translateToRelative(ptRef1); Point ptRef2 = connection.getTargetAnchor().getReferencePoint(); connection.translateToRelative(ptRef2); TransactionalEditingDomain editingDomain = getHost().getEditingDomain(); SetConnectionBendpointsAndLabelCommmand sbbCommand = new SetConnectionBendpointsAndLabelCommmand(editingDomain); sbbCommand.setEdgeAdapter(new EObjectAdapter((EObject) part.getModel())); sbbCommand.setNewPointList(connection.getPoints(), ptRef1, ptRef2); sbbCommand.setLabelsToUpdate(part, getInitialPoints(connection)); return new ICommandProxy(sbbCommand); }
Example #11
Source File: DataWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public DataWizard(final TransactionalEditingDomain editingDomain, final EObject container, final EStructuralFeature dataContainmentFeature, final Set<EStructuralFeature> featureToCheckForUniqueID, final boolean showAutogenerateForm, final String fixedReturnType) { initDataWizard(dataContainmentFeature, showAutogenerateForm); this.editingDomain = editingDomain; this.container = container; dataWorkingCopy = createWorkingCopy(container); editMode = false; this.featureToCheckForUniqueID = new HashSet<EStructuralFeature>(); this.featureToCheckForUniqueID.add(dataContainmentFeature); this.fixedReturnType = fixedReturnType; setWindowTitle(Messages.newVariable); }
Example #12
Source File: ScriptRefactoringAction.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public ScriptRefactoringAction(final List<T> pairsToRefactor, final List<ScriptContainer<?>> scriptExpressions, final CompoundCommand compoundCommand, final TransactionalEditingDomain domain, final RefactoringOperationType operationType) { this.scriptExpressions = scriptExpressions; this.compoundCommand = compoundCommand; this.operationType = operationType; this.pairsToRefactor = pairsToRefactor; this.domain = domain; }
Example #13
Source File: IteratorRefactorOperationFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public RefactorDataOperation createRefactorOperation( final TransactionalEditingDomain domain, final EObject item, final Object newValue) { checkArgument(item instanceof Expression); checkArgument(newValue instanceof String); final MultiInstantiable parentFlowElement = ModelHelper.getFirstContainerOfType(item, MultiInstantiable.class); final Data oldData = ExpressionHelper.dataFromIteratorExpression( parentFlowElement, (Expression) item, mainProcess(parentFlowElement)); final RefactorDataOperation refactorOperation = new RefactorDataOperation(RefactoringOperationType.UPDATE); refactorOperation.setEditingDomain(domain); refactorOperation.setAskConfirmation(true); refactorOperation.setDataContainer(ModelHelper.getFirstContainerOfType(item, DataAware.class)); refactorOperation.addItemToRefactor(dataWithNewName(oldData, (String) newValue), oldData); return refactorOperation; }
Example #14
Source File: MoveDataCommand.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public MoveDataCommand(TransactionalEditingDomain editingDomain, DataAware container, List<Data> datas, DataAware target) { super(editingDomain, MoveDataCommand.class.getName(), getWorkspaceFiles(datas)); this.container = container; this.target = target; this.datas = datas; this.dataNotMoved = new ArrayList<Data>(); }
Example #15
Source File: SimulationImageRenderer.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private Resource reload(IFile file) { final URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true); Factory factory = ResourceFactoryRegistryImpl.INSTANCE.getFactory(uri); Resource resource = factory.createResource(uri); ResourceSet resourceSet = new ResourceSetImpl(); TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet); resourceSet.getResources().add(resource); try { resource.load(Collections.EMPTY_MAP); } catch (IOException e) { throw new IllegalStateException("Error loading resource", e); } return resource; }
Example #16
Source File: EditBusinessObjectDataWizardTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class); final MainProcess diagram = ProcessFactory.eINSTANCE.createMainProcess(); container = ProcessFactory.eINSTANCE.createPool(); container.setName("Test Process"); diagram.getElements().add(container); final DataType bType = ProcessFactory.eINSTANCE.createBusinessObjectType(); bType.setName(DataTypeLabels.businessObjectType); diagram.getDatatypes().add(bType); final BusinessObjectData data = ProcessFactory.eINSTANCE.createBusinessObjectData(); data.setName("testData"); data.setDataType(bType); data.setBusinessDataRepositoryId("fake"); data.setEClassName("Entity"); data.setClassName("org.bonitasoft.test.Entity"); container.getData().add(data); final BusinessObjectData data2 = ProcessFactory.eINSTANCE.createBusinessObjectData(); data2.setName("testData2"); data2.setDataType(bType); data2.setBusinessDataRepositoryId("fake"); data2.setEClassName("Entity2"); data2.setClassName("org.bonitasoft.test.Entity2"); container.getData().add(data2); final Resource r = new ResourceImpl(URI.createFileURI("test.proc")); r.getContents().clear(); r.getContents().add(diagram); final ResourceSet rSet = new ResourceSetImpl(); rSet.getResources().add(r); editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(rSet); wizardUnderTest = new EditBusinessObjectDataWizard(data, store, editingDomain); wizardUnderTest.setContainer(wizardContainer); }
Example #17
Source File: MoveConnectorWizardTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_add_a_MoveConnectorWizardPage() throws Exception { final MoveConnectorWizard wizard = new MoveConnectorWizard(mock(IOperationHistory.class), mock(TransactionalEditingDomain.class), newArrayList(aConnector().in(aPool()).build())); wizard.addPages(); assertThat(wizard.getPage(MoveConnectorWizardPage.class.getName())).isNotNull(); }
Example #18
Source File: MoveConnectorWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public MoveConnectorWizard(final IOperationHistory operationHistory, final TransactionalEditingDomain editingDomain, final Collection<Connector> connectorsToMove) { checkArgument(connectorsToMove != null && !connectorsToMove.isEmpty(), "connectorsToMove cannot be null or empty"); this.connectorsToMove = connectorsToMove; sourceProcess = sourceProcess(); this.editingDomain = editingDomain; this.operationHistory = operationHistory; targetLocation = new WritableValue(sourceConnectableElement(), ConnectableElement.class); connectorEventObservable = new WritableValue(connectorEvent(), String.class); }
Example #19
Source File: CommandUtil.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public static List<IFile> getAffectedFiles(ResourceSet resourceSet) { final List<IFile> affectedFiles = new ArrayList<IFile>(); final TransactionalEditingDomain domain = TransactionUtil .getEditingDomain(resourceSet); for (final Resource next : resourceSet.getResources()) { if (!domain.isReadOnly(next)) { final IFile file = WorkspaceSynchronizer .getUnderlyingFile(next); Assert.isNotNull(file, next.getURI() + ""); affectedFiles.add(file); } } return affectedFiles; }
Example #20
Source File: ProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated BonitaSoft * Open intro if all editors are closed. * Force OperationHistory to be cleaned. */ @Override public void dispose() { TransactionalEditingDomain domain = getEditingDomain(); if (processPref != null) { processPref.removePropertyChangeListener(paletteChangeListener); } IOperationHistory history = (IOperationHistory) getAdapter(IOperationHistory.class); if (history != null) { history.dispose(getUndoContext(), true, true, true); } super.dispose(); //Remove event broker listener for editingDomain if (domain != null) { final DiagramEventBroker eventBroker = DiagramEventBroker.getInstance(domain); if (eventBroker != null) { DiagramEventBroker.stopListening(domain); } domain = null; } //avoid Memory leak if (getDiagramGraphicalViewer() != null) { getDiagramGraphicalViewer().deselectAll(); if (getDiagramGraphicalViewer().getVisualPartMap() != null) { getDiagramGraphicalViewer().getVisualPartMap().clear(); } if (getDiagramGraphicalViewer().getEditPartRegistry() != null) { getDiagramGraphicalViewer().getEditPartRegistry().clear(); } } //GMF bug, avoid memory leak final RulerComposite rulerComposite = getRulerComposite(); if (rulerComposite != null) { rulerComposite.dispose(); } }
Example #21
Source File: DataWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public DataWizard(final TransactionalEditingDomain editingDomain, final Data data, final EStructuralFeature dataContainmentFeature, final Set<EStructuralFeature> featureToCheckForUniqueID, final boolean showAutogenerateForm) { initDataWizard(dataContainmentFeature, showAutogenerateForm); Assert.isNotNull(data); this.editingDomain = editingDomain; setNeedsProgressMonitor(true); container = data.eContainer(); originalData = data; this.dataUpdater = new EMFModelUpdater<Data>().from(data); dataWorkingCopy = dataUpdater.getWorkingCopy(); editMode = true; this.featureToCheckForUniqueID = featureToCheckForUniqueID; setWindowTitle(Messages.editVariable); }
Example #22
Source File: StringAttributeParser.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) { if (newString == null) { return UnexecutableCommand.INSTANCE; } EObject element = (EObject) adapter.getAdapter(EObject.class); TransactionalEditingDomain editingDomain = TransactionUtil .getEditingDomain(element); if (editingDomain == null) { return UnexecutableCommand.INSTANCE; } SetRequest request = new SetRequest(element, provider.getAttribute(), newString); return new SetValueCommand(request); }
Example #23
Source File: EMFEditWithRefactorObservables.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public static IObservableFactory valueWithRefactorFactory(final Realm realm, final EStructuralFeature eStructuralFeature, IRefactorOperationFactory refactorOperationFactory, IProgressService progressService) { return new IObservableFactory() { @Override public IObservable createObservable(final Object target) { final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(target); return new ObservableValueWithRefactor(editingDomain, (EObject) target, eStructuralFeature, refactorOperationFactory, progressService); } }; }
Example #24
Source File: ValidateAction.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ public static void runValidation(DiagramEditPart diagramEditPart, View view) { final DiagramEditPart fpart = diagramEditPart; final View fview = view; TransactionalEditingDomain txDomain = TransactionUtil.getEditingDomain(view); ProcessValidationProvider.runWithConstraints(txDomain, new Runnable() { public void run() { validate(fpart, fview); } }); }
Example #25
Source File: AddBusinessObjectDataWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public AddBusinessObjectDataWizard(final DataAware container, final BusinessObjectModelRepositoryStore businessObjectDefinitionStore, final TransactionalEditingDomain editingDomain) { this.container = container; businessObjectData = newBusinessData(container); this.businessObjectDefinitionStore = businessObjectDefinitionStore; this.editingDomain = editingDomain; setDefaultPageImageDescriptor(Pics.getWizban()); setWindowTitle(Messages.addBusinessObjectDataWindowTitle); }
Example #26
Source File: EMFModelUpdater.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public RecordingCommand createUpdateCommand(TransactionalEditingDomain editingDomain) { return new RecordingCommand(editingDomain) { @Override protected void doExecute() { synched.clear(); manyFeaturesSynched.clear(); deepEObjectUpdate(source, workingCopy); } }; }
Example #27
Source File: CompartmentRepositionEObjectCommand.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public CompartmentRepositionEObjectCommand(EditPart childToMove, TransactionalEditingDomain editingDomain, String label, EList elements, EObject element, int displacement, int newIndex) { super(editingDomain, label, elements, element, displacement); this.childToMove = childToMove; this.newIndex = newIndex; }
Example #28
Source File: DiagramPartitioningDocumentProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected ElementInfo createElementInfo(Object element) throws CoreException { ElementInfo info = super.createElementInfo(element); if (element instanceof IDiagramEditorInput) { Resource eResource = ((IDiagramEditorInput) element).getDiagram().eResource(); TransactionalEditingDomain sharedDomain = DiagramPartitioningUtil.getSharedDomain(); if (eResource.isLoaded() && !sharedDomain.isReadOnly(eResource) && eResource.isModified()) { info.fCanBeSaved = true; } } return info; }
Example #29
Source File: CustomFeedbackXYLayoutPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Override in order to change the location if a figure overrides another */ @Override protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) { final Rectangle newBounds = (Rectangle) constraint; final View shapeView = (View) child.getModel(); final TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); return new ICommandProxy(new OverlapSetBoundsCommand(editingDomain, (GraphicalEditPart) child, getHost(), new EObjectAdapter(shapeView), newBounds)); }
Example #30
Source File: DeleteHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void upadateLaneItems() { final CompoundCommand cc = new CompoundCommand(); for (final Lane l : lanes) { final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(l); for (final EObject task : ModelHelper.getAllItemsOfType(l, ProcessPackage.Literals.TASK)) { cc.append(SetCommand.create(domain, task, ProcessPackage.Literals.TASK__OVERRIDE_ACTORS_OF_THE_LANE, true)); } domain.getCommandStack().execute(cc); } }