Search in sources :

Example 16 with EJScreenItemController

use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.

the class EJRWTBarChartRecordBlockRenderer method buildGuiComponent.

@Override
public void buildGuiComponent(EJRWTEntireJGridPane blockCanvas) {
    EJFrameworkExtensionProperties appProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
    if (appProp != null) {
        EJFrameworkExtensionProperties propertyGroup = appProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
        if (propertyGroup != null) {
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY);
            addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY);
        }
    }
    EJBlockProperties blockProperties = _block.getProperties();
    EJMainScreenProperties mainScreenProperties = blockProperties.getMainScreenProperties();
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = mainScreenProperties.getWidth();
    gridData.heightHint = mainScreenProperties.getHeight();
    gridData.horizontalSpan = mainScreenProperties.getHorizontalSpan();
    gridData.verticalSpan = mainScreenProperties.getVerticalSpan();
    gridData.grabExcessHorizontalSpace = mainScreenProperties.canExpandHorizontally();
    gridData.grabExcessVerticalSpace = mainScreenProperties.canExpandVertically();
    if (gridData.grabExcessHorizontalSpace) {
        gridData.minimumWidth = mainScreenProperties.getWidth();
    }
    if (gridData.grabExcessVerticalSpace) {
        gridData.minimumHeight = mainScreenProperties.getHeight();
    }
    _rendererProp = blockProperties.getBlockRendererProperties();
    blockCanvas.setLayoutData(gridData);
    EJFrameworkExtensionProperties sectionProperties = null;
    if (_rendererProp != null) {
        sectionProperties = _rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
    }
    if (sectionProperties != null && sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
        int style = ExpandableComposite.TITLE_BAR;
        String mode = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
        if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
            style = style | ExpandableComposite.TWISTIE;
        } else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
            style = style | ExpandableComposite.TREE_NODE;
        }
        if (sectionProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
            style = style | ExpandableComposite.EXPANDED;
        }
        Section section = toolkit.createSection(blockCanvas, style);
        section.setLayoutData(gridData);
        String title = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
        if (title != null) {
            section.setText(title);
        }
        EJRWTImageRetriever.getGraphicsProvider().rendererSection(section);
        String frameTitle = mainScreenProperties.getFrameTitle();
        if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
            Group group = new Group(section, SWT.NONE);
            group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            group.setLayout(new FillLayout());
            group.setLayoutData(gridData);
            hookKeyListener(group);
            group.setText(frameTitle);
            _mainPane = new EJRWTEntireJGridPane(group, 1, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            section.setClient(group);
        } else {
            _mainPane = new EJRWTEntireJGridPane(section, 1);
            _mainPane.setLayoutData(gridData);
            _mainPane.cleanLayoutHorizontal();
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            section.setClient(_mainPane);
        }
        final EJFrameworkExtensionPropertyList propertyList = sectionProperties.getPropertyList(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTIONS);
        if (propertyList != null && propertyList.getAllListEntries().size() > 0) {
            ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
            final ToolBar toolbar = toolBarManager.createControl(section);
            final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
            toolbar.setCursor(handCursor);
            // Cursor needs to be explicitly disposed
            toolbar.addDisposeListener(new DisposeListener() {

                @Override
                public void widgetDisposed(DisposeEvent e) {
                    if (handCursor != null && handCursor.isDisposed() == false) {
                        handCursor.dispose();
                    }
                }
            });
            List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
            for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
                final String actionID = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_ID);
                String actionImage = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_IMAGE);
                String actionName = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_NAME);
                String actionTooltip = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_TOOLTIP);
                if (actionID != null) {
                    Action action = new Action(actionID, IAction.AS_PUSH_BUTTON) {

                        @Override
                        public void runWithEvent(Event event) {
                            _block.executeActionCommand(actionID, EJScreenType.MAIN);
                        }
                    };
                    if (actionName != null) {
                        action.setText(actionName);
                    }
                    if (actionTooltip != null) {
                        action.setDescription(actionTooltip);
                    }
                    if (actionImage != null && actionImage.length() > 0) {
                        action.setImageDescriptor((EJRWTImageRetriever.createDescriptor(actionImage)));
                    }
                    toolBarManager.add(action);
                }
            }
            toolBarManager.update(true);
            section.setTextClient(toolbar);
        }
    } else {
        String frameTitle = mainScreenProperties.getFrameTitle();
        if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
            Group group = new Group(blockCanvas, SWT.NONE);
            group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            group.setLayout(new FillLayout());
            group.setLayoutData(gridData);
            hookKeyListener(group);
            group.setText(frameTitle);
            _mainPane = new EJRWTEntireJGridPane(group, 1, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
        } else {
            _mainPane = new EJRWTEntireJGridPane(blockCanvas, 1);
            _mainPane.setLayoutData(gridData);
            _mainPane.cleanLayout();
            _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
        }
    }
    hookKeyListener(_mainPane);
    int style = SWT.NONE;
    Collection<EJItemGroupProperties> allItemGroupProperties = _block.getProperties().getScreenItemGroupContainer(EJScreenType.MAIN).getAllItemGroupProperties();
    {
        _chartView = null;
        if (allItemGroupProperties.size() > 0) {
            EJItemGroupProperties displayProperties = allItemGroupProperties.iterator().next();
            if (displayProperties.dispayGroupFrame() && displayProperties.getFrameTitle() != null && displayProperties.getFrameTitle().length() > 0) {
                Group group = new Group(_mainPane, SWT.NONE);
                group.setLayout(new FillLayout());
                group.setText(displayProperties.getFrameTitle());
                group.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
                _chartView = new BarChart(group, style) {

                    protected void action(String method, org.eclipse.rap.json.JsonObject parameters) {
                        processAction(method, parameters);
                    }
                };
            } else {
                _chartView = new BarChart(_mainPane, displayProperties.dispayGroupFrame() ? style | SWT.BORDER : style) {

                    protected void action(String method, org.eclipse.rap.json.JsonObject parameters) {
                        processAction(method, parameters);
                    }
                };
                _chartView.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
            }
        } else {
            _chartView = new BarChart(_mainPane, style) {

                protected void action(String method, org.eclipse.rap.json.JsonObject parameters) {
                    processAction(method, parameters);
                }
            };
            _chartView.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
        }
    }
    _chartView.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent arg0) {
            setHasFocus(false);
        }

        @Override
        public void focusGained(FocusEvent arg0) {
            setHasFocus(true);
        }
    });
    _mainPane.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent arg0) {
            if (!_chartView.isFocusControl()) {
                setHasFocus(true);
            }
        }
    });
    _chartView.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent arg0) {
            if (!_chartView.isFocusControl()) {
                setHasFocus(true);
            }
        }
    });
    for (EJItemGroupProperties groupProperties : allItemGroupProperties) {
        Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
        for (EJScreenItemProperties screenItemProperties : itemProperties) {
            EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) screenItemProperties;
            String visualAttribute = mainScreenItemProperties.getBlockRendererRequiredProperties().getStringProperty(VISUAL_ATTRIBUTE_PROPERTY);
            EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, mainScreenItemProperties.getReferencedItemName());
            EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) item.getManagedItemRenderer().getUnmanagedRenderer();
            if (visualAttribute != null) {
                EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
                if (va != null) {
                    itemRenderer.setInitialVisualAttribute(va);
                }
            }
            if (item.getProperties().getVisualAttributeProperties() != null) {
                itemRenderer.setVisualAttribute(item.getProperties().getVisualAttributeProperties());
            }
        }
    }
    appItemRenderer = null;
    final EJItemController blockItemController = _block.getBlockItemController(xAxisColumn);
    String itemRendererName = blockItemController.getProperties().getItemRendererName();
    if (itemRendererName != null) {
        EJScreenItemController itemController = new EJScreenItemController() {

            @Override
            public boolean validateFromLov() {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void setItemLovMapping(String lovMapping) {
            // TODO Auto-generated method stub
            }

            @Override
            public void removeItemValueChangedListener(EJScreenItemValueChangedListener listener) {
            // TODO Auto-generated method stub
            }

            @Override
            public void removeItemFocusListener(EJItemFocusListener listener) {
            // TODO Auto-generated method stub
            }

            @Override
            public void itemValueChaged(Object newValue) {
            // TODO Auto-generated method stub
            }

            @Override
            public void itemFocusLost() {
            // TODO Auto-generated method stub
            }

            @Override
            public void itemFocusGained() {
            // TODO Auto-generated method stub
            }

            @Override
            public boolean isVisible() {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public boolean isSpacerItem() {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void initialiseRenderer() {
            // TODO Auto-generated method stub
            }

            @Override
            public void initialise(EJBlockItemRendererRegister blockItemRegister) {
            // TODO Auto-generated method stub
            }

            @Override
            public EJScreenType getScreenType() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public EJItemProperties getReferencedItemProperties() {
                return blockItemController.getProperties();
            }

            @Override
            public EJScreenItemProperties getProperties() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public String getName() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public EJManagedItemRendererWrapper getManagedItemRenderer() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public EJBlockItemRendererRegister getItemRendererRegister() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public EJItemRenderer getItemRenderer() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public EJItemLovController getItemLovController() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public EJInternalForm getForm() {
                // TODO Auto-generated method stub
                return _block.getForm();
            }

            @Override
            public EJInternalBlock getBlock() {
                return _block.getBlock();
            }

            @Override
            public void gainFocus() {
            // TODO Auto-generated method stub
            }

            @Override
            public void executeActionCommand() {
            // TODO Auto-generated method stub
            }

            @Override
            public void addItemValueChangedListener(EJScreenItemValueChangedListener listener) {
            // TODO Auto-generated method stub
            }

            @Override
            public void addItemFocusListener(EJItemFocusListener listener) {
            // TODO Auto-generated method stub
            }
        };
        EJManagedItemRendererWrapper renderer = EJRendererFactory.getInstance().getItemRenderer(itemController, new EJCoreMainScreenItemProperties(_block.getProperties(), false));
        if (renderer != null && renderer.getUnmanagedRenderer() instanceof EJRWTAppItemRenderer) {
            appItemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
        }
    }
    refresh();
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) EJRWTDeleteAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTDeleteAction) EJRWTQueryAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTQueryAction) EJRWTUpdateAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTUpdateAction) EJRWTInsertAction(org.entirej.applicationframework.rwt.application.components.actions.EJRWTInsertAction) Action(org.eclipse.jface.action.Action) EJItemGroupProperties(org.entirej.framework.core.properties.interfaces.EJItemGroupProperties) EJBlockItemRendererRegister(org.entirej.framework.core.renderers.registry.EJBlockItemRendererRegister) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) JsonObject(org.eclipse.rap.json.JsonObject) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) ToolBarManager(org.eclipse.jface.action.ToolBarManager) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) BarChart(org.eclipse.rap.chartjs.bar.BarChart) EJScreenItemValueChangedListener(org.entirej.framework.core.renderers.eventhandlers.EJScreenItemValueChangedListener) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJFrameworkExtensionPropertyList(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList) MouseEvent(org.eclipse.swt.events.MouseEvent) EJItemFocusListener(org.entirej.framework.core.renderers.eventhandlers.EJItemFocusListener) MouseAdapter(org.eclipse.swt.events.MouseAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJBlockProperties(org.entirej.framework.core.properties.interfaces.EJBlockProperties) EJItemController(org.entirej.framework.core.data.controllers.EJItemController) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) JsonObject(org.eclipse.rap.json.JsonObject) EJMainScreenProperties(org.entirej.framework.core.properties.interfaces.EJMainScreenProperties) EJItemFocusListener(org.entirej.framework.core.renderers.eventhandlers.EJItemFocusListener) FocusListener(org.eclipse.swt.events.FocusListener) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 17 with EJScreenItemController

