org.eclipse.emf.transaction.util.TransactionUtil Java Examples

The following examples show how to use org.eclipse.emf.transaction.util.TransactionUtil. 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: ProcessDataViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void moveData(final IStructuredSelection structuredSelection) {
    final DataAware container = (DataAware) getDataContainerObservable().getValue();
    final MoveDataWizard moveDataWizard = new MoveDataWizard(container);
    if (createWizardDialog(moveDataWizard, IDialogConstants.FINISH_LABEL).open() == Dialog.OK) {
        final DataAware dataAware = moveDataWizard.getSelectedDataAwareElement();
        try {
            final MoveDataCommand cmd = new MoveDataCommand(TransactionUtil.getEditingDomain(dataAware), container,
                    structuredSelection.toList(), dataAware);
            OperationHistoryFactory.getOperationHistory().execute(cmd, null, null);

            if (!(cmd.getCommandResult().getStatus().getSeverity() == Status.OK)) {
                final List<Object> data = (List<Object>) cmd.getCommandResult().getReturnValue();
                String dataNames = "";
                for (final Object d : data) {
                    dataNames = dataNames + ((Element) d).getName() + ",";
                }
                dataNames = dataNames.substring(0, dataNames.length() - 1);
                MessageDialog.openWarning(Display.getDefault().getActiveShell(), Messages.PromoteDataWarningTitle,
                        Messages.bind(Messages.PromoteDataWarningMessage, dataNames));
            }

        } catch (final ExecutionException e1) {
            BonitaStudioLog.error(e1);
        }
    }
}
 
Example #2
Source File: SharedEditingDomainFactory.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void unloadWithReferences(Resource resource) {
	TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resource);
	try {
		editingDomain.runExclusive(new Runnable() {
			@Override
			public void run() {
				Set<Resource> resourcesToUnload = new HashSet<>();
				collectTransitiveReferences(resource, resourcesToUnload);
				resourcesToUnload.add(resource);
				
				collectResourcesWithErrors(resource, resourcesToUnload);
				
				for (Resource current : resourcesToUnload) {
					if (current instanceof AbstractSCTResource || !current.getURI().isPlatform())
						continue;
					current.unload();
				}
			}

		});
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}
 
Example #3
Source File: AbstractPackageImportUriMapper.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Optional<PackageImport> findPackageImport(Resource context, String packageImport) {
	try {
		return TransactionUtil.runExclusive(getSharedEditingDomain(),
				new RunnableWithResult.Impl<Optional<PackageImport>>() {
					@Override
					public void run() {
						Set<PackageImport> allImports = getAllImports(getContextResource(context));
						for (PackageImport currentImport : allImports) {
							if (currentImport.getName().equals(packageImport)) {
								setResult(Optional.of(currentImport));
								return;
							}
						}
						setResult(Optional.empty());
					}

				});
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	return Optional.empty();
}
 
Example #4
Source File: BonitaTreeOutlinePage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * initialize the outline viewer
 */
protected void initializeOutlineViewer() {
    try {
        TransactionUtil.getEditingDomain(getDiagram()).runExclusive(
                new Runnable() {

                    @Override
                    public void run() {
                        getViewer().setContents(getDiagram());
                    }
                });
    } catch (final InterruptedException e) {
        Trace.catching(DiagramUIPlugin.getInstance(),
                DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "initializeOutlineViewer", e); //$NON-NLS-1$
        Log.error(DiagramUIPlugin.getInstance(),
                DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "initializeOutlineViewer", e); //$NON-NLS-1$
    }
    ((BonitaTreeViewer) getViewer())
            .setDiagramEditPart(getDiagramEditPart());
}
 
Example #5
Source File: VariableAndOptionPage.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates the {@link EditingDomain} for the given {@link Generation}.
 * 
 * @param gen
 *            the {@link Generation}
 */
private void updateEditingDomain(Generation gen) {
    final ResourceSetImpl defaultResourceSet = new ResourceSetImpl();
    defaultResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*",
            new XMIResourceFactoryImpl());

    if (editingDomain != null) {
        M2DocUtils.cleanResourceSetForModels(queryEnvironment, editingDomain.getResourceSet());
    }
    if (createdEditingDomaine) {
        editingDomain.dispose();
        editingDomain = null;
    }

    final ResourceSet modelResourceSet = M2DocUtils.createResourceSetForModels(new ArrayList<Exception>(),
            queryEnvironment, defaultResourceSet, GenconfUtils.getOptions(gen));
    final TransactionalEditingDomain modelEditingDomain = TransactionUtil.getEditingDomain(modelResourceSet);
    if (modelEditingDomain == null) {
        editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(modelResourceSet);
        createdEditingDomaine = true;
    } else {
        editingDomain = modelEditingDomain;
        createdEditingDomaine = false;
    }
}
 
