Design Decision Editor
As part of Palladio, there is an architectural design decision editor for design decision models. The editor is realized as a JFace/SWT-to-EMF binding, i.e. the elements of the UI (JFace/Forms/SWT) are bound to EMF elements from the decision metamodel.
Editor Code
Metamodel
- edu.kit.ipd.sdq.dm
- edu.kit.ipd.sdq.dm.edit -- support for deprecated EMF-generated editor.
- edu.kit.ipd.sdq.dm.editor -- tree-based editor, replaced by editor linked above!
Data Bindings
As pointed out before, the binding between JFace elements and EMF elements is realized via a databinding mechanism. An introductory tutorial can be found here [1].
Primitive Bindings (swt.widget.Text to EString attribute)
/**** Bind ID attribute ****/ DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(text_ID), EMFProperties.value(DecisionPackage.Literals.DECISION__ID).observe(decision));
Rationale is a meta class in the decision metamodel. It can be reached over the reference Decision->Rationale. The displayed text shall be the rationale's description:
/**** Bind Rationale attribute ****/ FeaturePath feature = FeaturePath.fromList( DecisionPackage.Literals.DECISION__RATIONALE, DecisionPackage.Literals.RATIONALE__DESCRIPTION); bindingContext.bindValue( WidgetProperties.text(SWT.Modify).observe(text_Rationale), EMFProperties.value(feature).observe(decision));
Bindings with type conversion (Date <--> String)
The model stores dates as java.util.Date which must be expressed as Strings in the textual representation and vice versa:
/**** Bind Date attribute ****/ EMFUpdateValueStrategy t2s = new EMFUpdateValueStrategy(); t2s.setConverter(new StringToDateConverter()); EMFUpdateValueStrategy s2t = new EMFUpdateValueStrategy(); s2t.setConverter(new DateToStringConverter()); bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(text_Date), EMFProperties.value(DecisionPackage.Literals.DECISION__TIME_STAMP).observe(decision), t2s, s2t);
Bindings with type conversion (Date <--> String)
A reference of multiplicity 0..* can be realized in a JFace-ListViewer:
/**** Bind triggered Issues reference ****/ IListProperty widgetList2 = EMFProperties.list(DecisionPackage.Literals.DECISION__TRIGGER); IObservableList input2 = widgetList2.observe(decision); triggeredIssuesListViewer.setContentProvider(new ObservableListContentProvider()); triggeredIssuesListViewer.setLabelProvider(new IssueLabelProvider()); // simple Labelprovider that shows an issue's key as text. triggeredIssuesListViewer.setInput(input2);