Search in sources :

Example 26 with MultiValidator

use of org.eclipse.core.databinding.validation.MultiValidator in project portfolio by buchen.

the class SecurityTaxonomyPage method setupWeightMultiValidator.

private void setupWeightMultiValidator(Label sumOfWeights, TaxonomyDesignation designation, final List<IObservableValue> weightObservables) {
    MultiValidator multiValidator = new WeightsAreGreaterThan100Validator(sumOfWeights, designation.getTaxonomy(), weightObservables);
    bindings.getBindingContext().addValidationStatusProvider(multiValidator);
    validators.add(multiValidator);
    for (int ii = 0; ii < weightObservables.size(); ii++) {
        IObservableValue observable = weightObservables.get(ii);
        ClassificationLink link = designation.getLinks().get(ii);
        UpdateValueStrategy strategy = new UpdateValueStrategy();
        strategy.setAfterConvertValidator(new GreaterThanZeroValidator());
        validators.add(bindings.getBindingContext().bindValue(multiValidator.observeValidatedValue(observable), BeanProperties.value("weight").observe(link), strategy, // $NON-NLS-1$
        null));
    }
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) ClassificationLink(name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.ClassificationLink) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator)

Example 27 with MultiValidator

use of org.eclipse.core.databinding.validation.MultiValidator in project portfolio by buchen.

the class SecurityTaxonomyPage method setupClassificationMultiValidator.

private void setupClassificationMultiValidator(TaxonomyDesignation designation, final List<IObservableValue> classificationObservables) {
    MultiValidator multiValidator = new ClassificationNotTwiceValidator(classificationObservables);
    bindings.getBindingContext().addValidationStatusProvider(multiValidator);
    validators.add(multiValidator);
    for (int ii = 0; ii < classificationObservables.size(); ii++) {
        IObservableValue observable = classificationObservables.get(ii);
        ClassificationLink link = designation.getLinks().get(ii);
        UpdateValueStrategy strategy = new UpdateValueStrategy();
        strategy.setAfterConvertValidator(new NotNullValidator());
        validators.add(bindings.getBindingContext().bindValue(multiValidator.observeValidatedValue(observable), BeanProperties.value("classification").observe(link), strategy, // $NON-NLS-1$
        null));
    }
}
Also used : UpdateValueStrategy(org.eclipse.core.databinding.UpdateValueStrategy) ClassificationLink(name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.ClassificationLink) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator)

Aggregations

MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)27 IStatus (org.eclipse.core.runtime.IStatus)12 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)11 Composite (org.eclipse.swt.widgets.Composite)11 Label (org.eclipse.swt.widgets.Label)11 Button (org.eclipse.swt.widgets.Button)6 Connection (org.jboss.tools.openshift.core.connection.Connection)6 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)5 Text (org.eclipse.swt.widgets.Text)5 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)5 WritableValue (org.eclipse.core.databinding.observable.value.WritableValue)4 ConnectionWizardPageModel (org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel)4 Test (org.junit.Test)4 DatePicker (name.abuchen.portfolio.ui.util.DatePicker)3 SimpleDateTimeDateSelectionProperty (name.abuchen.portfolio.ui.util.SimpleDateTimeDateSelectionProperty)3 Binding (org.eclipse.core.databinding.Binding)3 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)3 Converter (org.eclipse.core.databinding.conversion.Converter)3 IValueChangeListener (org.eclipse.core.databinding.observable.value.IValueChangeListener)3 ValueChangeEvent (org.eclipse.core.databinding.observable.value.ValueChangeEvent)3