Project: Eclipse_Platform_UI
Bug 168709 [Viewers] Request to open up ViewerColumn#setEditingSupport
Reported: 2006-12-20 10:44:00 | Status: resolved fixed

setEditingSupport is now marked final. I would like to override this method to handle a very specific situation. The Grid can contain a checkbox in any column as opposed to Table which can only contain a checkbox in the first column. The new viewer API allows us to easily populate these checkboxes, but there is currently nothing that propogates any changes from the widget back to the model - i.e. if someone checks a checkbox the model currently doesn't get updated because this happens without an editor. So I designed a new CheckEditingSupport class. This is essentially a marker interface that lets me know that the user has set this as a check cell. The only method used from CheckEditingSupport is setValue. Here is my setEditingSupport implementation for reference: public void setEditingSupport(EditingSupport editingSupport) { if (editingSupport instanceof CheckEditingSupport) { if (checkEditingSupport == null) { final int colIndex = getColumn().getParent().indexOf(getColumn()); getColumn().getParent().addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (event.detail == SWT.CHECK && event.index == colIndex) { GridItem item = (GridItem)event.item; Object element = viewer.getElementAt(viewer.getGrid().indexOf(item)); checkEditingSupport.setValue(element, new Boolean(item.getChecked(colIndex))); } } }); } checkEditingSupport = (CheckEditingSupport)editingSupport; } else { super.setEditingSupport(editingSupport); } }

Files changed in fix:
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java