Example usage for org.eclipse.jface.databinding.swt SWTObservables observeSelection

List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt SWTObservables observeSelection.

Prototype

@Deprecated
public static ISWTObservableValue observeSelection(Control control) 

Source Link

Document

Returns an observable observing the selection attribute of the provided control.

Usage

From source file:org.bonitasoft.studio.simulation.wizards.AddSimulationDataWizardPage.java

License:Open Source License

private void createNameAndDescription(Composite composite) {
    Label nameLabel = new Label(composite, SWT.NONE);
    nameLabel.setText(Messages.dataNameLabel);
    final Text labelText = new Text(composite, SWT.BORDER);
    labelText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    // Add an validator so that age can only be a number
    IValidator validator = new IValidator() {

        Set<String> existingDataNames = null;

        @Override/*from   w ww.  ja  va 2 s  .c  o  m*/
        public IStatus validate(Object arg0) {
            if (existingDataNames == null) {
                existingDataNames = new HashSet<String>();
                if (element != null) {
                    for (SimulationData simuData : element.getSimulationData()) {
                        existingDataNames.add(simuData.getName());
                    }
                }
            }

            if (existingDataNames.contains(labelText.getText())) {

                return ValidationStatus.error("Data name already exists.");
            }
            return ValidationStatus.ok();
        }

    };
    UpdateValueStrategy strategy = new UpdateValueStrategy();
    strategy.setBeforeSetValidator(validator);

    Binding bindingDataName = context.bindValue(SWTObservables.observeText(labelText, SWT.Modify),
            PojoObservables.observeValue(this, "dataName"), strategy, null);

    ControlDecorationSupport.create(bindingDataName, SWT.TOP | SWT.LEFT);
    //labelText.addModifyListener(updateButtonModifyListener) ;

    Label isExpressionLabel = new Label(composite, SWT.NONE);
    isExpressionLabel.setText(Messages.BasedOn);

    Composite radioBasedComposite = new Composite(composite, SWT.NONE);
    radioBasedComposite.setLayout(new GridLayout(2, true));

    isExpressionBased = new Button(radioBasedComposite, SWT.RADIO);
    isExpressionBased.setText(Messages.Expression);
    isExpressionBased.setSelection(expressionBased);
    isOtherBased = new Button(radioBasedComposite, SWT.RADIO);
    isOtherBased.setSelection(!expressionBased);
    isOtherBased.setText(Messages.AddSimulationDataWizardPage_probability);
    context.bindValue(SWTObservables.observeSelection(isExpressionBased),
            PojoObservables.observeValue(this, "expressionBased"));
    context.bindValue(SWTObservables.observeSelection(isOtherBased),
            PojoObservables.observeValue(this, "expressionBased"),
            new UpdateValueStrategy().setConverter(new Converter(Boolean.class, Boolean.class) {
                @Override
                public Object convert(Object fromObject) {
                    return !(Boolean) fromObject;
                }
            }), new UpdateValueStrategy().setConverter(new Converter(Boolean.class, Boolean.class) {
                @Override
                public Object convert(Object fromObject) {
                    return !(Boolean) fromObject;
                }
            }));

    Label expressionLabel = new Label(composite, SWT.NONE);
    expressionLabel.setText(Messages.Expression);

    ExpressionViewer expressionViewer = new ExpressionViewer(composite, SWT.BORDER, null);//FIXME: Expressionviewer
    expressionViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    if (element != null) {
        expressionViewer.setInput(element);
    } else {
        expressionViewer.setInput(data.eContainer());
    }
    expressionViewer.addFilter(new AvailableExpressionTypeFilter(
            new String[] { ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.VARIABLE_TYPE,
                    ExpressionConstants.SCRIPT_TYPE, ExpressionConstants.SIMULATION_VARIABLE_TYPE }));
    expressionViewer.setSelection(new StructuredSelection(dataExpression));

    context.bindValue(SWTObservables.observeVisible(expressionLabel),
            SWTObservables.observeSelection(isExpressionBased));
    context.bindValue(SWTObservables.observeVisible(expressionViewer.getControl()),
            SWTObservables.observeSelection(isExpressionBased));

    isOtherBased.addSelectionListener(updateButtonSelectionListener);
    isExpressionBased.addSelectionListener(updateButtonSelectionListener);

}

From source file:org.bonitasoft.studio.validators.ui.property.section.ValidatorsPropertySection.java

License:Open Source License