use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.

the class EJRWTBarChartRecordBlockRenderer method refresh.

public void refresh(Object input) {
    if (_chartView != null && !_chartView.isDisposed()) {
        if (xAxisColumn == null && xAxisColumn.isEmpty()) {
            return;
        }
        Map<Object, Map<String, Float>> dataset = new HashMap<Object, Map<String, Float>>();
        Map<Object, Map<String, EJCoreVisualAttributeProperties>> datasetVa = new HashMap<Object, Map<String, EJCoreVisualAttributeProperties>>();
        Collection<EJDataRecord> records = _block.getRecords();
        Collection<EJScreenItemController> screenItems = getScreenItems();
        List<Object> labelsIndex = new ArrayList<Object>();
        Map<String, Number> lastVal = new HashMap<String, Number>();
        for (EJDataRecord ejDataRecord : records) {
            Object xobject = ejDataRecord.getValue(xAxisColumn);
            if (xobject != null) {
                Map<String, Float> set = dataset.get(xobject);
                Map<String, EJCoreVisualAttributeProperties> setVa = datasetVa.get(xobject);
                if (set == null) {
                    set = new HashMap<String, Float>();
                    setVa = new HashMap<String, EJCoreVisualAttributeProperties>();
                    dataset.put(xobject, set);
                    datasetVa.put(xobject, setVa);
                    labelsIndex.add(xobject);
                }
                for (EJScreenItemController sItem : screenItems) {
                    if (!sItem.isSpacerItem()) {
                        Object yvalue = ejDataRecord.getValue(sItem.getName());
                        Float val = null;
                        if (yvalue instanceof Number) {
                            lastVal.put(sItem.getName(), (Number) yvalue);
                            val = ((Number) yvalue).floatValue();
                        } else {
                            Number last = lastVal.get(sItem.getName());
                            val = last != null ? last.floatValue() : 0f;
                        }
                        set.put(sItem.getName(), val);
                        EJCoreVisualAttributeProperties visualAttribute = ejDataRecord.getItem(sItem.getName()).getVisualAttribute();
                        if (visualAttribute == null)
                            visualAttribute = sItem.getItemRenderer().getVisualAttributeProperties();
                        setVa.put(sItem.getName(), visualAttribute);
                    }
                }
            }
        }
        List<String> xlabel = new ArrayList<String>(labelsIndex.size());
        for (Object object : labelsIndex) {
            String xvalue;
            xvalue = getStrValue(object);
            xlabel.add(xvalue);
        }
        BarChartRowData chartRowData = new BarChartRowData(xlabel.toArray(new String[0]));
        for (EJScreenItemController sItem : screenItems) {
            if (sItem.isSpacerItem())
                continue;
            List<Float> row = new ArrayList<Float>();
            List<EJCoreVisualAttributeProperties> rowVa = new ArrayList<EJCoreVisualAttributeProperties>();
            for (Object object : labelsIndex) {
                Map<String, Float> map = dataset.get(object);
                Map<String, EJCoreVisualAttributeProperties> mapVa = datasetVa.get(object);
                if (map == null || mapVa == null)
                    continue;
                row.add(map.get(sItem.getName()));
                rowVa.add(mapVa.get(sItem.getName()));
            }
            float[] floatArray = new float[row.size()];
            ChartStyle[] styleArray = new ChartStyle[row.size()];
            int i = 0;
            for (Float f : row) {
                floatArray[i] = (f != null ? f : 0);
                ChartStyle colors = new ChartStyle(220, 220, 220, 0.8f);
                EJCoreVisualAttributeProperties attributeProperties = rowVa.get(i);
                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()));
                    }
                }
                styleArray[i] = colors;
                i++;
            }
            /*
                 * String pointStyle = "circle";
                 * 
                 * ChartStyle chartStyle;
                 */
            BarChartRowData.RowInfo info = new BarChartRowData.RowInfo();
            String label = sItem.getProperties().getLabel();
            if (label.trim().isEmpty()) {
                label = sItem.getProperties().getReferencedItemName();
            }
            info.setLabel(label);
            EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) sItem.getProperties();
            String action = mainScreenItemProperties.getBlockRendererRequiredProperties().getStringProperty("action");
            if (action == null || action.trim().isEmpty()) {
                action = "select";
            }
            ChartStyle colors = new ChartStyle(220, 220, 220, 0.8f);
            EJCoreVisualAttributeProperties attributeProperties = sItem.getItemRenderer().getVisualAttributeProperties();
            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()));
                }
            }
            info.setAction(action);
            info.setChartStyle(colors);
            info.setHidden(!sItem.isVisible());
            chartRowData.addRow(info, floatArray, styleArray);
        // chartRowData.addRow(floatArray, colors);
        }
        if (horizontalBar)
            _chartView.loadHorizontal(chartRowData, options);
        else
            _chartView.load(chartRowData, options);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) ChartStyle(org.eclipse.rap.chartjs.ChartStyle) Color(java.awt.Color) RGB(org.eclipse.swt.graphics.RGB) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) JsonObject(org.eclipse.rap.json.JsonObject) Map(java.util.Map) HashMap(java.util.HashMap) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties) BarChartRowData(org.eclipse.rap.chartjs.bar.BarChartRowData)

