Search in sources :

Example 1 with ValidationStatusProvider

use of org.eclipse.core.databinding.ValidationStatusProvider in project egit by eclipse.

the class InitDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayoutFactory.swtDefaults().numColumns(4).applyTo(container);
    createInputs(container);
    DataBindingContext bindingContext = initDataBinding();
    TitleAreaDialogSupport.create(this, bindingContext).setValidationMessageProvider(new ValidationMessageProvider() {

        @Override
        public String getMessage(ValidationStatusProvider statusProvider) {
            if (statusProvider == null) {
                return InitDialog_chooseBranchNamesAndPrefixes;
            }
            return super.getMessage(statusProvider);
        }

        @Override
        public int getMessageType(ValidationStatusProvider statusProvider) {
            int type = super.getMessageType(statusProvider);
            Button okButton = getButton(OK_ID);
            if (okButton != null) {
                okButton.setEnabled(type != ERROR);
            }
            return type;
        }
    });
    return area;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) ValidationMessageProvider(org.eclipse.jface.databinding.dialog.ValidationMessageProvider) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider)

Example 2 with ValidationStatusProvider

use of org.eclipse.core.databinding.ValidationStatusProvider in project jbosstools-openshift by jbosstools.

the class DataBindingUtils method isValid.

public static boolean isValid(DataBindingContext dbc) {
    if (dbc == null) {
        return false;
    }
    for (Object element : dbc.getValidationStatusProviders()) {
        ValidationStatusProvider validationProvider = (ValidationStatusProvider) element;
        IStatus validationStatus = (IStatus) validationProvider.getValidationStatus().getValue();
        if (!isDisposed(validationProvider) && !validationStatus.isOK()) {
            return false;
        }
    }
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider)

Example 3 with ValidationStatusProvider

use of org.eclipse.core.databinding.ValidationStatusProvider in project jbosstools-openshift by jbosstools.

the class FormPresenterSupport method init.

/**
 * @noreference This method is not intended to be referenced by clients.
 */
protected void init() {
    ObservableTracker.setIgnore(true);
    try {
        aggregateStatusProvider = new MaxSeverityValidationStatusProvider(dbc);
    } finally {
        ObservableTracker.setIgnore(false);
    }
    aggregateStatusProvider.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(ValueChangeEvent event) {
            statusProviderChanged();
        }
    });
    formPresenter.getControl().addListener(SWT.Dispose, new Listener() {

        @Override
        public void handleEvent(Event event) {
            dispose();
        }
    });
    aggregateStatusProvider.addStaleListener(new IStaleListener() {

        @Override
        public void handleStale(StaleEvent staleEvent) {
            currentStatusStale = true;
            handleStatusChanged();
        }
    });
    statusProviderChanged();
    dbc.getValidationStatusProviders().addListChangeListener(validationStatusProvidersListener);
    for (Iterator it = dbc.getValidationStatusProviders().iterator(); it.hasNext(); ) {
        ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it.next();
        IObservableList targets = validationStatusProvider.getTargets();
        targets.addListChangeListener(validationStatusProviderTargetsListener);
        for (Iterator iter = targets.iterator(); iter.hasNext(); ) {
            ((IObservable) iter.next()).addChangeListener(uiChangeListener);
        }
    }
}
Also used : IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) StaleEvent(org.eclipse.core.databinding.observable.StaleEvent) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) IChangeListener(org.eclipse.core.databinding.observable.IChangeListener) Listener(org.eclipse.swt.widgets.Listener) IStaleListener(org.eclipse.core.databinding.observable.IStaleListener) IListChangeListener(org.eclipse.core.databinding.observable.list.IListChangeListener) IStaleListener(org.eclipse.core.databinding.observable.IStaleListener) Iterator(java.util.Iterator) IObservable(org.eclipse.core.databinding.observable.IObservable) StaleEvent(org.eclipse.core.databinding.observable.StaleEvent) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) Event(org.eclipse.swt.widgets.Event) ListChangeEvent(org.eclipse.core.databinding.observable.list.ListChangeEvent) ChangeEvent(org.eclipse.core.databinding.observable.ChangeEvent) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 4 with ValidationStatusProvider

use of org.eclipse.core.databinding.ValidationStatusProvider in project jbosstools-openshift by jbosstools.

the class FormPresenterSupport method handleUIChanged.

/**
 * @noreference This method is not intended to be referenced by clients.
 */
protected void handleUIChanged() {
    uiChanged = true;
    if (currentStatus != null) {
        handleStatusChanged();
    }
    dbc.getValidationStatusProviders().removeListChangeListener(validationStatusProvidersListener);
    for (Iterator it = dbc.getValidationStatusProviders().iterator(); it.hasNext(); ) {
        ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it.next();
        IObservableList targets = validationStatusProvider.getTargets();
        targets.removeListChangeListener(validationStatusProviderTargetsListener);
        for (Iterator iter = targets.iterator(); iter.hasNext(); ) {
            ((IObservable) iter.next()).removeChangeListener(uiChangeListener);
        }
    }
}
Also used : Iterator(java.util.Iterator) IObservable(org.eclipse.core.databinding.observable.IObservable) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Example 5 with ValidationStatusProvider

use of org.eclipse.core.databinding.ValidationStatusProvider in project jbosstools-openshift by jbosstools.

the class FormPresenterSupport method dispose.

/**
 * Disposes of this wizard page support object, removing any listeners it
 * may have attached.
 */
public void dispose() {
    if (aggregateStatusProvider != null)
        aggregateStatusProvider.dispose();
    if (dbc != null && !uiChanged) {
        for (Iterator it = dbc.getValidationStatusProviders().iterator(); it.hasNext(); ) {
            ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it.next();
            IObservableList targets = validationStatusProvider.getTargets();
            if (targets != null) {
                targets.removeListChangeListener(validationStatusProviderTargetsListener);
                for (Iterator iter = targets.iterator(); iter.hasNext(); ) {
                    ((IObservable) iter.next()).removeChangeListener(uiChangeListener);
                }
            }
        }
        dbc.getValidationStatusProviders().removeListChangeListener(validationStatusProvidersListener);
    }
    aggregateStatusProvider = null;
    dbc = null;
    uiChangeListener = null;
    validationStatusProvidersListener = null;
    validationStatusProviderTargetsListener = null;
    formPresenter = null;
}
Also used : Iterator(java.util.Iterator) IObservable(org.eclipse.core.databinding.observable.IObservable) ValidationStatusProvider(org.eclipse.core.databinding.ValidationStatusProvider) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList)

Aggregations

ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)9 Button (org.eclipse.swt.widgets.Button)4 Iterator (java.util.Iterator)3 IObservable (org.eclipse.core.databinding.observable.IObservable)3 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)3 Binding (org.eclipse.core.databinding.Binding)2 IStatus (org.eclipse.core.runtime.IStatus)2 InvertingBooleanConverter (org.jboss.tools.common.ui.databinding.InvertingBooleanConverter)2 DisableableMultiValitdator (org.jboss.tools.openshift.internal.common.ui.databinding.DisableableMultiValitdator)2 OpenShiftIdentifierValidator (org.jboss.tools.openshift.internal.ui.validator.OpenShiftIdentifierValidator)2 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)1 ChangeEvent (org.eclipse.core.databinding.observable.ChangeEvent)1 IChangeListener (org.eclipse.core.databinding.observable.IChangeListener)1 IStaleListener (org.eclipse.core.databinding.observable.IStaleListener)1 StaleEvent (org.eclipse.core.databinding.observable.StaleEvent)1 IListChangeListener (org.eclipse.core.databinding.observable.list.IListChangeListener)1