Custom Table Views (Step 1)
1. Extend one of the out-of-the-box Table View classes:
Table
|
View Class
|
Change Object
|
Affected Objects
|
ChangeTaskAffectedItemsTableViews
VarianceAffectedDataTableViews
AffectedDataTableViews
|
Change Task
Variance
Problem Report and Change Request
|
Resulting Objects
|
ChangeTaskResultingItemsTableViews
|
Change Task
|
2. Override the getSpecialTableColumnsAttrDefinition() method to include the new attributes.
3. Add the column to all views or only to selected views.
◦ To add the column to all views, override the method getDefaultColumns() and insert the column in the appropriate location.
◦ To add a column to selected views override the method getOOTBTableViews() first calling the super.getOOTBTableViews(), find the view(s) needed to be updated and update those views by changing the TableColumnDefinitions.
Sample Code
public class DistributingResultingItemsTableViews extends
ChangeTaskResultingItemsTableViews {
/**
* The distributionList will only be added to the Parts and All views
immediately after
* the name column.
*/
@SuppressWarnings("unchecked")
@Override
public List getOOTBTableViews(String tableId, Locale locale)
throws WTException
{
List<TableViewDescriptor> result =
super.getOOTBTableViews(tableId, locale);
for(TableViewDescriptor descriptor: result) {
if( descriptor.getName().equals(PARTS_VIEW) ||
descriptor.getName()
.equals(ALL_VIEW)) {
Vector<ableColumnDefinition> columns =
descriptor.getTableColumnDefinition();
for(int c = 0; c < columns.size(); c++) {
if( "name".equals(columns.get(c).getName())) {
String key = DistributingChangeRecordConstants.
DISTRIBUTION_ATTRIBUTE;
columns.add(c++,TableColumnDefinition.
newTableColumnDefinition
(key,isColumnLocked(key)));
break;
}
}
}
}
return result;
}
@Override
@SuppressWarnings("unchecked")
public List<?> getSpecialTableColumnsAttrDefinition(Locale locale) {
List<Attribute.TextAttribute> results = (List<TextAttribute>)
super.getSpecialTableColumnsAttrDefinition(locale);
results.add(new Attribute.TextAttribute
(DistributingChangeRecordConstants.
DISTRIBUTION_ATTRIBUTE,
"Distribution List" /*Should be localized label*/, locale));
return results;
}
}