Example 18 with EJScreenItemController

use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.

the class EJRWTHtmlTableBlockRenderer method createHTML.

private void createHTML() {
    if (_browser == null || _browser.isDisposed()) {
        return;
    }
    StringBuilder builder = new StringBuilder();
    {
        builder.append("<div id=\"table\" style=\"float:left;width:100%;height:100%; overflow:auto\">");
        {
            EJCoreBlockProperties blockProperties = _block.getProperties();
            int cellSpacing = blockProperties.getBlockRendererProperties().getIntProperty(CELL_SPACING_PROPERTY, 0);
            int cellPadding = blockProperties.getBlockRendererProperties().getIntProperty(CELL_PADDING_PROPERTY, 0);
            boolean rowSelection = blockProperties.getBlockRendererProperties().getBooleanProperty(ROW_SELECTION, false);
            String rowSelectionVA = blockProperties.getBlockRendererProperties().getStringProperty(ROW_SELECTION_VA);
            String selectionTD = "<td width=1 class=\"rowindi\" style=\" border-left: 2px solid #4D90F0;\n" + "    background-color: #fafafa; visibility:hidden \"></td>";
            if (rowSelectionVA != null && !rowSelectionVA.isEmpty()) {
                EJCoreVisualAttributeProperties selectVa = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(rowSelectionVA);
                Color backgroundColor = selectVa.getBackgroundColor();
                if (selectVa != null) {
                    String hexString = toHex(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue());
                    selectionTD = "<td width=1 class=\"rowindi\" style=\" border-left: 2px solid " + hexString + ";\n" + "    background-color: #fafafa; visibility:hidden \"></td>";
                }
            }
            String tdStyle = null;
            if (cellPadding > 0) {
                String str = String.valueOf(cellPadding);
                tdStyle = String.format("padding: %spx %spx %spx %spx; ", str, str, str, str);
            }
            builder.append("<table border=0 cellspacing=").append(cellSpacing).append(" width=\"100%\" >");
            {
                builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
                builder.append(createVACSSUrl());
                builder.append("\">");
                int charHeight = EJRWTImageRetriever.getGraphicsProvider().getCharHeight(Display.getDefault().getSystemFont());
                if (_headerTag != null) {
                    String sortHeader = _headerTag;
                    if (activeSortColumn != null) {
                        StringBuilder header = new StringBuilder();
                        if (activeSortColumn.direction != SortInfo.DIRECTION.NONE) {
                            header.append("&nbsp <img name=\"open\" ");
                            header.append("src=\"");
                            header.append(createImageUrl(activeSortColumn.direction == SortInfo.DIRECTION.ASC ? "resource/widget/rap/column/sort-indicator-up.png" : "resource/widget/rap/column/sort-indicator-down.png"));
                            header.append("\"");
                            header.append(" >");
                        }
                        sortHeader = _headerTag.replace(String.format("<esh %s/>", activeSortColumn.id), header.toString());
                    }
                    builder.append(sortHeader);
                }
                Collection<EJDataRecord> records = _tableBaseRecords;
                builder.append("<tbody>");
                if (records.size() > 0) {
                    records = sortedRecords(records);
                    int lastRowSpan = 0;
                    String oddVA = "default_all";
                    String valueVA = blockProperties.getBlockRendererProperties().getStringProperty(ROW_ODD_VA);
                    if (valueVA != null && valueVA.length() > 0) {
                        oddVA = valueVA;
                    }
                    String evenVA = "default_all";
                    valueVA = blockProperties.getBlockRendererProperties().getStringProperty(ROW_EVEN_VA);
                    if (valueVA != null && valueVA.length() > 0) {
                        evenVA = valueVA;
                    }
                    int rowid = 0;
                    for (EJDataRecord record : records) {
                        String trDef = String.format("<tr style=\"height: %spx\" recid=\"%s\" >", String.valueOf(charHeight), String.valueOf(getDisplayedRecordNumber(record)));
                        rowid++;
                        if (lastRowSpan > 1) {
                            for (int i = 1; i < lastRowSpan; i++) {
                                builder.append(trDef).append("</tr>");
                            }
                            lastRowSpan = 0;
                        }
                        builder.append(trDef);
                        if (rowSelection) {
                            builder.append(selectionTD);
                        }
                        for (EJCoreMainScreenItemProperties item : _items) {
                            String styleClass = (rowid % 2) != 0 ? oddVA : evenVA;
                            String actionDef = null;
                            String alignment = null;
                            float width = -1;
                            ColumnLabelProvider columnLabelProvider = _itemLabelProviders.get(item.getReferencedItemName());
                            EJScreenItemController screenItem = _block.getScreenItem(EJScreenType.MAIN, item.getReferencedItemName());
                            EJCoreVisualAttributeProperties iva = screenItem.getManagedItemRenderer().getVisualAttributeProperties();
                            if (iva != null) {
                                styleClass = iva.getName();
                            }
                            EJFrameworkExtensionProperties rendererProperties = item.getReferencedItemProperties().getItemRendererProperties();
                            EJCoreVisualAttributeProperties diva = record.getItem(item.getReferencedItemName()).getVisualAttribute();
                            if (diva != null) {
                                styleClass = diva.getName();
                            }
                            builder.append(String.format("<td class=\"%s\" ", styleClass));
                            if (tdStyle != null) {
                                builder.append(String.format(" style=\'%s\'", tdStyle));
                            }
                            EJFrameworkExtensionProperties extentionProperties = item.getBlockRendererRequiredProperties();
                            if (width == -1) {
                                width = extentionProperties.getIntProperty(DISPLAY_WIDTH_PROPERTY, 0);
                            }
                            String action = extentionProperties.getStringProperty(CELL_ACTION_COMMAND);
                            if (action == null || action.length() == 0) {
                                action = item.getActionCommand();
                            }
                            if (action != null && action.length() > 0) {
                                actionDef = String.format("em='eaction' earg='%s , %s' ", action, String.valueOf(getDisplayedRecordNumber(record)));
                            }
                            if (width > 0) {
                                Font font = columnLabelProvider.getFont(new Object());
                                if (font == null)
                                    font = _browser.getFont();
                                if (font != null) {
                                    float avgCharWidth = RWTUtils.getAvgCharWidth(font);
                                    if (avgCharWidth > 0) {
                                        if (width != 1) {
                                            // add +1 padding
                                            width = ((int) (((width + 1) * avgCharWidth)));
                                        }
                                    }
                                }
                                builder.append(String.format(" width=%s ", width));
                            }
                            if (alignment == null) {
                                String alignmentProperty = rendererProperties.getStringProperty(PROPERTY_ALIGNMENT);
                                if (alignmentProperty == null) {
                                    alignmentProperty = rendererProperties.getStringProperty("ALLIGNMENT");
                                }
                                alignment = getComponentAlignment(alignmentProperty);
                            }
                            if (alignment != null) {
                                builder.append(String.format(" align=\'%s\'", alignment));
                            }
                            final String caseProperty = getComponentCase(rendererProperties.getStringProperty(PROPERTY_CASE));
                            builder.append(String.format(" font style=\'%s\'", caseProperty));
                            if (item.getHint() != null && !item.getHint().isEmpty()) {
                                builder.append(String.format(" title=\'%s\'", item.getHint()));
                            }
                            builder.append(">");
                            String text = columnLabelProvider instanceof HtmlBaseColumnLabelProvider ? ((HtmlBaseColumnLabelProvider) columnLabelProvider).getSrcText(record) : columnLabelProvider.getText(record);
                            boolean htmlformatting = extentionProperties.getBooleanProperty(ENABLE_MARKUP, false) || rendererProperties.getBooleanProperty("HTML_FORMAT", false);
                            if (!htmlformatting)
                                text = ignoreHtml(text);
                            if (actionDef != null && text != null && text.length() > 0) {
                                builder.append(String.format("<ejl><u %s class=\"%s, %s\"  ", "style=\"line-height: 100%;cursor: pointer; cursor: hand;\"", ("default_all".equals(styleClass) ? "default_link_fg" : "default_link"), styleClass));
                                builder.append(actionDef).append(">");
                            }
                            Image image = columnLabelProvider instanceof HtmlBaseColumnLabelProvider ? ((HtmlBaseColumnLabelProvider) columnLabelProvider).getSrcImage(record) : columnLabelProvider.getImage(record);
                            if (image != null) {
                                if (actionDef == null) {
                                    builder.append("<img src=\"");
                                    builder.append(ImageFactory.getImagePath(image));
                                    builder.append("\"");
                                    builder.append(String.format(" class=\"default %s\"  >", styleClass));
                                } else {
                                    builder.append("<ejl><img src=\"");
                                    builder.append(ImageFactory.getImagePath(image));
                                    builder.append("\"");
                                    builder.append(String.format("style=\"cursor: hand;\" class=\"%s \" %s  > </ejl>", styleClass, actionDef));
                                }
                            }
                            // builder.append(String.format("<p class=\"default %s\">",
                            // styleClass));
                            // if(textSelection && actionDef == null && !htmlformatting)
                            // {
                            // builder.append("<input value=\"");
                            // builder.append(text);
                            // builder.append("\" ");
                            // builder.append("style=\"border:none;\"");
                            // builder.append(" readonly />");
                            // }
                            // else
                            builder.append(text);
                            builder.append("</td>");
                        }
                        builder.append("</tr>");
                    }
                } else {
                    String trDef = String.format("<tr style=\"height: %spx\"  >", String.valueOf(charHeight));
                    builder.append(trDef);
                    for (EJCoreMainScreenItemProperties item : _items) {
                        String padding = tdStyle;
                        float width = -1;
                        ColumnLabelProvider columnLabelProvider = _itemLabelProviders.get(item.getReferencedItemName());
                        builder.append(String.format("<td class=\"%s\" ", "default_all"));
                        if (padding != null) {
                            builder.append(String.format(" style=\'%s\'", padding));
                        }
                        EJFrameworkExtensionProperties extentionProperties = item.getBlockRendererRequiredProperties();
                        if (width == -1) {
                            width = extentionProperties.getIntProperty(DISPLAY_WIDTH_PROPERTY, 0);
                        }
                        if (width > 0) {
                            Font font = columnLabelProvider.getFont(new Object());
                            if (font == null)
                                font = _browser.getFont();
                            if (font != null) {
                                float avgCharWidth = RWTUtils.getAvgCharWidth(font);
                                if (avgCharWidth > 0) {
                                    if (width != 1) {
                                        // add +1 padding
                                        width = ((int) (((width + 1) * avgCharWidth)));
                                    }
                                }
                            }
                            builder.append(String.format(" width=%s ", width));
                        }
                        builder.append(">");
                        builder.append("</td>");
                    }
                    builder.append("</tr>");
                }
            }
            builder.append("</tbody></table>");
        }
        builder.append("</<div>");
    }
    String html = builder.toString();
    if (_browser.getText() == null || (!html.equals(_browser.getText()))) {
        _browser.setText(html);
        LOGGER.debug(html);
    }
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) Color(java.awt.Color) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) BufferedImage(java.awt.image.BufferedImage) Image(org.eclipse.swt.graphics.Image) Font(org.eclipse.swt.graphics.Font) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) HtmlBaseColumnLabelProvider(org.entirej.applicationframework.rwt.table.HtmlBaseColumnLabelProvider) HtmlBaseColumnLabelProvider(org.entirej.applicationframework.rwt.table.HtmlBaseColumnLabelProvider) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) Collection(java.util.Collection) JsonObject(org.eclipse.rap.json.JsonObject) EJCoreBlockProperties(org.entirej.framework.core.properties.EJCoreBlockProperties) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 19 with EJScreenItemController

