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;
}
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;
}
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);
}
}
}
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);
}
}
}
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;
}
Aggregations