public void saveColumns(MiniTable table)
{
TableColumn tcol;
String tcolName;
TableColumnModel model = table.getColumnModel();
X_AD_ColumnLayout colLayout = null;
boolean modified = false;
// Iterate over the columns of the table
for (int modelIndex = 0; modelIndex < table.getColumnCount(); modelIndex++)
{
tcol = model.getColumn(modelIndex);
tcolName = tcol.getHeaderValue().toString();
colLayout = columns.get(modelIndex);
// If the position of column layout does not match the position of the
// column in the table then move the column in the layout to match its
// position in the table.
if (!colLayout.getColumnName().equals(tcolName))
{
colLayout = null;
for (X_AD_ColumnLayout currentLayout : columns)
{
if (currentLayout.getColumnName().equals(tcolName))
{
colLayout = currentLayout;
break;
}
}
if (colLayout != null)
{
columns.remove(colLayout);
columns.add(modelIndex, colLayout);
modified = true;
}
}
// If the visibility of the column layout does not match the visibility
// of the table column than change the column layout to match.
if (colLayout != null &&
table.isColumnVisible(tcol) != colLayout.isActive())
{
colLayout.setIsActive(table.isColumnVisible(tcol));
modified = true;
}
} // end for