use of org.compiere.grid.ed.VCellEditor in project adempiere by adempiere.
the class GridController method setupVTable.
// getTitle
/**
* Setup Multi-Row Table (add fields)
* @param aPanel Panel
* @param mTab Model Tab
* @param table JTable
* @return size
*/
private int setupVTable(APanel aPanel, GridTab mTab, VTable table) {
if (!mTab.isDisplayed())
return 0;
int size = mTab.getFieldCount();
TableColumnModel tcm = table.getColumnModel();
if (size != tcm.getColumnCount())
throw new IllegalStateException("TableColumn Size <> TableModel");
for (int i = 0; i < size; i++) {
GridField mField = mTab.getField(i);
TableColumn tc = tcm.getColumn(i);
tc.setMinWidth(30);
// FR 3051618 - Hide in list view
if (!mField.isDisplayedGrid()) {
vTable.setColumnVisibility(tc, false);
}
if (mField.getColumnName().equals(tc.getIdentifier().toString())) {
//don't show included tab field in grid
if (mField.getIncluded_Tab_ID() > 0) {
TableCellNone tcn = new TableCellNone(mField.getColumnName());
tc.setCellRenderer(tcn);
tc.setCellEditor(tcn);
tc.setHeaderValue(null);
tc.setMinWidth(0);
tc.setMaxWidth(0);
tc.setPreferredWidth(0);
table.setColumnVisibility(tc, false);
} else if (mField.getDisplayType() == DisplayType.RowID) {
tc.setCellRenderer(new VRowIDRenderer(false));
tc.setCellEditor(new VRowIDEditor(false));
tc.setHeaderValue("");
tc.setMaxWidth(2);
} else {
// need to set CellEditor explicitly as default editor based on class causes problem (YesNo-> Boolean)
if (mField.isDisplayed() && mField.isDisplayedGrid()) {
tc.setCellRenderer(new VCellRenderer(mField));
VCellEditor ce = new VCellEditor(mField);
tc.setCellEditor(ce);
//
tc.setHeaderValue(mField.getHeader());
tc.setPreferredWidth(Math.max(mField.getDisplayLength(), 30));
tc.setHeaderRenderer(new VHeaderRenderer(mField));
// Enable Button actions in grid
if (mField.getDisplayType() == DisplayType.Button) {
ce.setActionListener(aPanel);
}
} else // column not displayed
{
TableCellNone tcn = new TableCellNone(mField.getColumnName());
tc.setCellRenderer(tcn);
tc.setCellEditor(tcn);
tc.setHeaderValue(null);
tc.setMinWidth(0);
tc.setMaxWidth(0);
tc.setPreferredWidth(0);
table.setColumnVisibility(tc, false);
}
}
} else
// found field
log.log(Level.SEVERE, "TableColumn " + tc.getIdentifier() + " <> MField " + mField.getColumnName() + mField.getHeader());
}
// for all fields
return size;
}
Aggregations