Bug 168709 [Viewers] Request to open up ViewerColumn#setEditingSupport
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); } }
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java
}
	/**
	 * Refresh the cell for the given columnIndex. <strong>NOTE:</strong>the
	 * {@link ViewerCell} provided to this method is no longer valid after this
	 * method returns. Do not cache the cell for future use.
	 * 
	 * @param cell
	 *            {@link ViewerCell}
	 */
	void refresh(ViewerCell cell) {
		getLabelProvider().update(cell);
	}
	/**
	 * Disposes of the label provider (if set), deregisters the listener and
	 * nulls the references to the label provider and editing support. This
	 * method is called when the underlying widget is disposed. Subclasses may
	 * extend but must call the super implementation.
	 */
	protected void handleDispose() {
		boolean disposeLabelProvider = listenerRegistered;
		CellLabelProvider cellLabelProvider = labelProvider;
		setLabelProvider(null, false);
		if (disposeLabelProvider) {
			cellLabelProvider.dispose();
		}
		editingSupport = null;
		listener = null;
	}
}