org.eclipse.jface.viewers.ICheckable Java Examples

The following examples show how to use org.eclipse.jface.viewers.ICheckable. 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: ConstraintEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ConstraintEditionControl(Composite parent,
        AbstractBdmFormPage formPage,
        DataBindingContext ctx) {
    this.formPage = formPage;
    this.fieldStyleStringProvider = new FieldStyleStringProvider();
    this.actualsFieldsObservable = EMFObservables.observeDetailList(Realm.getDefault(),
            formPage.observeBusinessObjectSelected(),
            BusinessDataModelPackage.Literals.BUSINESS_OBJECT__FIELDS);
    this.constraintsObservable = EMFObservables.observeDetailList(Realm.getDefault(),
            formPage.observeBusinessObjectSelected(),
            BusinessDataModelPackage.Literals.BUSINESS_OBJECT__UNIQUE_CONSTRAINTS);
    this.errorColor = new LocalResourceManager(JFaceResources.getResources(),
            parent).createColor(ColorConstants.ERROR_RGB);

    this.mainComposite = formPage.getToolkit().createComposite(parent);
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    createConstraintDefinitionSection();
    createConstraintEditionComposite(ctx);
    enableButtons(ctx);

    ctx.bindSet(ViewerProperties.checkedElements(Field.class).observe((ICheckable) constraintEditionViewer),
            attributesSetObservable);
    selectedConstraintObservable.addValueChangeListener(e -> {
        attributesSetObservable.clear();
        if (e.diff.getNewValue() != null) {
            e.diff.getNewValue().getFieldNames().stream()
                    .map(this::findCorrespondingField)
                    .forEach(attributesSetObservable::add);
            constraintEditionViewer.refresh();
        }
    });
}