Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Using EditingSupport.setValue(Object element, Object value) with strings.(can't get EditingSupport.setValue(Object element, Object value) to actually set a value when 'value' and 'element' are strings.)
Using EditingSupport.setValue(Object element, Object value) with strings. [message #689662] Tue, 28 June 2011 02:24 Go to next message
M  is currently offline M
Messages: 4
Registered: June 2011
Junior Member
I've got a JFace TableViewer with a single column. I want to be able to databind an EMF list of strings to this table, and enable editing support.

I'm using EMF to get an IObservableList. In the code below:
- businessObject is IAssociation from my generated EMF model
- I'm using graphiti, so the editingDomain is getDiagramEditor().getEditingDomain()
- The Comments attribute of Association is of type EList<String>

...snip...
tableViewer.setContentProvider(new ObservableListContentProvider());
...snip...
IObservableList list = EMFEditObservables.observeList(getDiagramEditor().getEditingDomain(),businessObject,SimpleMappingPackage.eINSTANCE.getAssociation_Comments());
...snip...
tableViewer.setInput(list);


In my EditingSupport class I'm using a TextCellEditor, and trying to update the value from it:

@Override
protected void setValue(Object element, Object value) {
	element = String.valueOf(value)
}


The 'value' does not seem to be retained. This makes sense, since 'element' comes from a getter. In
EditingSupport.saveCellEditorValue(CellEditor cellEditor, ViewerCell cell)

setValue(cell.getElement(), value);


How do I set 'element' to 'value' when they are both strings? Or should I be doing this some other way?

Re: Using EditingSupport.setValue(Object element, Object value) with strings. [message #757224 is a reply to message #689662] Thu, 17 November 2011 03:44 Go to previous message
Christian Pontesegger is currently offline Christian Pontesegger
Messages: 43
Registered: July 2009
Location: Graz, Austria
Member
Editing support needs an object that can be manipulated. Unfortunately String is immutable. You could use a StringBuffer and edit its contents or wrap you String within another object that has getters and setters for your String.
Previous Topic:MenuManager as submenu with ISelectionListener
Next Topic:DialogCellEditor databinding
Goto Forum:
  


Current Time: Mon Jul 28 06:31:59 EDT 2014

Powered by FUDForum. Page generated in 0.01967 seconds