Bug 113713 - [Viewers] Allow Per-Item CellEditors in TreeViewer
Summary: [Viewers] Allow Per-Item CellEditors in TreeViewer
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement with 3 votes (vote)
Target Milestone: 3.3 M2   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, investigate
Depends on: 149193
Blocks:
  Show dependency tree
 
Reported: 2005-10-25 17:11 EDT by Bradley Hawkes CLA
Modified: 2008-11-06 19:40 EST (History)
12 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bradley Hawkes CLA 2005-10-25 17:11:00 EDT
Currently the assumption of the TreeTableViewer is that it is sufficient to
provide an array of CellEditor objects corresponding to the columns. While this
works in many situations it doesn't seem to fit with the rest of the pattern of
delegation in the JFace structure. I suggest the addition of an interface akin
to the ITableLabel provider which can provide a CellEditor for a given item and
column and allow the consumer to provide this interface to the Viewer. 
This would be fairly straight forward to setup inside of the activateCellEditor
function inside TreeEditorImpl.

This is of interest as it would provide facility similar to what is in the
properties view but with a more general architecture based on the
ContentProvider framework.
Comment 1 Boris Bokowski CLA 2005-12-12 12:29:05 EST
Changed the summary (note that TableTree is deprecated).
Comment 2 Serge Yuschenko CLA 2005-12-12 14:50:43 EST
I think the same issue exists for the TableViewer as well.
Comment 3 Ed Burnette CLA 2005-12-12 22:10:25 EST
See http://www.eclipsezone.com/eclipse/forums/t59401.html for the hoops you have to go through now to get this effect.
Comment 4 Serge Yuschenko CLA 2005-12-13 10:22:58 EST
This is the right reference to the discussion http://www.eclipsezone.com/eclipse/forums/t59419.html

I would suggest slightly different approach that works for me. I don't use setCellEditors() and getCellEditors() methods at all. A CellModifier already has getValue() and modify() methods so it knows what kind of data is contained in a cell and how to work with it. I extended the ICellModifier interface with a public CellEditor getCellEditor( Object element, String property ) method and changed activateCellEditor() method in the TableEditorImpl class:

private void activateCellEditor() {
	if( null == cellModifier )
		return;

	String property = columnProperties[ columnNumber ];

	if( ! cellModifier.canModify( tableItem, property ))
		return;

	cellEditor = cellModifier.getCellEditor( tableItem, property );

	if( null == cellEditor )
		return;

In this case even canModify() call may be omitted since null cellEditor clearly indicates that cell cannot be modified.
Comment 5 Thomas Schindl CLA 2006-05-23 09:23:23 EDT
(In reply to comment #4)
> This is the right reference to the discussion
> http://www.eclipsezone.com/eclipse/forums/t59419.html
> 
> I would suggest slightly different approach that works for me. I don't use
> setCellEditors() and getCellEditors() methods at all. A CellModifier already
> has getValue() and modify() methods so it knows what kind of data is contained
> in a cell and how to work with it. I extended the ICellModifier interface with
> a public CellEditor getCellEditor( Object element, String property ) method and
> changed activateCellEditor() method in the TableEditorImpl class:
> 
> private void activateCellEditor() {
>         if( null == cellModifier )
>                 return;
> 
>         String property = columnProperties[ columnNumber ];
> 
>         if( ! cellModifier.canModify( tableItem, property ))
>                 return;
> 
>         cellEditor = cellModifier.getCellEditor( tableItem, property );
> 
>         if( null == cellEditor )
>                 return;
> 
> In this case even canModify() call may be omitted since null cellEditor clearly
> indicates that cell cannot be modified.
> 


The problem arising here is also addressed in bug #142655 where multiple cell-editors are available for one column no matter whether it is a Tree or a Table
Comment 6 Thomas Schindl CLA 2006-08-17 09:18:03 EDT
This bug can be closed because since the patch from bug 149193 was released into head this is possible see EditingSupport#getCellEditor(Object element).
Comment 7 Boris Bokowski CLA 2006-08-17 10:30:58 EDT
Marking as fixed.