Bug 51051 - [CellEditors] [ErrorHandling] Omitting tableViewer.setColumnProperties(String[]) creates null pointer when using DialogCellEditor
Summary: [CellEditors] [ErrorHandling] Omitting tableViewer.setColumnProperties(String...
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2004-02-02 08:43 EST by Björn Johansson CLA
Modified: 2009-08-30 02:11 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Johansson CLA 2004-02-02 08:43:21 EST
I create a table (with a tableViewer) without a column header. I am using a 
DialogCellEditor.
If I do not set columnProperties (tableViewer.setColumnProperties(String[])) 
there will be an error in the eventDispatch thread (I think) when I click the 
table. If the code looks like this:

Composite iTableViewerComposite = new Composite(permissionsGroup, SWT.NONE);
iTableViewerComposite.setLayout(itvFillLayout);
GridData itGridData = new GridData(GridData.FILL_BOTH);
iTableViewerComposite.setLayoutData(itGridData);
Table instanceTable = new Table(iTableViewerComposite,			
	SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI);
TableColumn column = new TableColumn(instanceTable, SWT.LEFT);
		column.setWidth(200);
		instanceTable.setLinesVisible(true);
		instanceTableViewer = new TableViewer(instanceTable);
		instanceTableViewer.setContentProvider(new ArrayContentProvider
());
		instanceTableViewer.setLabelProvider(new 
InstanceTableLabelProvider());
		instanceTableViewer.setCellModifier(
			new InstanceCellModifier(instanceTableViewer));
		instanceTableViewer.setCellEditors(
			new CellEditor[] {
				 new InstanceDialogCellEditor(instanceTable)});
		instanceTableViewer.setInput(populateInstances());

...and I click the table I get an error like this:

java.lang.NullPointerException
	at org.eclipse.jface.viewers.TableViewerImpl.activateCellEditor
(TableViewerImpl.java:61)
	at org.eclipse.jface.viewers.TableViewerImpl.activateCellEditor
(TableViewerImpl.java:134)
	at org.eclipse.jface.viewers.TableViewerImpl.handleMouseDown
(TableViewerImpl.java:231)
	at org.eclipse.jface.viewers.TableViewer$1.mouseDown
(TableViewer.java:320)
	at org.eclipse.swt.widgets.TypedListener.handleEvent
(TypedListener.java:128)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2173)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1863)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:583)
	at org.eclipse.jface.window.Window.open(Window.java:563)
	at se.capitalc.prototype.moonraypermission.MoonrayPermissionClient.main
(MoonrayPermissionClient.java:26)

But if I complete the code with:
String[] iColumnNames = {"Instance"};
//... code above
instanceTableViewer.setColumnProperties(iColumnNames);
// Not using columnHeaders!

...it works just fine!

If this is by design, it makes no sense to me in this case or at least it is 
poorly documented(I spent 2 days trying to find out what was wrong)
Comment 1 Nick Edgar CLA 2004-02-04 12:02:01 EST
The property names are needed to pass to the ICellModifier methods.
I agree that the error handling could be improved though.
Comment 2 Nick Edgar CLA 2006-03-15 13:53:35 EST
Reassigning bugs in component areas that are changing ownership.
Comment 3 Eric Moffatt CLA 2006-06-23 15:55:30 EDT
Cleaning up defect lists by setting ones without recent traffic to 'REMIND'.
Comment 4 Denis Roy CLA 2009-08-30 02:11:05 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.