Java Code Examples for org.eclipse.swt.events.SelectionAdapter#widgetSelected()

The following examples show how to use org.eclipse.swt.events.SelectionAdapter#widgetSelected() . 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: SelectDataWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_select_first_businessVariable_whenSelecting_businessDataType() {
    final List<Data> availableBusinessData = new ArrayList<Data>();
    final List<Document> availableDocuments = new ArrayList<Document>();
    final Contract contract = aContract().build();
    final BusinessObjectData bd = aBusinessData().build();
    availableBusinessData.add(bd);
    final Document document = ProcessFactory.eINSTANCE.createDocument();
    availableDocuments.add(document);
    final WritableValue selectedDataObservable = new WritableValue();
    selectedDataObservable.setValue(document);
    final SelectDataWizardPage page = new SelectDataWizardPage(contract, availableBusinessData, availableDocuments, selectedDataObservable,
            selectedDataObservable, new GenerationOptions(), store);
    page.setBusinessDataTypeSelected(false);
    final SelectionAdapter bvSelectionAdapter = page.createBusinessVariableSelectionAdapter();
    bvSelectionAdapter.widgetSelected(mock(SelectionEvent.class));
    assertThat(page.isBusinessDataTypeSelected()).isTrue();
    assertThat(selectedDataObservable.getValue()).isEqualTo(bd);
}
 
Example 2
Source File: SelectDataWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_select_first_document_whenSelecting_businessDataType() {
    final List<Data> availableBusinessData = new ArrayList<Data>();
    final List<Document> availableDocuments = new ArrayList<Document>();
    final Contract contract = aContract().build();
    final BusinessObjectData bd = aBusinessData().build();
    availableBusinessData.add(bd);
    final Document document = ProcessFactory.eINSTANCE.createDocument();
    availableDocuments.add(document);
    final WritableValue selectedDataObservable = new WritableValue();
    selectedDataObservable.setValue(bd);
    final SelectDataWizardPage page = new SelectDataWizardPage(contract, availableBusinessData, availableDocuments, selectedDataObservable,
            selectedDataObservable, new GenerationOptions(), store);
    page.setBusinessDataTypeSelected(true);
    final SelectionAdapter documentSelectionAdapter = page.createDocumentSelectionAdapter();
    documentSelectionAdapter.widgetSelected(mock(SelectionEvent.class));
    assertThat(page.isBusinessDataTypeSelected()).isFalse();
    assertThat(selectedDataObservable.getValue()).isEqualTo(document);
}
 
Example 3
Source File: CreateContractInputFromBusinessObjectWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_setAllFieldToInputContractMappingsGenerated_toTrue_whenSelectingAllFields() {
    BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee").build();
    Contract contract = aContract().build();
    Pool process = aPool().havingContract(contract).build();
    process.getData().add(data);
    GenerationOptions options = new GenerationOptions();
    BusinessObjectModelRepositoryStore<BusinessObjectModelFileStore> store = mock(
            BusinessObjectModelRepositoryStore.class);
    WritableValue<BusinessObjectData> selectedDataObservable = new WritableValue<>();
    selectedDataObservable.setValue(data);
    WritableValue<String> rootNameObservable = new WritableValue<>();
    rootNameObservable.setValue("employeeInput");
    WritableList<FieldToContractInputMapping> fieldToContractInputMappingsObservable = new WritableList<>();
    CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(
            process, options,
            selectedDataObservable, new FieldToContractInputMappingFactory(store),
            fieldToContractInputMappingsObservable,
            store);
    FieldToContractInputMapping rootMapping1 = new RelationFieldToContractInputMapping(
            Mockito.mock(RelationField.class));
    SimpleFieldToContractInputMapping childMapping1 = new SimpleFieldToContractInputMapping(
            Mockito.mock(SimpleField.class));
    SimpleFieldToContractInputMapping childMapping2 = new SimpleFieldToContractInputMapping(
            Mockito.mock(SimpleField.class));
    rootMapping1.addChild(childMapping1);
    rootMapping1.addChild(childMapping2);
    FieldToContractInputMapping rootMapping2 = new RelationFieldToContractInputMapping(
            Mockito.mock(RelationField.class));
    page.setMappings(Lists.newArrayList(rootMapping1, rootMapping2));
    WritableSet<FieldToContractInputMapping> checkedElements = new WritableSet<>();
    checkedElements.addAll(Arrays.asList(rootMapping1, childMapping2));
    SelectionAdapter listener = page.createSelectAllListener(checkedElements);
    listener.widgetSelected(mock(SelectionEvent.class));
    assertThat(rootMapping1.isGenerated()).isTrue();
    assertThat(childMapping1.isGenerated()).isTrue();
    assertThat(childMapping2.isGenerated()).isTrue();
    assertThat(rootMapping2.isGenerated()).isTrue();
}
 
