Search in sources :

Example 1 with MandatoryStringValidator

use of org.jboss.tools.common.ui.databinding.MandatoryStringValidator in project jbosstools-openshift by jbosstools.

the class CreateComponentWizardPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);
    Label componentNameLabel = new Label(parent, SWT.NONE);
    componentNameLabel.setText("Name:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(componentNameLabel);
    Text componentNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(componentNameText);
    ISWTObservableValue<String> componentNameObservable = WidgetProperties.text(SWT.Modify).observe(componentNameText);
    Binding componentNameBinding = ValueBindingBuilder.bind(componentNameObservable).validatingAfterGet(new MandatoryStringValidator("Please specify a name")).to(BeanProperties.value(ComponentModel.PROPERTY_COMPONENT_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(componentNameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    IObservableValue<Object> projectObservable = BeanProperties.value(CreateComponentModel.PROPERTY_ECLIPSE_PROJECT).observe(model);
    SelectProjectComponentBuilder builder = new SelectProjectComponentBuilder();
    builder.setTextLabel("Use existing workspace project:").setRequired(true).setEclipseProjectObservable(projectObservable).setSelectionListener(SelectionListener.widgetSelectedAdapter(this::onBrowseProjects)).setButtonIndent(0).build(parent, dbc, 1);
    CLabel information = new CLabel(parent, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(information);
    ValueBindingBuilder.bind(WidgetProperties.text().observe(information)).notUpdatingParticipant().to(BeanProperties.value(CreateComponentModel.PROPERTY_ECLIPSE_PROJECT_HAS_DEVFILE).observe(model)).converting(IConverter.create(flag -> (boolean) flag ? "Project has a devfile, component type selection is not required" : "")).in(dbc);
    ValueBindingBuilder.bind(WidgetProperties.image().observe(information)).notUpdatingParticipant().to(BeanProperties.value(CreateComponentModel.PROPERTY_ECLIPSE_PROJECT_HAS_DEVFILE).observe(model)).converting(IConverter.create(flag -> (boolean) flag ? INFORMATION_IMAGE : null)).in(dbc);
    Label componentTypesLabel = new Label(parent, SWT.NONE);
    componentTypesLabel.setText("Component type:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(componentTypesLabel);
    org.eclipse.swt.widgets.List componentTypesList = new org.eclipse.swt.widgets.List(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(componentTypesList);
    ListViewer componentTypesListViewer = new ListViewer(componentTypesList);
    componentTypesListViewer.setContentProvider(ArrayContentProvider.getInstance());
    componentTypesListViewer.setLabelProvider(new ComponentTypeColumLabelProvider());
    componentTypesListViewer.setInput(model.getComponentTypes());
    Binding componentTypesBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(componentTypesListViewer)).validatingAfterGet(new ComponentTypeValidator(ValidationStatus.cancel("You have to select a component type."))).to(BeanProperties.value(CreateComponentModel.PROPERTY_SELECTED_COMPONENT_TYPE, ComponentType.class).observe(model)).in(dbc);
    ControlDecorationSupport.create(componentTypesBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(componentTypesList)).to(BeanProperties.value(CreateComponentModel.PROPERTY_ECLIPSE_PROJECT_HAS_DEVFILE).observe(model)).converting(new InvertingBooleanConverter()).in(dbc);
    Label componentStartersLabel = new Label(parent, SWT.NONE);
    componentStartersLabel.setText("Project starter:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(componentStartersLabel);
    Combo componentStartersVersionsCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(componentStartersVersionsCombo);
    ComboViewer componentStartersComboViewer = new ComboViewer(componentStartersVersionsCombo);
    componentStartersComboViewer.setContentProvider(new ObservableListContentProvider<>());
    componentStartersComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof Starter) {
                return ((Starter) element).getName();
            }
            return "";
        }
    });
    componentStartersComboViewer.setInput(BeanProperties.list(CreateComponentModel.PROPERTY_SELECTED_COMPONENT_STARTERS).observe(model));
    Binding componentStartersBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(componentStartersComboViewer)).to(BeanProperties.value(CreateComponentModel.PROPERTY_SELECTED_COMPONENT_STARTER).observe(model)).in(dbc);
    IObservableValue<List> selectedStartersObservable = BeanProperties.value(CreateComponentModel.PROPERTY_SELECTED_COMPONENT_STARTERS, List.class).observe(model);
    IObservableValue<Boolean> emptyProjectObservable = BeanProperties.value(CreateComponentModel.PROPERTY_ECLIPSE_PROJECT_EMPTY, Boolean.class).observe(model);
    IObservableValue<Boolean> computedObservable = ComputedValue.create(() -> {
        return !selectedStartersObservable.getValue().isEmpty() && emptyProjectObservable.getValue();
    });
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(componentStartersVersionsCombo)).to(computedObservable).in(dbc);
    ValueBindingBuilder.bind(WidgetProperties.text().observe(information)).notUpdatingParticipant().to(computedObservable).converting(IConverter.create(flag -> (boolean) flag ? "Your project is empty, you can initialize it from starters (templates)" : "")).in(dbc);
    ValueBindingBuilder.bind(WidgetProperties.image().observe(information)).notUpdatingParticipant().to(computedObservable).converting(IConverter.create(flag -> (boolean) flag ? INFORMATION_IMAGE : null)).in(dbc);
    Label applicationLabel = new Label(parent, SWT.NONE);
    applicationLabel.setText("Application:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(applicationLabel);
    Text applicationNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(applicationNameText);
    ISWTObservableValue<String> applicationNameObservable = WidgetProperties.text(SWT.Modify).observe(applicationNameText);
    Binding applicationNameBinding = ValueBindingBuilder.bind(applicationNameObservable).validatingAfterGet(new MandatoryStringValidator("Please specify an application")).to(BeanProperties.value(CreateComponentModel.PROPERTY_APPLICATION_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(applicationNameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    if (!model.isDefaultApplication()) {
        applicationNameText.setEnabled(false);
    }
    Label pushAfterCreateLabel = new Label(parent, SWT.NONE);
    pushAfterCreateLabel.setText("Push after create:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(pushAfterCreateLabel);
    Button pushAfterCreateButton = new Button(parent, SWT.CHECK);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(pushAfterCreateButton);
    ISWTObservableValue<Boolean> pushAfterCreateObservable = WidgetProperties.buttonSelection().observe(pushAfterCreateButton);
    Binding pushAfterCreateBinding = ValueBindingBuilder.bind(pushAfterCreateObservable).to(BeanProperties.value(CreateComponentModel.PROPERTY_PUSH_AFTER_CREATE).observe(model)).in(dbc);
    ControlDecorationSupport.create(pushAfterCreateBinding, SWT.LEFT | SWT.TOP);
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) MandatoryStringValidator(org.jboss.tools.common.ui.databinding.MandatoryStringValidator) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Starter(org.jboss.tools.openshift.core.odo.Starter) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Button(org.eclipse.swt.widgets.Button) List(java.util.List) Binding(org.eclipse.core.databinding.Binding) ListViewer(org.eclipse.jface.viewers.ListViewer) ComponentType(org.jboss.tools.openshift.core.odo.ComponentType) InvertingBooleanConverter(org.jboss.tools.common.ui.databinding.InvertingBooleanConverter) SelectProjectComponentBuilder(org.jboss.tools.openshift.internal.common.ui.SelectProjectComponentBuilder) Text(org.eclipse.swt.widgets.Text) ComboViewer(org.eclipse.jface.viewers.ComboViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 2 with MandatoryStringValidator

use of org.jboss.tools.common.ui.databinding.MandatoryStringValidator in project jbosstools-openshift by jbosstools.

the class CreateServiceWizardPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);
    Label serviceNameLabel = new Label(parent, SWT.NONE);
    serviceNameLabel.setText("Name:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(serviceNameLabel);
    Text serviceNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(serviceNameText);
    ISWTObservableValue<String> serviceNameObservable = WidgetProperties.text(SWT.Modify).observe(serviceNameText);
    Binding serviceNameBinding = ValueBindingBuilder.bind(serviceNameObservable).validatingAfterGet(new MandatoryStringValidator("Please specify a name")).to(BeanProperties.value(CreateServiceModel.PROPERTY_SERVICE_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(serviceNameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    Label serviceTemplatesLabel = new Label(parent, SWT.NONE);
    serviceTemplatesLabel.setText("Service:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(serviceTemplatesLabel);
    Combo serviceTemplatesCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(serviceTemplatesCombo);
    ComboViewer serviceTemplatesComboViewer = new ComboViewer(serviceTemplatesCombo);
    serviceTemplatesComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    serviceTemplatesComboViewer.setLabelProvider(new ServiceTemplateColumLabelProvider());
    serviceTemplatesComboViewer.setInput(model.getServiceTemplates());
    Binding serviceTemplatesBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(serviceTemplatesComboViewer)).validatingAfterGet(new IsNotNullValidator(ValidationStatus.cancel("You have to select a template."))).to(BeanProperties.value(CreateServiceModel.PROPERTY_SELECTED_SERVICE_TEMPLATE, ServiceTemplate.class).observe(model)).in(dbc);
    ControlDecorationSupport.create(serviceTemplatesBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    Label serviceCRDsLabel = new Label(parent, SWT.NONE);
    serviceCRDsLabel.setText("Type:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(serviceCRDsLabel);
    Combo serviceCRDsCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(serviceCRDsCombo);
    ComboViewer serviceCRDsComboViewer = new ComboViewer(serviceCRDsCombo);
    serviceCRDsComboViewer.setContentProvider(new ObservableListContentProvider<>());
    serviceCRDsComboViewer.setLabelProvider(new ServiceTemplateCRDColumLabelProvider());
    serviceCRDsComboViewer.setInput(BeanProperties.list(CreateServiceModel.PROPERTY_SELECTED_SERVICE_TEMPLATE_CRDS).observe(model));
    Binding serviceCRDsBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(serviceCRDsComboViewer)).validatingAfterGet(new IsNotNullValidator(ValidationStatus.cancel("You have to select a type."))).to(BeanProperties.value(CreateServiceModel.PROPERTY_SELECTED_SERVICE_TEMPLATE_CRD, OperatorCRD.class).observe(model)).in(dbc);
    ControlDecorationSupport.create(serviceCRDsBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    ScrolledComposite schemaParentComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(3, 1).applyTo(schemaParentComposite);
    schemaParentComposite.setExpandHorizontal(true);
    schemaParentComposite.setExpandVertical(true);
    schemaWidget = new JsonSchemaWidget(schemaParentComposite, ERROR, schemaParentComposite);
    schemaParentComposite.setContent(schemaWidget);
    schemaParentComposite.setMinHeight(250);
    serviceCRDsComboViewer.addSelectionChangedListener(e -> {
        initSchemaWidget();
    });
    initSchemaWidget();
    Label applicationLabel = new Label(parent, SWT.NONE);
    applicationLabel.setText("Application:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(applicationLabel);
    Text applicationNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(applicationNameText);
    ISWTObservableValue<String> applicationNameObservable = WidgetProperties.text(SWT.Modify).observe(applicationNameText);
    Binding applicationNameBinding = ValueBindingBuilder.bind(applicationNameObservable).validatingAfterGet(new MandatoryStringValidator("Please specify an application")).to(BeanProperties.value(CreateServiceModel.PROPERTY_APPLICATION_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(applicationNameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    if (StringUtils.isNotBlank(model.getApplicationName())) {
        applicationNameText.setEnabled(false);
    }
}
Also used : Binding(org.eclipse.core.databinding.Binding) MandatoryStringValidator(org.jboss.tools.common.ui.databinding.MandatoryStringValidator) ServiceTemplate(org.jboss.tools.openshift.core.odo.ServiceTemplate) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) OperatorCRD(org.jboss.tools.openshift.core.odo.OperatorCRD) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) ComboViewer(org.eclipse.jface.viewers.ComboViewer) JsonSchemaWidget(org.jboss.tools.openshift.internal.ui.widgets.JsonSchemaWidget) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IsNotNullValidator(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNullValidator)

Example 3 with MandatoryStringValidator

use of org.jboss.tools.common.ui.databinding.MandatoryStringValidator in project jbosstools-openshift by jbosstools.

the class CreateURLWizardPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);
    Label urlNameLabel = new Label(parent, SWT.NONE);
    urlNameLabel.setText("Name:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(urlNameLabel);
    Text urlNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(urlNameText);
    ISWTObservableValue<String> urlNameObservable = WidgetProperties.text(SWT.Modify).observe(urlNameText);
    Binding urlNameBinding = ValueBindingBuilder.bind(urlNameObservable).validatingAfterGet(new MandatoryStringValidator("Please specify a name")).to(BeanProperties.value(CreateURLModel.PROPERTY_URL_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(urlNameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    Label portLabel = new Label(parent, SWT.NONE);
    portLabel.setText("Port:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(portLabel);
    Text portText = new Text(parent, SWT.SINGLE);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(portText);
    Binding portBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(portText)).validatingAfterGet(new PortValidator()).to(BeanProperties.value(CreateURLModel.PROPERTY_PORT).observe(model)).converting(NumberToStringConverter.fromInteger(new DecimalFormat("#"), true)).in(dbc);
    ControlDecorationSupport.create(portBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    Label secureLabel = new Label(parent, SWT.NONE);
    secureLabel.setText("Secure:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(secureLabel);
    Button secureButton = new Button(parent, SWT.CHECK);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(secureButton);
    ISWTObservableValue<Boolean> secureObservable = WidgetProperties.buttonSelection().observe(secureButton);
    Binding secureBinding = ValueBindingBuilder.bind(secureObservable).to(BeanProperties.value(CreateURLModel.PROPERTY_SECURE).observe(model)).in(dbc);
    ControlDecorationSupport.create(secureBinding, SWT.LEFT | SWT.TOP);
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) MandatoryStringValidator(org.jboss.tools.common.ui.databinding.MandatoryStringValidator) Button(org.eclipse.swt.widgets.Button) DecimalFormat(java.text.DecimalFormat) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 4 with MandatoryStringValidator

use of org.jboss.tools.common.ui.databinding.MandatoryStringValidator in project jbosstools-openshift by jbosstools.

the class CreateDevfileRegistryPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);
    Label nameLabel = new Label(parent, SWT.NONE);
    nameLabel.setText("Name:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(nameLabel);
    Text nameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(nameText);
    ISWTObservableValue<String> nameObservable = WidgetProperties.text(SWT.Modify).observe(nameText);
    Binding nameBinding = ValueBindingBuilder.bind(nameObservable).validatingAfterGet(new MandatoryStringValidator("Please specify a name")).to(BeanProperties.value(CreateDevfileRegistryModel.PROPERTY_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    Label urlLabel = new Label(parent, SWT.NONE);
    urlLabel.setText("URL:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(urlLabel);
    Text urlText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(urlText);
    ISWTObservableValue<String> urlObservable = WidgetProperties.text(SWT.Modify).observe(urlText);
    Binding urlBinding = ValueBindingBuilder.bind(urlObservable).validatingAfterGet(new URLValidator("registry", false)).to(BeanProperties.value(CreateDevfileRegistryModel.PROPERTY_URL).observe(model)).in(dbc);
    ControlDecorationSupport.create(urlBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    Label secureLabel = new Label(parent, SWT.NONE);
    secureLabel.setText("Secure:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(secureLabel);
    Button secureButton = new Button(parent, SWT.CHECK);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(secureButton);
    ISWTObservableValue<Boolean> secureObservable = WidgetProperties.buttonSelection().observe(secureButton);
    Binding secureBinding = ValueBindingBuilder.bind(secureObservable).to(BeanProperties.value(CreateDevfileRegistryModel.PROPERTY_SECURE).observe(model)).in(dbc);
    ControlDecorationSupport.create(secureBinding, SWT.LEFT | SWT.TOP);
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) MandatoryStringValidator(org.jboss.tools.common.ui.databinding.MandatoryStringValidator) URLValidator(org.jboss.tools.openshift.internal.ui.validator.URLValidator) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 5 with MandatoryStringValidator

use of org.jboss.tools.common.ui.databinding.MandatoryStringValidator in project jbosstools-openshift by jbosstools.

the class CreateStorageWizardPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);
    Label storageNameLabel = new Label(parent, SWT.NONE);
    storageNameLabel.setText("Name:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(storageNameLabel);
    Text storageNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(storageNameText);
    ISWTObservableValue<String> storageNameObservable = WidgetProperties.text(SWT.Modify).observe(storageNameText);
    Binding storageNameBinding = ValueBindingBuilder.bind(storageNameObservable).validatingAfterGet(new MandatoryStringValidator("Please specify a name")).to(BeanProperties.value(CreateStorageModel.PROPERTY_STORAGE_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(storageNameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    Label mountPathLabel = new Label(parent, SWT.NONE);
    mountPathLabel.setText("Mount path:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(mountPathLabel);
    Text mountPathText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(mountPathText);
    ISWTObservableValue<String> mountPathObservable = WidgetProperties.text(SWT.Modify).observe(mountPathText);
    Binding mountPathBinding = ValueBindingBuilder.bind(mountPathObservable).validatingAfterGet(new MandatoryStringValidator("Please specify a mount path")).to(BeanProperties.value(CreateStorageModel.PROPERTY_MOUNT_PATH).observe(model)).in(dbc);
    ControlDecorationSupport.create(mountPathBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    Label sizeLabel = new Label(parent, SWT.NONE);
    sizeLabel.setText("Size:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(sizeLabel);
    Combo sizeCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sizeCombo);
    ComboViewer sizeComboViewer = new ComboViewer(sizeCombo);
    sizeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    sizeComboViewer.setInput(model.getSizes());
    Binding portBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(sizeComboViewer)).validatingAfterGet(new IsNotNullValidator(ValidationStatus.cancel("You have to select a size."))).to(BeanProperties.value(CreateStorageModel.PROPERTY_SIZE).observe(model)).in(dbc);
    ControlDecorationSupport.create(portBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) MandatoryStringValidator(org.jboss.tools.common.ui.databinding.MandatoryStringValidator) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) IsNotNullValidator(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNullValidator)

Aggregations

Binding (org.eclipse.core.databinding.Binding)5 Label (org.eclipse.swt.widgets.Label)5 Text (org.eclipse.swt.widgets.Text)5 MandatoryStringValidator (org.jboss.tools.common.ui.databinding.MandatoryStringValidator)5 RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)5 ComboViewer (org.eclipse.jface.viewers.ComboViewer)3 Button (org.eclipse.swt.widgets.Button)3 Combo (org.eclipse.swt.widgets.Combo)3 IsNotNullValidator (org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNullValidator)2 DecimalFormat (java.text.DecimalFormat)1 List (java.util.List)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 ListViewer (org.eclipse.jface.viewers.ListViewer)1 CLabel (org.eclipse.swt.custom.CLabel)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 InvertingBooleanConverter (org.jboss.tools.common.ui.databinding.InvertingBooleanConverter)1 ComponentType (org.jboss.tools.openshift.core.odo.ComponentType)1 OperatorCRD (org.jboss.tools.openshift.core.odo.OperatorCRD)1 ServiceTemplate (org.jboss.tools.openshift.core.odo.ServiceTemplate)1 Starter (org.jboss.tools.openshift.core.odo.Starter)1