use of org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer in project rap by entirej.
the class EJRWTStandardLovRenderer method createScreenItem.
public ColumnLabelProvider createScreenItem(EJRWTTableViewerColumnFactory factory, EJCoreMainScreenItemProperties itemProps) {
if (itemProps.isSpacerItem()) {
return null;
}
EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
if (renderer != null) {
EJFrameworkExtensionProperties blockProperties = itemProps.getLovRendererRequiredProperties();
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
if (labelProvider != null) {
int _widthHint = blockProperties.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
// width
if (_widthHint == 0) {
if (itemProps.getLabel() != null) {
// offset
_widthHint = itemProps.getLabel().length() + 2;
} else {
_widthHint = 5;
}
}
String alignmentProperty = blockProperties.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
TableViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), _widthHint, labelProvider, getComponentStyle(alignmentProperty));
TableColumn column = viewerColumn.getColumn();
column.setToolTipText(itemProps.getHint());
column.setMoveable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
column.setResizable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_RESIZE, true));
if (blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_ROW_SORTING, true)) {
EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
if (columnSorter != null) {
new EJRWTTableSortSelectionListener(_tableViewer, column, columnSorter, SWT.UP, false);
}
}
// ensure that the width property of the table column is in
// Characters
Font font = labelProvider.getFont(new Object());
if (font == null) {
font = _tableViewer.getTable().getFont();
}
if (font != null) {
float avgCharWidth = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(font);
if (avgCharWidth > 0) {
// add
column.setWidth((int) ((column.getWidth() + 1) * avgCharWidth));
// +1
// padding
}
}
return labelProvider;
}
}
return null;
}
Aggregations