public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String name = (String) table.getValueAt(row, 0); EditorModelHandler handler = getHandler(name); if (handler != null) return handler.getPropertyRenderer(name, value); else { defaultEditor.setText(value != null ? value.toString() : null); return defaultEditor; } }
@Override protected boolean commitPropertyChanges(String name, Object value) { if (currentEditorHandler != null) { currentEditorHandler.commitProperty(widgets, editingName, value); currentEditorHandler = null; return true; } currentEditorHandler = null; return false; }
@Override protected void prepareEditor(int row, int column) { super.prepareEditor(row, column); EditorModelHandler handler = getHandler(editingName); if (handler != null) { cellEditor.removeCellEditorListener( this); // otherwise we might get notifications during init that could stop editing // prematurely handler.initializeEditor(widgets, propertyEditor, editingName); // the thing is... we still have our own listener on the table... it seems like we should give // the handler // a chance to be the one to notify and if it doesn't then we use our regular one. // now we do both. handler.removeEditorListener(this); handler.addEditorListener(this); // when would be a good time to remove this listener? cellEditor.addCellEditorListener(this); } currentEditorHandler = handler; }