Java Code Examples for org.eclipse.emf.transaction.TransactionalEditingDomain

The following examples show how to use org.eclipse.emf.transaction.TransactionalEditingDomain. These examples are extracted from open source projects. 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 Project: bonita-studio   Author: bonitasoft   File: ProcessValidationProvider.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
* @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 #2
Source Project: bonita-studio   Author: bonitasoft   File: BatchValidationOperation.java    License: GNU General Public License v2.0 6 votes vote down vote up
@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 Project: bonita-studio   Author: bonitasoft   File: DiagramFileStore.java    License: GNU General Public License v2.0 6 votes vote down vote up
@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 Project: M2Doc   Author: ObeoNetwork   File: VariableAndOptionPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #5
Source Project: M2Doc   Author: ObeoNetwork   File: VariableAndOptionPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #6
Source Project: statecharts   Author: Yakindu   File: ToggleSubRegionLayoutCommand.java    License: Eclipse Public License 1.0 6 votes vote down vote up
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 #7
Source Project: bonita-studio   Author: bonitasoft   File: ObservableValueWithRefactor.java    License: GNU General Public License v2.0 6 votes vote down vote up
@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 #8
Source Project: bonita-studio   Author: bonitasoft   File: CustomCutCommand.java    License: GNU General Public License v2.0 6 votes vote down vote up
@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 #9
Source Project: statecharts   Author: Yakindu   File: FixedBendpointEditPolicy.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@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 #10
Source Project: bonita-studio   Author: bonitasoft   File: BatchValidationHandler.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 #11
Source Project: bonita-studio   Author: bonitasoft   File: MoveConnectorWizard.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 #12
Source Project: bonita-studio   Author: bonitasoft   File: MoveDataCommand.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 #13
Source Project: bonita-studio   Author: bonitasoft   File: IteratorRefactorOperationFactory.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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 Project: bonita-studio   Author: bonitasoft   File: EMFModelUpdater.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the changes to the source object limiting UUID changes
 */
public T update() {
    TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(source);
    if (editingDomain != null) {
        editingDomain.getCommandStack().execute(createUpdateCommand(editingDomain));
    } else {
        synched.clear();
        manyFeaturesSynched.clear();
        deepEObjectUpdate(source, workingCopy);
    }
    return source;
}
 
Example #15
Source Project: bonita-studio   Author: bonitasoft   File: SelectionFeedbackEditPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void deactivate() {
	super.deactivate();
	zoomManager.removeZoomListener(this) ;
	TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain() ;
	View view = ((IGraphicalEditPart)getHost()).getNotationView() ; 
	DiagramEventBroker.getInstance(editingDomain).removeNotificationListener(view,NotationPackage.eINSTANCE.getLineStyle_LineColor(), styleListener ) ;
	feedbackFigures.clear();
	sourceFigure =null;
	layer = null;
	feedBackFigure = null;
}
 
Example #16
Source Project: M2Doc   Author: ObeoNetwork   File: GenerationFileNamesPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Updates the generation URI.
 * 
 * @param gen
 *            the {@link Generation}
 * @param newGenconfURI
 *            the new generation URI
 */
private void updateGenconfURI(final Generation gen, final URI newGenconfURI) {
    final URI templateAbsolutURI;
    if (gen.getTemplateFileName() != null) {
        templateAbsolutURI = GenconfUtils.getResolvedURI(gen, URI.createURI(gen.getTemplateFileName(), false));
    } else {
        templateAbsolutURI = null;
    }
    final URI validationAbsolutURI;
    if (gen.getValidationFileName() != null) {
        validationAbsolutURI = GenconfUtils.getResolvedURI(gen, URI.createURI(gen.getValidationFileName(), false));
    } else {
        validationAbsolutURI = null;
    }
    final URI resultAbsolutURI;
    if (gen.getResultFileName() != null) {
        resultAbsolutURI = GenconfUtils.getResolvedURI(gen, URI.createURI(gen.getResultFileName()));
    } else {
        resultAbsolutURI = null;
    }

    gen.eResource().setURI(newGenconfURI);

    final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(gen);
    editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {

        @Override
        protected void doExecute() {
            if (templateAbsolutURI != null) {
                gen.setTemplateFileName(URI.decode(templateAbsolutURI.deresolve(newGenconfURI).toString()));
            }
            if (validationAbsolutURI != null) {
                gen.setValidationFileName(URI.decode(validationAbsolutURI.deresolve(newGenconfURI).toString()));
            }
            if (resultAbsolutURI != null) {
                gen.setResultFileName(URI.decode(resultAbsolutURI.deresolve(newGenconfURI).toString()));
            }
        }
    });
}
 
