List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties selection
public static IWidgetValueProperty selection()
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectionWizardPage.java
License:Open Source License
private Composite createExistingConnectionComposite(Composite container, DataBindingContext dbc) { Composite passwordWidgets = new Composite(container, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(passwordWidgets); // password/*from w w w. jav a 2 s. c om*/ Label passwordLabel = new Label(passwordWidgets, SWT.NONE); passwordLabel.setText("&Password:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(passwordLabel); this.passwordCompositePasswordText = new Text(passwordWidgets, SWT.BORDER | SWT.PASSWORD); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(passwordCompositePasswordText); Binding passwordBinding = ValueBindingBuilder .bind(WidgetProperties.text(SWT.Modify).observe(passwordCompositePasswordText)) .validatingAfterGet(new RequiredStringValidator("password")) .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_PASSWORD).observe(pageModel)).in(dbc); ControlDecorationSupport.create(passwordBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); // remember password Button rememberPasswordCheckBox = new Button(passwordWidgets, SWT.CHECK); rememberPasswordCheckBox.setText(OpenshiftUIMessages.OpenshiftWizardSavePassword); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false) .applyTo(rememberPasswordCheckBox); ValueBindingBuilder.bind(WidgetProperties.selection().observe(rememberPasswordCheckBox)) .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_REMEMBER_PASSWORD).observe(pageModel)) .in(dbc); // credentials status IObservableValue credentialsStatusObservable = BeanProperties .value(ConnectionWizardPageModel.PROPERTY_VALID, IStatus.class).observe(pageModel); final CredentialsValidator credentialsValidator = new CredentialsValidator(credentialsStatusObservable); dbc.addValidationStatusProvider(credentialsValidator); ControlDecorationSupport.create(credentialsValidator, SWT.LEFT | SWT.TOP); return passwordWidgets; }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectionWizardPage.java
License:Open Source License
private Composite createNewConnectionComposite(Composite container, DataBindingContext dbc) { Composite connectionWidgets = new Composite(container, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(connectionWidgets); // use default server Button defaultServerCheckbox = new Button(connectionWidgets, SWT.CHECK); defaultServerCheckbox.setText("Use default server"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).applyTo(defaultServerCheckbox); ValueBindingBuilder.bind(WidgetProperties.selection().observe(defaultServerCheckbox)) .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USE_DEFAULTSERVER).observe(pageModel)) .in(dbc);//www. ja va2 s.c o m // host Label serverLabel = new Label(connectionWidgets, SWT.NONE); serverLabel.setText("&Server:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(serverLabel); Combo serversCombo = new Combo(connectionWidgets, SWT.BORDER); ComboViewer serverComboViewer = new ComboViewer(serversCombo); serverComboViewer.setLabelProvider(new ServerLabelProvider()); serverComboViewer.setContentProvider(ArrayContentProvider.getInstance()); serverComboViewer.setInput(pageModel.getServers()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(serversCombo); IObservableValue serverObservable = WidgetProperties.text().observe(serversCombo); Binding serverBinding = ValueBindingBuilder.bind(serverObservable) .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_HOST).observe(pageModel)).in(dbc); ControlDecorationSupport.create(serverBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); ValidationStatusProvider hostValidation = new RequiredStringValidationProvider(serverObservable, "server"); dbc.addValidationStatusProvider(hostValidation); ControlDecorationSupport.create(hostValidation, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(serversCombo)).notUpdatingParticipant() .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USE_DEFAULTSERVER).observe(pageModel)) .converting(new InvertingBooleanConverter()).in(dbc); // username Label rhLoginLabel = new Label(connectionWidgets, SWT.NONE); rhLoginLabel.setText("&Username:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rhLoginLabel); connectionCompositeUsernameText = new Text(connectionWidgets, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(connectionCompositeUsernameText); IObservableValue usernameObservable = WidgetProperties.text(SWT.Modify) .observe(connectionCompositeUsernameText); ValueBindingBuilder.bind(usernameObservable).converting(new TrimmingStringConverter()) .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USERNAME).observe(pageModel)).in(dbc); ValidationStatusProvider usernameValidation = new RequiredStringValidationProvider(usernameObservable, "username"); dbc.addValidationStatusProvider(usernameValidation); ControlDecorationSupport.create(usernameValidation, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); // password Label passwordLabel = new Label(connectionWidgets, SWT.NONE); passwordLabel.setText("&Password:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(passwordLabel); this.connectionCompositePasswordText = new Text(connectionWidgets, SWT.BORDER | SWT.PASSWORD); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(connectionCompositePasswordText); IObservableValue passwordObservable = WidgetProperties.text(SWT.Modify) .observe(connectionCompositePasswordText); ValueBindingBuilder.bind(passwordObservable) .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_PASSWORD).observe(pageModel)).in(dbc); ValidationStatusProvider passwordValidation = new RequiredStringValidationProvider(passwordObservable, "password"); dbc.addValidationStatusProvider(passwordValidation); ControlDecorationSupport.create(passwordValidation, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); Button rememberPasswordCheckBox = new Button(connectionWidgets, SWT.CHECK); rememberPasswordCheckBox.setText(OpenshiftUIMessages.OpenshiftWizardSavePassword); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false) .applyTo(rememberPasswordCheckBox); ValueBindingBuilder.bind(WidgetProperties.selection().observe(rememberPasswordCheckBox)) .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_REMEMBER_PASSWORD).observe(pageModel)) .in(dbc); // credentials status IObservableValue credentialsStatusObservable = BeanProperties .value(ConnectionWizardPageModel.PROPERTY_VALID, IStatus.class).observe(pageModel); final CredentialsValidator credentialsValidator = new CredentialsValidator(credentialsStatusObservable); dbc.addValidationStatusProvider(credentialsValidator); return connectionWidgets; }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.connection.ExpressConnectionEditor.java
License:Open Source License
private void bindWidgetsToInternalModel(DataBindingContext dbc) { // username/* ww w . j a v a2s.c om*/ this.usernameBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(usernameText)) .converting(new TrimmingStringConverter()) .validatingAfterConvert(new RequiredStringValidator("username")).to(usernameObservable).in(dbc); ControlDecorationSupport.create(usernameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); // password this.passwordBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(passwordText)) .converting(new TrimmingStringConverter()) .validatingAfterConvert(new RequiredStringValidator("password")).to(passwordObservable).in(dbc); ControlDecorationSupport.create(passwordBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); // remember password this.rememberPasswordBinding = ValueBindingBuilder .bind(WidgetProperties.selection().observe(rememberPasswordCheckBox)).to(rememberPasswordObservable) .in(dbc); ControlDecorationSupport.create(rememberPasswordBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.snapshot.RestoreSnapshotWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { // snapshot type GridLayoutFactory.fillDefaults().numColumns(5).margins(10, 10).applyTo(parent); Label snapshotTypeLabel = new Label(parent, SWT.None); snapshotTypeLabel.setText("Snapshot Type:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(snapshotTypeLabel); Button fullSnapshotButton = new Button(parent, SWT.RADIO); fullSnapshotButton.setText("Full"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(fullSnapshotButton); ValueBindingBuilder.bind(WidgetProperties.selection().observe(fullSnapshotButton)) .converting(new InvertingBooleanConverter()).to(BeanProperties .value(RestoreSnapshotWizardPageModel.PROPERTY_DEPLOYMENT_SNAPSHOT).observe(pageModel)) .converting(new InvertingBooleanConverter()).in(dbc); Button deploymentSnapshotButton = new Button(parent, SWT.RADIO); deploymentSnapshotButton.setText("Deployment"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(deploymentSnapshotButton); ValueBindingBuilder/*from w ww. ja v a 2 s . c o m*/ .bind(WidgetProperties.selection().observe(deploymentSnapshotButton)).to(BeanProperties .value(RestoreSnapshotWizardPageModel.PROPERTY_DEPLOYMENT_SNAPSHOT).observe(pageModel)) .in(dbc); // horizontal filler GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(new Composite(parent, SWT.None)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(new Composite(parent, SWT.None)); // file Label filepathLabel = new Label(parent, SWT.None); filepathLabel.setText("File:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(filepathLabel); Text filepathText = new Text(parent, SWT.BORDER); filepathText.setEditable(false); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).hint(100, SWT.DEFAULT) .grab(true, false).applyTo(filepathText); ISWTObservableValue filenameObservable = WidgetProperties.text(SWT.Modify).observe(filepathText); ValueBindingBuilder.bind(filenameObservable) .to(BeanProperties.value(RestoreSnapshotWizardPageModel.PROPERTY_FILEPATH).observe(pageModel)) .in(dbc); Button workspaceButton = new Button(parent, SWT.PUSH); workspaceButton.setText("Workspace..."); GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).hint(100, SWT.DEFAULT) .applyTo(workspaceButton); workspaceButton.addSelectionListener(onWorkspace()); Button browseButton = new Button(parent, SWT.PUSH); browseButton.setText("Browse..."); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseButton); browseButton.addSelectionListener(onBrowse()); // hot-deploy Button hotDeployButton = new Button(parent, SWT.CHECK); hotDeployButton.setText("Use Hot Deployment"); GridDataFactory.fillDefaults().span(5, 1).align(SWT.FILL, SWT.CENTER).applyTo(hotDeployButton); ValueBindingBuilder.bind(WidgetProperties.selection().observe(hotDeployButton)) .to(BeanProperties.value(RestoreSnapshotWizardPageModel.PROPERTY_HOT_DEPLOY).observe(pageModel)) .in(dbc); MultiValidator filenameValidator = new FilepathValidator(filenameObservable); dbc.addValidationStatusProvider(filenameValidator); ControlDecorationSupport.create(filenameValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); // vertical filler GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(3, 1).grab(true, true) .applyTo(new Composite(parent, SWT.None)); }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.snapshot.SaveSnapshotWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { // snapshot type GridLayoutFactory.fillDefaults().numColumns(5).margins(10, 10).applyTo(parent); Label snapshotTypeLabel = new Label(parent, SWT.None); snapshotTypeLabel.setText("Snapshot Type:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(snapshotTypeLabel); Button fullSnapshotButton = new Button(parent, SWT.RADIO); fullSnapshotButton.setText("Full"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(fullSnapshotButton); ValueBindingBuilder.bind(WidgetProperties.selection().observe(fullSnapshotButton)) .converting(new InvertingBooleanConverter()).to(BeanProperties .value(SaveSnapshotWizardPageModel.PROPERTY_DEPLOYMENT_SNAPSHOT).observe(pageModel)) .converting(new InvertingBooleanConverter()).in(dbc); Button deploymentSnapshotButton = new Button(parent, SWT.RADIO); deploymentSnapshotButton.setText("Deployment"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(deploymentSnapshotButton); ValueBindingBuilder/*from w w w . j a va2 s. c o m*/ .bind(WidgetProperties.selection().observe(deploymentSnapshotButton)).to(BeanProperties .value(SaveSnapshotWizardPageModel.PROPERTY_DEPLOYMENT_SNAPSHOT).observe(pageModel)) .in(dbc); // horizontal fillers GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(new Composite(parent, SWT.None)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(new Composite(parent, SWT.None)); // destination Label filepathLabel = new Label(parent, SWT.None); filepathLabel.setText("Destination:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(filepathLabel); Text filepathText = new Text(parent, SWT.BORDER); filepathText.setEditable(false); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).hint(200, SWT.DEFAULT) .grab(true, false).applyTo(filepathText); ISWTObservableValue filenameObservable = WidgetProperties.text(SWT.Modify).observe(filepathText); ValueBindingBuilder.bind(filenameObservable) .to(BeanProperties.value(SaveSnapshotWizardPageModel.PROPERTY_FILEPATH).observe(pageModel)).in(dbc); Button workspaceButton = new Button(parent, SWT.PUSH); workspaceButton.setText("Workspace..."); GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).hint(100, SWT.DEFAULT) .applyTo(workspaceButton); workspaceButton.addSelectionListener(onWorkspace()); Button browseButton = new Button(parent, SWT.PUSH); browseButton.setText("Browse..."); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseButton); browseButton.addSelectionListener(onBrowse()); MultiValidator filenameValidator = new FilenameValidator(filenameObservable); dbc.addValidationStatusProvider(filenameValidator); ControlDecorationSupport.create(filenameValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); // vertical filler GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(3, 1).grab(true, true) .applyTo(new Composite(parent, SWT.None)); }
From source file:org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPage.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from w w w .j ava2s . c o m protected void doCreateControls(final Composite parent, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent); // userdoc link (JBIDE-20401) this.userdocLink = new StyledText(parent, SWT.WRAP); // text set in #showHideUserdocLink 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.DEFAULT); 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.DEFAULT); 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()); 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(); }
From source file:org.jboss.tools.openshift.internal.ui.portforwading.PortForwardingWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(parent); Composite container = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(container); Composite tableContainer = new Composite(container, SWT.NONE); final TableViewer viewer = createTable(tableContainer, dbc); GridDataFactory.fillDefaults().span(1, 3).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(tableContainer);//ww w .j av a 2 s. c o m final Button startButton = new Button(container, SWT.PUSH); startButton.setText("Start All"); GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).align(SWT.FILL, SWT.TOP).applyTo(startButton); startButton.addSelectionListener(onStartPortForwarding(viewer)); final Button stopButton = new Button(container, SWT.PUSH); stopButton.setText("Stop All"); GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).align(SWT.FILL, SWT.TOP).applyTo(stopButton); stopButton.addSelectionListener(onStopPortForwarding(viewer)); final Button findFreesPortButton = new Button(container, SWT.CHECK); findFreesPortButton.setText("Find free local ports for remote ports"); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(false, false) .applyTo(findFreesPortButton); final IObservableValue findFreePortsButtonObservable = BeanProperties .value(PortForwardingWizardModel.PROPERTY_USE_FREE_PORTS).observe(wizardModel); final IObservableValue findFreePortsButtonSelection = WidgetProperties.selection() .observe(findFreesPortButton); dbc.bindValue(findFreePortsButtonSelection, findFreePortsButtonObservable); DataBindingUtils.addDisposableValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { refreshViewerInput(viewer); } }, findFreePortsButtonObservable, viewer.getTable()); // enabling/disabling controls IObservableValue portForwardingStartedObservable = BeanProperties .value(PortForwardingWizardModel.PROPERTY_PORT_FORWARDING).observe(wizardModel); IObservableValue portForwardingAllowedObservable = BeanProperties .value(PortForwardingWizardModel.PROPERTY_PORT_FORWARDING_ALLOWED).observe(wizardModel); IObservableValue freePortSearchAllowedObservable = BeanProperties .value(PortForwardingWizardModel.PROPERTY_FREE_PORT_SEARCH_ALLOWED).observe(wizardModel); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(startButton)) .notUpdating(portForwardingAllowedObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(stopButton)) .notUpdating(portForwardingStartedObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(findFreesPortButton)) .notUpdating(freePortSearchAllowedObservable).in(dbc); }
From source file:org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPage.java
License:Open Source License
private void createDeploymentControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {/* www .j a va 2 s. com*/ Button useInferredPodPathButton = new Button(container, SWT.CHECK); useInferredPodPathButton.setText("&Use inferred Pod Deployment Path"); GridDataFactory.fillDefaults().span(4, 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().span(3, 1).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); }
From source file:org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPage.java
License:Open Source License
private void createRouteControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {/*www. ja v a 2s . c om*/ Group routeGroup = new Group(container, SWT.NONE); routeGroup.setText("Route"); GridDataFactory.fillDefaults().span(4, 1).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)); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.connection.BasicAuthenticationDetailView.java
License:Open Source License
@Override public void onVisible(IObservableValue detailsViewModel, DataBindingContext dbc) { dbc.addValidationStatusProvider(connectionValidator); bindWidgetsToInternalModel(dbc);/* w w w . j av a2 s .co m*/ this.rememberPasswordBinding = ValueBindingBuilder .bind(WidgetProperties.selection().observe(rememberPasswordCheckbox)).to(rememberPasswordObservable) .in(dbc); }