Skip to main content


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 06:24 Go to next message
M  is currently offline M Friend
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 08:44 Go to previous message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 250
Registered: July 2009
Location: Graz, Austria
Senior 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:Databinding - Writable and the opposite path.
Next Topic:JFace ApplicationWindow in Eclipse Viewpart
Goto Forum:
  


Current Time: Sat Apr 27 12:27:08 GMT 2024

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

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

Back to the top