org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl Java Examples

The following examples show how to use org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl. 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: ViewBasedRefactoringTest.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void testRefactoring(String pathToInitialSct, String pathToExpectedSct, String contextElementName) {
	Statechart initial = models
			.loadStatechartFromResource(pathToInitialSct);

	TransactionalEditingDomainImpl.FactoryImpl.INSTANCE.createEditingDomain(initial.eResource().getResourceSet());
	
	View contextView = getViewForState(initial, contextElementName);

	AbstractRefactoring<View> refactoring = getRefactoring();
	refactoring.setContextObjects(Collections.singletonList(contextView));
	
	AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
	initialRes.setSerializerEnabled(true);
	refactoring.execute();
	initialRes.setSerializerEnabled(false);

	Statechart expected = models
			.loadStatechartFromResource(pathToExpectedSct);
	
	compareStatecharts(initial, expected);
}
 
Example #2
Source File: ContractInputTreeViewerTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    parent = realm.createComposite();
    FileActionDialog.setDisablePopup(true);
    inputTreeViewer = new ContractInputTreeViewer(parent, new FormToolkit(parent.getDisplay()), progressService, sharedImages);
    final ContractInputController inputController = spy(new ContractInputController(new FakeProgressService()));
    doReturn(new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory())).when(inputController).editingDomain(any(Contract.class));
    inputTreeViewer.initialize(inputController, messageManager, new EMFDataBindingContext());
    final WritableValue contractObservableValue = new WritableValue();
    final Contract contract = ProcessFactory.eINSTANCE.createContract();
    input = ProcessFactory.eINSTANCE.createContractInput();
    input.setName("name");
    input.setType(ContractInputType.TEXT);
    contract.getInputs().add(input);
    aTask().build().setContract(contract);
    contractObservableValue.setValue(contract);
    inputTreeViewer.setInput(contractObservableValue);
}
 
Example #3
Source File: ContractInputControllerTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_open_an_error_dialog_if_remove_operation_failed() throws Exception {
    final IProgressService mockProgressService = mock(IProgressService.class);
    contractInputController = spy(new ContractInputController(mockProgressService));
    doReturn(new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory())).when(contractInputController).editingDomain(any(Contract.class));

    final Contract contract = aContract().havingInput(aContractInput()).in(aTask()).build();
    observableValue.setValue(contract);
    when(viewer.getSelection()).thenReturn(new StructuredSelection(contract.getInputs()));
    final InvocationTargetException error = new InvocationTargetException(new Throwable());
    doThrow(error).when(mockProgressService).run(anyBoolean(), anyBoolean(), any(IRunnableWithProgress.class));

    contractInputController.remove(viewer);

    verify(contractInputController).openErrorDialog(error);
}
 
Example #4
Source File: RefactorDataOperationTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    domain = new TransactionalEditingDomainImpl(new CustomProcessItemProviderAdapterFactory(), new TransactionalCommandStackImpl());
    parentProcess = ProcessFactory.eINSTANCE.createPool();
    myData = ProcessFactory.eINSTANCE.createData();
    myData.setName("myData");
    myData.setDataType(initialBooleanDataType);
    parentProcess.getData().add(myData);
    final Task task = ProcessFactory.eINSTANCE.createTask();
    operation = ExpressionFactory.eINSTANCE.createOperation();
    leftOperand = ExpressionFactory.eINSTANCE.createExpression();
    leftOperand.setName(myData.getName());
    leftOperand.setContent(myData.getName());
    leftOperand.setType(ExpressionConstants.VARIABLE_TYPE);
    leftOperand.getReferencedElements().add(ExpressionHelper.createDependencyFromEObject(myData));
    operation.setLeftOperand(leftOperand);
    operation.setRightOperand(rightOperand);
    task.getOperations().add(operation);
    parentProcess.getElements().add(task);
}
 
Example #5
Source File: M2DocMainVariablePage.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Constructor.
 */
public M2DocMainVariablePage() {
    super("Set the main variable value and name for your template.");
    adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
    editingDomain = new TransactionalEditingDomainImpl(adapterFactory, resourceSet);
}
 
Example #6
Source File: TestDocumentRefactor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private TransactionalEditingDomain createEditingDomain() {
    final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
            ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ProcessAdapterFactory());

    // command stack that will notify this editor as commands are executed
    final TransactionalCommandStackImpl commandStack = new TransactionalCommandStackImpl();

    // Create the editing domain with our adapterFactory and command stack.
    return new TransactionalEditingDomainImpl(adapterFactory, commandStack);
}
 
Example #7
Source File: DataWizardTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    when(refactorOperation.canExecute()).thenReturn(true);
    editingDomain = new TransactionalEditingDomainImpl(new ProcessAdapterFactory(), new TransactionalCommandStackImpl());
    final Data data = ProcessFactory.eINSTANCE.createData();
    wizard = spy(new DataWizard(editingDomain, data, ProcessPackage.Literals.DATA_AWARE__DATA, Collections.<EStructuralFeature> emptySet(), true));
    doReturn(refactorOperation).when(wizard).createRefactorOperation(eq(editingDomain), any(Data.class));
    final Data workingCopy = EcoreUtil.copy(data);
    doReturn(workingCopy).when(wizard).getWorkingCopy();
    doReturn(wizardContainer).when(wizard).getContainer();
    doReturn(true).when(wizard).isEdited(workingCopy);
}
 