Example #6
Source File: CreateParameterProposalListener.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String handleEvent(final EObject context, final String fixedReturnType) {
    Assert.isNotNull(context);
    final AbstractProcess parentProcess = ModelHelper.getParentProcess(context);
    final AddParameterWizard parameterWizard = new AddParameterWizard(parentProcess,
            TransactionUtil.getEditingDomain(context));
    final ParameterWizardDialog parameterDialog = new ParameterWizardDialog(
            Display.getDefault().getActiveShell(), parameterWizard);
    if (parameterDialog.open() == Dialog.OK) {
        final Parameter param = parameterWizard.getNewParameter();
        if (param != null) {
            return param.getName();
        }
    }
    return null;
}
 
Example #7
Source File: ShadowModelValidationJob.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void cloneResource(final IProgressMonitor monitor, final Resource shadowResource)
		throws ExecutionException {
	final ByteArrayOutputStream bout = new ByteArrayOutputStream();
	try {
		TransactionUtil.getEditingDomain(resource).runExclusive(() -> {
			try {
				XMISaveImpl saver = new XMISaveImpl(new XMIHelperImpl((XMLResource) resource));
				saver.save((XMLResource) resource, bout, Collections.emptyMap());
				bout.flush();
			} catch (Throwable tt) {
				tt.printStackTrace();
			}
		});
	} catch (InterruptedException e1) {
		e1.printStackTrace();
	}
	try {
		shadowResource.load(new ByteArrayInputStream(bout.toByteArray()), Collections.emptyMap());
	} catch (IOException e) {
		e.printStackTrace();
	}

}
 
Example #8
Source File: ToggleSubRegionLayoutCommand.java    From statecharts with 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 #9
Source File: AbstractSemanticModification.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Executes the modification in a transactional command.
 */
public void modify() {
	if (! isApplicable()) throw new IllegalStateException("Modification " + getClass().getSimpleName() + " is not executable.");
	
	final EObject semanticObject = getTargetView().getElement();
	AbstractTransactionalCommand refactoringCommand = new AbstractTransactionalCommand(
			TransactionUtil.getEditingDomain(semanticObject), getClass().getName(), Collections.EMPTY_LIST) {
		@Override
		protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
				throws ExecutionException {
			try {
				AbstractSemanticModification.this.execute(semanticObject, getTargetView());
			} catch (Exception ex) {
				ex.printStackTrace();
				return CommandResult.newErrorCommandResult(ex);
			}
			return CommandResult.newOKCommandResult();
		}
	};
	executeCommand(refactoringCommand, semanticObject.eResource());
}
 
Example #10
Source File: CustomEMFEditObservables.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static IObservableFactory listFactory(final Realm realm, final EStructuralFeature eStructuralFeature) {
    return new IObservableFactory()
    {

        @Override
        public IObservable createObservable(final Object target)
        {
            if (((EObject) target).eResource() != null) {
                final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(target);
                if (domain != null) {
                    return observeList(realm, domain, (EObject) target, eStructuralFeature);
                }
            }

            return observeList(realm, (EObject) target, eStructuralFeature);

        }
    };
}
 
