use of org.jboss.tools.openshift.internal.ui.widgets.JsonSchemaWidget 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);
}
}
Aggregations