}
}
private void setCellValidators( IAdaptable adaptable ) {
CellEditor[] editors = tableViewer.getCellEditors();
SimpleFeatureType schema = features.getSchema();
// offset is usually 1 but if the number of validators==number of attributes then the offset
// is 0
// because the first column is the FID column which doesn't have a listener.
int offset = 1;
ICellEditorValidator[] validators = null;
if (adaptable.getAdapter(ICellEditorValidator[].class) != null) {
validators = (ICellEditorValidator[]) adaptable
.getAdapter(ICellEditorValidator[].class);
int attributeCount = features.getSchema().getAttributeCount();
if (validators.length < attributeCount) {
UiPlugin.log(
"not enough cell editors for feature type so not used", new Exception()); //$NON-NLS-1$
validators = null;
} else if (validators.length == attributeCount) {
offset = 0;
}
}
for( int i = 0; i < editors.length - offset; i++ ) {
CellEditor editor = editors[i + offset];
if (editor == null)
continue;
if (validators != null && validators[i] != null)
editor.setValidator(validators[i]);
else
editor.setValidator(new AttributeValidator(schema.getDescriptor(i), schema));
}
}