Search in sources :

Example 1 with IObservable

use of org.eclipse.core.databinding.observable.IObservable 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 2 with IObservable

use of org.eclipse.core.databinding.observable.IObservable 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 3 with IObservable

use of org.eclipse.core.databinding.observable.IObservable 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

Iterator (java.util.Iterator)3 ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)3 IObservable (org.eclipse.core.databinding.observable.IObservable)3 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)3 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 ListChangeEvent (org.eclipse.core.databinding.observable.list.ListChangeEvent)1 IValueChangeListener (org.eclipse.core.databinding.observable.value.IValueChangeListener)1 ValueChangeEvent (org.eclipse.core.databinding.observable.value.ValueChangeEvent)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1