Example #11
Source File: CreateVariableProposalListener.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String handleEvent(final EObject context, final String fixedReturnType) {
    Assert.isNotNull(context);
    final EObject dataContainer = getDataContainer(context);
    final Data dataWorkingCopy = ProcessFactory.eINSTANCE.createData();
    dataWorkingCopy.setMultiple(multipleData);
    dataWorkingCopy.setDataType(ModelHelper.getDataTypeForID(dataContainer, DataTypeLabels.stringDataType));
    final DataWizard newWizard = new DataWizard(TransactionUtil.getEditingDomain(context), dataContainer, dataWorkingCopy, feature,
            Collections.singleton(feature), true,
            fixedReturnType);
    newWizard.setIsPageFlowContext(isPageFlowContext);
    final CustomWizardDialog wizardDialog = new CustomWizardDialog(activeShell(), newWizard, IDialogConstants.FINISH_LABEL);
    if (wizardDialog.open() == Dialog.OK) {
        RepositoryManager.getInstance().getCurrentRepository().buildXtext();
        final Data newData = newWizard.getNewData();
        if (newData != null) {
            return newData.getName();
        }
    }
    return null;
}
 
Example #12
Source File: ModelHelper.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param form
 * @return the diagram corresponding to the form.
 */
public static Diagram getDiagramFor(final EObject element, final Resource resource) {
    if (element == null) {
        return null;
    }
    if (!resource.isLoaded()) {
        throw new IllegalStateException("EMF Resource is not loaded.");
    }

    final RunnableWithResult<Diagram> runnableWithResult = new DiagramForElementRunnable(resource, element);
    final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resource);
    if (editingDomain != null) {
        try {
            editingDomain.runExclusive(runnableWithResult);
        } catch (final InterruptedException e) {
            BonitaStudioLog.error(e);
        }
    } else {
        runnableWithResult.run();
    }
    return runnableWithResult.getResult();
}
 
Example #13
Source File: DiagramFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Remove the migration report from the proc file.
 *
 * @param save , Whether we save the resoruce after deletion or not
 * @throws IOException
 */
public void clearMigrationReport(final boolean save) throws IOException {
    final EObject toRemove = null;
    final Resource emfResource = getEMFResource();
    final Report report = getMigrationReport();
    if (report != null) {
        final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(toRemove);
        if (domain != null) {
            domain.getCommandStack().execute(new RecordingCommand(domain) {

                @Override
                protected void doExecute() {
                    emfResource.getContents().remove(report);
                }
            });
            if (save) {
                emfResource.save(Collections.emptyMap());
            }
        }
    }
}
 
Example #14
Source File: DiagramFileStore.java    From bonita-studio with 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 #15
Source File: BPMNDataExportImportTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected DocumentRoot exportToBPMNProcessWithData(final Data data, final String dataType) throws IOException {
    final NewDiagramCommandHandler newDiagramCommandHandler = new NewDiagramCommandHandler();
    final DiagramFileStore newDiagramFileStore = newDiagramCommandHandler.newDiagram();
    Resource emfResource = newDiagramFileStore.getEMFResource();
    TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(emfResource);
    MainProcess mainProcess = newDiagramFileStore.getContent();
    final AbstractProcess abstractProcess = newDiagramFileStore.getProcesses().get(0);
    editingDomain.getCommandStack()
            .execute(AddCommand.create(editingDomain, abstractProcess, ProcessPackage.Literals.DATA_AWARE__DATA,
                    data));
    mainProcess.getDatatypes().stream()
            .filter(dt -> Objects.equals(NamingUtils.convertToId(dataType), dt.getName()))
            .findFirst()
            .ifPresent(dt -> editingDomain.getCommandStack()
                    .execute(SetCommand.create(editingDomain, data, ProcessPackage.Literals.DATA__DATA_TYPE, dt)));
    assertThat(data.getDataType())
            .overridingErrorMessage("No datatype '%s' set on data %s", NamingUtils.convertToId(dataType), data)
            .isNotNull();
    newDiagramFileStore.save(mainProcess);
    return BPMNTestUtil.exportToBpmn(emfResource);
}
 
