Search in sources :

Example 1 with ProjectDisplayNameValidator

use of org.jboss.tools.openshift.internal.ui.validator.ProjectDisplayNameValidator in project jbosstools-openshift by jbosstools.

the class NewProjectWizardPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(parent);
    GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(parent);
    // project name
    Label lblName = new Label(parent, SWT.NONE);
    lblName.setText(OpenShiftUIMessages.Name);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblName);
    lblName.setToolTipText(ProjectNameValidator.projectNameDescription);
    Text txtName = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtName);
    IObservableValue nameTextObservable = WidgetProperties.text(SWT.Modify).observe(txtName);
    Binding nameBinding = ValueBindingBuilder.bind(nameTextObservable).validatingAfterConvert(new ProjectNameValidator(getDescription(), model.getUnavailableNames())).to(BeanProperties.value(NewProjectWizardModel.PROPERTY_PROJECT_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    // display name
    Label lblDisplayName = new Label(parent, SWT.NONE);
    lblDisplayName.setText(OpenShiftUIMessages.DisplayName);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblDisplayName);
    Text txtDispalayName = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtDispalayName);
    ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(txtDispalayName)).validatingAfterConvert(new ProjectDisplayNameValidator()).to(BeanProperties.value(NewProjectWizardModel.PROPERTY_DISPLAY_NAME).observe(model)).in(dbc);
    // description
    Label lblDescription = new Label(parent, SWT.NONE);
    lblDescription.setText(OpenShiftUIMessages.Description);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblDisplayName);
    Text txtDescription = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtDescription);
    ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(txtDescription)).to(BeanProperties.value(NewProjectWizardModel.PROPERTY_DESCRIPTION).observe(model)).in(dbc);
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Label(org.eclipse.swt.widgets.Label) ProjectDisplayNameValidator(org.jboss.tools.openshift.internal.ui.validator.ProjectDisplayNameValidator) Text(org.eclipse.swt.widgets.Text) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ProjectNameValidator(org.jboss.tools.openshift.internal.ui.validator.ProjectNameValidator)

Aggregations

Binding (org.eclipse.core.databinding.Binding)1 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)1 ProjectDisplayNameValidator (org.jboss.tools.openshift.internal.ui.validator.ProjectDisplayNameValidator)1 ProjectNameValidator (org.jboss.tools.openshift.internal.ui.validator.ProjectNameValidator)1