use of org.jboss.tools.openshift.internal.ui.validator.GitReferenceValidator in project jbosstools-openshift by jbosstools.
the class BuildConfigPage method createSourceControls.
@SuppressWarnings({ "unchecked" })
private void createSourceControls(Composite root, DataBindingContext dbc) {
Composite parent = new Composite(root, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(parent);
GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parent);
// url
Label gitUrlLabel = new Label(parent, SWT.NONE);
gitUrlLabel.setText("Git Repository URL:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(gitUrlLabel);
final Text gitUrlText = new Text(parent, SWT.BORDER);
gitUrlText.setToolTipText("The URL to the Git repository.");
// TODO add 'try it' link here
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(gitUrlText);
Binding gitUrlBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observeDelayed(500, gitUrlText)).validatingAfterConvert(new IValidator() {
@Override
public IStatus validate(Object value) {
if (UrlUtils.isValid((String) value)) {
return Status.OK_STATUS;
}
return ValidationStatus.error("A valid URL to a Git repository is required");
}
}).to(BeanProperties.value(IBuildConfigPageModel.PROPERTY_GIT_REPOSITORY_URL).observe(model)).in(dbc);
ControlDecorationSupport.create(gitUrlBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// reference
Label gitReferenceLabel = new Label(parent, SWT.NONE);
gitReferenceLabel.setText("Git Reference:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(gitReferenceLabel);
gitReferenceLabel.setToolTipText("Optional branch, tag, or commit.");
final Text gitReferenceText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(gitReferenceText);
IObservableValue gitReferenceTextObservable = WidgetProperties.text(SWT.Modify).observe(gitReferenceText);
GitReferenceValidator validator = new GitReferenceValidator(gitReferenceTextObservable);
Binding gitReferenceBinding = ValueBindingBuilder.bind(gitReferenceTextObservable).validatingAfterConvert(validator).to(BeanProperties.value(IBuildConfigPageModel.PROPERTY_GIT_REFERENCE).observe(model)).in(dbc);
dbc.addValidationStatusProvider(validator);
ControlDecorationSupport.create(gitReferenceBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// context dir
Label contextDirLabel = new Label(parent, SWT.NONE);
contextDirLabel.setText("Context Directory:");
contextDirLabel.setToolTipText("Optional subdirectory for the application source code, used as the context directory for the build.");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(contextDirLabel);
final Text contextDirText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(contextDirText);
ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(contextDirText)).to(BeanProperties.value(IBuildConfigPageModel.PROPERTY_CONTEXT_DIR).observe(model)).in(dbc);
}
Aggregations