use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties in project rap by entirej.
the class EJRWTListRecordBlockRenderer 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) {
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
if (labelProvider != null) {
EJFrameworkExtensionProperties blockProperties = itemProps.getBlockRendererRequiredProperties();
String visualAttribute = blockProperties.getStringProperty(EJRWTListRecordBlockDefinitionProperties.VISUAL_ATTRIBUTE_PROPERTY);
if (visualAttribute != null) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null)
itemRenderer.setInitialVisualAttribute(va);
}
}
return labelProvider;
}
return null;
}
use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties 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.properties.EJCoreVisualAttributeProperties 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.properties.EJCoreVisualAttributeProperties in project rap by entirej.
the class EJRWTStatusbar method createContainer.
@Override
public void createContainer(final EJRWTApplicationManager manager, Composite parent, EJFrameworkExtensionProperties rendererprop) {
int style = SWT.NONE;
panel = new Composite(parent, style);
panel.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
actionProcessor = manager.getApplicationActionProcessor();
final EJFrameworkExtensionPropertyList propertyList = rendererprop.getPropertyList(SECTIONS);
if (propertyList == null) {
return;
}
List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
GridLayout layout = new GridLayout(allListEntries.size(), false);
panel.setLayout(layout);
for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
Control control;
final String action = entry.getProperty(ACTION);
if (action != null && action.trim().length() > 0) {
final Link linkField;
String alignmentProperty = entry.getProperty(PROPERTY_ALIGNMENT);
// use workaround to make sure link also provide alignment
if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
if (alignmentProperty.equals(PROPERTY_ALIGNMENT_LEFT)) {
control = linkField = new Link(panel, style);
} else if (alignmentProperty.equals(PROPERTY_ALIGNMENT_RIGHT)) {
EJRWTEntireJGridPane sub = new EJRWTEntireJGridPane(panel, 3);
control = sub;
sub.cleanLayout();
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
linkField = new Link(sub, style);
} else if (alignmentProperty.equals(PROPERTY_ALIGNMENT_CENTER)) {
EJRWTEntireJGridPane sub = new EJRWTEntireJGridPane(panel, 3);
control = sub;
sub.cleanLayout();
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
linkField = new Link(sub, style);
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
} else {
control = linkField = new Link(panel, style);
}
} else {
control = linkField = new Link(panel, style);
}
String paramName = entry.getProperty(PARAMETER);
if (paramName != null && paramName.length() > 0) {
final EJApplicationLevelParameter applicationLevelParameter = manager.getApplicationLevelParameter(paramName);
if (applicationLevelParameter != null) {
Object value = applicationLevelParameter.getValue();
linkField.setText(String.format("<a>%s</a>", (value == null ? "" : value.toString())));
applicationLevelParameter.addParameterChangedListener(new ParameterChangedListener() {
@Override
public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
linkField.setText(String.format("<a>%s</a>", (newValue == null ? "" : newValue.toString())));
}
});
}
}
if (actionProcessor != null) {
linkField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
actionProcessor.executeActionCommand(manager.getFrameworkManager(), action);
} catch (EJActionProcessorException e1) {
logger.error(e1.getMessage(), e);
}
}
});
}
// set VA
String visualAttribute = entry.getProperty(VISUAL_ATTRIBUTE_PROPERTY);
if (visualAttribute != null && visualAttribute.length() > 0) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null) {
Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(va);
if (background != null) {
linkField.setBackground(background);
}
Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(va);
if (foreground != null) {
linkField.setForeground(foreground);
}
linkField.setFont(EJRWTVisualAttributeUtils.INSTANCE.getFont(va, linkField.getFont()));
}
}
linkField.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
control.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
} else {
final Label section = new Label(panel, getComponentStyle(entry.getProperty(PROPERTY_ALIGNMENT), SWT.NONE));
control = section;
section.setData(EJ_RWT.MARKUP_ENABLED, Boolean.TRUE);
String paramName = entry.getProperty(PARAMETER);
if (paramName != null && paramName.length() > 0) {
final EJApplicationLevelParameter applicationLevelParameter = manager.getApplicationLevelParameter(paramName);
if (applicationLevelParameter != null) {
Object value = applicationLevelParameter.getValue();
section.setText(value == null ? "" : value.toString());
applicationLevelParameter.addParameterChangedListener(new ParameterChangedListener() {
@Override
public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
section.setText(newValue == null ? "" : newValue.toString());
}
});
}
}
// set VA
String visualAttribute = entry.getProperty(VISUAL_ATTRIBUTE_PROPERTY);
if (visualAttribute != null && visualAttribute.length() > 0) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null) {
Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(va);
if (background != null) {
section.setBackground(background);
}
Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(va);
if (foreground != null) {
section.setForeground(foreground);
}
section.setFont(EJRWTVisualAttributeUtils.INSTANCE.getFont(va, section.getFont()));
}
}
}
GridData gridData = new GridData();
gridData.verticalAlignment = SWT.CENTER;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
control.setLayoutData(gridData);
boolean expand = Boolean.valueOf(entry.getProperty(EXPAND_X));
if (expand) {
gridData.grabExcessHorizontalSpace = true;
}
String width = entry.getProperty(WIDTH);
if (width != null && width.length() > 0) {
try {
gridData.widthHint = (Integer.parseInt(width));
} catch (Exception ex) {
// ignore
}
}
//
}
}
use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties in project rap by entirej.
the class EJRWTDateTimeItemRenderer method createColumnLabelProvider.
@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
final DateFormat format = createDateFormat(controller);
ColumnLabelProvider provider = new ColumnLabelProvider() {
@Override
public Color getBackground(Object element) {
EJCoreVisualAttributeProperties properties = getAttributes(item, element);
if (properties != null) {
Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(properties);
if (background != null) {
return background;
}
}
return super.getBackground(element);
}
@Override
public Color getForeground(Object element) {
EJCoreVisualAttributeProperties properties = getAttributes(item, element);
if (properties != null) {
Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(properties);
if (foreground != null) {
return foreground;
}
}
return super.getForeground(element);
}
private EJCoreVisualAttributeProperties getAttributes(final EJScreenItemProperties item, Object element) {
EJCoreVisualAttributeProperties properties = null;
if (element instanceof EJDataRecord) {
EJDataRecord record = (EJDataRecord) element;
properties = record.getItem(item.getReferencedItemName()).getVisualAttribute();
}
if (properties == null) {
properties = _visualAttributeProperties;
}
return properties;
}
@Override
public Font getFont(Object element) {
EJCoreVisualAttributeProperties properties = getAttributes(item, element);
if (properties != null) {
return EJRWTVisualAttributeUtils.INSTANCE.getFont(properties, super.getFont(element));
}
return super.getFont(element);
}
@Override
public String getText(Object element) {
if (element instanceof EJDataRecord) {
EJDataRecord record = (EJDataRecord) element;
Object value = record.getValue(item.getReferencedItemName());
if (value != null) {
return format.format(value);
}
}
return "";
}
};
return provider;
}
Aggregations