Example #16
Source File: DuplicateDiagramOperation.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private DiagramFileStore copyDiagram() {
    final DiagramRepositoryStore diagramStore = RepositoryManager.getInstance()
            .getRepositoryStore(DiagramRepositoryStore.class);

    final Copier copier = new Copier(true, false);
    final Collection<EObject> copiedElements = copier.copyAll(diagram.eResource().getContents());
    copier.copyReferences();//don't forget this line otherwise we loose link between diagrams and model
    final DiagramFileStore store = diagramStore
            .createRepositoryFileStore(NamingUtils.toDiagramFilename(diagramName, diagramVersion));
    store.save(copiedElements);

    final MainProcess newDiagram = store.getContent();
    final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(newDiagram.eResource());
    changeProcessNameAndVersion(newDiagram, editingDomain, diagramName, diagramVersion);
    editingDomain.getCommandStack().execute(
            SetCommand.create(editingDomain, newDiagram, ProcessPackage.Literals.MAIN_PROCESS__CONFIG_ID,
                    ConfigurationIdProvider
                            .getConfigurationIdProvider().getConfigurationId(newDiagram)));
    duplicateConfigurations(diagram, newDiagram);
    return store;
}
 
Example #17
Source File: NewDiagramCommandHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public DiagramFileStore execute(final ExecutionEvent event) throws ExecutionException {
    final DiagramFileStore diagramFileStore = newDiagram();
    Display.getDefault().asyncExec(() -> {
            final IEditorPart editor = (IEditorPart) diagramFileStore.open();
            if (editor instanceof DiagramEditor) {
                final String author = System.getProperty("user.name", "unknown");
                final TransactionalEditingDomain editingDomain = TransactionUtil
                        .getEditingDomain(diagramFileStore.getEMFResource());
                editingDomain.getCommandStack().execute(
                        SetCommand.create(editingDomain,
                                ((DiagramEditor) editor).getDiagramEditPart().resolveSemanticElement(),
                                ProcessPackage.Literals.ABSTRACT_PROCESS__AUTHOR, author));
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(editor);
            }
    });
    return diagramFileStore;
}
 
Example #18
Source File: BatchValidationOperation.java    From bonita-studio with 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 #19
Source File: TestDocumentRefactoring.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void refactorDocument(final Pool pool) throws InvocationTargetException, InterruptedException {
    final Document documentToRefactor = pool.getDocuments().get(0);
    final RefactorDocumentOperation refactorOperation = new RefactorDocumentOperation(RefactoringOperationType.UPDATE);
    refactorOperation.setEditingDomain(TransactionUtil.getEditingDomain(pool));
    final Document newDocument = EcoreUtil.copy(documentToRefactor);
    newDocument.setName(newDocumentName);
    refactorOperation.addItemToRefactor(newDocument, documentToRefactor);
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(refactorOperation);
    final Document documentRefactored = pool.getDocuments().get(0);
    assertEquals(newDocument.getName(), documentRefactored.getName());
    testDocumentInExpressionsRefactored(documentRefactored, 2, pool);
    final Document currentDoc = refactorDocumentTypeAndMultiplicity(pool, documentRefactored);
    testRemoveDocumentRefactoring(currentDoc, pool);

}
 
Example #20
Source File: TestDocumentRefactoring.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Document refactorDocumentTypeAndMultiplicity(final Pool pool, final Document document)
        throws InvocationTargetException, InterruptedException {
    final Document newDocument = EcoreUtil.copy(document);
    newDocument.setMultiple(true);
    newDocument.setDocumentType(DocumentType.EXTERNAL);
    final RefactorDocumentOperation refactorOperation = new RefactorDocumentOperation(RefactoringOperationType.UPDATE);
    refactorOperation.setEditingDomain(TransactionUtil.getEditingDomain(pool));
    refactorOperation.addItemToRefactor(newDocument, document);
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(refactorOperation);
    final Document documentRefactored = pool.getDocuments().get(0);
    assertEquals(newDocument.getName(), documentRefactored.getName());
    assertEquals(newDocument.getDocumentType(), documentRefactored.getDocumentType());
    return documentRefactored;

}
 
Example #21
Source File: BatchValidationHandler.java    From bonita-studio with 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 #22
Source File: DiagramEditorContextMenuProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
public void buildContextMenu(final IMenuManager menu) {
	getViewer().flush();
	try {
		TransactionUtil.getEditingDomain((EObject) getViewer().getContents().getModel())
				.runExclusive(new Runnable() {

					public void run() {
						ContributionItemService.getInstance()
								.contributeToPopupMenu(DiagramEditorContextMenuProvider.this, part);
						menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL);
						menu.appendToGroup("editGroup", deleteAction);
					}
				});
	} catch (Exception e) {
		CrossflowDiagramEditorPlugin.getInstance().logError("Error building context menu", e);
	}
}
 
