use of org.jboss.tools.common.ui.databinding.InvertingBooleanConverter in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createRouteControls.
@SuppressWarnings("unchecked")
private void createRouteControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
Group routeGroup = new Group(container, SWT.NONE);
routeGroup.setText("Route");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(routeGroup);
GridLayoutFactory.fillDefaults().applyTo(routeGroup);
// additional nesting required because of
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=478618
Composite routeContainer = new Composite(routeGroup, SWT.None);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(routeContainer);
GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(routeContainer);
Button promptRouteButton = new Button(routeContainer, SWT.CHECK);
promptRouteButton.setSelection(true);
promptRouteButton.setText("Prompt for route when multiple routes available to show in browser");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).applyTo(promptRouteButton);
Label routeLabel = new Label(routeContainer, SWT.NONE);
routeLabel.setText("Use Route: ");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(routeLabel);
StructuredViewer routesViewer = new ComboViewer(routeContainer);
GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(routesViewer.getControl());
routesViewer.setContentProvider(new ObservableListContentProvider());
routesViewer.setLabelProvider(new RouteLabelProvider());
routesViewer.setInput(BeanProperties.list(ServerSettingsWizardPageModel.PROPERTY_ROUTES).observe(model));
// routesViewer.setComparer(new IElementComparer() {
//
// @Override
// public boolean equals(Object object1, Object object2) {
// if (object1 instanceof IRoute) {
// if (!(object2 instanceof IRoute)) {
// return false;
// }
//
// IRoute route1 = (IRoute) object1;
// IRoute route2 = (IRoute) object2;
//
// return Objects.equals(route1.getServiceName(), route2.getServiceName())
// && Objects.equals(route1.getURL(), route2.getURL());
// } else if (object2 instanceof IRoute) {
// return false;
// } else {
// return Objects.equals(object1, object2);
// }
// }
//
// @Override
// public int hashCode(Object element) {
// if (element instanceof IRoute) {
// IRoute route = (IRoute) element;
// return new HashCodeBuilder()
// .append(route.getServiceName())
// .append(route.getURL())
// .toHashCode();
// }
// return element.hashCode();
// }
// });
IObservableValue<IResource> selectedRouteObservable = ViewerProperties.singleSelection().observe(routesViewer);
ValueBindingBuilder.bind(selectedRouteObservable).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_ROUTE).observe(model)).in(dbc);
final IObservableValue<Boolean> isSelectDefaultRouteObservable = WidgetProperties.selection().observe(promptRouteButton);
final IObservableValue<Boolean> selectDefaultRouteModelObservable = BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_SELECT_DEFAULT_ROUTE).observe(model);
ValueBindingBuilder.bind(isSelectDefaultRouteObservable).converting(new InvertingBooleanConverter()).to(selectDefaultRouteModelObservable).converting(new InvertingBooleanConverter()).in(dbc);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(routesViewer.getControl())).notUpdating(selectDefaultRouteModelObservable).in(dbc);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(routeLabel)).notUpdating(selectDefaultRouteModelObservable).in(dbc);
RouteValidator routeValidator = new RouteValidator(isSelectDefaultRouteObservable, selectedRouteObservable);
dbc.addValidationStatusProvider(routeValidator);
ControlDecorationSupport.create(routeValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
}
use of org.jboss.tools.common.ui.databinding.InvertingBooleanConverter in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createEnableDebuggingControls.
@SuppressWarnings("unchecked")
private void createEnableDebuggingControls(Composite parent, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
Label enableDevmodeLabel = new Label(parent, SWT.None);
enableDevmodeLabel.setText("Enable debugging:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(enableDevmodeLabel);
Button useImageDevmodeKey = new Button(parent, SWT.CHECK);
useImageDevmodeKey.setText("use image provided key");
GridDataFactory.fillDefaults().span(4, 1).align(SWT.FILL, SWT.CENTER).applyTo(useImageDevmodeKey);
IObservableValue<Boolean> useImageDevmodeKeyObservable = BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_USE_IMAGE_DEVMODE_KEY).observe(model);
ValueBindingBuilder.bind(WidgetProperties.selection().observe(useImageDevmodeKey)).to(useImageDevmodeKeyObservable).in(dbc);
// 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 devmodeKeyText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(devmodeKeyText);
IObservableValue<String> devmodeKeyObservable = WidgetProperties.text(SWT.Modify).observe(devmodeKeyText);
ValueBindingBuilder.bind(devmodeKeyObservable).to(BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_DEVMODE_KEY).observe(model)).in(dbc);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(devmodeKeyText)).notUpdating(useImageDevmodeKeyObservable).converting(new InvertingBooleanConverter()).in(dbc);
ValidationStatusProvider devmodeKeyValidator = new DisableableMultiValitdator<String>(useImageDevmodeKeyObservable, devmodeKeyObservable, new OpenShiftIdentifierValidator());
dbc.addValidationStatusProvider(devmodeKeyValidator);
ControlDecorationSupport.create(devmodeKeyValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
}
use of org.jboss.tools.common.ui.databinding.InvertingBooleanConverter in project jbosstools-openshift by jbosstools.
the class ConnectionWizardPage method doCreateControls.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void doCreateControls(final Composite parent, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);
// userdoc link (JBIDE-20401)
// text set in #showHideUserdocLink
this.userdocLink = new StyledText(parent, SWT.WRAP);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(userdocLink);
showHideUserdocLink();
IObservableValue userdocUrlObservable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USERDOCURL).observe(pageModel);
StyledTextUtils.emulateLinkAction(userdocLink, r -> onUserdocLinkClicked(userdocUrlObservable));
userdocUrlObservable.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
showHideUserdocLink();
}
});
IObservableValue connectionFactoryObservable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_CONNECTION_FACTORY).observe(pageModel);
// filler
Label fillerLabel = new Label(parent, SWT.NONE);
GridDataFactory.fillDefaults().span(3, 3).hint(SWT.DEFAULT, 6).applyTo(fillerLabel);
// existing connections combo
Label connectionLabel = new Label(parent, SWT.NONE);
connectionLabel.setText("Connection:");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(connectionLabel);
Combo connectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
// disable the connection combo if we're editing a connection or creating a new one from scratch
connectionCombo.setEnabled(pageModel.isAllowConnectionChange());
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(connectionCombo);
ComboViewer connectionComboViewer = new ComboViewer(connectionCombo);
connectionComboViewer.setContentProvider(ArrayContentProvider.getInstance());
connectionComboViewer.setLabelProvider(new ConnectionColumLabelProvider());
connectionComboViewer.setInput(pageModel.getAllConnections());
Binding selectedConnectionBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(connectionComboViewer)).validatingAfterGet(new IsNotNullValidator(ValidationStatus.cancel("You have to select or create a new connection."))).to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_SELECTED_CONNECTION, IConnection.class).observe(pageModel)).in(dbc);
ControlDecorationSupport.create(selectedConnectionBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
// server type
Label connectionFactoryLabel = new Label(parent, SWT.NONE);
connectionFactoryLabel.setText("Server type:");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(connectionFactoryLabel);
Combo connectionFactoryCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(connectionFactoryCombo);
ComboViewer connectionFactoriesViewer = new ComboViewer(connectionFactoryCombo);
connectionFactoriesViewer.setContentProvider(ArrayContentProvider.getInstance());
connectionFactoriesViewer.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (!(element instanceof IConnectionFactory)) {
return element.toString();
} else {
return ((IConnectionFactory) element).getName();
}
}
});
connectionFactoriesViewer.setInput(pageModel.getAllConnectionFactories());
// Disable the server type when editing a connection
if (!pageModel.isAllowConnectionChange() && pageModel.getSelectedConnection() != null) {
IConnection c = pageModel.getSelectedConnection();
if (!(c instanceof NewConnectionMarker)) {
connectionFactoryCombo.setEnabled(false);
}
}
final IViewerObservableValue selectedServerType = ViewerProperties.singleSelection().observe(connectionFactoriesViewer);
ValueBindingBuilder.bind(selectedServerType).to(connectionFactoryObservable).in(dbc);
// server
Button useDefaultServerCheckbox = new Button(parent, SWT.CHECK);
useDefaultServerCheckbox.setText("Use default server");
GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).applyTo(useDefaultServerCheckbox);
ValueBindingBuilder.bind(WidgetProperties.selection().observe(useDefaultServerCheckbox)).to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USE_DEFAULT_HOST, IConnection.class).observe(pageModel)).in(dbc);
IObservableValue hasDefaultHostObservable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_HAS_DEFAULT_HOST).observe(pageModel);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(useDefaultServerCheckbox)).notUpdating(hasDefaultHostObservable).in(dbc);
Label serverLabel = new Label(parent, SWT.NONE);
serverLabel.setText("Server:");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(serverLabel);
Combo serversCombo = new Combo(parent, SWT.BORDER);
ComboViewer serversViewer = new ComboViewer(serversCombo);
serversViewer.setContentProvider(new ObservableListContentProvider());
serversViewer.setInput(BeanProperties.list(ConnectionWizardPageModel.PROPERTY_ALL_HOSTS).observe(pageModel));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(serversCombo);
final IObservableValue serverUrlObservable = WidgetProperties.text().observe(serversCombo);
serversCombo.addFocusListener(onServerFocusLost(serverUrlObservable));
ValueBindingBuilder.bind(serverUrlObservable).converting(new TrimTrailingSlashConverter()).to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_HOST).observe(pageModel)).in(dbc);
MultiValidator serverUrlValidator = new MultiValidator() {
@Override
protected IStatus validate() {
Object value = serverUrlObservable.getValue();
if (!(value instanceof String) || StringUtils.isEmpty((String) value)) {
return ValidationStatus.cancel("Please provide an OpenShift server url.");
} else if (!UrlUtils.isValid((String) value)) {
return ValidationStatus.error("Please provide a valid OpenShift server url.");
}
return ValidationStatus.ok();
}
};
ControlDecorationSupport.create(serverUrlValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
dbc.addValidationStatusProvider(serverUrlValidator);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(serversCombo)).notUpdatingParticipant().to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USE_DEFAULT_HOST).observe(pageModel)).converting(new InvertingBooleanConverter()).in(dbc);
// connect error
dbc.addValidationStatusProvider(new MultiValidator() {
IObservableValue observable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_CONNECTED_STATUS, IStatus.class).observe(pageModel);
@Override
protected IStatus validate() {
return (IStatus) observable.getValue();
}
});
// connection editors
Group authenticationDetailsGroup = new Group(parent, SWT.NONE);
authenticationDetailsGroup.setText("Authentication");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(3, 1).applyTo(authenticationDetailsGroup);
GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(authenticationDetailsGroup);
// additional nesting required because of https://bugs.eclipse.org/bugs/show_bug.cgi?id=478618
Composite authenticationDetailsContainer = new Composite(authenticationDetailsGroup, SWT.None);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(authenticationDetailsContainer);
this.connectionEditors = new ConnectionEditorsStackedView(connectionFactoryObservable, this, authenticationDetailsContainer, dbc);
connectionEditors.createControls();
// adv editors
Composite advEditorContainer = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(authenticationDetailsGroup);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(3, 1).grab(true, true).applyTo(advEditorContainer);
this.advConnectionEditors = new AdvancedConnectionEditorsStackedView(connectionFactoryObservable, pageModel, advEditorContainer, dbc);
advConnectionEditors.createControls();
}
use of org.jboss.tools.common.ui.databinding.InvertingBooleanConverter in project jbosstools-openshift by jbosstools.
the class GitCloningWizardPage method createCloneGroup.
private Composite createCloneGroup(Composite parent, DataBindingContext dbc) {
Group cloneGroup = new Group(parent, SWT.NONE);
cloneGroup.setText("Clone destination");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(cloneGroup);
GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(cloneGroup);
Composite cloneGroupComposite = new Composite(cloneGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(cloneGroupComposite);
GridLayoutFactory.fillDefaults().numColumns(3).applyTo(cloneGroupComposite);
// use default clone destination path
Button useDefaultCloneDestinationButton = new Button(cloneGroupComposite, SWT.CHECK);
useDefaultCloneDestinationButton.setText("Use default clone destination");
useDefaultCloneDestinationButton.setToolTipText("Uncheck if you want to use a custom location to clone to");
GridDataFactory.fillDefaults().span(3, 1).align(SWT.LEFT, SWT.CENTER).applyTo(useDefaultCloneDestinationButton);
final IObservableValue<Boolean> useDefaultCloneDestinationObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_USE_DEFAULT_CLONE_DESTINATION).observe(model);
ValueBindingBuilder.bind(WidgetProperties.selection().observe(useDefaultCloneDestinationButton)).to(useDefaultCloneDestinationObservable).in(dbc);
// clone destination
Label repoPathLabel = new Label(cloneGroupComposite, SWT.NONE);
repoPathLabel.setText("Git Clone Location:");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(repoPathLabel);
final Text cloneDestinationText = new Text(cloneGroupComposite, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(cloneDestinationText);
final IObservableValue<String> cloneDestinationObservable = WidgetProperties.text(SWT.Modify).observe(cloneDestinationText);
final IObservableValue<String> cloneDestinationModelObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_CLONE_DESTINATION).observe(model);
ValueBindingBuilder.bind(cloneDestinationObservable).to(cloneDestinationModelObservable).in(dbc);
Button browseCloneDestinationButton = new Button(cloneGroupComposite, SWT.PUSH);
browseCloneDestinationButton.setText("Browse...");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseCloneDestinationButton);
browseCloneDestinationButton.addSelectionListener(onCloneDestination());
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(cloneDestinationText)).notUpdating(useDefaultCloneDestinationObservable).converting(new InvertingBooleanConverter()).in(dbc);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseCloneDestinationButton)).notUpdating(useDefaultCloneDestinationObservable).converting(new InvertingBooleanConverter()).in(dbc);
// move focus to the project location text control when not choosing the
// 'Use default location' option.
UIUtils.focusOnSelection(useDefaultCloneDestinationButton, cloneDestinationText);
// Reuse git repository
Button reuseRepositoryButton = new Button(cloneGroupComposite, SWT.CHECK);
reuseRepositoryButton.setSelection(false);
reuseRepositoryButton.setText("Do not clone - use existing repository");
GridDataFactory.fillDefaults().span(3, 1).align(SWT.LEFT, SWT.CENTER).applyTo(reuseRepositoryButton);
final IObservableValue<Boolean> reuseGitReposityObservable = WidgetProperties.selection().observe(reuseRepositoryButton);
ValueBindingBuilder.bind(reuseGitReposityObservable).to(BeanProperties.value(IGitCloningPageModel.PROPERTY_REUSE_GIT_REPOSITORY).observe(model)).in(dbc);
IObservableValue<File> repoPathObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_REPO_PATH).observe(model);
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(reuseRepositoryButton)).notUpdating(repoPathObservable).converting(new FileExistsConverter()).in(dbc);
ISWTObservableValue reuseRepoButtonEnabled = WidgetProperties.enabled().observe(reuseRepositoryButton);
ValueBindingBuilder.bind(reuseRepoButtonEnabled).notUpdating(repoPathObservable).converting(new Converter(File.class, Boolean.class) {
@Override
public Object convert(Object fromObject) {
return fromObject instanceof File && EGitUtils.isRepository((File) fromObject);
}
}).in(dbc);
this.cloneDestinationPathValidator = new CloneDestinationPathValidator(useDefaultCloneDestinationObservable, cloneDestinationObservable, reuseGitReposityObservable, repoPathObservable);
dbc.addValidationStatusProvider(cloneDestinationPathValidator);
ControlDecorationSupport.create(cloneDestinationPathValidator, SWT.LEFT | SWT.TOP);
// checkout reused repo button
Composite checkoutComposite = new Composite(cloneGroupComposite, SWT.NONE);
GridDataFactory.fillDefaults().span(3, 1).indent(20, SWT.DEFAULT).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(checkoutComposite);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(checkoutComposite);
Button checkoutBranchCheckbox = new Button(checkoutComposite, SWT.CHECK);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(checkoutBranchCheckbox);
ISWTObservableValue checkoutBranchCheckboxObservable = WidgetProperties.selection().observe(checkoutBranchCheckbox);
ValueBindingBuilder.bind(checkoutBranchCheckboxObservable).validatingAfterConvert(new CheckoutBranchValidator()).to(BeanProperties.value(IGitCloningPageModel.PROPERTY_CHECKOUT_BRANCH_REUSED_REPO).observe(model)).validatingAfterConvert(new CheckoutBranchValidator()).in(dbc);
IObservableValue<Boolean> isRepositoryBranchGitRefObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_IS_REPOSITORY_BRANCH_GIT_REF).observe(model);
ComputedValue<Boolean> checkoutBranchEnablement = new ComputedValue<Boolean>() {
@Override
protected Boolean calculate() {
// access all involved observables
Boolean isReuseRepoButtonEnabled = (Boolean) reuseRepoButtonEnabled.getValue();
Boolean isRepositoryBranchGitRef = isRepositoryBranchGitRefObservable.getValue();
Boolean isReuseGitRepository = reuseGitReposityObservable.getValue();
return isReuseRepoButtonEnabled && !isRepositoryBranchGitRef && isReuseGitRepository;
}
};
// checkout branch label
Label checkoutBranchLabel = new Label(checkoutComposite, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(true, false).applyTo(checkoutBranchLabel);
checkoutBranchLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
checkoutBranchCheckboxObservable.setValue(!checkoutBranchCheckbox.getSelection());
}
});
ValueBindingBuilder.bind(WidgetProperties.text().observe(checkoutBranchLabel)).notUpdating(BeanProperties.value(IGitCloningPageModel.PROPERTY_GIT_REF).observe(model)).converting(new Converter(String.class, String.class) {
@Override
public Object convert(Object fromObject) {
return "Check out branch " + fromObject;
}
}).in(dbc);
ValueBindingBuilder.bind(new WritableValue<Boolean>() {
@Override
public void doSetValue(Boolean value) {
checkoutBranchCheckbox.setEnabled(value);
checkoutBranchLabel.setEnabled(value);
}
}).notUpdating(checkoutBranchEnablement).in(dbc);
return cloneGroup;
}
use of org.jboss.tools.common.ui.databinding.InvertingBooleanConverter 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));
}
Aggregations