Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [Databinding] - List of Objects to Editable TableViewer(My editor has an editable table that connects to a list of objects inside the editors input. )
[Databinding] - List of Objects to Editable TableViewer [message #628753] Thu, 23 September 2010 23:34 Go to next message
eshvar60  is currently offline eshvar60 Friend
Messages: 51
Registered: March 2010
Member
Hey guys,
So here is the problem I've been trying to figure out for a while.

I have made an editor who takes as an input an object of type Event.

The Event class has, among other things, has a List<Parameter>.
Each Parameter object has two values: Name and Type.

I populate a TableViewer in my editor with a list of these parameters using the following code.
ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
tableViewer.setContentProvider(listContentProvider); 
		
IObservableMap[] observeMaps = PojoObservables.observeMaps(listContentProvider.getKnownElements(), Parameter.class, new String[]{"name", "type"});
tableViewer.setLabelProvider(new ObservableMapLabelProvider(observeMaps));

// Bind the parameter/attribute sheets
IObservableList eventParametersObserveList = PojoObservables.observeDetailList(model, "parameters", Parameter.class);
parameterSheet.setInput(eventParametersObserveList);

where model is an IObservableValue of type Event(this is set up by the editor framework I am using).

I then set up my cell editors for each of my columns via:


CellEditor cellEditor = new TextCellEditor(parameterSheet.getTable());
IValueProperty cellEditorProperty = BeanProperties.value("value"); IBeanValueProperty valueProperty = BeanProperties.value("name");
		parameterNameColumn.setEditingSupport(ObservableValueEditingSupport.create(parameterSheet.getTableViewer(), dataBindingContext, cellEditor, cellEditorProperty, valueProperty));
		
ComboBoxViewerCellEditor typeComboEditor = new ComboBoxViewerCellEditor(parameterSheet.getTable(), SWT.READ_ONLY);
typeComboEditor.setContenProvider(new ArrayContentProvider());
typeComboEditor.setLabelProvider(new LabelProvider());
typeComboEditor.setInput(getParameterTypes());
		
IValueProperty cellEditorProperty_1 = BeanProperties.value("value");
IBeanValueProperty valueProperty_1 = BeanProperties.value("type");
		parameterTypeColumn.setEditingSupport(ObservableValueEditingSupport.create(parameterSheet.getTableViewer(), dataBindingContext, typeComboEditor, cellEditorProperty_1, valueProperty_1));
	


My problem is that my model values never change. I understand that I have not bound my list properly but I do not understand how I am suppose to do that. Can anyone give me a hint please?

Thank you
Eugene


Re: [Databinding] - List of Objects to Editable TableViewer [message #629384 is a reply to message #628753] Tue, 28 September 2010 06:14 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Your cell editor property is incorrect. The cell editor property is the
property of the CellEditor object that should be observed.

See corrections inline:

On 09/23/2010 05:34 PM, eshvar60 wrote:
> CellEditor cellEditor = new TextCellEditor(parameterSheet.getTable());
> IValueProperty cellEditorProperty = BeanProperties.value("value");

What you really want to observe is TextCellEditor.control.text:

IValueProperty cellEditorProperty = CellEditorProperties.control()
.value(WidgetProperties.text(SWT.Modify));

> IBeanValueProperty valueProperty = BeanProperties.value("name");
> parameterNameColumn.setEditingSupport(ObservableValueEditing Support.create(parameterSheet.getTableViewer(),
> dataBindingContext, cellEditor, cellEditorProperty, valueProperty));
>
> ComboBoxViewerCellEditor typeComboEditor = new
> ComboBoxViewerCellEditor(parameterSheet.getTable(), SWT.READ_ONLY);
> typeComboEditor.setContenProvider(new ArrayContentProvider());
> typeComboEditor.setLabelProvider(new LabelProvider());
> typeComboEditor.setInput(getParameterTypes());
>
> IValueProperty cellEditorProperty_1 = BeanProperties.value("value");

In this case you want to observe the single viewer selection of the cell
editor's viewer property:

IValueProperty cellEditorProperty_1 =
PojoProperties.value("viewer")
.value(ViewerProperties.singleSelection());

> IBeanValueProperty valueProperty_1 = BeanProperties.value("type");
> parameterTypeColumn.setEditingSupport(ObservableValueEditing Support.create(parameterSheet.getTableViewer(),
> dataBindingContext, typeComboEditor, cellEditorProperty_1,
> valueProperty_1));
>
> My problem is that my model values never change. I understand that I
> have not bound my list properly but I do not understand how I am suppose
> to do that. Can anyone give me a hint please?

Hope this helps,

Matthew
Previous Topic:Adding multiple instances of a same view programmaticaly and with different params
Next Topic:syntax coloring doesn't work in a multline line rule?
Goto Forum:
  


Current Time: Tue Apr 16 08:20:16 GMT 2024

Powered by FUDForum. Page generated in 0.18303 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top