Example 4
Source File: CreateContractInputFromBusinessObjectWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_setAllFieldToInputContractMappingsGenerated_toFalse_whenDeselectingAllFields() {
    BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee").build();
    Contract contract = aContract().build();
    Pool process = aPool().havingContract(contract).build();
    process.getData().add(data);
    GenerationOptions options = new GenerationOptions();
    BusinessObjectModelRepositoryStore<BusinessObjectModelFileStore> store = mock(
            BusinessObjectModelRepositoryStore.class);
    WritableValue<BusinessObjectData> selectedDataObservable = new WritableValue<>();
    selectedDataObservable.setValue(data);
    WritableValue<String> rootNameObservable = new WritableValue<>();
    rootNameObservable.setValue("employeeInput");
    WritableList<FieldToContractInputMapping> fieldToContractInputMappingsObservable = new WritableList<>();
    CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(
            process, options,
            selectedDataObservable, new FieldToContractInputMappingFactory(store),
            fieldToContractInputMappingsObservable,
            store);
    FieldToContractInputMapping rootMapping1 = new RelationFieldToContractInputMapping(
            Mockito.mock(RelationField.class));
    SimpleFieldToContractInputMapping childMapping1 = new SimpleFieldToContractInputMapping(
            Mockito.mock(SimpleField.class));
    SimpleFieldToContractInputMapping childMapping2 = new SimpleFieldToContractInputMapping(
            Mockito.mock(SimpleField.class));
    rootMapping1.addChild(childMapping1);
    rootMapping1.addChild(childMapping2);
    FieldToContractInputMapping rootMapping2 = new RelationFieldToContractInputMapping(
            Mockito.mock(RelationField.class));
    page.setMappings(Lists.newArrayList(rootMapping1, rootMapping2));
    WritableSet<FieldToContractInputMapping> checkedElements = new WritableSet<>();
    checkedElements.addAll(Arrays.asList(rootMapping1, childMapping2));
    SelectionAdapter listener = page.createDeselectAllListener(checkedElements);
    listener.widgetSelected(mock(SelectionEvent.class));
    assertThat(rootMapping1.isGenerated()).isFalse();
    assertThat(childMapping1.isGenerated()).isFalse();
    assertThat(childMapping2.isGenerated()).isFalse();
    assertThat(rootMapping2.isGenerated()).isFalse();
}
 
Example 5
Source File: CreateContractInputFromBusinessObjectWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_CheckedElementsList_Contains_AllFieldToInputContractMappingsGenerated_whenSelectingAllFields() {
    BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee").build();
    Contract contract = aContract().build();
    Pool process = aPool().havingContract(contract).build();
    process.getData().add(data);
    GenerationOptions options = new GenerationOptions();
    BusinessObjectModelRepositoryStore<BusinessObjectModelFileStore> store = mock(
            BusinessObjectModelRepositoryStore.class);
    WritableValue<BusinessObjectData> selectedDataObservable = new WritableValue<>();
    selectedDataObservable.setValue(data);
    WritableValue<String> rootNameObservable = new WritableValue<>();
    rootNameObservable.setValue("employeeInput");
    WritableList<FieldToContractInputMapping> fieldToContractInputMappingsObservable = new WritableList<>();
    CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(
            process, options,
            selectedDataObservable, new FieldToContractInputMappingFactory(store),
            fieldToContractInputMappingsObservable,
            store);
    FieldToContractInputMapping rootMapping1 = new RelationFieldToContractInputMapping(
            Mockito.mock(RelationField.class));
    SimpleFieldToContractInputMapping childMapping1 = new SimpleFieldToContractInputMapping(
            Mockito.mock(SimpleField.class));
    SimpleFieldToContractInputMapping childMapping2 = new SimpleFieldToContractInputMapping(
            Mockito.mock(SimpleField.class));
    rootMapping1.addChild(childMapping1);
    rootMapping1.addChild(childMapping2);
    FieldToContractInputMapping rootMapping2 = new RelationFieldToContractInputMapping(
            Mockito.mock(RelationField.class));
    WritableSet<FieldToContractInputMapping> checkedElements = new WritableSet<>();
    checkedElements.addAll(Arrays.asList(rootMapping1, childMapping2));
    page.setMappings(Lists.newArrayList(rootMapping1, rootMapping2));
    SelectionAdapter listener = page.createSelectAllListener(checkedElements);
    listener.widgetSelected(mock(SelectionEvent.class));
    assertThat(checkedElements.size()).isEqualTo(4);
    assertThat(checkedElements)
            .containsAll(Lists.newArrayList(rootMapping1, rootMapping2, childMapping1, childMapping2));
}
 