Example #8
Source File: ContractInputControllerTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    FileActionDialog.setDisablePopup(true);
    contractInputController = spy(new ContractInputController(progressService));
    doReturn(new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory())).when(contractInputController).editingDomain(any(Contract.class));
    doReturn(scriptRefactoringOperationFactory).when(contractInputController).scriptRefactoringOperationFactory();
    when(scriptRefactoringOperationFactory.createScriptOperationFactory(anyString(), anyList())).thenReturn(refactorScriptOperation);
    observableValue = new WritableValue(Realm.getDefault());
    when(viewer.getInput()).thenReturn(observableValue);
    final Tree tree = mock(Tree.class);
    when(tree.getDisplay()).thenReturn(display);
    when(viewer.getControl()).thenReturn(tree);
}
 
Example #9
Source File: CustomWorkspaceCommandStackTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_create_always_valid_trigger_command_transaction_if_command_a_command_trigger() throws Exception {
    final CustomWorkspaceCommandStack commandStack = new CustomWorkspaceCommandStack(new DefaultOperationHistory());
    commandStack.setEditingDomain(new TransactionalEditingDomainImpl(new ProcessAdapterFactory()));

    final EMFCommandTransaction transaction = commandStack.createTransaction(new TriggerCommand(Collections.<Command> emptyList()), Collections.emptyMap());

    assertThat(transaction).isInstanceOf(AlwaysValidTriggerCommandTransaction.class);
}
 
Example #10
Source File: CustomWorkspaceCommandStackTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_create_always_valid_emf_transaction_if_command_is_not_a_command_trigger() throws Exception {
    final CustomWorkspaceCommandStack commandStack = new CustomWorkspaceCommandStack(new DefaultOperationHistory());
    commandStack.setEditingDomain(new TransactionalEditingDomainImpl(new ProcessAdapterFactory()));

    final EMFCommandTransaction transaction = commandStack.createTransaction(null, Collections.emptyMap());

    assertThat(transaction).isInstanceOf(AlwaysValidEMFOperationTransaction.class);
}
 
Example #11
Source File: AlwaysValidEMFOperationTransactionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_validate_always_return_OK_status() throws Exception {
    final AlwaysValidEMFOperationTransaction alwaysValidTransaction = new AlwaysValidEMFOperationTransaction(null, new TransactionalEditingDomainImpl(
            new AdapterFactoryImpl()),
            Collections.emptyMap());

    StatusAssert.assertThat(alwaysValidTransaction.validate()).isOK();
}
 
Example #12
Source File: AlwaysValidTriggerCommandTransactionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_validate_always_return_OK_status() throws Exception {
    final AlwaysValidTriggerCommandTransaction alwaysValidTransaction = new AlwaysValidTriggerCommandTransaction(null,
            new TransactionalEditingDomainImpl(new AdapterFactoryImpl()),
            Collections.emptyMap());

    StatusAssert.assertThat(alwaysValidTransaction.validate()).isOK();
}
 
Example #13
Source File: AlwaysValidTransactionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_validate_always_return_OK_status() throws Exception {
    final AlwaysValidTransaction alwaysValidTransaction = new AlwaysValidTransaction(new TransactionalEditingDomainImpl(new AdapterFactoryImpl()), false,
            Collections.emptyMap());

    StatusAssert.assertThat(alwaysValidTransaction.validate()).isOK();
}
 
Example #14
Source File: CreateAndEditFormContributionItemTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private EditingDomain editingDomain() {
    return new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory());
}
 
Example #15
Source File: FormReferenceExpressionViewerTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private TransactionalEditingDomain editingDomain() {
    return new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory());
}
 
Example #16
Source File: UpdateFormMappingCommandTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    editingDomain = new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory(), new TransactionalCommandStackImpl());
}
 
Example #17
Source File: ConditionExpressionScriptContrainerTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private EditingDomain editingDomain() {
    return new TransactionalEditingDomainImpl(new ExpressionItemProviderAdapterFactory());
}
 
Example #18
Source File: GroovyExpressionScriptContrainerTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private TransactionalEditingDomain editingDomain() {
    return new TransactionalEditingDomainImpl(new ExpressionItemProviderAdapterFactory());
}
 
Example #19
Source File: ContractInputGenerationWizardTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private EditingDomain editingDomain() {
    return new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory());
}
 
Example #20
Source File: ConstraintExpressionScriptContainerTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private TransactionalEditingDomainImpl editingDomain() {
    return new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory());
}
 
Example #21
Source File: RefactorContractInputOperationTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private TransactionalEditingDomainImpl transactionalEditingDomain() {
    return new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory());
}
 
Example #22
Source File: AddBusinessObjectDataWizardTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    editingDomain = new TransactionalEditingDomainImpl(new ProcessAdapterFactory());

}
 
Example #23
Source File: GenconfEditor.java    From M2Doc with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * This sets up the editing domain for the model editor.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 * @deprecated
 */
protected void initializeEditingDomain() {
    // Create an adapter factory that yields item providers.
    //
    adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new GenconfItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());

    // Create the command stack that will notify this editor as commands are executed.
    //
    TransactionalCommandStack commandStack = new TransactionalCommandStackImpl();

    // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
    //
    commandStack.addCommandStackListener(new CommandStackListener() {
        public void commandStackChanged(final EventObject event) {
            getContainer().getDisplay().asyncExec(new Runnable() {
                public void run() {
                    firePropertyChange(IEditorPart.PROP_DIRTY);

                    // Try to select the affected objects.
                    //
                    Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
                    if (mostRecentCommand != null) {
                        setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                    }
                    for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext();) {
                        PropertySheetPage propertySheetPage = i.next();
                        if (propertySheetPage.getControl().isDisposed()) {
                            i.remove();
                        } else {
                            propertySheetPage.refresh();
                        }
                    }
                }
            });
        }
    });

    // Create the editing domain with a special command stack.
    //
    editingDomain = new TransactionalEditingDomainImpl(adapterFactory, commandStack);
}