Bug 1938 - [JFace] ICellModifier.modify() is passed Item, not element (1GCQZOM)
Summary: [JFace] ICellModifier.modify() is passed Item, not element (1GCQZOM)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 F4   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
: 11581 14491 22805 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-10-10 22:22 EDT by Nick Edgar CLA
Modified: 2003-02-10 07:40 EST (History)
3 users (show)

See Also:


Attachments
ICellModifier.java with changed spec for modify (2.15 KB, text/plain)
2002-06-19 12:58 EDT, Nick Edgar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2001-10-10 22:22:39 EDT
The modify(...) method on ICellModifier is passed the Item widget, not the element object.
This is contrary to how it is spec'ed.

See also: 1G7CG5V: ITPUI:ALL - API : What object should an ICellModifier receive


NOTES:

KH (8/13/2001 2:03:38 PM)
	No breaking API changes.
Comment 1 DJ Houghton CLA 2001-10-24 06:50:37 EDT
PRODUCT VERSION:
0.047

Comment 2 Nick Edgar CLA 2002-01-22 22:16:08 EST
Can't change implementation.
Need to fix spec to document current behaviour.
Comment 3 Nick Edgar CLA 2002-04-24 14:35:05 EDT
*** Bug 14491 has been marked as a duplicate of this bug. ***
Comment 4 Nick Edgar CLA 2002-06-14 15:37:41 EDT
Should still do this.
Comment 5 Nick Edgar CLA 2002-06-19 12:53:42 EDT
The offending code (which cannot be fixed without breaking many existing 
implementations of ICellModifier) is in 
org.eclipse.jface.viewers.TableViewerImpl.saveEditorValue(CellEditor, Item).
Comment 6 Nick Edgar CLA 2002-06-19 12:56:36 EDT
Changing the spec for ICellModifier.modify(...) from:

/**
 * Modifies the value for the given property of the given element.
 * Has no effect if the element does not have the given property,
 * or if the property cannot be modified.
 * 
 * @param element the model element
 * @param property the property
 * @param value the new property value
 */


to:

/**
 * Modifies the value for the given property of the given element.
 * Has no effect if the element does not have the given property,
 * or if the property cannot be modified.
 * <p>
 * Note that due to an implementation bug (#1938), an SWT Item
 * can get passed instead of the model element.
 * Unfortunately, fixing this bug would break most existing implementations
 * of this method which now assume an Item is always passed.
 * To work around this in a safe way, use:
 * <pre>
 *     if (element instanceof Item) {
 *         element = ((Item) element).getData();
 *     }
 *     // modify the element's property here
 * </pre>
 * </p>
 * 
 * @param element the model element or SWT Item (see above)
 * @param property the property
 * @param value the new property value
 * 
 * @see org.eclipse.swt.widgets.Item
 */
Comment 7 Nick Edgar CLA 2002-06-19 12:58:52 EDT
Created attachment 1516 [details]
ICellModifier.java with changed spec for modify
Comment 8 Randy Giffen CLA 2002-06-19 13:14:05 EDT
Reviewed spec change, OK to release.
Comment 9 Nick Edgar CLA 2002-06-19 21:46:06 EDT
Released change with slightly different wording recommended by KH.
Randy, could you please double-check it again?
Comment 10 Nick Edgar CLA 2002-10-15 15:40:56 EDT
*** Bug 11581 has been marked as a duplicate of this bug. ***
Comment 11 Nick Edgar CLA 2003-02-10 07:40:42 EST
*** Bug 22805 has been marked as a duplicate of this bug. ***