List of usage examples for org.eclipse.jface.databinding.viewers ViewerProperties singleSelection
public static IViewerValueProperty singleSelection()
From source file:at.medevit.elexis.gdt.ui.dialog.NeueUntersuchungAnfordernDialog.java
License:Open Source License
protected void initDataBindings() { DataBindingContext bindingContext = new DataBindingContext(); IObservableMap gdt6302ValuesObserveMap = PojoObservables.observeMap(gdt6302, "values", Integer.class, String.class); Text[] control = { txtPatientenKennung, txtPatientNachname, txtPatientVorname, txtIDReceiver, txtIDSender, txtGewicht, txtGroesse, txtGuVK, txtMuttersprache, txtOrt, txtStrasse, txtTitel, txtVersichertenNr, txtTestIdent };/*from ww w. j a v a 2 s . co m*/ int[] property = { GDTConstants.FELDKENNUNG_PATIENT_KENNUNG, GDTConstants.FELDKENNUNG_PATIENT_NAME, GDTConstants.FELDKENNUNG_PATIENT_VORNAME, GDTConstants.FELDKENNUNG_GDT_ID_EMPFAENGER, GDTConstants.FELDKENNUNG_GDT_ID_SENDER, GDTConstants.FELDKENNUNG_PATIENT_GEWICHT, GDTConstants.FELDKENNUNG_PATIENT_GROESSE, GDTConstants.FELDKENNUNG_GERAETE_UND_VERFAHRENSSPEZIFISCHES_KENNFELD, GDTConstants.FELDKENNUNG_PATIENT_MUTTERSPRACHE, GDTConstants.FELDKENNUNG_PATIENT_WOHNORT, GDTConstants.FELDKENNUNG_PATIENT_STRASSE, GDTConstants.FELDKENNUNG_PATIENT_TITEL, GDTConstants.FELDKENNUNG_PATIENT_VERSICHERTENNUMMER, GDTConstants.FELDKENNUNG_TEST_IDENT }; for (int i = 0; i < control.length; i++) { bindMapValue(control[i], property[i], bindingContext, gdt6302ValuesObserveMap); } IObservableValue widgetValueGeschlecht = ViewerProperties.singleSelection().observe(comboViewerGeschlecht); IObservableValue observableMapValueGeschlecht = Observables.observeMapEntry(gdt6302ValuesObserveMap, GDTConstants.FELDKENNUNG_PATIENT_GESCHLECHT, String.class); bindingContext.bindValue(widgetValueGeschlecht, observableMapValueGeschlecht); IObservableValue widgetValueVersichertenart = ViewerProperties.singleSelection() .observe(comboViewerVersichertenart); IObservableValue observableMapValueVersichertenart = Observables.observeMapEntry(gdt6302ValuesObserveMap, GDTConstants.FELDKENNUNG_PATIENT_VERSICHERTENART, String.class); bindingContext.bindValue(widgetValueVersichertenart, observableMapValueVersichertenart); IObservableValue widgetValueGeburtstag = new DateTimeObservableValue(dateTimeBirthday); IObservableValue observableValueGeburtstag = Observables.observeMapEntry(gdt6302ValuesObserveMap, GDTConstants.FELDKENNUNG_PATIENT_GEBURTSDATUM, String.class); UpdateValueStrategy geburtstagUvs = new UpdateValueStrategy(); geburtstagUvs.setConverter(new DateTimeTargetToModelUVS()); Binding bday = bindingContext.bindValue(widgetValueGeburtstag, observableValueGeburtstag, geburtstagUvs, null); bday.updateTargetToModel(); }
From source file:at.medevit.elexis.gdt.ui.dialog.StammdatenUebermittelnDialog.java
License:Open Source License
protected void initDataBindings() { DataBindingContext bindingContext = new DataBindingContext(); IObservableMap gdt6301ValuesObserveMap = PojoObservables.observeMap(gdt6301, "values", Integer.class, String.class); Text[] control = { txtPatientenKennung, txtPatientNachname, txtPatientVorname, txtIDReceiver, txtIDSender, txtGewicht, txtGroesse, txtMuttersprache, txtOrt, txtStrasse, txtTitel, txtVersichertenNr }; int[] property = { GDTConstants.FELDKENNUNG_PATIENT_KENNUNG, GDTConstants.FELDKENNUNG_PATIENT_NAME, GDTConstants.FELDKENNUNG_PATIENT_VORNAME, GDTConstants.FELDKENNUNG_GDT_ID_EMPFAENGER, GDTConstants.FELDKENNUNG_GDT_ID_SENDER, GDTConstants.FELDKENNUNG_PATIENT_GEWICHT, GDTConstants.FELDKENNUNG_PATIENT_GROESSE, GDTConstants.FELDKENNUNG_PATIENT_MUTTERSPRACHE, GDTConstants.FELDKENNUNG_PATIENT_WOHNORT, GDTConstants.FELDKENNUNG_PATIENT_STRASSE, GDTConstants.FELDKENNUNG_PATIENT_TITEL, GDTConstants.FELDKENNUNG_PATIENT_VERSICHERTENNUMMER }; for (int i = 0; i < control.length; i++) { bindMapValue(control[i], property[i], bindingContext, gdt6301ValuesObserveMap); }/*from www . j a v a2 s . c o m*/ IObservableValue widgetValueGeschlecht = ViewerProperties.singleSelection().observe(comboViewerGeschlecht); IObservableValue observableMapValueGeschlecht = Observables.observeMapEntry(gdt6301ValuesObserveMap, GDTConstants.FELDKENNUNG_PATIENT_GESCHLECHT, String.class); bindingContext.bindValue(widgetValueGeschlecht, observableMapValueGeschlecht); IObservableValue widgetValueVersichertenart = ViewerProperties.singleSelection() .observe(comboViewerVersichertenart); IObservableValue observableMapValueVersichertenart = Observables.observeMapEntry(gdt6301ValuesObserveMap, GDTConstants.FELDKENNUNG_PATIENT_VERSICHERTENART, String.class); bindingContext.bindValue(widgetValueVersichertenart, observableMapValueVersichertenart); IObservableValue widgetValueGeburtstag = new DateTimeObservableValue(dateTimeBirthday); IObservableValue observableValueGeburtstag = Observables.observeMapEntry(gdt6301ValuesObserveMap, GDTConstants.FELDKENNUNG_PATIENT_GEBURTSDATUM, String.class); UpdateValueStrategy geburtstagUvs = new UpdateValueStrategy(); geburtstagUvs.setConverter(new DateTimeTargetToModelUVS()); Binding bday = bindingContext.bindValue(widgetValueGeburtstag, observableValueGeburtstag, geburtstagUvs, null); bday.updateTargetToModel(); }
From source file:com.hibouhome.rcp.spikes.databinding.parts.StockistsPart.java
License:Open Source License
private void addCountrySelectionListener() { final IObservableValue selectedCountry = ViewerProperties.singleSelection().observe(countriesListViewer); selectedCountry.addValueChangeListener(new IValueChangeListener() { @Override/*from w ww . j av a 2 s . c om*/ public void handleValueChange(final ValueChangeEvent evt) { final Country country = (Country) evt.diff.getNewValue(); final IEMFListProperty regionsProperty = EMFProperties .list(StockistsPackage.Literals.COUNTRY__REGIONS); final IObservableList regionsObservableList = regionsProperty.observe(country); regionsListViewer.setInput(regionsObservableList); stockistsListViewer.setInput(null); } }); }
From source file:com.hibouhome.rcp.spikes.databinding.parts.StockistsPart.java
License:Open Source License
private void addRegionSelectionListener() { final IObservableValue selectedRegion = ViewerProperties.singleSelection().observe(regionsListViewer); selectedRegion.addValueChangeListener(new IValueChangeListener() { @Override//from ww w. j av a 2s .c o m public void handleValueChange(final ValueChangeEvent evt) { final Region region = (Region) evt.diff.getNewValue(); final IEMFListProperty stockistsProperty = EMFProperties .list(StockistsPackage.Literals.REGION__STOCKISTS); stockistsListViewer.setInput(stockistsProperty.observe(region)); } }); }
From source file:com.iks.hto.karteikastensystem.simple.rcp.views.KarteikastenSystemExplorerPart.java
License:Open Source License
private TreeViewer init(Composite parent, KarteikastenSystem karteikastensystem) { KarteikastensystemItemProviderAdapterFactory adapterFactory = new KarteikastensystemItemProviderAdapterFactory(); TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); viewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); viewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); viewer.setInput(karteikastensystem); MenuManager mgr = new MenuManager(); mgr.add(new GroupMarker("additions")); viewer.getControl().setMenu(mgr.createContextMenu(viewer.getControl())); site.registerContextMenu(Activator.PLUGIN_ID + ".karteikastenSystemAdditions", mgr, viewer); IObservableValue treeObs = ViewerProperties.singleSelection().observe(viewer); treeObs.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { ISourceProviderService s = (ISourceProviderService) site.getService(ISourceProviderService.class); ResourceProvider p = (ResourceProvider) s.getSourceProvider(ResourceProvider.MODEL_RESOURCE_NAME); if (event.diff.getNewValue() instanceof Person) { Person person = (Person) event.diff.getNewValue(); p.setBenutzer(person);/*from www . j a va 2 s . c om*/ p.setKarteikasten(null); p.setFach(null); } else if (event.diff.getNewValue() instanceof Karteikasten) { Karteikasten kk = (Karteikasten) event.diff.getNewValue(); p.setBenutzer(kk.getPerson()); p.setKarteikasten(kk); p.setFach(null); } else if (event.diff.getNewValue() instanceof Fach) { Fach f = (Fach) event.diff.getNewValue(); p.setBenutzer(f.getKarteikasten().getPerson()); p.setKarteikasten(f.getKarteikasten()); p.setFach(f); } else { p.setBenutzer(null); p.setKarteikasten(null); p.setFach(null); } } }); return viewer; }
From source file:com.netxforge.netxstudio.callflow.screens.protocols.NewEditProtocol.java
License:Open Source License
public EMFDataBindingContext initDataBindings_() { EMFDataBindingContext context = new EMFDataBindingContext(); // text widgets. IObservableValue nameObservable = SWTObservables.observeText(txtName, SWT.Modify); IObservableValue specificationObservable = SWTObservables.observeText(this.txtSpecification, SWT.Modify); IObservableValue descriptionObservable = SWTObservables.observeText(txtDescription, SWT.Modify); // Properties IEMFValueProperty nameProperty = EMFEditProperties.value(editingService.getEditingDomain(), ProtocolsPackage.Literals.PROTOCOL__NAME); IEMFValueProperty descriptionProperty = EMFEditProperties.value(editingService.getEditingDomain(), ProtocolsPackage.Literals.PROTOCOL__DESCRIPTION); IEMFValueProperty specificationProperty = EMFEditProperties.value(editingService.getEditingDomain(), ProtocolsPackage.Literals.PROTOCOL__SPECIFICATION); context.bindValue(nameObservable, nameProperty.observe(protocol), null, null); context.bindValue(descriptionObservable, descriptionProperty.observe(protocol), null, null); context.bindValue(specificationObservable, specificationProperty.observe(protocol), null, null); // Combo viewer. cmbLevelViewer.setContentProvider(new ArrayContentProvider()); cmbLevelViewer.setLabelProvider(new LabelProvider()); cmbLevelViewer.setInput(OSIType.VALUES); IEMFValueProperty osiProperty = EMFEditProperties.value(editingService.getEditingDomain(), ProtocolsPackage.Literals.PROTOCOL__OSI); IValueProperty selectionProperty = ViewerProperties.singleSelection(); context.bindValue(selectionProperty.observe(cmbLevelViewer), osiProperty.observe(protocol), null, null); return context; }
From source file:com.netxforge.netxstudio.screens.f2.details.NewEditEquipment.java
License:Open Source License
protected void bindDurationSection(EMFDataBindingContext context) { IObservableValue expansionDurationObservable; // Expansion duration binding. cmbViewerExpansionDuration.setContentProvider(new ArrayContentProvider()); cmbViewerExpansionDuration.setLabelProvider(new LabelProvider()); cmbViewerExpansionDuration.setInput(ExpansionDuration.VALUES); IValueProperty selectionProperty = ViewerProperties.singleSelection(); expansionDurationObservable = selectionProperty.observe(cmbViewerExpansionDuration); IEMFValueProperty durationProperty = EMFEditProperties.value(editingService.getEditingDomain(), LibraryPackage.Literals.COMPONENT__DURATION); context.bindValue(expansionDurationObservable, durationProperty.observe(comp), null, null); }
From source file:com.netxforge.netxstudio.screens.f4.MappingStatistics.java
License:Open Source License
public EMFDataBindingContext initDataBindings_() { EMFDataBindingContext bindingContext = new EMFDataBindingContext(); ObservableListTreeContentProvider treeContentProvider = new ObservableListTreeContentProvider( new IObservableFactory() { private IEMFListProperty subStatisticsObservableProperty = EMFEditProperties.list( editingService.getEditingDomain(), MetricsPackage.Literals.MAPPING_STATISTIC__SUB_STATISTICS); public IObservable createObservable(Object target) { IObservable ol = null; if (target instanceof IObservableList) { ol = (IObservable) target; } else if (target instanceof MappingStatistic) { ol = subStatisticsObservableProperty.observe(target); }/*from w w w .j av a 2 s . c o m*/ return ol; } }, new TreeStructureAdvisor() { @Override public Object getParent(Object element) { if (element instanceof EObject) { EObject eo = (EObject) element; if (eo.eContainer() != null) { return eo.eContainer(); } } return null; } @Override public Boolean hasChildren(Object element) { if (element instanceof MappingStatistic) { return ((MappingStatistic) element).getSubStatistics().size() > 0 ? Boolean.TRUE : null; } return super.hasChildren(element); } }); statisticsTreeViewer.setContentProvider(treeContentProvider); IObservableMap[] observeMaps = EMFObservables.observeMaps(treeContentProvider.getKnownElements(), new EStructuralFeature[] { MetricsPackage.Literals.MAPPING_STATISTIC__MESSAGE }); statisticsTreeViewer.setLabelProvider(new StatisticObservableMapLabelProvider(observeMaps)); // Cool, observer the whole resource. IEMFListProperty l = EMFProperties.list(MetricsPackage.Literals.METRIC_SOURCE__STATISTICS); IObservableList metricSourceObservableList = l.observe(metricSource); statisticsTreeViewer.setInput(metricSourceObservableList); /** * Set a comparator to sort our columns, only sort the objects of type * */ statisticsTreeViewer.setComparator(new ViewerComparator() { /* * (non-Javadoc) * * @see * org.eclipse.jface.viewers.ViewerComparator#category(java.lang * .Object) */ @Override public int category(Object element) { // Set categories for our objects, only interrested in Service // flows for now. if (element instanceof MappingStatistic) return 1; return super.category(element); } /* * (non-Javadoc) * * @see * org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse * .jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ @Override public int compare(Viewer viewer, Object e1, Object e2) { int cat1 = category(e1); int cat2 = category(e2); if (cat1 != cat2) { return cat1 - cat2; } if (e1 instanceof MappingStatistic && e2 instanceof MappingStatistic) { MappingStatistic ms1 = (MappingStatistic) e1; MappingStatistic ms2 = (MappingStatistic) e2; if (ms1.eIsSet(MetricsPackage.Literals.MAPPING_STATISTIC__MAPPING_DURATION) && ms2.eIsSet(MetricsPackage.Literals.MAPPING_STATISTIC__MAPPING_DURATION)) { return ms2.getMappingDuration().getBegin().compare(ms1.getMappingDuration().getBegin()); } } return 0; // Do not compare other types. // return super.compare(viewer, e1, e2); } }); final IObservableValue selectionObservable = ViewerProperties.singleSelection() .observe(statisticsTreeViewer); // Observables for a single selection. IObservableValue messageObservable = SWTObservables.observeText(this.txtMessage, SWT.None); IObservableValue totalRecordsObservable = SWTObservables.observeText(this.txtTotalRecords, SWT.None); IObservableValue startTimeObservable = SWTObservables.observeText(this.txtStartDateTime, SWT.None); IObservableValue endTimeObservable = SWTObservables.observeText(this.txtEndDateTime, SWT.None); IObservableValue metricStartTimeObservable = SWTObservables.observeText(this.txtMetricStartDateTime, SWT.None); IObservableValue metricEndTimeObservable = SWTObservables.observeText(this.txtMetricEndDateTime, SWT.None); IObservableValue totalExpectedValuesObservable = SWTObservables.observeText(this.txtTotalValues, SWT.None); IObservableValue totalFailedValuesObservable = SWTObservables.observeText(this.txtTotalFailedValues, SWT.None); IEMFValueProperty messageProperty = EMFProperties.value(MetricsPackage.Literals.MAPPING_STATISTIC__MESSAGE); final IEMFValueProperty totalRecordsProperty = EMFProperties .value(MetricsPackage.Literals.MAPPING_STATISTIC__TOTAL_RECORDS); IEMFValueProperty startDateTimeProperty = EMFProperties .value(FeaturePath.fromList(MetricsPackage.Literals.MAPPING_STATISTIC__MAPPING_DURATION, GenericsPackage.Literals.DATE_TIME_RANGE__BEGIN)); IEMFValueProperty endDateTimeProperty = EMFProperties .value(FeaturePath.fromList(MetricsPackage.Literals.MAPPING_STATISTIC__MAPPING_DURATION, GenericsPackage.Literals.DATE_TIME_RANGE__END)); IEMFValueProperty metricStartDateTimeProperty = EMFProperties .value(FeaturePath.fromList(MetricsPackage.Literals.MAPPING_STATISTIC__PERIOD_ESTIMATE, GenericsPackage.Literals.DATE_TIME_RANGE__BEGIN)); IEMFValueProperty metricEndDateTimeProperty = EMFProperties .value(FeaturePath.fromList(MetricsPackage.Literals.MAPPING_STATISTIC__PERIOD_ESTIMATE, GenericsPackage.Literals.DATE_TIME_RANGE__END)); ComputedValue computedTotalExpectedValue = new ComputedValue() { @Override protected Object calculate() { Object value = totalRecordsProperty.observeDetail(selectionObservable).getValue(); if (value instanceof Integer) { return new Integer(StudioUtils.metricsInMetricSource(metricSource).size() * (Integer) value) .toString(); } return 0; } }; ComputedValue computedTotalFailedValue = new ComputedValue() { @Override protected Object calculate() { Object selectedObject = selectionObservable.getValue(); // recursively compute for sub-statistics. if (selectedObject instanceof MappingStatistic) { return new Integer(StudioUtils.mappingFailedCount((MappingStatistic) selectedObject)) .toString(); } return 0; } }; EMFUpdateValueStrategy modelToTargetStrategy = new EMFUpdateValueStrategy(); modelToTargetStrategy.setConverter(new ModelDateConverter()); bindingContext.bindValue(messageObservable, messageProperty.observeDetail(selectionObservable)); bindingContext.bindValue(totalRecordsObservable, totalRecordsProperty.observeDetail(selectionObservable)); bindingContext.bindValue(startTimeObservable, startDateTimeProperty.observeDetail(selectionObservable), null, modelToTargetStrategy); bindingContext.bindValue(endTimeObservable, endDateTimeProperty.observeDetail(selectionObservable), null, modelToTargetStrategy); bindingContext.bindValue(metricStartTimeObservable, metricStartDateTimeProperty.observeDetail(selectionObservable), null, modelToTargetStrategy); bindingContext.bindValue(metricEndTimeObservable, metricEndDateTimeProperty.observeDetail(selectionObservable), null, modelToTargetStrategy); bindingContext.bindValue(totalExpectedValuesObservable, computedTotalExpectedValue); bindingContext.bindValue(totalFailedValuesObservable, computedTotalFailedValue); // bindingContext.bindValue(totalExpectedValuesObservable, // computedTotalExpectedValue, new UpdateValueStrategy(false, // UpdateValueStrategy.POLICY_NEVER), null); // // bindingContext.bindValue(totalFailedValuesObservable, // computedTotalFailedValue, new UpdateValueStrategy(false, // UpdateValueStrategy.POLICY_NEVER), null); ObservableListContentProvider recordsContentProvider = new ObservableListContentProvider(); tblViewerRecords.setContentProvider(recordsContentProvider); // IObservableMap[] recordsObserveMaps = EMFObservables.observeMaps( // listContentProvider.getKnownElements(), // new EStructuralFeature[] { // MetricsPackage.Literals.MAPPING_RECORD__ROW, // MetricsPackage.Literals.MAPPING_RECORD__COLUMN, // MetricsPackage.Literals.MAPPING_RECORD__MESSAGE, }); tblViewerRecords.setLabelProvider(new RecordsObservableMapLabelProvider()); IEMFListProperty recordsProperty = EMFProperties .list(MetricsPackage.Literals.MAPPING_STATISTIC__FAILED_RECORDS); tblViewerRecords.setInput(recordsProperty.observeDetail(selectionObservable)); return bindingContext; }
From source file:com.netxforge.netxstudio.screens.f4.NewEditMappingColumn.java
License:Open Source License
private void initDataBindingDataMappingColumn(EMFDataBindingContext context, IEMFValueProperty dataKindProperty) { // Metric option selected. btnMetricWritableValue = new WritableValue(); metricObservable = SWTObservables.observeSelection(btnMetricValue); context.bindValue(metricObservable, btnMetricWritableValue, null, null); // We should really observe the button. metricValueObservable = SWTObservables.observeText(txtMetric, SWT.Modify); // valuePatternObservable = SWTObservables.observeText( // this.txtMetricValuePattern, SWT.Modify); EMFUpdateValueStrategy metricModelToTargetStrategy = new EMFUpdateValueStrategy(); metricModelToTargetStrategy.setConverter(new DataKindModelToTargetConverter() { public Object convert(Object fromObject) { if (fromObject instanceof ValueDataKind) { Metric metric = ((ValueDataKind) fromObject).getMetricRef(); if (metric != null) { return metric.getName(); }// w w w .ja v a 2 s .c o m } return null; } }); context.bindValue(metricValueObservable, dataKindProperty.observe(mxlsColumn), null, metricModelToTargetStrategy); cmbViewrMetricKindHint.setContentProvider(new ArrayContentProvider()); cmbViewrMetricKindHint.setLabelProvider(new LabelProvider()); cmbViewrMetricKindHint.setInput(KindHintType.VALUES); metricKindHintObservable = ViewerProperties.singleSelection().observe(cmbViewrMetricKindHint); IEMFEditValueProperty KindHintProperty = EMFEditProperties.value(editingService.getEditingDomain(), FeaturePath.fromList(MetricsPackage.Literals.MAPPING_COLUMN__DATA_TYPE, MetricsPackage.Literals.VALUE_DATA_KIND__KIND_HINT)); context.bindValue(metricKindHintObservable, KindHintProperty.observe(mxlsColumn), null, null); }
From source file:com.netxforge.netxstudio.screens.nf3.Retention.java
License:Open Source License
private void addUIRule(MetricRetentionRule r, EMFDataBindingContext context, boolean isEditable) { final IEMFValueProperty retentionPeriodProperty = EMFEditProperties.value(editingService.getEditingDomain(), MetricsPackage.Literals.METRIC_RETENTION_RULE__PERIOD); IValueProperty selectionProperty = ViewerProperties.singleSelection(); if (!isEditable) { addUIRule(cmpRules, r, context, retentionPeriodProperty, selectionProperty); } else {//from www .j a va 2 s . co m addCustomUIRule(cmpCustomRules, r, context, retentionPeriodProperty, selectionProperty); } }