Search in sources :

Example 6 with EJDevBlockRendererDefinitionControl

use of org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl in project rap by entirej.

the class EJRWTBarChartRecordBlockDefinition method addBlockControlToCanvas.

@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
    EJFrameworkExtensionProperties rendererProperties = blockDisplayProperties.getBlockRendererProperties();
    if (blockDisplayProperties != null) {
        rendererProperties = rendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
    }
    Composite layoutBody;
    if (rendererProperties != null && rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
        int style = ExpandableComposite.TITLE_BAR;
        String mode = rendererProperties.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 (rendererProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
            style = style | ExpandableComposite.EXPANDED;
        }
        String title = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
        Section section = toolkit.createSection(parent, style);
        if (title != null)
            section.setText(title);
        section.setFont(parent.getFont());
        section.setForeground(parent.getForeground());
        if (mainScreenProperties.getDisplayFrame()) {
            layoutBody = new Group(section, SWT.NONE);
            layoutBody.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
            if (mainScreenProperties.getFrameTitle() != null)
                ((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
        } else {
            layoutBody = toolkit.createComposite(section);
        }
        section.setClient(layoutBody);
    } else {
        if (mainScreenProperties.getDisplayFrame()) {
            layoutBody = new Group(parent, SWT.NONE);
            if (mainScreenProperties.getFrameTitle() != null)
                ((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
        } else {
            layoutBody = new Composite(parent, SWT.NONE);
        }
    }
    layoutBody.setLayout(new GridLayout(mainScreenProperties.getNumCols(), false));
    EJDevBlockRendererDefinitionControl control = addTreeTable(blockDisplayProperties, layoutBody, toolkit);
    return control;
}
Also used : EJDevPropertyDefinitionGroup(org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup) EJPropertyDefinitionGroup(org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup) Group(org.eclipse.swt.widgets.Group) EJDevBlockRendererDefinitionControl(org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Section(org.eclipse.ui.forms.widgets.Section)

Example 7 with EJDevBlockRendererDefinitionControl

use of org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl in project rap by entirej.

the class EJRWTBarChartRecordBlockDefinition method addTreeTable.

private EJDevBlockRendererDefinitionControl addTreeTable(EJDevBlockDisplayProperties blockDisplayProperties, Composite client, FormToolkit toolkit) {
    Label label = new Label(client, SWT.NONE);
    label.setText("Bar Chart");
    return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
Also used : EJDevBlockRendererDefinitionControl(org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl) Label(org.eclipse.swt.widgets.Label)

Example 8 with EJDevBlockRendererDefinitionControl

use of org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl in project rap by entirej.

the class EJRWTHtmlTableBlockRendererDefinition method addBlockControlToCanvas.

@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
    Composite layoutBody;
    if (mainScreenProperties.getDisplayFrame()) {
        if (mainScreenProperties.getFrameTitle() != null && mainScreenProperties.getFrameTitle().length() > 0) {
            layoutBody = new Group(parent, SWT.NONE);
            ((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
        } else {
            layoutBody = new Composite(parent, SWT.BORDER);
        }
    } else {
        layoutBody = new Composite(parent, SWT.NONE);
    }
    layoutBody.setLayout(new FillLayout());
    if (System.getProperty("os.name").toLowerCase().indexOf("win") > -1) {
        Label label = new Label(layoutBody, SWT.NONE);
        label.setText("HTML Table Block");
        return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
    }
    EJDevItemGroupDisplayProperties displayProperties = null;
    if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
        displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
    }
    EJFrameworkExtensionProperties blockRendererProperties = mainScreenProperties.getBlockProperties().getBlockRendererProperties();
    boolean addHeader = true;
    StringBuilder header = new StringBuilder();
    if (blockRendererProperties != null) {
        addHeader = blockRendererProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_HEADING_PROPERTY, true);
    }
    int cellPadding = blockDisplayProperties.getBlockRendererProperties().getIntProperty(CELL_PADDING_PROPERTY, 0);
    String paddingStyle = null;
    if (cellPadding > 0) {
        String str = String.valueOf(cellPadding);
        paddingStyle = String.format("padding: %spx %spx %spx %spx; ", str, str, str, str);
    }
    if (displayProperties != null) {
        for (final EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
            if (screenItem.isSpacerItem()) {
                continue;
            }
            if (addHeader) {
                String styleClass = "default_all";
                EJFrameworkExtensionProperties rendererProperties = screenItem.getBlockItemDisplayProperties().getItemRendererProperties();
                header.append("<th ");
                String alignment = "left";
                String alignmentProperty = rendererProperties.getStringProperty("ALIGNMENT");
                if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
                    if (alignmentProperty.equals("JUSTIFY")) {
                        alignment = "justify";
                    } else if (alignmentProperty.equals("RIGHT")) {
                        alignment = "right";
                    } else if (alignmentProperty.equals("CENTER")) {
                        alignment = "center";
                    }
                }
                String valueVA = blockDisplayProperties.getBlockRendererProperties().getStringProperty(HEADER_VA);
                if (valueVA != null && valueVA.length() > 0) {
                    styleClass = valueVA;
                    valueVA = rendererProperties.getStringProperty(HEADER_VA);
                    if (valueVA != null && valueVA.length() > 0)
                        styleClass = valueVA;
                }
                header.append(String.format(" class=\"%s\" ", styleClass));
                if (alignment != null) {
                    header.append(String.format(" align=\'%s\'", alignment));
                }
                if (paddingStyle != null) {
                    header.append(String.format(" style=\'%s\'", paddingStyle));
                }
                header.append("> ");
                header.append(screenItem.getLabel());
                header.append("</th>");
            }
        }
        final Browser browser = new Browser(layoutBody, SWT.NONE);
        StringBuilder builder = new StringBuilder();
        {
            builder.append("<html>");
            builder.append(getStyleDef(blockDisplayProperties.getEntireJProperties()));
            builder.append("<div id=\"table\" style=\"float:left;width:100%;height:100%; overflow:auto\">");
            {
                EJDevBlockDisplayProperties blockProperties = blockDisplayProperties;
                int cellSpacing = blockProperties.getBlockRendererProperties().getIntProperty(CELL_SPACING_PROPERTY, 0);
                builder.append("<table border=0 cellspacing=").append(cellSpacing).append(" width=\"100%\" >");
                {
                    int charHeight = (Display.getDefault().getSystemFont()).getFontData()[0].getHeight();
                    ;
                    String trDef = String.format("<tr style=\"height: %spx\">", String.valueOf(charHeight));
                    if (addHeader) {
                        builder.append(header.toString());
                    }
                    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 (int k = 0; k < 4; k++) {
                        rowid++;
                        if (lastRowSpan > 1) {
                            for (int i = 1; i < lastRowSpan; i++) {
                                builder.append(trDef).append("</tr>");
                            }
                            lastRowSpan = 0;
                        }
                        builder.append(trDef);
                        for (final EJDevScreenItemDisplayProperties item : displayProperties.getAllItemDisplayProperties()) {
                            String styleClass = (rowid % 2) != 0 ? oddVA : evenVA;
                            String alignment = null;
                            float width = -1;
                            EJFrameworkExtensionProperties rendererProperties = ((EJDevMainScreenItemDisplayProperties) item).getBlockRendererRequiredProperties();
                            builder.append(String.format("<td class=\"%s\" ", styleClass));
                            if (paddingStyle != null) {
                                builder.append(String.format(" style=\'%s\'", paddingStyle));
                            }
                            if (width == -1) {
                                width = rendererProperties.getIntProperty(DISPLAY_WIDTH_PROPERTY, 0);
                            }
                            if (width > 0) {
                                Font font = browser.getFont();
                                if (font != null) {
                                    float avgCharWidth = 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 = item.getBlockItemDisplayProperties().getItemRendererProperties().getStringProperty("ALIGNMENT");
                                alignment = "left";
                                if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
                                    if (alignmentProperty.equals("JUSTIFY")) {
                                        alignment = "justify";
                                    } else if (alignmentProperty.equals("RIGHT")) {
                                        alignment = "right";
                                    } else if (alignmentProperty.equals("CENTER")) {
                                        alignment = "center";
                                    }
                                }
                            }
                            if (alignment != null) {
                                builder.append(String.format(" align=\'%s\'", alignment));
                            }
                            builder.append(">");
                            // builder.append(String.format("<p class=\"default %s\">",
                            // styleClass));
                            String text = item.getReferencedItemName();
                            builder.append(text);
                            builder.append("</td>");
                        }
                        builder.append("</tr>");
                    }
                }
                builder.append("</table>");
            }
            builder.append("</<div>");
            builder.append("</html>");
        }
        browser.setText(builder.toString());
    }
    return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
Also used : EJDevPropertyDefinitionGroup(org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup) EJPropertyDefinitionGroup(org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup) Group(org.eclipse.swt.widgets.Group) EJDevItemGroupDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevItemGroupDisplayProperties) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJDevScreenItemDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties) Composite(org.eclipse.swt.widgets.Composite) EJDevBlockDisplayProperties(org.entirej.framework.dev.properties.interfaces.EJDevBlockDisplayProperties) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) Font(org.eclipse.swt.graphics.Font) EJDevBlockRendererDefinitionControl(org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl) Browser(org.eclipse.swt.browser.Browser)

Example 9 with EJDevBlockRendererDefinitionControl

use of org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl in project rap by entirej.

the class EJRWTLineChartRecordBlockDefinition method addBlockControlToCanvas.

@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
    EJFrameworkExtensionProperties rendererProperties = blockDisplayProperties.getBlockRendererProperties();
    if (blockDisplayProperties != null) {
        rendererProperties = rendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
    }
    Composite layoutBody;
    if (rendererProperties != null && rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
        int style = ExpandableComposite.TITLE_BAR;
        String mode = rendererProperties.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 (rendererProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
            style = style | ExpandableComposite.EXPANDED;
        }
        String title = rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
        Section section = toolkit.createSection(parent, style);
        if (title != null)
            section.setText(title);
        section.setFont(parent.getFont());
        section.setForeground(parent.getForeground());
        if (mainScreenProperties.getDisplayFrame()) {
            layoutBody = new Group(section, SWT.NONE);
            layoutBody.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
            if (mainScreenProperties.getFrameTitle() != null)
                ((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
        } else {
            layoutBody = toolkit.createComposite(section);
        }
        section.setClient(layoutBody);
    } else {
        if (mainScreenProperties.getDisplayFrame()) {
            layoutBody = new Group(parent, SWT.NONE);
            if (mainScreenProperties.getFrameTitle() != null)
                ((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
        } else {
            layoutBody = new Composite(parent, SWT.NONE);
        }
    }
    layoutBody.setLayout(new GridLayout(mainScreenProperties.getNumCols(), false));
    EJDevBlockRendererDefinitionControl control = addTreeTable(blockDisplayProperties, layoutBody, toolkit);
    return control;
}
Also used : EJDevPropertyDefinitionGroup(org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup) EJPropertyDefinitionGroup(org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup) Group(org.eclipse.swt.widgets.Group) EJDevBlockRendererDefinitionControl(org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Section(org.eclipse.ui.forms.widgets.Section)

Aggregations

EJDevBlockRendererDefinitionControl (org.entirej.framework.dev.renderer.definition.EJDevBlockRendererDefinitionControl)9 Composite (org.eclipse.swt.widgets.Composite)6 Group (org.eclipse.swt.widgets.Group)6 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)6 EJPropertyDefinitionGroup (org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup)6 EJDevPropertyDefinitionGroup (org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup)6 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)5 Section (org.eclipse.ui.forms.widgets.Section)5 GridLayout (org.eclipse.swt.layout.GridLayout)4 Label (org.eclipse.swt.widgets.Label)4 FillLayout (org.eclipse.swt.layout.FillLayout)2 EJDevItemGroupDisplayProperties (org.entirej.framework.dev.properties.interfaces.EJDevItemGroupDisplayProperties)2 EJDevScreenItemDisplayProperties (org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties)2 Browser (org.eclipse.swt.browser.Browser)1 Font (org.eclipse.swt.graphics.Font)1 Tree (org.eclipse.swt.widgets.Tree)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 EJDevBlockDisplayProperties (org.entirej.framework.dev.properties.interfaces.EJDevBlockDisplayProperties)1 EJDevItemRendererDefinitionControl (org.entirej.framework.dev.renderer.definition.EJDevItemRendererDefinitionControl)1