Java Code Examples for org.eclipse.jface.databinding.viewers.ViewersObservables#observeInput()

The following examples show how to use org.eclipse.jface.databinding.viewers.ViewersObservables#observeInput() . 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: FileContractInputSelectionComposite.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void bindControl(final Document document, final EObject context, final EMFDataBindingContext emfDataBindingContext) {
    checkArgument(document != null);
    checkArgument(context != null);
    checkArgument(emfDataBindingContext != null);
    final IObservableValue observeInput = ViewersObservables.observeInput(getContractInputComboViewer());
    final IObservableValue multipleDocumentObervable = EMFObservables.observeValue(document, ProcessPackage.Literals.DOCUMENT__MULTIPLE);
    emfDataBindingContext.bindValue(observeInput,
            multipleDocumentObervable,
            neverUpdateValueStrategy().create(),
            updateValueStrategy().withConverter(toInputList(document, context)).create());

    final IViewerObservableValue observeSingleSelection = ViewersObservables.observeSingleSelection(getContractInputComboViewer());
    ControlDecorationSupport.create(emfDataBindingContext.bindValue(observeSingleSelection,
            EMFObservables.observeValue(document, ProcessPackage.Literals.DOCUMENT__CONTRACT_INPUT)), SWT.LEFT);
    emfDataBindingContext.addValidationStatusProvider(createContractInputParameter(document, observeInput, observeSingleSelection));
}
 
Example 2
Source File: CreateContractInputFromBusinessObjectWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createProcessDataMappingTreeViewer(Composite composite, EMFDataBindingContext dbc) {
    final Composite viewerComposite = new Composite(composite, SWT.NONE);
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 15).create());
    createButtonComposite(viewerComposite);
    treeViewer = new CheckboxTreeViewer(viewerComposite,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    treeViewer.getTree()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.addFilter(hidePersistenceIdMapping());
    final FieldToContractInputMappingViewerCheckStateManager manager = new FieldToContractInputMappingViewerCheckStateManager();
    treeViewer.addCheckStateListener(manager);
    treeViewer.setCheckStateProvider(manager);
    final ObservableListTreeContentProvider provider = new ObservableListTreeContentProvider(
            new FieldToContractInputMappingObservableFactory(),
            new FieldToContractInputMappingTreeStructureAdvisor());
    treeViewer.setContentProvider(provider);

    final TreeViewerColumn nameTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    nameTreeViewerColumn.getColumn().setText(Messages.attributeName);
    nameTreeViewerColumn.getColumn().setWidth(250);
    lazyFieldStatusProvider = new UnselectLazyReferencesInMultipleContainer();
    nameTreeViewerColumn.setLabelProvider(new FieldNameColumnLabelProvider(lazyFieldStatusProvider));

    final TreeViewerColumn typeTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    typeTreeViewerColumn.getColumn().setText(Messages.attributetype);
    typeTreeViewerColumn.getColumn().setWidth(150);
    typeTreeViewerColumn.setLabelProvider(new FieldTypeColumnLabelProvider());

    final TreeViewerColumn inputTypeTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    inputTypeTreeViewerColumn.getColumn().setText(Messages.inputType);
    inputTypeTreeViewerColumn.getColumn().setWidth(150);
    inputTypeTreeViewerColumn.setLabelProvider(new InputTypeColumnLabelProvider(contract));
    inputTypeTreeViewerColumn.setEditingSupport(new ContractInputTypeEditingSupport(treeViewer, contract));

    final TreeViewerColumn mandatoryTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    mandatoryTreeViewerColumn.getColumn().setText(Messages.mandatory);
    mandatoryTreeViewerColumn.getColumn().setWidth(80);
    mandatoryTreeViewerColumn.setLabelProvider(new MandatoryColumnLabelProvider());

    IViewerObservableSet checkedElements = ViewersObservables.observeCheckedElements(treeViewer,
            FieldToContractInputMapping.class);

    final IObservableValue<FieldToContractInputMapping> observeInput = ViewersObservables.observeInput(treeViewer);
    dbc.bindValue(observeInput,
            selectedDataObservable,
            null,
            UpdateStrategyFactory.updateValueStrategy().withConverter(selectedDataToFieldMappings()).create());

    generationOptions.getEditModeObservable().addValueChangeListener(event -> {
        if (selectedDataObservable.getValue() instanceof BusinessObjectData) {
            createMapping(selectedDataObservable.getValue());
            treeViewer.setInput(mappings);
        }
    });

    createButtonListeners(checkedElements);

    multiValidator = new EmptySelectionMultivalidator(selectedDataObservable, checkedElements, mappings,
            contract.eContainer(), generationOptions.getEditModeObservable());
    dbc.addValidationStatusProvider(multiValidator);

    new Label(viewerComposite, SWT.NONE); //FILLER

    Link formGenerationDocLink = new Link(viewerComposite, SWT.NONE);
    formGenerationDocLink.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    formGenerationDocLink.setText(Messages.moreInfoFormGenerationLink);
    formGenerationDocLink.addListener(SWT.Selection, event -> openBrowser(FORM_GENERATION_REDIRECT_ID));

    ColumnViewerToolTipSupport.enableFor(treeViewer);
}