Example #23
Source File: ExpressionCollectionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private ListExpression addLineInTableExpression(final Object expressionInput) {
    final ListExpression rowExp = createListExpressionForNewLineInTable();
    if (editingDomain == null) {
        editingDomain = TransactionUtil.getEditingDomain(expressionInput);
    }
    if (editingDomain != null) {
        editingDomain
                .getCommandStack()
                .execute(
                        AddCommand
                                .create(editingDomain,
                                        expressionInput,
                                        ExpressionPackage.Literals.TABLE_EXPRESSION__EXPRESSIONS,
                                        rowExp));
    } else {
        ((TableExpression) expressionInput).getExpressions().add(rowExp);
    }

    return rowExp;
}
 
Example #24
Source File: ExpressionViewerValidator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public IStatus doValidate(final Object value,final Expression expression) {
    final IExpressionValidator delagateValidator = getExpressionValidator(expression);
    if (delagateValidator != null) {
        delagateValidator.setDomain(TransactionUtil.getEditingDomain(expression));
        delagateValidator.setContext(getContext());
        delagateValidator.setInputExpression(expression);
        Object toValidate = value;
        if (toValidate == null) {
            toValidate = "";
        }
        return delagateValidator.validate(toValidate);
    }
    return ValidationStatus.ok();
}
 
Example #25
Source File: OpenDiagramEditPolicy.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
OpenDiagramCommand(HintedDiagramLinkStyle linkStyle) {
	// editing domain is taken for original diagram, 
	// if we open diagram from another file, we should use another editing domain
	super(TransactionUtil.getEditingDomain(linkStyle), Messages.CommandName_OpenDiagram, null);
	diagramFacet = linkStyle;
}
 
Example #26
Source File: MigrationStatusView.java    From bonita-studio with 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 #27
Source File: ConfigurationSynchronizer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ConfigurationSynchronizer(final AbstractProcess process, final Configuration configuration) {
    this();
    this.process = process;
    this.configuration = configuration;
    synchronizeLocalConfiguraiton = ConfigurationPreferenceConstants.LOCAL_CONFIGURAITON.equals(configuration.getName()) || configuration.getName() == null;
    editingDomain = (AdapterFactoryEditingDomain) TransactionUtil.getEditingDomain(process);
}
 
Example #28
Source File: ConfigurationSynchronizer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void synchronize(Pool process, Configuration configuration) {
    this.process = process;
    this.configuration = configuration;
    synchronizeLocalConfiguraiton = ConfigurationPreferenceConstants.LOCAL_CONFIGURAITON.equals(configuration.getName()) || configuration.getName() == null;
    editingDomain = (AdapterFactoryEditingDomain) TransactionUtil.getEditingDomain(process);
    synchronize();
}
 
Example #29
Source File: TestParametersRefactoring.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void removeParameter(final List<Pool> pools, final List<Parameter> pool1Parameters,
        final List<Operation> operations)
        throws InvocationTargetException,
        InterruptedException {
    final RemoveParametersOperation op = new RemoveParametersOperation(pool1Parameters.get(0), pools.get(0));
    op.setEditingDomain(TransactionUtil.getEditingDomain(pools.get(0)));
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.busyCursorWhile(op);
    assertEquals("parameter has not been removed", 1, pools.get(0).getParameters().size());
    assertEquals("parameter reference has not been removed", "", operations.get(0).getRightOperand().getName());
    final Configuration localeConfiguration = getLocalConfiguration(pools.get(0));
    assertEquals("parameter has not been removed correctly in ", 1, localeConfiguration.getParameters().size());
}
 
Example #30
Source File: ParameterEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void expressionButtonListener(final EObject context) {
    final ParameterWizardDialog parameterDialog = new ParameterWizardDialog(
            Display.getCurrent().getActiveShell(),
            new AddParameterWizard(ModelHelper.getParentProcess(context), TransactionUtil.getEditingDomain(context)));
    if (parameterDialog.open() == Dialog.OK) {
        fillViewerInput(context);
    }
}