Example 6
Source File: CreateContractInputFromBusinessObjectWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void should_selectAllMandatoryAttributes_whenClickingOnMandatoryAttributes() {
    BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee").build();
    Contract contract = aContract().build();
    Pool process = aPool().havingContract(contract).build();
    process.getData().add(data);
    GenerationOptions options = new GenerationOptions();
    BusinessObjectModelRepositoryStore<BusinessObjectModelFileStore> store = mock(
            BusinessObjectModelRepositoryStore.class);
    WritableValue<BusinessObjectData> selectedDataObservable = new WritableValue<>();
    selectedDataObservable.setValue(data);
    WritableValue<String> rootNameObservable = new WritableValue<>();
    rootNameObservable.setValue("employeeInput");
    WritableList<FieldToContractInputMapping> fieldToContractInputMappingsObservable = new WritableList<>();
    CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(
            process, options,
            selectedDataObservable, new FieldToContractInputMappingFactory(store),
            fieldToContractInputMappingsObservable,
            store);
    RelationField rootMandatoryField = Mockito.mock(RelationField.class);
    RelationField rootOptionalField = Mockito.mock(RelationField.class);
    SimpleField childOptionalField = Mockito.mock(SimpleField.class);
    SimpleField childMandatoryField = Mockito.mock(SimpleField.class);
    when(rootMandatoryField.isNullable()).thenReturn(false);
    when(rootOptionalField.isNullable()).thenReturn(true);
    when(childOptionalField.isNullable()).thenReturn(true);
    when(childMandatoryField.isNullable()).thenReturn(false);
    FieldToContractInputMapping rootMappingMandatoryField = new RelationFieldToContractInputMapping(
            rootMandatoryField);
    SimpleFieldToContractInputMapping childMappingOptional = new SimpleFieldToContractInputMapping(
            childOptionalField);
    SimpleFieldToContractInputMapping childMappingMandatory = new SimpleFieldToContractInputMapping(
            childMandatoryField);
    rootMappingMandatoryField.addChild(childMappingOptional);
    rootMappingMandatoryField.addChild(childMappingMandatory);
    rootMappingMandatoryField.setGenerated(false);
    FieldToContractInputMapping rootMappingOptionalField = new RelationFieldToContractInputMapping(
            rootOptionalField);
    rootMappingOptionalField.setGenerated(false);
    childMappingOptional.setGenerated(false);
    childMappingMandatory.setGenerated(false);
    page.setMappings(Lists.newArrayList(rootMappingMandatoryField, rootMappingOptionalField));
    WritableSet<FieldToContractInputMapping> checkedElements = new WritableSet<>();
    SelectionAdapter listener = page.createMandatoryAttributesSelectionListener(checkedElements);
    listener.widgetSelected(mock(SelectionEvent.class));
    assertThat(checkedElements.size()).isEqualTo(2);
    assertThat(checkedElements.contains(rootMappingMandatoryField)).isTrue();
    assertThat(checkedElements.contains(rootMappingOptionalField)).isFalse();
    assertThat(checkedElements.contains(childMappingOptional)).isFalse();
    assertThat(checkedElements.contains(childMappingMandatory)).isTrue();
}