Search in sources :

Example 1 with ValidationMessageProvider

use of org.eclipse.jface.databinding.dialog.ValidationMessageProvider 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)

Aggregations

DataBindingContext (org.eclipse.core.databinding.DataBindingContext)1 ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)1 ValidationMessageProvider (org.eclipse.jface.databinding.dialog.ValidationMessageProvider)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1