use of org.entirej.applicationframework.rwt.table.EJRWTTreeTableSortSelectionListener in project rap by entirej.
the class EJRWTTreeTableRecordBlockRenderer method createScreenItem.
public ColumnLabelProvider createScreenItem(EJRWTTreeTableViewerColumnFactory 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.getBlockRendererRequiredProperties();
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
if (labelProvider != null) {
String labelOrientation = blockProperties.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.COLUMN_ALIGNMENT);
int displayedWidth = blockProperties.getIntProperty(EJRWTTreeTableBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
// width
if (displayedWidth == 0) {
if (itemProps.getLabel() != null) {
// add
displayedWidth = itemProps.getLabel().length() + 2;
// offset
} else {
displayedWidth = 5;
}
}
String visualAttribute = blockProperties.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.VISUAL_ATTRIBUTE_PROPERTY);
if (visualAttribute != null) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null) {
itemRenderer.setInitialVisualAttribute(va);
}
}
if (item.getProperties().getVisualAttributeProperties() != null) {
renderer.setVisualAttribute(item.getProperties().getVisualAttributeProperties());
}
TreeViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), displayedWidth, labelProvider, getComponentStyle(labelOrientation));
TreeColumn column = viewerColumn.getColumn();
EJ_RWT.setTestId(column, blockProperties.getName() + "." + itemProps.getReferencedItemName());
column.setData("KEY", itemProps.getReferencedItemName());
column.setData("VIEWER", viewerColumn);
column.setData("ITEM", item);
column.setToolTipText(itemProps.getHint());
ColumnInfo info = new ColumnInfo();
column.setData("INFO", info);
column.setMoveable(blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
column.setResizable(info.resizable = blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_COLUMN_RESIZE, true));
if (blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_ROW_SORTING, true)) {
EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
if (columnSorter != null) {
new EJRWTTreeTableSortSelectionListener(_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.getTree().getFont();
}
if (font != null) {
float avgCharWidth = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(font);
if (avgCharWidth > 0) {
// add
column.setWidth(info.width = ((int) ((column.getWidth() + 1) * avgCharWidth)));
// +1
// padding
}
}
return labelProvider;
}
}
return null;
}
Aggregations