List of usage examples for org.eclipse.jface.databinding.viewers ViewerProperties singleSelection
public static IViewerValueProperty singleSelection()
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);/*from w w w. j a va 2s . 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);// ww w. j a va 2s . c o m 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.markers.ConfigureMarkersWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(parent); // markers table Composite tableContainer = new Composite(parent, SWT.NONE); this.viewer = createTable(tableContainer); GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 250).grab(true, true) .applyTo(tableContainer);/* ww w . jav a2 s . co m*/ dbc.bindSet(ViewerProperties.checkedElements(IOpenShiftMarker.class).observe(viewer), BeanProperties.set(ConfigureMarkersWizardPageModel.PROPERTY_CHECKED_MARKERS).observe(pageModel)); ValueBindingBuilder .bind(ViewerProperties.singleSelection().observe(viewer)).to(BeanProperties .value(ConfigureMarkersWizardPageModel.PROPERTY_SELECTED_MARKER).observe(pageModel)) .in(dbc); // marker description Group descriptionGroup = new Group(parent, SWT.NONE); descriptionGroup.setText("Marker Description"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(descriptionGroup); GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(descriptionGroup); StyledText descriptionText = new StyledText(descriptionGroup, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY); descriptionText.setAlwaysShowScrollBars(false); StyledTextUtils.setTransparent(descriptionText); GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 80).align(SWT.FILL, SWT.FILL).grab(true, false) .applyTo(descriptionText); dbc.bindSet(ViewersObservables.observeCheckedElements(viewer, IOpenShiftMarker.class), BeanProperties.set(ConfigureMarkersWizardPageModel.PROPERTY_CHECKED_MARKERS).observe(pageModel)); ValueBindingBuilder .bind(WidgetProperties.text().observe(descriptionText)).notUpdating(BeanProperties .value(ConfigureMarkersWizardPageModel.PROPERTY_SELECTED_MARKER).observe(pageModel)) .converting(new Converter(IOpenShiftMarker.class, String.class) { @Override public Object convert(Object fromObject) { if (!(fromObject instanceof BaseOpenShiftMarker)) { return null; } return ((IOpenShiftMarker) fromObject).getDescription(); } }).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);/*ww w. ja va 2 s . c o 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.express.internal.ui.wizard.ssh.NewSSHKeyWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(parent); Group newSSHKeyGroup = new Group(parent, SWT.NONE); newSSHKeyGroup.setText("New SSH Key"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newSSHKeyGroup); GridLayoutFactory.fillDefaults().numColumns(4).margins(6, 6).applyTo(newSSHKeyGroup); Label nameLabel = new Label(newSSHKeyGroup, SWT.NONE); nameLabel.setText("Name:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel); Text nameText = new Text(newSSHKeyGroup, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(3, 1).applyTo(nameText); Binding nameBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(nameText)) .validatingAfterConvert(new SSHPublicKeyNameValidator(pageModel)) .to(BeanProperties.value(NewSSHKeyWizardPageModel.PROPERTY_NAME).observe(pageModel)) .notUpdatingParticipant().in(dbc); ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); Label typeLabel = new Label(newSSHKeyGroup, SWT.NONE); typeLabel.setText("Key Type:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(typeLabel); ComboViewer typeCombo = new ComboViewer(newSSHKeyGroup, SWT.READ_ONLY); typeCombo.setContentProvider(ArrayContentProvider.getInstance()); typeCombo.setInput(SSHKeyType.values()); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(typeCombo.getControl()); ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(typeCombo)) .to(BeanProperties.value(NewSSHKeyWizardPageModel.PROPERTY_TYPE).observe(pageModel)).in(dbc); Label fillerLabel = new Label(newSSHKeyGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).applyTo(fillerLabel); Label ssh2HomeLabel = new Label(newSSHKeyGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(ssh2HomeLabel); ssh2HomeLabel.setText("SSH2 Home:"); Text ssh2HomeText = new Text(newSSHKeyGroup, SWT.BORDER); ssh2HomeText.setEditable(false);//from w ww . j ava2s.c o m GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(ssh2HomeText); Binding ssh2HomeBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(ssh2HomeText)) .validatingAfterConvert(new DirectoryValidator("ssh2 home directory")) .to(BeanProperties.value(NewSSHKeyWizardPageModel.PROPERTY_SSH2_HOME).observe(pageModel)).in(dbc); ControlDecorationSupport.create(ssh2HomeBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); Button ssh2HomeBrowseButton = new Button(newSSHKeyGroup, SWT.PUSH); ssh2HomeBrowseButton.setText("Browse..."); ssh2HomeBrowseButton.addSelectionListener(onBrowse(ssh2HomeText)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(ssh2HomeBrowseButton); Button defaultSSH2HomeHomeButton = new Button(newSSHKeyGroup, SWT.CHECK); defaultSSH2HomeHomeButton.setText("Default"); defaultSSH2HomeHomeButton.addSelectionListener(onDefault(ssh2HomeText, ssh2HomeBrowseButton)); defaultSSH2HomeHomeButton.setSelection(true); updateSSH2HomeWidgets(true, ssh2HomeText, ssh2HomeBrowseButton); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(ssh2HomeBrowseButton); Label privateKeyLabel = new Label(newSSHKeyGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(privateKeyLabel); privateKeyLabel.setText("Private Key:"); Text privateKeyText = new Text(newSSHKeyGroup, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(3, 1) .applyTo(privateKeyText); Binding privateKeyBinding = ValueBindingBuilder .bind(WidgetProperties.text(SWT.Modify).observe(privateKeyText)) .validatingAfterConvert(new FileNameValidator()) .to(BeanProperties.value(NewSSHKeyWizardPageModel.PROPERTY_PRIVATEKEY_FILENAME).observe(pageModel)) .in(dbc); ControlDecorationSupport.create(privateKeyBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); Label passphraseLabel = new Label(newSSHKeyGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(passphraseLabel); passphraseLabel.setText("Private Key Passphrase:"); Text passphraseText = new Text(newSSHKeyGroup, SWT.BORDER | SWT.PASSWORD); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(3, 1) .applyTo(passphraseText); ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(passphraseText)).to( BeanProperties.value(NewSSHKeyWizardPageModel.PROPERTY_PRIVATEKEY_PASSPHRASE).observe(pageModel)) .in(dbc); Label publicKeyLabel = new Label(newSSHKeyGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(publicKeyLabel); publicKeyLabel.setText("Public Key:"); Text publicKeyText = new Text(newSSHKeyGroup, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(3, 1) .applyTo(publicKeyText); Binding publicKeyBinding = ValueBindingBuilder .bind(WidgetProperties.text(SWT.Modify).observe(publicKeyText)) .validatingAfterConvert(new FileNameValidator()) .to(BeanProperties.value(NewSSHKeyWizardPageModel.PROPERTY_PUBLICKEY_FILENAME).observe(pageModel)) .in(dbc); ControlDecorationSupport.create(publicKeyBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater()); Link sshPrefsLink = new Link(parent, SWT.NONE); sshPrefsLink.setText( "The private key of your new SSH key pair will get added to 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 ww w. ja v a 2 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.handler.EditResourceLimitsPage.java
License:Open Source License
private void createResourceWidgets(String label, String property, String[] suffixes, String[] labels, Group parent, DataBindingContext dbc) { // label/*from ww w . ja va2 s . c o m*/ Label labelComp = new Label(parent, SWT.NONE); labelComp.setText(label); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(labelComp); // value text Text text = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(text); // unit combo ComboViewer combo = new ComboViewer(parent); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(140, SWT.DEFAULT) .applyTo(combo.getControl()); combo.setContentProvider(ArrayContentProvider.getInstance()); combo.setInput(suffixes); combo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return getLabelForSuffix(element, suffixes, labels); } private String getLabelForSuffix(Object element, String[] suffixes, String[] labels) { String label = (String) element; for (int i = 0; i < suffixes.length; ++i) { if (element.equals(suffixes[i])) { label = labels[i]; break; } } return label; } }); IObservableValue<String> valueObservable = WidgetProperties.text(SWT.Modify).observe(text); IObservableValue<String> selectedUnitObservable = ViewerProperties.singleSelection().observe(combo); IObservableValue<IContainer> master = BeanProperties.value(EditResourceLimitsPageModel.SELECTED_CONTAINER) .observe(model); ValueBindingBuilder.bind(valueObservable) .validatingAfterGet(new NumericValidator("integer", Integer::parseInt)) .converting(new AggregatingConverter(selectedUnitObservable, true)) .to(PojoProperties.value(property).observeDetail(master)) .converting(new KeywordConverter(suffixes, true)).in(dbc); ValueBindingBuilder.bind(selectedUnitObservable) .converting(new AggregatingConverter(valueObservable, false)) .to(PojoProperties.value(property).observeDetail(master)) .converting(new KeywordConverter(suffixes, false)).in(dbc); }
From source file:org.jboss.tools.openshift.internal.ui.server.OpenShiftServerEditorSection.java
License:Open Source License
private void createConnectionContols(Composite parent, DataBindingContext dbc) { Label connectionLabel = new Label(parent, SWT.NONE); connectionLabel.setText("Connection:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(connectionLabel); Combo connectionCombo = new Combo(parent, SWT.DEFAULT); ComboViewer connectionViewer = new ComboViewer(connectionCombo); connectionViewer.setContentProvider(new ObservableListContentProvider()); connectionViewer.setLabelProvider(new ConnectionColumLabelProvider()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(connectionCombo); connectionViewer//from w ww . j a va2 s.c om .setInput(BeanProperties.list(OpenShiftServerEditorModel.PROPERTY_CONNECTIONS).observe(model)); Binding connectionBinding = ValueBindingBuilder .bind(ViewerProperties.singleSelection().observe(connectionViewer)) .validatingAfterGet(new IValidator() { @Override public IStatus validate(Object value) { if (!(value instanceof Connection)) { return ValidationStatus.cancel("Please select a connection for this server adapter."); } return ValidationStatus.ok(); } }).to(BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_CONNECTION).observe(model)).in(dbc); ControlDecorationSupport.create(connectionBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true)); Button newConnectionButton = new Button(parent, SWT.PUSH); newConnectionButton.setText("New..."); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(100, SWT.DEFAULT) .applyTo(newConnectionButton); newConnectionButton.addSelectionListener(onNewConnection(connectionViewer)); }
From source file:org.jboss.tools.openshift.internal.ui.server.OpenShiftServerEditorSection.java
License:Open Source License
private void createProjectControls(Composite parent, DataBindingContext dbc) { Label projectLabel = new Label(parent, SWT.NONE); projectLabel.setText("Eclipse Project: "); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(projectLabel); StructuredViewer projectsViewer = new ComboViewer(parent); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(projectsViewer.getControl()); projectsViewer.setContentProvider(new ObservableListContentProvider()); projectsViewer.setLabelProvider(new ColumnLabelProvider() { @Override/*from ww w .j a v a 2 s. c o m*/ public String getText(Object element) { if (!(element instanceof IProject)) { return null; } return ((IProject) element).getName(); } }); projectsViewer.setInput(BeanProperties.list(OpenShiftServerEditorModel.PROPERTY_PROJECTS).observe(model)); IObservableValue selectedProjectObservable = ViewerProperties.singleSelection().observe(projectsViewer); Binding selectedProjectBinding = ValueBindingBuilder.bind(selectedProjectObservable) .validatingAfterConvert(new IValidator() { @Override public IStatus validate(Object value) { if (value instanceof IProject) { return ValidationStatus.ok(); } return ValidationStatus.cancel("Please choose a project to deploy."); } }).to(BeanProperties.value(OpenShiftServerEditorModel.PROPERTY_DEPLOYPROJECT).observe(model)) .in(dbc); ControlDecorationSupport.create(selectedProjectBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true)); // browse projects Button browseProjectsButton = new Button(parent, SWT.NONE); browseProjectsButton.setText("Browse..."); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT) .applyTo(browseProjectsButton); browseProjectsButton.addSelectionListener(onBrowseProjects(model, browseProjectsButton.getShell())); }
From source file:org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPage.java
License:Open Source License
private void createServiceControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {/* ww w.jav a 2 s.c o m*/ Group servicesGroup = new Group(container, SWT.NONE); servicesGroup.setText("Services"); GridDataFactory.fillDefaults().span(4, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(servicesGroup); GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(servicesGroup); Label selectorLabel = new Label(servicesGroup, SWT.NONE); selectorLabel.setText("Selector:"); Text selectorText = UIUtils.createSearchText(servicesGroup); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(selectorText); final TreeViewer servicesViewer = createServicesTreeViewer(servicesGroup, model, selectorText); IObservableList serviceItemsObservable = BeanProperties .list(ServerSettingsWizardPageModel.PROPERTY_SERVICE_ITEMS).observe(model); DataBindingUtils.addDisposableListChangeListener(onServiceItemsChanged(servicesViewer), serviceItemsObservable, servicesViewer.getTree()); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 160).grab(true, true) .applyTo(servicesViewer.getControl()); selectorText.addModifyListener(onFilterTextModified(servicesViewer)); IViewerObservableValue selectedServiceTreeItem = ViewerProperties.singleSelection().observe(servicesViewer); ValueBindingBuilder.bind(selectedServiceTreeItem) .converting(new ObservableTreeItem2ModelConverter(IService.class)) .validatingAfterConvert(new IValidator() { @Override public IStatus validate(Object value) { if (!(value instanceof IService)) { return ValidationStatus .cancel("Please select a service that this adapter will be bound to."); } return ValidationStatus.ok(); } }).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_SERVICE).observe(model)) .converting(new Model2ObservableTreeItemConverter( new ServerSettingsWizardPageModel.ServiceTreeItemsFactory())) .in(dbc); // details ExpandableComposite expandable = new ExpandableComposite(servicesGroup, SWT.None); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150) .applyTo(expandable); expandable.setText("Service Details"); expandable.setExpanded(true); GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(0, 0).applyTo(expandable); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150) .applyTo(expandable); Composite detailsContainer = new Composite(expandable, SWT.NONE); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150) .applyTo(detailsContainer); IObservableValue<IResource> selectedService = new WritableValue<IResource>(); ValueBindingBuilder.bind(selectedServiceTreeItem).converting(new ObservableTreeItem2ModelConverter()) .to(selectedService).notUpdatingParticipant().in(dbc); new ServiceDetailViews(selectedService, detailsContainer, dbc).createControls(); expandable.setClient(detailsContainer); expandable.addExpansionListener(new IExpansionListener() { @Override public void expansionStateChanging(ExpansionEvent e) { } @Override public void expansionStateChanged(ExpansionEvent e) { servicesGroup.update(); servicesGroup.layout(true); } }); }