use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.
the class EJRWTPieChartRecordBlockRenderer method refresh.
public void refresh(Object input) {
if (_chartView != null && !_chartView.isDisposed()) {
Collection<EJDataRecord> records = (!multi) ? Arrays.asList(currentRecord == null ? getFirstRecord() : currentRecord) : _block.getRecords();
Collection<EJScreenItemController> screenItems = getScreenItems();
List<String> xlabel = new ArrayList<String>(screenItems.size());
for (EJScreenItemController sItem : screenItems) {
if (sItem.isSpacerItem())
continue;
xlabel.add(sItem.getProperties().getLabel());
}
PieChartRowData chartRowData = new PieChartRowData(xlabel.toArray(new String[0]));
for (EJDataRecord ejDataRecord : records) {
if (ejDataRecord == null)
continue;
Object lbl = labelColumn != null ? ejDataRecord.getValue(labelColumn) : "";
PieChartRowData.RowInfo rowInfo = new RowInfo();
rowInfo.setLabel(lbl != null ? lbl.toString() : "");
boolean[] hidden = new boolean[screenItems.size()];
ChartStyle[] styles = new ChartStyle[screenItems.size()];
double[] data = new double[screenItems.size()];
int[] widths = new int[screenItems.size()];
int index = 0;
for (EJScreenItemController sItem : screenItems) {
ChartStyle colors = new ChartStyle(220, 220, 220, 0.8f);
EJCoreVisualAttributeProperties attributeProperties = sItem.getItemRenderer().getVisualAttributeProperties();
EJCoreVisualAttributeProperties visualAttribute = ejDataRecord.getItem(sItem.getName()).getVisualAttribute();
if (visualAttribute != null) {
attributeProperties = visualAttribute;
}
if (attributeProperties != null) {
if (attributeProperties.getForegroundColor() != null) {
Color color = attributeProperties.getForegroundColor();
colors = new ChartStyle(color.getRed(), color.getGreen(), color.getBlue(), 0.8f);
}
if (attributeProperties.getBackgroundColor() != null) {
Color color = attributeProperties.getBackgroundColor();
colors.setFillColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
}
}
EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) sItem.getProperties();
styles[index] = (colors);
hidden[index] = (!sItem.isVisible());
widths[index] = (mainScreenItemProperties.getBlockRendererRequiredProperties().getIntProperty(LINE_WIDTH, 1));
Object yvalue = ejDataRecord.getValue(sItem.getName());
double val = 0;
if (yvalue instanceof Number) {
val = ((Number) yvalue).doubleValue();
}
data[index] = (val);
index++;
}
// rowInfo.setHidden(hidden);
rowInfo.setChartStyle(styles);
rowInfo.setBorderWidth(widths);
rowInfo.setAction("_pie_select");
chartRowData.addRow(rowInfo, data);
}
_chartView.load(chartRowData, options);
}
}
use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.
the class EJRWTPieChartRecordBlockRenderer method getScreenItems.
List<EJScreenItemController> getScreenItems() {
Collection<EJItemGroupProperties> allItemGroupProperties = _block.getProperties().getScreenItemGroupContainer(EJScreenType.MAIN).getAllItemGroupProperties();
List<EJScreenItemController> list = new ArrayList<EJScreenItemController>();
for (EJItemGroupProperties groupProperties : allItemGroupProperties) {
Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
for (EJScreenItemProperties screenItemProperties : itemProperties) {
EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) screenItemProperties;
EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, mainScreenItemProperties.getReferencedItemName());
list.add(item);
}
}
return list;
}
use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.
the class EJRWTPieChartRecordBlockRenderer method processAction.
protected void processAction(String method, JsonObject parameters) {
if (method.equals("_pie_select")) {
if (parameters.names().contains("label") && parameters.names().contains("value")) {
currentRecord = null;
EJScreenItemController dataItem = null;
List<EJScreenItemController> screenItems = getScreenItems();
for (EJScreenItemController sItem : screenItems) {
String label = sItem.getProperties().getLabel();
if (label.trim().isEmpty()) {
label = sItem.getProperties().getReferencedItemName();
}
if (label.equals(parameters.get("label").asString())) {
dataItem = sItem;
break;
}
}
if (dataItem != null) {
// Collection<EJDataRecord> records = _block.getRecords();
// Object lastVal=null;
// for (EJDataRecord record : records)
// {
// Object value = record.getValue(dataItem.getName());
// if(value==null)
// value = lastVal;
//
// if (
// value != null && value.equals(parameters.get("value").asDouble()))
// {
// currentRecord = record;
// break;
// }
// lastVal = value;
//
// }
EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) dataItem.getProperties();
String action = mainScreenItemProperties.getBlockRendererRequiredProperties().getStringProperty("action");
if (action != null && !action.trim().isEmpty()) {
_block.executeActionCommand(action, EJScreenType.MAIN);
}
}
}
}
}
use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.
the class EJRWTMultiRecordBlockRenderer 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.getBlockRendererRequiredProperties();
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
if (labelProvider != null) {
String labelOrientation = blockProperties.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
int displayedWidth = blockProperties.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
// width
if (displayedWidth == 0) {
if (itemProps.getLabel() != null) {
// add offset
displayedWidth = itemProps.getLabel().length() + 2;
} else {
displayedWidth = 5;
}
}
String visualAttribute = blockProperties.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.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());
}
TableViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), displayedWidth, labelProvider, getComponentStyle(labelOrientation));
TableColumn column = viewerColumn.getColumn();
EJ_RWT.setTestId(column, blockProperties.getName() + "." + itemProps.getReferencedItemName());
column.setData("KEY", itemProps.getReferencedItemName());
column.setData("ITEM", item);
column.setToolTipText(itemProps.getHint());
ColumnInfo info = new ColumnInfo();
column.setData("INFO", info);
column.setMoveable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
column.setResizable(info.resizable = 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 + 1 padding
column.setWidth(info.width = ((int) ((column.getWidth() + 1) * avgCharWidth)));
}
}
if (!item.isVisible()) {
column.setWidth(0);
column.setResizable(false);
}
return labelProvider;
}
}
return null;
}
use of org.entirej.framework.core.interfaces.EJScreenItemController 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