List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties enabled
public static IWidgetValueProperty enabled()
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.ApplicationTemplateWizardPage.java
License:Open Source License
private void createNewApplicationControls(Composite parent, SelectObservableValue useExitingApplication, IObservableValue useExistingApplication, DataBindingContext dbc) { // existing app radio Button newApplicationButton = new Button(parent, SWT.RADIO); newApplicationButton.setText("Create a new OpenShift application:"); newApplicationButton.setToolTipText("If selected we will create a new application in OpenShift."); GridDataFactory.fillDefaults().span(2, 1).indent(0, 8).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(newApplicationButton); useExitingApplication.addOption(Boolean.FALSE, WidgetProperties.selection().observe(newApplicationButton)); // new app explanatory label Label existingAppLabel = new Label(parent, SWT.None); existingAppLabel.setText(/*from w ww. j a v a2 s . co m*/ "You can create an application form scratch or handpick from existing cartridges you need."); existingAppLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND)); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(existingAppLabel); Composite applicationTemplatesTreeComposite = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(applicationTemplatesTreeComposite); GridLayoutFactory.fillDefaults().spacing(2, 2).applyTo(applicationTemplatesTreeComposite); // filter text Text templateFilterText = UIUtils.createSearchText(applicationTemplatesTreeComposite); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(templateFilterText); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(templateFilterText)).notUpdatingParticipant() .to(useExistingApplication).converting(new InvertingBooleanConverter()).in(dbc); // application templates tree final TreeViewer applicationTemplatesViewer = createApplicationTemplatesViewer( applicationTemplatesTreeComposite, templateFilterText); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(400, 180) .applyTo(applicationTemplatesViewer.getControl()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(applicationTemplatesViewer.getControl())) .notUpdatingParticipant().to(useExistingApplication).converting(new InvertingBooleanConverter()) .in(dbc); templateFilterText.addModifyListener(onFilterTextModified(applicationTemplatesViewer)); IObservableValue selectedApplicationTemplateViewerObservable = ViewerProperties.singleSelection() .observe(applicationTemplatesViewer); IObservableValue selectedApplicationTemplateModelObservable = BeanProperties .value(ApplicationTemplateWizardPageModel.PROPERTY_SELECTED_APPLICATION_TEMPLATE) .observe(pageModel); ValueBindingBuilder.bind(selectedApplicationTemplateViewerObservable) .to(selectedApplicationTemplateModelObservable).in(dbc); ApplicationTemplateValidator selectedApplicationTemplateValidator = new ApplicationTemplateValidator( useExitingApplication, selectedApplicationTemplateViewerObservable); dbc.addValidationStatusProvider(selectedApplicationTemplateValidator); ControlDecorationSupport.create(selectedApplicationTemplateValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true)); // selected application template details final Group detailsContainer = new Group(applicationTemplatesTreeComposite, SWT.NONE); detailsContainer.setText("Details"); enableTemplateDetailsControls(detailsContainer, !pageModel.isUseExistingApplication()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 106).applyTo(detailsContainer); useExistingApplication.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { final Boolean enabled = Boolean.FALSE.equals(event.diff.getNewValue()); enableTemplateDetailsControls(detailsContainer, enabled); } }); new ApplicationTemplateDetailViews(selectedApplicationTemplateModelObservable, useExitingApplication, detailsContainer, dbc).createControls(); }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.GitCloningSettingsWizardPage.java
License:Open Source License
private Composite createCloneGroup(Composite parent, DataBindingContext dbc) { Group cloneGroup = new Group(parent, SWT.NONE); cloneGroup.setText("Cloning settings"); cloneGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).margins(10, 10).applyTo(cloneGroup); // Repo Path Management useDefaultRepoPathButton = new Button(cloneGroup, SWT.CHECK); useDefaultRepoPathButton.setText("Use default location"); useDefaultRepoPathButton.setToolTipText("Uncheck if you want to use a custom location for your project"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(useDefaultRepoPathButton); Label labelForRepoPath = new Label(cloneGroup, SWT.NONE); labelForRepoPath.setText("Location:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(false, false).indent(10, 0) .applyTo(labelForRepoPath);/* w ww . j a v a 2 s . c o m*/ final Text repoPathText = new Text(cloneGroup, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(repoPathText); final IObservableValue repoPathObservable = WidgetProperties.text(SWT.Modify).observe(repoPathText); final IObservableValue repoPathModelObservable = BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_REPO_PATH).observe(pageModel); ValueBindingBuilder.bind(repoPathObservable).to(repoPathModelObservable).in(dbc); Button browseRepoPathButton = new Button(cloneGroup, SWT.PUSH); browseRepoPathButton.setText("Browse..."); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT) .applyTo(browseRepoPathButton); browseRepoPathButton.addSelectionListener(onRepoPath()); final IObservableValue isDefaultRepoObservable = WidgetProperties.selection() .observe(useDefaultRepoPathButton); final IObservableValue useDefaultRepoModelObservable = BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_USE_DEFAULT_REPO_PATH).observe(pageModel); ValueBindingBuilder.bind(isDefaultRepoObservable).to(useDefaultRepoModelObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(repoPathText)) .notUpdating(useDefaultRepoModelObservable).converting(new InvertingBooleanConverter()).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseRepoPathButton)) .notUpdating(useDefaultRepoModelObservable).converting(new InvertingBooleanConverter()).in(dbc); // move focus to the project location text control when not choosing the // 'Use default location' option. UIUtils.focusOnSelection(useDefaultRepoPathButton, repoPathText); final IObservableValue applicationNameModelObservable = BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_APPLICATION_NAME).observe(pageModel); final IObservableValue newProjectModelObservable = BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_NEW_PROJECT).observe(pageModel); this.repoPathValidator = new RepoPathValidationStatusProvider(repoPathObservable, applicationNameModelObservable, newProjectModelObservable); dbc.addValidationStatusProvider(repoPathValidator); ControlDecorationSupport.create(repoPathValidator, SWT.LEFT | SWT.TOP); // Remote Name Management useDefaultRemoteNameButton = new Button(cloneGroup, SWT.CHECK); useDefaultRemoteNameButton.setText("Use default remote name"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(useDefaultRemoteNameButton); this.remoteNameLabel = new Label(cloneGroup, SWT.NONE); remoteNameLabel.setText("Remote name:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(false, false).indent(10, 0) .applyTo(remoteNameLabel); remoteNameText = new Text(cloneGroup, SWT.BORDER); GridDataFactory.fillDefaults().span(1, 1).align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER) .grab(true, false).applyTo(remoteNameText); final IObservableValue remoteNameTextObservable = WidgetProperties.text(SWT.Modify).observe(remoteNameText); final IObservableValue remoteNameModelObservable = BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_REMOTE_NAME).observe(pageModel); ValueBindingBuilder.bind(remoteNameTextObservable).to(remoteNameModelObservable).in(dbc); final IObservableValue useDefaultRemoteNameModelObservable = BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_USE_DEFAULT_REMOTE_NAME).observe(pageModel); final IObservableValue useDefaultRemoteNameObservable = WidgetProperties.selection() .observe(useDefaultRemoteNameButton); ValueBindingBuilder.bind(useDefaultRemoteNameObservable).to(useDefaultRemoteNameModelObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(remoteNameText)) .notUpdating(useDefaultRemoteNameModelObservable).converting(new InvertingBooleanConverter()) .in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(remoteNameLabel)) .notUpdating(useDefaultRemoteNameModelObservable).converting(new InvertingBooleanConverter()) .in(dbc); // move focus to the project name text control when choosing the 'Use an // existing project' option. useDefaultRemoteNameButton.addSelectionListener(onDefaultRemoteNameUnchecked()); final IObservableValue projectNameModelObservable = BeanProperties .value(IOpenShiftExpressWizardModel.PROJECT_NAME).observe(wizardModel); dbc.addValidationStatusProvider( new RemoteNameValidationStatusProvider(remoteNameTextObservable, projectNameModelObservable)); this.sshLink = new Link(parent, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).indent(10, 0).applyTo(sshLink); sshLink.addSelectionListener(onSshPrefs("SSH2 Preferences")); sshLink.addSelectionListener(onManageSSHKeys("SSH Keys wizard", dbc)); // we need a binding to have validation setting wizard validation status Label dummyLabel = new Label(parent, SWT.None); dummyLabel.setVisible(false); GridDataFactory.fillDefaults().exclude(true).applyTo(dummyLabel); ValueBindingBuilder .bind(WidgetProperties.text().observe(dummyLabel)).notUpdating(BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_HAS_REMOTEKEYS).observe(pageModel)) .validatingAfterGet(new IValidator() { @Override public IStatus validate(Object value) { if (!(value instanceof Boolean)) { return ValidationStatus.ok(); } Boolean hasRemoteKeys = (Boolean) value; if (hasRemoteKeys) { return ValidationStatus.ok(); } else { return ValidationStatus .error("No public keys found in your account. Please use the SSH keys wizard."); } } }).in(dbc); refreshHasRemoteKeys(dbc); return cloneGroup; }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.ProjectAndServerAdapterSettingsWizardPage.java
License:Open Source License
private Composite createProjectGroup(Composite parent, DataBindingContext dbc) { Composite projectGroup = new Composite(parent, SWT.NONE); // projectGroup.setText("Project"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(projectGroup);//www.j av a 2 s . c om GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(projectGroup); // new project checkbox Button newProjectRadioBtn = new Button(projectGroup, SWT.CHECK); newProjectRadioBtn.setText("Create a new project"); newProjectRadioBtn.setToolTipText( "The OpenShift application code will be pulled into the newly created project or merged into the selected one."); newProjectRadioBtn.setFocus(); GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(false, false) .applyTo(newProjectRadioBtn); final IObservableValue newProjectObservable = BeanProperties .value(ProjectAndServerAdapterSettingsWizardPageModel.PROPERTY_IS_NEW_PROJECT).observe(pageModel); final ISWTObservableValue newProjectRadioBtnSelection = WidgetProperties.selection() .observe(newProjectRadioBtn); dbc.bindValue(newProjectRadioBtnSelection, newProjectObservable); // existing project Label existingProjectLabel = new Label(projectGroup, SWT.NONE); existingProjectLabel.setText("Use existing project:"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(false, false).indent(10, 0) .applyTo(existingProjectLabel); existingProjectNameText = new Text(projectGroup, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false) .applyTo(existingProjectNameText); final IObservableValue projectNameModelObservable = BeanProperties .value(ProjectAndServerAdapterSettingsWizardPageModel.PROPERTY_PROJECT_NAME).observe(pageModel); final ISWTObservableValue existingProjectNameTextObservable = WidgetProperties.text(SWT.Modify) .observe(existingProjectNameText); ValueBindingBuilder.bind(existingProjectNameTextObservable).to(projectNameModelObservable).in(dbc); // disable the project name text when the model state is set to 'new project' ValueBindingBuilder.bind(WidgetProperties.enabled().observe(existingProjectNameText)) .notUpdating(newProjectObservable).converting(new InvertingBooleanConverter()).in(dbc); // move focus to the project name text control when choosing the 'Use an existing project' option. newProjectRadioBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { existingProjectNameText.setFocus(); existingProjectNameText.selectAll(); } }); // let's provide content assist on the existing project name ControlDecoration dec = new ControlDecoration(existingProjectNameText, SWT.TOP | SWT.LEFT); FieldDecoration contentProposalFieldIndicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); dec.setImage(contentProposalFieldIndicator.getImage()); dec.setDescriptionText("Auto-completion is enabled when you start typing a project name."); dec.setShowOnlyOnFocus(true); AutoCompleteField adapter = new AutoCompleteField(existingProjectNameText, new TextContentAdapter(), new String[] {}); adapter.setProposals(getOpenProjectsInWorkspace()); Button browseProjectsButton = new Button(projectGroup, SWT.NONE); browseProjectsButton.setText("Browse..."); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).span(1, 1) .grab(false, false).applyTo(browseProjectsButton); browseProjectsButton.addSelectionListener(onBrowseProjects()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseProjectsButton)) .notUpdating(newProjectObservable).converting(new InvertingBooleanConverter()).in(dbc); final IObservableValue applicationNameModelObservable = BeanProperties .value(GitCloningSettingsWizardPageModel.PROPERTY_APPLICATION_NAME).observe(pageModel); final UseExistingOpenProjectValidator existingProjectValidator = new UseExistingOpenProjectValidator( applicationNameModelObservable, newProjectObservable, projectNameModelObservable); dbc.addValidationStatusProvider(existingProjectValidator); ControlDecorationSupport.create(existingProjectValidator, SWT.LEFT | SWT.TOP); return projectGroup; }
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);/*from w w w . j av a 2 s . co 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.domain.ManageDomainsWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(parent); Group domainsGroup = new Group(parent, SWT.NONE); domainsGroup.setText("Domains"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(domainsGroup); GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(domainsGroup); // domains table Composite tableContainer = new Composite(domainsGroup, SWT.NONE); this.viewer = createTable(tableContainer); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(tableContainer);/* w w w . j a v a 2 s .c o m*/ viewer.setContentProvider(new ObservableListContentProvider()); viewer.setInput(BeanProperties.list(ManageDomainsWizardPageModel.PROPERTY_DOMAINS).observe(pageModel)); loadDomains(dbc); IObservableValue viewerSingleSelection = ViewerProperties.singleSelection().observe(viewer); ValueBindingBuilder.bind(viewerSingleSelection) .to(BeanProperties.value(ManageDomainsWizardPageModel.PROPERTY_SELECTED_DOMAIN).observe(pageModel)) .in(dbc); // new domain Button newButton = new Button(domainsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(newButton); newButton.setText("New..."); newButton.addSelectionListener(onNew(dbc)); // edit domain Button editButton = new Button(domainsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(editButton); editButton.setText("Edit..."); editButton.addSelectionListener(onEdit(dbc)); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(editButton)).notUpdatingParticipant() .to(viewerSingleSelection).converting(new IsNotNull2BooleanConverter()).in(dbc); // remove Button removeButton = new Button(domainsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(removeButton); removeButton.setText("Remove..."); removeButton.addSelectionListener(onRemove(dbc)); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(removeButton)).notUpdatingParticipant() .to(viewerSingleSelection).converting(new IsNotNull2BooleanConverter()).in(dbc); Composite filler = new Composite(domainsGroup, SWT.None); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(filler); // refresh Button refreshButton = new Button(domainsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.END).applyTo(refreshButton); refreshButton.setText("Refresh..."); refreshButton.addSelectionListener(onRefresh(dbc)); }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.environment.EnvironmentVariablesWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite container, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(container); Group envVariableGroup = new Group(container, SWT.NONE); envVariableGroup.setText(ExpressUIMessages.EnvironmentVariables); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(envVariableGroup); GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(envVariableGroup); Composite tableContainer = new Composite(envVariableGroup, SWT.NONE); this.viewer = createTable(tableContainer); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(tableContainer);/* w w w . j a va 2s. com*/ ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(viewer)) .to(BeanProperties.value(AbstractEnvironmentVariablesWizardModel.PROPERTY_SELECTED).observe(model)) .in(dbc); viewer.setComparator(new ViewerComparator()); viewer.setContentProvider(new ObservableListContentProvider()); viewer.setInput( BeanProperties.list(AbstractEnvironmentVariablesWizardModel.PROPERTY_VARIABLES).observe(model)); Button addButton = new Button(envVariableGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(addButton); addButton.setText(ExpressUIMessages.Add); addButton.addSelectionListener(onAdd()); Button editExistingButton = new Button(envVariableGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(editExistingButton); editExistingButton.setText(ExpressUIMessages.Edit); editExistingButton.addSelectionListener(onEdit()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(editExistingButton)).notUpdatingParticipant() .to(BeanProperties.value(AbstractEnvironmentVariablesWizardModel.PROPERTY_SELECTED).observe(model)) .converting(new IsNotNull2BooleanConverter()).in(dbc); Button removeButton = new Button(envVariableGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(removeButton); removeButton.setText(ExpressUIMessages.Remove); removeButton.addSelectionListener(onRemove()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(removeButton)).notUpdatingParticipant() .to(BeanProperties.value(AbstractEnvironmentVariablesWizardModel.PROPERTY_SELECTED).observe(model)) .converting(new IsNotNull2BooleanConverter()).in(dbc); Label filler = new Label(envVariableGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, true).applyTo(filler); Button refreshButton = new Button(envVariableGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(refreshButton); refreshButton.setText(ExpressUIMessages.Refresh); refreshButton.addSelectionListener(onRefresh()); // not supported enableEnvVariableGroup(model.isSupported(), envVariableGroup); Label validationLabel = new Label(envVariableGroup, SWT.NONE); validationLabel.setVisible(false); GridDataFactory.fillDefaults().exclude(true).applyTo(validationLabel); ValueBindingBuilder .bind(WidgetProperties.enabled().observe(validationLabel)).notUpdating(BeanProperties .value(AbstractEnvironmentVariablesWizardModel.PROPERTY_SUPPORTED).observe(model)) .validatingAfterGet(new IValidator() { @Override public IStatus validate(Object value) { if (Boolean.FALSE.equals((Boolean) value)) { return ValidationStatus.warning( NLS.bind(ExpressUIMessages.ServerDoesNotSupportChanging, model.getHost())); } return ValidationStatus.ok(); } }).in(dbc); }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.ssh.ManageSSHKeysWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(parent); Group sshKeysGroup = new Group(parent, SWT.NONE); sshKeysGroup.setText("SSH Public Keys"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sshKeysGroup); GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(sshKeysGroup); Composite tableContainer = new Composite(sshKeysGroup, SWT.NONE); this.viewer = createTable(tableContainer); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(tableContainer);//from w w w . j a v a 2 s. co m ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(viewer)) .to(BeanProperties.value(ManageSSHKeysWizardPageModel.PROPERTY_SELECTED_KEY).observe(pageModel)) .in(dbc); Button addExistingButton = new Button(sshKeysGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(addExistingButton); addExistingButton.setText("Add Existing..."); addExistingButton.addSelectionListener(onAddExisting()); Button addNewButton = new Button(sshKeysGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(addNewButton); addNewButton.setText("New..."); addNewButton.addSelectionListener(onAddNew()); Button removeButton = new Button(sshKeysGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(removeButton); removeButton.setText("Remove..."); removeButton.addSelectionListener(onRemove()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(removeButton)) .to(ViewerProperties.singleSelection().observe(viewer)) .converting(new Converter(IOpenShiftSSHKey.class, Boolean.class) { @Override public Object convert(Object fromObject) { IOpenShiftSSHKey key = (IOpenShiftSSHKey) fromObject; return key != null; } }).in(dbc); Composite filler = new Composite(sshKeysGroup, SWT.None); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(filler); Button refreshButton = new Button(sshKeysGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.END).applyTo(refreshButton); refreshButton.setText("Refresh..."); refreshButton.addSelectionListener(onRefresh()); Link sshPrefsLink = new Link(parent, SWT.NONE); sshPrefsLink.setText( "Please make sure that your private keys for these public keys are listed in the\n<a>SSH2 Preferences</a>"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(sshPrefsLink); sshPrefsLink.addSelectionListener(onSshPrefs()); }
From source file:org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPage.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from w ww . jav a2 s. 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);/* w w w . j a v 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) {/*from w ww . j a v a 2 s . c om*/ 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); }