use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createSourcePathControls.
@SuppressWarnings("unchecked")
private void createSourcePathControls(Composite parent, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
Label sourcePathLabel = new Label(parent, SWT.NONE);
sourcePathLabel.setText("Source Path: ");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(sourcePathLabel);
Text sourcePathText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sourcePathText);
Binding sourcePathBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(sourcePathText)).validatingAfterConvert(new IValidator() {
@Override
public IStatus validate(Object value) {
String path = (String) value;
if (StringUtils.isEmpty(path)) {
return ValidationStatus.cancel("Please provide a local path to deploy from.");
}
String provideValidPathMessage = "Please provide a valid local path to deploy from.";
try {
path = VariablesHelper.replaceVariables(path);
} catch (OpenShiftCoreException e) {
String message = org.apache.commons.lang.StringUtils.substringAfter(e.getMessage(), "Exception:");
return ValidationStatus.error(provideValidPathMessage + "\nError: " + message);
}
if (!isReadableFile(path)) {
return ValidationStatus.error(provideValidPathMessage);
}
return ValidationStatus.ok();
}
private boolean isReadableFile(String path) {
return new File(path).canRead();
}
}).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_SOURCE_PATH).observe(model)).in(dbc);
ControlDecorationSupport.create(sourcePathBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
Button browseSourceButton = new Button(parent, SWT.PUSH);
browseSourceButton.setText("Browse...");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(10, SWT.DEFAULT).applyTo(browseSourceButton);
browseSourceButton.addSelectionListener(onBrowseSource(browseSourceButton.getShell()));
Button browseWorkspaceSourceButton = new Button(parent, SWT.PUSH | SWT.READ_ONLY);
browseWorkspaceSourceButton.setText("Workspace...");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(browseWorkspaceSourceButton);
browseWorkspaceSourceButton.addSelectionListener(onBrowseWorkspace(browseWorkspaceSourceButton.getShell()));
UIUtils.setEqualButtonWidth(browseSourceButton, browseWorkspaceSourceButton);
}
use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createDebuggingPortControls.
@SuppressWarnings("unchecked")
private void createDebuggingPortControls(Composite parent, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
Label debugPortLabel = new Label(parent, SWT.None);
debugPortLabel.setText("Debugging Port:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(debugPortLabel);
// use image key & value checkbox
Button useImageDebugPortKeyButton = new Button(parent, SWT.CHECK);
useImageDebugPortKeyButton.setText("use image provided key and value");
GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).applyTo(useImageDebugPortKeyButton);
IObservableValue<Boolean> useImageDebugPortKey = BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_USE_IMAGE_DEBUG_PORT_KEY).observe(model);
ValueBindingBuilder.bind(WidgetProperties.selection().observe(useImageDebugPortKeyButton)).to(useImageDebugPortKey).in(dbc);
// filler
new Label(parent, SWT.NONE);
// key text field
// filler
new Label(parent, SWT.NONE);
Label keyLabel = new Label(parent, SWT.NONE);
keyLabel.setText("Key:");
GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(keyLabel);
Text debugPortKeyText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(debugPortKeyText);
IObservableValue<String> debugPortKeyTextObservable = WidgetProperties.text(SWT.Modify).observe(debugPortKeyText);
ValueBindingBuilder.bind(debugPortKeyTextObservable).to(BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_DEBUG_PORT_KEY).observe(model)).in(dbc);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(debugPortKeyText)).notUpdating(useImageDebugPortKey).converting(new InvertingBooleanConverter()).in(dbc);
ValidationStatusProvider debugPortKeyValidator = new DisableableMultiValitdator<String>(useImageDebugPortKey, debugPortKeyTextObservable, new OpenShiftIdentifierValidator());
dbc.addValidationStatusProvider(debugPortKeyValidator);
ControlDecorationSupport.create(debugPortKeyValidator, SWT.LEFT | SWT.TOP, parent, new RequiredControlDecorationUpdater(true));
// port text field
IObservableValue<Boolean> useImageDebugPortValue = BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_USE_IMAGE_DEBUG_PORT_VALUE).observe(model);
ValueBindingBuilder.bind(WidgetProperties.selection().observe(useImageDebugPortKeyButton)).to(useImageDebugPortValue).in(dbc);
Label portLabel = new Label(parent, SWT.NONE);
portLabel.setText("Port:");
GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(portLabel);
Text debugPortText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(debugPortText);
IObservableValue<String> debugPortValueObservable = WidgetProperties.text(SWT.Modify).observe(debugPortText);
ValueBindingBuilder.bind(debugPortValueObservable).to(BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_DEBUG_PORT_VALUE).observe(model)).in(dbc);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(debugPortText)).notUpdating(useImageDebugPortValue).converting(new InvertingBooleanConverter()).in(dbc);
ValidationStatusProvider debugPortValueValidator = new DisableableMultiValitdator<String>(useImageDebugPortValue, debugPortValueObservable, new NumericValidator("integer", Integer::parseInt, true));
dbc.addValidationStatusProvider(debugPortValueValidator);
ControlDecorationSupport.create(debugPortValueValidator, SWT.LEFT | SWT.TOP, parent, new RequiredControlDecorationUpdater(true));
}
use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createResourcePathControls.
@SuppressWarnings("unchecked")
private void createResourcePathControls(Composite parent, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, true).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).applyTo(container);
Button useInferredPodPathButton = new Button(container, SWT.CHECK);
useInferredPodPathButton.setText("&Use inferred Pod Deployment Path");
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(useInferredPodPathButton);
ISWTObservableValue useInferredPodPathObservable = WidgetProperties.selection().observe(useInferredPodPathButton);
ValueBindingBuilder.bind(useInferredPodPathObservable).to(BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_USE_INFERRED_POD_PATH).observe(model)).in(dbc);
Label podPathLabel = new Label(container, SWT.NONE);
podPathLabel.setText("Pod Deployment Path: ");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(podPathLabel);
Text podPathText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(podPathText);
ISWTObservableValue podPathObservable = WidgetProperties.text(SWT.Modify).observe(podPathText);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(podPathText)).notUpdatingParticipant().to(useInferredPodPathObservable).converting(new InvertingBooleanConverter()).in(dbc);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(podPathLabel)).notUpdatingParticipant().to(useInferredPodPathObservable).converting(new InvertingBooleanConverter()).in(dbc);
ValueBindingBuilder.bind(podPathObservable).to(BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_POD_PATH).observe(model)).in(dbc);
PodPathValidator podPathValidator = new PodPathValidator(useInferredPodPathObservable, podPathObservable);
ControlDecorationSupport.create(podPathValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
dbc.addValidationStatusProvider(podPathValidator);
}
Aggregations