@Override
public void refresh() {
    super.refresh();

    if (tableViewer != null && !tableViewer.getTable().isDisposed() && comboViewerForValidatorClass != null
            && !comboViewerForValidatorClass.getCombo().isDisposed()) {
        if (getValidable().getValidators().size() > 0) {
            /*update value in the treeviewer when the name changed.*/
            tableViewer.refresh(true);/* w ww .  j  a v  a  2s  . co  m*/
            currentValidator = (Validator) ((IStructuredSelection) tableViewer.getSelection())
                    .getFirstElement();
        } else {
            /*update the treeviewer if the last validator is removed*/
            tableViewer.refresh(true);
            currentValidator = null;
        }

        if (lastEObject == null || !lastEObject.equals(getEObject())) {
            lastEObject = getEObject();
            if (lastEObject != null) {
                tableViewer.setInput(getValidable());
                comboViewerForValidatorClass.resetFilters();
                if (getEObject() instanceof Form) {
                    comboViewerForValidatorClass.addFilter(formFilter);
                } else {
                    comboViewerForValidatorClass.addFilter(fieldFilter);
                }

                //               for(Validator validator :((Validable)lastEObject).getValidators()){
                //                  if(validator.getValidatorClass() != null){
                //                     boolean stilExists = false ;
                //                     for(IRepositoryFileStore file : validatorStore.getChildren()){
                //                        ValidatorDescriptor desc = (ValidatorDescriptor) file.getContent() ;
                //                        if(desc.getClassName().equals(validator.getValidatorClass())){
                //                           stilExists = true ;
                //                           break ;
                //                        }
                //                     }
                //                     if(!stilExists){
                //                        getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), validator, FormPackage.Literals.VALIDATOR__VALIDATOR_CLASS, null)) ;
                //                     }
                //                  }
                //               }

                comboViewerForValidatorClass.setInput(validatorStore.getValidatorDescriptors());

                if (context != null) {
                    context.dispose();
                }
                context = new EMFDataBindingContext();

                updateFieldDependingOnValidatorClass();

                if (defaultValidatorContext != null) {
                    defaultValidatorContext.dispose();
                }
                defaultValidatorContext = new DataBindingContext();
                defaultValidatorContext.bindValue(SWTObservables.observeSelection(defaultValidator),
                        EMFObservables.observeValue(getEObject(),
                                FormPackage.Literals.VALIDABLE__USE_DEFAULT_VALIDATOR));

                defaultValidatorContext.bindValue(SWTObservables.observeSelection(defaultValidatorIsBelow),
                        EMFObservables.observeValue(getEObject(), FormPackage.Literals.VALIDABLE__BELOW));

                defaultValidatorContext.bindValue(SWTObservables.observeSelection(defaultValidatorIsAbove),
                        EMFObservables.observeValue(getEObject(), FormPackage.Literals.VALIDABLE__BELOW),
                        new UpdateValueStrategy().setConverter(converter),
                        new UpdateValueStrategy().setConverter(converter));

                defaultValidator.setVisible(
                        lastEObject instanceof Widget && !(lastEObject instanceof MultipleValuatedFormField));
                positionComp.setVisible(lastEObject instanceof Widget && defaultValidator.getSelection());

                /*
                 * Use pattern master-detail databinding in order to be up to date with the selection in the FilteredTreeViewer
                 * */

                //      labelField.setElement((Element) lastEObject);
                //      labelField.reset();

                /*Observe change in selection*/
                IViewerObservableValue treeViewerObservaleValue = ViewersObservables
                        .observeSingleSelection(tableViewer);

                //Observe the validator name property of the current selection
                IObservableValue nameDetailValue = EMFObservables.observeDetailValue(Realm.getDefault(),
                        treeViewerObservaleValue, FormPackage.Literals.VALIDATOR__NAME);

                //Bind the Text widget to the name detail
                ISWTObservableValue nameFieldObservableValue = SWTObservables.observeText(nameField,
                        SWT.Modify);
                context.bindValue(nameFieldObservableValue, nameDetailValue);
                nameFieldObservableValue.addValueChangeListener(new IValueChangeListener() {
                    @Override
                    public void handleValueChange(ValueChangeEvent event) {
                        /*update value in the treeviewer when the name changed.*/
                        tableViewer.refresh(true);
                    }
                });

                //Observe the validator classes of the current selection
                IObservableValue emfValidatorClassObservableDetailValue = EMFObservables.observeDetailValue(
                        Realm.getDefault(), treeViewerObservaleValue,
                        FormPackage.Literals.VALIDATOR__VALIDATOR_CLASS);

                //Bind the Combo widget to the validator class detail
                IViewerObservableValue comboViewerObservable = ViewersObservables
                        .observeSingleSelection(comboViewerForValidatorClass);
                UpdateValueStrategy targetStrategy = new UpdateValueStrategy();
                targetStrategy.setConverter(new Converter(ValidatorDescriptor.class, String.class) {

                    @Override
                    public Object convert(Object from) {
                        if (from != null && from instanceof ValidatorDescriptor) {
                            return ((ValidatorDescriptor) from).getClassName();
                        }
                        return null;
                    }
                });
                UpdateValueStrategy modelStrategy = new UpdateValueStrategy();
                modelStrategy.setConverter(new Converter(String.class, ValidatorDescriptor.class) {

                    @Override
                    public Object convert(Object from) {
                        if (from != null && from instanceof String) {
                            Collection<ValidatorDescriptor> input = (Collection<ValidatorDescriptor>) comboViewerForValidatorClass
                                    .getInput();
                            for (ValidatorDescriptor d : input) {
                                if (d.getClassName().equals(from)) {
                                    return d;
                                }
                            }
                        }
                        return null;
                    }
                });

                context.bindValue(comboViewerObservable, emfValidatorClassObservableDetailValue, targetStrategy,
                        modelStrategy);

                /*When value changed,
                 * look if need to enabled/disabled some widgets*/
                comboViewerObservable.addValueChangeListener(new IValueChangeListener() {
                    @Override
                    public void handleValueChange(ValueChangeEvent event) {
                        updateFieldDependingOnValidatorClass();
                    }
                });

                IObservableValue htmlDetailValue = EMFObservables.observeDetailValue(Realm.getDefault(),
                        treeViewerObservaleValue, FormPackage.Literals.VALIDATOR__HTML_CLASS);
                context.bindValue(SWTObservables.observeText(htmlClassField, SWT.Modify), htmlDetailValue);

                IObservableValue isBelowValue = EMFObservables.observeDetailValue(Realm.getDefault(),
                        treeViewerObservaleValue, FormPackage.Literals.VALIDATOR__BELOW_FIELD);
                context.bindValue(SWTObservables.observeSelection(isBelow), isBelowValue);
                context.bindValue(SWTObservables.observeSelection(isAbove), isBelowValue,
                        new UpdateValueStrategy().setConverter(converter),
                        new UpdateValueStrategy().setConverter(converter));
            }
        }
        //            else{
        //                comboViewerForValidatorClass.setInput(validatorStore.getValidatorDescriptors());
        //                Validator validator = (Validator) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement() ;
        //                if(validator != null && validator.getValidatorClass() != null){
        //                    comboViewerForValidatorClass.setSelection(new StructuredSelection(validatorStore.getValidatorDescriptor(validator.getValidatorClass())));
        //                }
        //            }
    }
}

