Search in sources :

Example 16 with EJCoreVisualAttributeProperties

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;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 17 with EJCoreVisualAttributeProperties

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);
    }
}
Also used : Color(java.awt.Color) ArrayList(java.util.ArrayList) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) ChartStyle(org.eclipse.rap.chartjs.ChartStyle) RGB(org.eclipse.swt.graphics.RGB) RowInfo(org.eclipse.rap.chartjs.pie.PieChartRowData.RowInfo) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) RowInfo(org.eclipse.rap.chartjs.pie.PieChartRowData.RowInfo) JsonObject(org.eclipse.rap.json.JsonObject) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) PieChartRowData(org.eclipse.rap.chartjs.pie.PieChartRowData) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 18 with EJCoreVisualAttributeProperties

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;
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) TableColumn(org.eclipse.swt.widgets.TableColumn) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) HtmlBaseColumnLabelProvider(org.entirej.applicationframework.rwt.table.HtmlBaseColumnLabelProvider) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJRWTTableSortSelectionListener(org.entirej.applicationframework.rwt.table.EJRWTTableSortSelectionListener) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties) EJRWTAbstractTableSorter(org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter)

Example 19 with EJCoreVisualAttributeProperties

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
            }
        }
    // 
    }
}
Also used : EJFrameworkExtensionPropertyList(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException) EJApplicationLevelParameter(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException) EJApplicationException(org.entirej.framework.core.EJApplicationException) ParameterChangedListener(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter.ParameterChangedListener) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Link(org.eclipse.swt.widgets.Link) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 20 with EJCoreVisualAttributeProperties

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;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Color(org.eclipse.swt.graphics.Color) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Aggregations

EJCoreVisualAttributeProperties (org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)24 EJScreenItemProperties (org.entirej.framework.core.properties.interfaces.EJScreenItemProperties)16 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)15 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)15 Color (org.eclipse.swt.graphics.Color)12 EJScreenItemController (org.entirej.framework.core.interfaces.EJScreenItemController)12 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)11 EJRWTAppItemRenderer (org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer)8 EJCoreMainScreenItemProperties (org.entirej.framework.core.properties.EJCoreMainScreenItemProperties)8 JsonObject (org.eclipse.rap.json.JsonObject)7 EJManagedItemRendererWrapper (org.entirej.framework.core.renderers.EJManagedItemRendererWrapper)7 EJFrameworkExtensionPropertyList (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList)6 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)6 GridData (org.eclipse.swt.layout.GridData)5 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)5 ArrayList (java.util.ArrayList)4 Action (org.eclipse.jface.action.Action)4 IAction (org.eclipse.jface.action.IAction)4 ToolBarManager (org.eclipse.jface.action.ToolBarManager)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4