DcObject dco = module.getItem();
getDcModel().setColumnCount(dco.getFields().size());
int counter = 0;
for (DcField field : dco.getFields()) {
TableColumn columnNew = getColumnModel().getColumn(counter);
columnNew.setIdentifier(field.getIndex());
columnNew.setHeaderValue(field.getLabel());
columnNew.setPreferredWidth(getPreferredWidth(field.getIndex()));
if ( field.getIndex() == DcObject._ID
|| field.getIndex() == DcObject._SYS_LENDBY
|| field.getIndex() == DcObject._SYS_LOANDURATION
|| field.getIndex() == DcObject._SYS_CREATED
|| field.getIndex() == DcObject._SYS_MODIFIED) {
DcShortTextField text = ComponentFactory.getTextFieldDisabled();
columnNew.setCellEditor(new DefaultCellEditor(text));
DcTableCellRenderer renderer = DcTableCellRenderer.getInstance();
renderer.setFont(ComponentFactory.getSystemFont());
columnNew.setCellRenderer(renderer);
} else if (field.getFieldType() == ComponentFactory._REFERENCESFIELD) {
columnNew.setCellEditor(new DefaultCellEditor(ComponentFactory.getTextFieldDisabled()));
columnNew.setCellRenderer(ReferencesTableCellRenderer.getInstance());
} else if (field.getIndex() == DcObject._SYS_MODULE) {
DcShortTextField text = ComponentFactory.getTextFieldDisabled();
columnNew.setCellEditor(new DefaultCellEditor(text));
columnNew.setCellRenderer(ModuleTableCellRenderer.getInstance());
} else if (dco.getModule().getIndex() == DcModules._LOAN &&
field.getIndex() == Loan._C_CONTACTPERSONID) {
DcShortTextField text = ComponentFactory.getTextFieldDisabled();
columnNew.setCellEditor(new DefaultCellEditor(text));
columnNew.setCellRenderer(ContactPersonTableCellRenderer.getInstance());
} else {
switch (field.getFieldType()) {
case ComponentFactory._DATEFIELD:
columnNew.setCellEditor(new DefaultCellEditor(ComponentFactory.getTextFieldDisabled()));
columnNew.setCellRenderer(DateFieldCellRenderer.getInstance());
break;
case ComponentFactory._AVAILABILITYCOMBO:
columnNew.setCellEditor(new DefaultCellEditor(ComponentFactory.getTextFieldDisabled()));
columnNew.setCellRenderer(AvailabilityCheckBoxTableCellRenderer.getInstance());
break;
case ComponentFactory._CHECKBOX:
columnNew.setCellEditor(new DefaultCellEditor(ComponentFactory.getTextFieldDisabled()));
columnNew.setCellRenderer(CheckBoxTableCellRenderer.getInstance());
break;
case ComponentFactory._FILESIZEFIELD:
columnNew.setCellEditor(new DefaultCellEditor((JTextField) getEditor(field)));
columnNew.setCellRenderer(FileSizeTableCellRenderer.getInstance());
break;
case ComponentFactory._NUMBERFIELD:
case ComponentFactory._DECIMALFIELD:
columnNew.setCellEditor(new DefaultCellEditor((JTextField) getEditor(field)));
columnNew.setCellRenderer(NumberTableCellRenderer.getInstance());
break;
case ComponentFactory._LONGTEXTFIELD:
case ComponentFactory._SHORTTEXTFIELD:
columnNew.setCellEditor(new DefaultCellEditor((JTextField) getEditor(field)));
break;
case ComponentFactory._TIMEFIELD:
DcNumberField numberField = ComponentFactory.getNumberField();
columnNew.setCellEditor(new DefaultCellEditor(numberField));
columnNew.setCellRenderer(TimeFieldTableCellRenderer.getInstance());
break;
case ComponentFactory._URLFIELD:
columnNew.setCellEditor(new DefaultCellEditor((JTextField) getEditor(field)));
DcTableCellRenderer renderer = DcTableCellRenderer.getInstance();
renderer.setForeground(new Color(0, 0, 255));
columnNew.setCellRenderer(renderer);
break;
case ComponentFactory._PICTUREFIELD:
DcShortTextField text = ComponentFactory.getTextFieldDisabled();
text.setEditable(false);
text.setFont(ComponentFactory.getUnreadableFont());
columnNew.setCellEditor(new DefaultCellEditor(text));
columnNew.setCellRenderer(PictureTableCellRenderer.getInstance());
break;
case ComponentFactory._REFERENCEFIELD:
columnNew.setCellRenderer(ComboBoxTableCellRenderer.getInstance());
columnNew.setCellEditor(new DefaultCellEditor((JComboBox) getEditor(field)));
break;
case ComponentFactory._RATINGCOMBOBOX:
columnNew.setCellRenderer(RatingTableCellRenderer.getInstance());
columnNew.setCellEditor(new DefaultCellEditor((DcRatingComboBox) getEditor(field)));
break;
case ComponentFactory._YESNOCOMBO:
columnNew.setCellEditor(new DefaultCellEditor((JComboBox) getEditor(field)));
break;
case ComponentFactory._LOGINNAMEFIELD:
columnNew.setCellEditor(new DefaultCellEditor((DcLoginNameField) getEditor(field)));
break;
}
}
counter++;
}