From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.wizards.AbstractCloudFoundryServiceWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(10, LayoutConstants.getSpacing().y)
            .applyTo(composite);/* www.j  a v a  2 s  .c  o  m*/

    Label label = new Label(composite, SWT.NONE);
    label.setText("Name:");

    nameText = new Text(composite, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);
    nameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            service.setName(nameText.getText());
        }
    });

    bindingContext = new DataBindingContext();
    map = new WritableMap();

    WizardPageSupport.create(this, bindingContext);

    bindingContext.bindValue(SWTObservables.observeText(nameText, SWT.Modify),
            Observables.observeMapEntry(map, "name"),
            new UpdateValueStrategy().setAfterConvertValidator(new StringValidator()), null);

    label = new Label(composite, SWT.NONE);
    label.setText("Type:");

    typeCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(typeCombo);
    typeCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            int index = typeCombo.getSelectionIndex();
            if (index != -1) {
                ServiceConfiguration configuration = configurations.get(index);
                setCloudService(service, configuration);
            }
            refreshPlan();
        }
    });

    bindingContext.bindValue(SWTObservables.observeSelection(typeCombo),
            Observables.observeMapEntry(map, "type"),
            new UpdateValueStrategy().setAfterConvertValidator(new ComboValidator("Select a type")), null);

    pageBook = new PageBook(composite, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(pageBook);

    planGroup = new Group(pageBook, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(planGroup);
    planGroup.setLayout(new GridLayout());
    planGroup.setVisible(false);
    planGroup.setText(getPlanLabel());

    MultiValidator validator = new MultiValidator() {
        protected IStatus validate() {
            // access plan value to bind validator
            if (planObservable.getValue() == null) {
                return ValidationStatus.cancel(getValidationErrorMessage());
            }
            return ValidationStatus.ok();
        }
    };
    bindingContext.addValidationStatusProvider(validator);

    Dialog.applyDialogFont(composite);
    setControl(composite);
}

From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.wizards.CloudFoundryServiceWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(10, LayoutConstants.getSpacing().y)
            .applyTo(composite);//from  w  ww .  j  av a  2s .  c o  m

    Label label = new Label(composite, SWT.NONE);
    label.setText("Name:");

    nameText = new Text(composite, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);
    nameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            service.setName(nameText.getText());
        }
    });

    bindingContext = new DataBindingContext();
    map = new WritableMap();

    WizardPageSupport.create(this, bindingContext);

    bindingContext.bindValue(SWTObservables.observeText(nameText, SWT.Modify),
            Observables.observeMapEntry(map, "name"),
            new UpdateValueStrategy().setAfterConvertValidator(new StringValidator()), null);

    label = new Label(composite, SWT.NONE);
    label.setText("Type:");

    typeCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(typeCombo);
    typeCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            int index = typeCombo.getSelectionIndex();
            if (index != -1) {
                ServiceConfiguration configuration = configurations.get(index);
                service.setType(configuration.getType());
                service.setVendor(configuration.getVendor());
                service.setVersion(configuration.getVersion());
            }
            refreshTier();
        }
    });

    bindingContext.bindValue(SWTObservables.observeSelection(typeCombo),
            Observables.observeMapEntry(map, "type"),
            new UpdateValueStrategy().setAfterConvertValidator(new ComboValidator("Select a type")), null);

    pageBook = new PageBook(composite, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(pageBook);

    tierLabel = new Label(pageBook, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tierLabel);

    tierGroup = new Group(pageBook, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tierGroup);
    tierGroup.setLayout(new GridLayout());
    tierGroup.setVisible(false);
    tierGroup.setText("Tier");

    MultiValidator validator = new MultiValidator() {
        protected IStatus validate() {
            // access tier value to bind validator
            if (tierObservable.getValue() == null) {
                return ValidationStatus.cancel("Select a tier");
            }
            return ValidationStatus.ok();
        }
    };
    bindingContext.addValidationStatusProvider(validator);

    Dialog.applyDialogFont(composite);
    setControl(composite);
}