Example #17
Source Project: bonita-studio   Author: bonitasoft   File: ScriptRefactoringAction.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 #18
Source Project: bonita-studio   Author: bonitasoft   File: DataWizard.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 #19
Source Project: bonita-studio   Author: bonitasoft   File: ProcBuilderTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testAddGenericAttribute() throws ProcBuilderException, IOException {
    final String diagamFileName = "testDiagram.proc";
    final String diagramName = "testDiagram";
    final String poolName = "Pooli";
    final String description = "Simple description";
    final List<String> categories = new ArrayList<String>(2);
    categories.add("R&D");
    categories.add("Service");
    final File diagramFile = new File(ProjectUtil.getBonitaStudioWorkFolder(), diagamFileName);
    diagramFile.deleteOnExit();
    final URI targetURI = URI.createFileURI(diagramFile.getAbsolutePath());

    initProcBuilderWithDefaultContent(diagramName, poolName, description, categories, diagramFile);

    procBuilder.done();

    final TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE.createEditingDomain();
    final Resource diagramResource = editingDomain.getResourceSet().createResource(targetURI);
    diagramResource.load(new HashMap<String, String>());
    assertTrue("Import as failed", diagramResource.getContents().size() > 0);
    final MainProcess proc = (MainProcess) diagramResource.getContents().get(0);
    assertEquals(diagramName, proc.getName());
    final Pool p = (Pool) proc.getElements().get(0);
    assertEquals(poolName, p.getName());
    assertEquals("Missing pool categories", categories.size(), p.getCategories().size());
    final StartEvent event = (StartEvent) p.getElements().get(0);
    assertEquals("Start", event.getName());
    assertEquals(description, event.getDocumentation());

    diagramResource.delete(new HashMap<String, String>());
}
 
Example #20
Source Project: M2Doc   Author: ObeoNetwork   File: NewGenerationWizard.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Constructor.
 */
public NewGenerationWizard() {
    generation = GenconfPackage.eINSTANCE.getGenconfFactory().createGeneration();
    final Resource resource = new XMIResourceImpl();
    final ResourceSet rs = new ResourceSetImpl();
    rs.getResources().add(resource);
    resource.getContents().add(generation);
    TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(rs);
}
 
Example #21
Source Project: bonita-studio   Author: bonitasoft   File: MigrationStatusView.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void clearMigrationReport(final boolean save) throws IOException {
    final IEditorPart editorPart = (IEditorPart) tableViewer.getInput();
    if (editorPart != null && editorPart instanceof DiagramEditor) {
        final Resource emfResource = ((DiagramEditor) editorPart).getDiagramEditPart().getNotationView().eResource();
        final Report report = getMigrationReport(emfResource);
        if (report != null) {
            final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(emfResource);
            if (domain != null) {
                domain.getCommandStack().execute(new RecordingCommand(domain) {

                    @Override
                    protected void doExecute() {
                        emfResource.getContents().remove(report);
                    }
                });
                if (save) {
                    final ICommandService service = (ICommandService) getSite().getService(ICommandService.class);
                    final Command cmd = service.getCommand("org.eclipse.ui.file.save");
                    try {
                        cmd.executeWithChecks(new ExecutionEvent());
                    } catch (final Exception e) {
                        BonitaStudioLog.error(e, MigrationPlugin.PLUGIN_ID);
                    }
                }
            }
        }
    }
}
 
Example #22
Source Project: bonita-studio   Author: bonitasoft   File: UpdateDataTypeCommand.java    License: GNU General Public License v2.0 5 votes vote down vote up
public UpdateDataTypeCommand(TransactionalEditingDomain editingDomain,DataType dataType, String name, String description, List<String> literals) {
	super(editingDomain,UpdateDataTypeCommand.class.getName(),getWorkspaceFiles(dataType));
	this.name = name;
	this.description = description;
	this.dataType = dataType;
	this.process = ModelHelper.getMainProcess(dataType);
	this.literals = literals ;
}
 
Example #23
Source Project: bonita-studio   Author: bonitasoft   File: EditBusinessObjectDataWizardTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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 #24
Source Project: bonita-studio   Author: bonitasoft   File: DataWizard.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 #25
Source Project: bonita-studio   Author: bonitasoft   File: EMFEditWithRefactorObservables.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 #26
Source Project: bonita-studio   Author: bonitasoft   File: ValidateAction.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
* @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 #27
Source Project: statecharts   Author: Yakindu   File: DiagramPartitioningDocumentProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@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 #28
Source Project: bonita-studio   Author: bonitasoft   File: CustomFeedbackXYLayoutPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #29
Source Project: bonita-studio   Author: bonitasoft   File: EMFModelUpdater.java    License: GNU General Public License v2.0 5 votes vote down vote up
public RecordingCommand createUpdateCommand(TransactionalEditingDomain editingDomain) {
    return new RecordingCommand(editingDomain) {

        @Override
        protected void doExecute() {
            synched.clear();
            manyFeaturesSynched.clear();
            deepEObjectUpdate(source, workingCopy);
        }
    };
}
 
Example #30
Source Project: statecharts   Author: Yakindu   File: CompartmentRepositionEObjectCommand.java    License: Eclipse Public License 1.0 5 votes vote down vote up
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;
}