List of usage examples for org.eclipse.jface.databinding.viewers ViewerProperties singlePostSelection
public static IViewerValueProperty singlePostSelection()
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.SelectApplicationWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(parent); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent); Label existingApplicationsLabel = new Label(parent, SWT.NONE); existingApplicationsLabel.setText("Existing Applications:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).applyTo(existingApplicationsLabel); // applications tree this.applicationsTreeViewer = createApplicationsTree(parent, dbc); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 200).span(1, 4) .applyTo(applicationsTreeViewer.getControl()); Binding selectedApplicationBinding = ValueBindingBuilder .bind(ViewerProperties.singlePostSelection().observe(applicationsTreeViewer)) .validatingAfterGet(new IValidator() { @Override/*from ww w. ja va 2s . c o m*/ public IStatus validate(Object value) { if (!(value instanceof IApplication)) { return ValidationStatus .cancel("Please choose the existing application that you want to import."); } return ValidationStatus.ok(); } }).to(BeanProperties.value(SelectApplicationWizardPageModel.PROPERTY_SELECTED_APPLICATION) .observe(pageModel)) .in(dbc); ControlDecorationSupport.create(selectedApplicationBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true)); // buttons Button detailsButton = new Button(parent, SWT.PUSH); detailsButton.setText("De&tails..."); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).hint(80, SWT.DEFAULT).applyTo(detailsButton); DataBindingUtils.bindEnablementToValidationStatus(detailsButton, IStatus.OK, dbc, selectedApplicationBinding); detailsButton.addSelectionListener(onDetails(dbc)); Control filler = new Label(parent, SWT.NONE); GridDataFactory.fillDefaults().applyTo(filler); Button refreshButton = new Button(parent, SWT.PUSH); refreshButton.setText("R&efresh"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(refreshButton); refreshButton.addSelectionListener(onRefresh(dbc)); filler = new Label(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(false, true).applyTo(filler); }
From source file:org.jboss.tools.openshift.express.internal.ui.wizard.embed.EmbeddedCartridgesWizardPage.java
License:Open Source License
@Override protected void doCreateControls(Composite parent, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(parent); Composite tableContainer = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(500, 400) .applyTo(tableContainer);//from ww w .j a v a 2s. c o m CheckboxTableViewer viewer = createCartridgesTableViewer(tableContainer); viewer.setInput(BeanProperties.list(EmbeddedCartridgesWizardPageModel.PROPERTY_EMBEDDABLE_CARTRIDGES) .observe(pageModel)); // directly bind UI to model so that UI/model are synced (we'd have to update UI with strategy results otherwise) dbc.bindSet(ViewerProperties.checkedElements(ICartridge.class).observe(viewer), BeanProperties .set(EmbeddedCartridgesWizardPageModel.PROPERTY_CHECKED_CARTRIDGES).observe(pageModel)); // strategy has to be attached after the binding, so that the binding // can still add the checked cartridge and the strategy can correct viewer.addCheckStateListener(onCartridgeChecked(pageModel, this)); IObservableValue selectedCartridgeObservable = BeanProperties .value(EmbeddedCartridgesWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel); ValueBindingBuilder.bind(ViewerProperties.singlePostSelection().observe(viewer)) .to(selectedCartridgeObservable).in(dbc); createButtons(parent, dbc); // selected cartridge details Group cartridgeDetailsGroup = new Group(parent, SWT.NONE); cartridgeDetailsGroup.setText(" Selected Cartridge: "); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 140) .applyTo(cartridgeDetailsGroup); new CartridgeDetailViews(selectedCartridgeObservable, BeanProperties.value(ApplicationConfigurationWizardPageModel.PROPERTY_CAN_ADDREMOVE_CARTRIDGES) .observe(pageModel), cartridgeDetailsGroup, dbc).createControls(); }