From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.wizards.CloudFoundryServiceWizardPage.java

License:Open Source License

protected void refreshTierDetails(Tier tier) {
    for (Control control : tierDetailsComposite.getChildren()) {
        control.dispose();//from  w  w w.j a  v  a2 s  . co  m
    }
    for (final Option option : tier.getOptions()) {
        Label label = new Label(tierDetailsComposite, SWT.NONE);
        label.setText(option.getDescription());

        final Combo combo = new Combo(tierDetailsComposite, SWT.READ_ONLY);
        final List<Entry<String, Integer>> list = new ArrayList<Entry<String, Integer>>(
                option.getPriceByValue().entrySet());
        for (Entry<String, Integer> entry : list) {
            if (entry.getValue() != null) {
                combo.add(NLS.bind("{0} (${1}/{2})",
                        new Object[] { entry.getKey(), entry.getValue(), tier.getPricingPeriod() }));
            } else {
                combo.add(entry.getKey());
            }
        }
        combo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                service.getOptions().put(option.getName(), list.get(combo.getSelectionIndex()).getKey());
            }
        });

        bindingContext.bindValue(SWTObservables.observeSelection(combo),
                Observables.observeMapEntry(map, option.getName()),
                new UpdateValueStrategy().setAfterConvertValidator(
                        new ComboValidator(NLS.bind("Select a {0}", option.getName()))),
                null);
    }

    tierGroup.layout(true, true);
}