use of org.entirej.framework.core.interfaces.EJScreenItemController 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 20 with EJScreenItemController

use of org.entirej.framework.core.interfaces.EJScreenItemController in project rap by entirej.

the class EJRWTLineChartRecordBlockRenderer 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;
}
Also used : EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJItemGroupProperties(org.entirej.framework.core.properties.interfaces.EJItemGroupProperties) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) ArrayList(java.util.ArrayList) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties)

Aggregations

EJScreenItemController (org.entirej.framework.core.interfaces.EJScreenItemController)29 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)17 EJCoreMainScreenItemProperties (org.entirej.framework.core.properties.EJCoreMainScreenItemProperties)14 EJManagedItemRendererWrapper (org.entirej.framework.core.renderers.EJManagedItemRendererWrapper)13 EJCoreVisualAttributeProperties (org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)12 EJRWTAppItemRenderer (org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer)11 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)11 EJScreenItemProperties (org.entirej.framework.core.properties.interfaces.EJScreenItemProperties)11 JsonObject (org.eclipse.rap.json.JsonObject)10 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)9 EJBlockProperties (org.entirej.framework.core.properties.interfaces.EJBlockProperties)9 EJItemGroupProperties (org.entirej.framework.core.properties.interfaces.EJItemGroupProperties)9 ArrayList (java.util.ArrayList)8 FillLayout (org.eclipse.swt.layout.FillLayout)8 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)8 Action (org.eclipse.jface.action.Action)5 IAction (org.eclipse.jface.action.IAction)5 ToolBarManager (org.eclipse.jface.action.ToolBarManager)5 FocusEvent (org.eclipse.swt.events.FocusEvent)5 FocusListener (org.eclipse.swt.events.FocusListener)5