List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeItems
@Deprecated public static IObservableList observeItems(Control control)
control
. From source file:org.eclipse.rcptt.ui.report.ReportMainPage.java
License:Open Source License
public void createControl(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(panel); // Report name Label l = new Label(panel, SWT.NONE); l.setText(Messages.ReportMainPage_NameLabel); final Text reportName = new Text(panel, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(reportName); final ControlDecoration controlDecoration = new ControlDecoration(reportName, SWT.LEFT | SWT.TOP); controlDecoration.setDescriptionText(""); //$NON-NLS-1$ FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); controlDecoration.setImage(fieldDecoration.getImage()); controlDecoration.hide();/* www.ja v a2 s. c om*/ dbc.bindValue(SWTObservables.observeText(reportName, SWT.Modify), this.reportName); this.reportName.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { String name = (String) event.getObservableValue().getValue(); if (name.trim().length() == 0) { controlDecoration.show(); controlDecoration.showHoverText(Messages.ReportMainPage_EmptyReportNameMsg); validate(); return; } controlDecoration.hide(); validate(); } }); // Output format: l = new Label(panel, SWT.NONE); l.setText(Messages.ReportMainPage_FormatLabel); Combo reportFormat = new Combo(panel, SWT.BORDER | SWT.READ_ONLY); GridDataFactory.swtDefaults().grab(false, false).applyTo(reportFormat); dbc.bindList(SWTObservables.observeItems(reportFormat), this.reports, new UpdateListStrategy() { @Override public Object convert(Object value) { return convertReport(value); } }, new UpdateListStrategy() { @Override public Object convert(Object value) { return ((ReportRenderer) value).getName(); } }); dbc.bindValue(SWTObservables.observeSelection(reportFormat), this.reportFormat, new UpdateValueStrategy() { @Override public Object convert(Object value) { return convertReport(value); } }, new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value != null) { return ((ReportRenderer) value).getName(); } return null; } }); ReportRenderer defaultRenderer = null; for (int i = 0; i < reports.size(); i++) { ReportRenderer rr = (ReportRenderer) reports.get(i); if (rr.getExtension().equals("html")) { //$NON-NLS-1$ defaultRenderer = rr; break; } } if (defaultRenderer != null) { this.reportFormat.setValue(defaultRenderer); } else { this.reportFormat.setValue(reports.get(0)); } // Output location l = new Label(panel, SWT.NONE); GridDataFactory.fillDefaults().span(2, 1).applyTo(l); Composite sPanel = new Composite(panel, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(sPanel); GridDataFactory.fillDefaults().span(2, 1).applyTo(sPanel); l = new Label(sPanel, SWT.NONE); l.setText(Messages.ReportMainPage_OutputLabel); l = new Label(sPanel, SWT.HORIZONTAL | SWT.SEPARATOR); GridDataFactory.fillDefaults().grab(true, false).applyTo(l); // Generate to workspace createGenerateWorkspace(panel); // Generate to file system createGenerateToFilesystem(panel); setControl(panel); IDialogSettings ds = getDialogSettings(); if (ds != null) { String loc = ds.get("report.dialog.workspace.location"); //$NON-NLS-1$ if (loc != null) { workspaceLocation.setValue(loc); } } if (initialWorkspaceLocation != null) { workspaceLocation.setValue(initialWorkspaceLocation); } validate(); }
From source file:org.eclipse.riena.internal.ui.ridgets.swt.CComboRidget.java
License:Open Source License
@Override protected IObservableList getUIControlItemsObservable() { return SWTObservables.observeItems(getUIControl()); }
From source file:org.objectstyle.wolips.wooeditor.editor.DisplayGroupDetailsPage.java
License:Open Source License
private void bind() { // XXX This method is too long if (myDisplayGroup == null) { return;/*ww w . ja v a 2s . com*/ } myBindingContext = new DataBindingContext(); myBindingContext.bindValue(SWTObservables.observeText(myNameText, SWT.Modify), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.NAME), null, null); myBindingContext.bindList(SWTObservables.observeItems(myClassNameCombo), BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.CLASS_NAME_LIST), null, null); myBindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(myClassNameCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.CLASS_NAME_INDEX), null, null); myBindingContext.bindList(SWTObservables.observeItems(myEntityCombo), BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.ENTITY_LIST), null, null); myBindingContext.bindValue(SWTObservables.observeEnabled(myMasterDetailGroup), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); UpdateValueStrategy booleanInverse = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE) { @Override protected IStatus doSet(final IObservableValue observableValue, final Object value) { Boolean newValue = !(Boolean) value; return super.doSet(observableValue, newValue); } }; myBindingContext.bindValue(SWTObservables.observeEnabled(myEntityCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), booleanInverse); myBindingContext.bindValue(CustomSWTObservables.observeText(myEntityCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.ENTITY_NAME), null, null); myBindingContext.bindValue(SWTObservables.observeEnabled(myEditingContextText), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), booleanInverse); myBindingContext.bindValue(SWTObservables.observeText(myEditingContextText, SWT.Modify), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.EDITING_CONTEXT), null, null); myBindingContext.bindValue(SWTObservables.observeSelection(myHasDetailButton), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL), null, null); myBindingContext.bindList(SWTObservables.observeItems(myMasterEntityCombo), BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.ENTITY_LIST), null, null); myBindingContext.bindValue(CustomSWTObservables.observeText(myMasterEntityCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.MASTER_ENTITY_NAME), null, null); myBindingContext.bindList(SWTObservables.observeItems(myDetailKeyCombo), BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.DETAIL_KEY_LIST), null, null); myBindingContext.bindValue(CustomSWTObservables.observeText(myDetailKeyCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.DETAIL_KEY_NAME), null, null); myBindingContext.bindValue(SWTObservables.observeSelection(myEntriesPerBatchSpinner), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.ENTRIES_PER_BATCH), null, null); myBindingContext.bindValue(SWTObservables.observeSelection(mySelectsFirstObjectButton), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SELECTS_FIRST_OBJECT), null, null); myBindingContext.bindList(SWTObservables.observeItems(myQualificationCombo), BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.QUALIFICATION_LIST), null, null); myBindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(myQualificationCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.QUALIFICATION_INDEX), null, null); myBindingContext.bindValue(SWTObservables.observeSelection(myFetchOnLoadButton), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCHES_ON_LOAD), null, null); myBindingContext.bindList(SWTObservables.observeItems(mySortAttributeCombo), BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.SORT_LIST), null, null); myBindingContext.bindValue(CustomSWTObservables.observeSelection(mySortAttributeCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SORT_ORDER_KEY), null, null); myBindingContext.bindValue(CustomSWTObservables.observeSelection(mySortRadioGroup), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SORT_ORDER), null, null); UpdateValueStrategy fetchSpecEmpty = new UpdateValueStrategy(); fetchSpecEmpty.setConverter(new IConverter() { public Object convert(final Object fromObject) { boolean result = fromObject != null && ((List<?>) fromObject).size() > 0; if (!myHasDetailButton.getSelection()) { return result; } return false; } public Object getFromType() { return new ArrayList<String>(); } public Object getToType() { return true; } }); UpdateValueStrategy fetchSpecEnabled = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE) { @Override protected IStatus doSet(final IObservableValue observableValue, final Object value) { Boolean newValue = false; if (myFetchSpecCombo.getItemCount() > 0) { newValue = !(Boolean) value; } return super.doSet(observableValue, newValue); } }; myBindingContext.bindValue(SWTObservables.observeEnabled(myFetchSpecCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), fetchSpecEnabled); myBindingContext.bindValue(SWTObservables.observeEnabled(myFetchSpecCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCH_SPEC_LIST), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), fetchSpecEmpty); myBindingContext.bindList(SWTObservables.observeItems(myFetchSpecCombo), BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.FETCH_SPEC_LIST), null, null); UpdateValueStrategy fetchSpecSelection = new UpdateValueStrategy() { @Override protected IStatus doSet(IObservableValue observableValue, Object value) { if (value == null || value.equals("")) { value = DisplayGroup.FETCH_SPEC_NONE; } return super.doSet(observableValue, value); } }; myBindingContext.bindValue(CustomSWTObservables.observeSelection(myFetchSpecCombo), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCH_SPEC_NAME), null, fetchSpecSelection); myEntityCombo.addModifyListener(myEntityModifyListener); myMasterEntityCombo.addModifyListener(myMasterEntityListener); mySortAttributeCombo.addSelectionListener(mySortEntityListener); }
From source file:org.reap.internal.core.binding.BindingManager.java
License:Open Source License
private IObservable createSWTObservable(final Control control, final BindingConfig binding) { IObservable obs = null;//from w ww. j ava 2 s. com switch (binding.getType()) { case BACKGROUND: obs = SWTObservables.observeBackground(control); break; case EDITABLE: obs = SWTObservables.observeEditable(control); break; case ENABLED: obs = SWTObservables.observeEnabled(control); break; case FONT: obs = SWTObservables.observeFont(control); break; case FOREGROUND: obs = SWTObservables.observeForeground(control); break; case ITEMS: obs = SWTObservables.observeItems(control); break; case MAX: obs = SWTObservables.observeMax(control); break; case MIN: obs = SWTObservables.observeMin(control); break; case SELECTION: obs = SWTObservables.observeSelection(control); break; case SINGLESELECTIONINDEX: obs = SWTObservables.observeSingleSelectionIndex(control); break; case TEXT: obs = SWTObservables.observeText(control); break; case TEXTFOCUSOUT: obs = SWTObservables.observeText(control, SWT.FocusOut); break; case TEXTMODIFY: obs = SWTObservables.observeText(control, SWT.Modify); break; case TEXTNONE: obs = SWTObservables.observeText(control, SWT.None); break; case TOOLTIPTEXT: obs = SWTObservables.observeTooltipText(control); break; case VISIBLE: obs = SWTObservables.observeVisible(control); break; default: throw new IllegalArgumentException(); } return obs; }
From source file:uk.ac.stfc.isis.ibex.ui.synoptic.widgets.SynopticSelection.java
License:Open Source License
private void bind(SynopticSelectionViewModel model) { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindList(SWTObservables.observeItems(synopticCombo), BeanProperties.list(SynopticSelectionViewModel.SYNOPTIC_LIST).observe(model)); bindingContext.bindValue(WidgetProperties.selection().observe(synopticCombo), BeanProperties.value(SynopticSelectionViewModel.SELECTED).observe(model)); bindingContext.bindValue(WidgetProperties.enabled().observe(synopticCombo), BeanProperties.value(SynopticSelectionViewModel.ENABLED).observe(model)); bindingContext.bindValue(WidgetProperties.enabled().observe(refreshButton), BeanProperties.value(SynopticSelectionViewModel.ENABLED).observe(model)); }