From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.wizards.CloudFoundryServicePlanWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(10, LayoutConstants.getSpacing().y)
            .applyTo(composite);//from  www  .j  a  v  a 2  s .  co  m

    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.COMMONTXT_NAME_WITH_COLON);

    nameText = new Text(composite, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);
    nameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            service.setName(nameText.getText());
        }
    });

    bindingContext = new DataBindingContext();
    map = new WritableMap();

    WizardPageSupport.create(this, bindingContext);

    bindingContext.bindValue(SWTObservables.observeText(nameText, SWT.Modify),
            Observables.observeMapEntry(map, "name"), //$NON-NLS-1$
            new UpdateValueStrategy().setAfterConvertValidator(new StringValidator()), null);

    label = new Label(composite, SWT.NONE);
    label.setText(Messages.CloudFoundryServicePlanWizardPage_LABEL_TYPE);

    typeCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(typeCombo);
    typeCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            int index = typeCombo.getSelectionIndex();
            if (index != -1) {
                CloudServiceOffering configuration = serviceOfferings.get(index);
                setCloudService(service, configuration);
            }
            refreshPlan();
        }
    });

    bindingContext
            .bindValue(SWTObservables.observeSelection(typeCombo), Observables.observeMapEntry(map, "type"), //$NON-NLS-1$
                    new UpdateValueStrategy().setAfterConvertValidator(
                            new ComboValidator(Messages.CloudFoundryServicePlanWizardPage_TEXT_SELECT_TYPE)),
                    null);

    pageBook = new PageBook(composite, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(pageBook);

    planGroup = new Group(pageBook, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(planGroup);
    planGroup.setLayout(new GridLayout());
    planGroup.setVisible(false);
    planGroup.setText(getPlanLabel());

    MultiValidator validator = new MultiValidator() {
        protected IStatus validate() {
            // access plan value to bind validator
            if (planObservable.getValue() == null) {
                return ValidationStatus.cancel(getValidationErrorMessage());
            }
            return ValidationStatus.ok();
        }
    };
    bindingContext.addValidationStatusProvider(validator);

    Dialog.applyDialogFont(composite);
    setControl(composite);
}

From source file:org.dozer.eclipse.plugin.editorpage.utils.DozerUiUtils.java

License:Apache License

public static IObservableValue createLabelCheckbox(Composite client, String messagePrefix) {
    createLabel(client, messagePrefix);/*from w  w  w  . ja v a  2 s .c  o m*/

    Button checkbox = toolkit.createButton(client, "", SWT.CHECK);
    checkbox.setToolTipText(Messages.getString(messagePrefix + "_hint")); //$NON-NLS-1$
    checkbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    //Format
    TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
    checkbox.setLayoutData(td);

    return SWTObservables.observeSelection(checkbox);
}

From source file:org.dozer.eclipse.plugin.editorpage.utils.DozerUiUtils.java

License:Apache License

public static IObservableValue createCombo(Composite client, String messagePrefix, String[] values) {
    CCombo combo = new CCombo(client, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.FLAT | SWT.BORDER);
    for (String value : values) {
        combo.add(value);/*w w  w.  j  a  v  a 2 s .  c om*/
    }

    toolkit.adapt(combo);
    toolkit.paintBordersFor(combo);

    combo.setToolTipText(Messages.getString(messagePrefix + "_hint")); //$NON-NLS-1$

    //Format
    TableWrapData td = new TableWrapData();
    combo.setLayoutData(td);

    return SWTObservables.observeSelection(combo);
}

From source file:org.eclipse.alfresco.publisher.ui.properties.InlineBooleanEditingSupport.java

License:Open Source License

protected IObservableValue doCreateCellEditorObservable(CellEditor cellEditor) {
    return SWTObservables.observeSelection(cellEditor.getControl());
}

From source file:org.eclipse.bpmn2.modeler.core.merrimac.dialogs.BooleanObjectEditor.java

License:Open Source License

public Control createControl(Composite composite, String label, int style) {

    // create a separate label to the LEFT of the checkbox, otherwise the grid layout will
    // be off by one column for all other widgets that are created after this one.
    createLabel(composite, label);/*from  w  w  w .  ja v a  2s . c  om*/

    button = getToolkit().createButton(composite, "", SWT.CHECK);
    button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    button.setSelection((Boolean) object.eGet(feature));
    IObservableValue buttonObserver = SWTObservables.observeSelection(button);
    buttonObserver.addValueChangeListener(new IValueChangeListener() {

        @SuppressWarnings("restriction")
        @Override
        public void handleValueChange(ValueChangeEvent event) {

            if (!object.eGet(feature).equals(button.getSelection())) {
                TransactionalEditingDomain editingDomain = getDiagramEditor().getEditingDomain();
                editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
                    @Override
                    protected void doExecute() {
                        object.eSet(feature, button.getSelection());
                    }
                });

                //               if (getDiagramEditor().getDiagnostics()!=null) {
                //                  // revert the change and display error errorList message.
                //                  button.setSelection((Boolean) object.eGet(feature));
                //                  ErrorUtils.showErrorMessage(getDiagramEditor().getDiagnostics().getMessage());
                //               }
                //               else
                //                  ErrorUtils.showErrorMessage(null);
                button.setSelection((Boolean) object.eGet(feature));
            }
        }
    });

    button.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
        }

        @Override
        public void focusLost(FocusEvent e) {
            ErrorUtils.showErrorMessage(null);
        }
    });

    return button;
}