Search in sources :

Example 1 with EJCoreFrameworkExtensionPropertyList

use of org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList in project rap by entirej.

the class EJRWTHtmlTableBlockRenderer method buildGuiComponent.

@Override
public void buildGuiComponent(EJRWTEntireJGridPane blockCanvas) {
    if (_browser != null && !_browser.isDisposed()) {
        _browser.dispose();
    }
    EJBlockProperties blockProperties = _block.getProperties();
    EJMainScreenProperties mainScreenProperties = blockProperties.getMainScreenProperties();
    EJFrameworkExtensionProperties blockRendererProperties = blockProperties.getBlockRendererProperties();
    boolean addHeader = true;
    if (blockRendererProperties != null) {
        addHeader = blockRendererProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_HEADING_PROPERTY, true);
        EJCoreFrameworkExtensionPropertyList propertyList = blockRendererProperties.getPropertyList(ACTIONS);
        if (propertyList != null) {
            List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
            for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
                String actionID = entry.getProperty(ACTION_ID);
                String actionkey = entry.getProperty(ACTION_KEY);
                if (actionID != null && actionkey != null && actionID.trim().length() > 0 && actionkey.trim().length() > 0) {
                    addActionKeyinfo(actionkey, actionID);
                }
            }
        }
    }
    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.minimumHeight = mainScreenProperties.getHeight();
    // if (gridData.grabExcessVerticalSpace)
    // gridData.minimumWidth = mainScreenProperties.getHeight();
    blockCanvas.setLayoutData(gridData);
    scrollComposite = new EJRWTScrolledComposite(blockCanvas, SWT.V_SCROLL | SWT.H_SCROLL);
    scrollComposite.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
    scrollComposite.setExpandHorizontal(true);
    scrollComposite.setExpandVertical(true);
    scrollComposite.setMinSize(mainScreenProperties.getWidth(), mainScreenProperties.getHeight());
    boolean filtered = blockRendererProperties.getBooleanProperty(EJRWTTreeBlockDefinitionProperties.FILTER, false);
    this.filterKeepOnRefresh = blockRendererProperties.getBooleanProperty(EJRWTTreeBlockDefinitionProperties.FILTER_KEEP_ON_REFRESH, false);
    this.textSelection = blockRendererProperties.getBooleanProperty(TEXT_SELECTION, false);
    if (mainScreenProperties.getDisplayFrame()) {
        String frameTitle = mainScreenProperties.getFrameTitle();
        if (frameTitle != null && frameTitle.length() > 0) {
            Group group = new Group(scrollComposite, SWT.NONE);
            group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
            hookKeyListener(group);
            scrollComposite.setContent(group);
            group.setLayout(new GridLayout());
            scrollComposite.setLayoutData(gridData);
            if (frameTitle != null && frameTitle.length() > 0) {
                group.setText(frameTitle);
            }
            if (filtered) {
                filterHtml = new EJRWTAbstractFilteredHtml(group, SWT.NONE, textSelection) {

                    @Override
                    public void filter(String filter) {
                        _filteredContentProvider.setFilter(filter);
                        createHTML();
                    }

                    @Override
                    protected EJRWTHtmlView doCreateTableViewer(Composite parent, int style, boolean textSelection) {
                        return new EJRWTHtmlView(parent, SWT.NONE, textSelection) {

                            private static final long serialVersionUID = 1L;

                            @Override
                            public void action(String method, JsonObject parameters) {
                                if ("eselect".equals(method)) {
                                    final Object arg1 = parameters.get("0").asString();
                                    if (arg1 instanceof String) {
                                        EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg1));
                                        if (currentRec != recordAt) {
                                            currentRec = recordAt;
                                            if (currentRec != null)
                                                _block.newRecordInstance(currentRec);
                                        }
                                    }
                                } else if ("eaction".equals(method)) {
                                    final Object arg1 = parameters.get("0").asString();
                                    Object arg2 = parameters.get("1").asString();
                                    if (arg1 instanceof String) {
                                        if (arg2 instanceof String) {
                                            EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg2));
                                            if (currentRec != recordAt) {
                                                currentRec = recordAt;
                                                if (currentRec != null)
                                                    _block.newRecordInstance(currentRec);
                                            }
                                        }
                                        Display.getDefault().asyncExec(new Runnable() {

                                            @Override
                                            public void run() {
                                                try {
                                                    _block.executeActionCommand((String) arg1, EJScreenType.MAIN);
                                                } catch (EJApplicationException exception) {
                                                    _block.getFrameworkManager().handleException(exception);
                                                }
                                            }
                                        });
                                    }
                                } else if ("esort".equals(method)) {
                                    handleSort(parameters);
                                }
                            }
                        };
                    }
                };
                _browser = filterHtml.getViewer();
                defaultMessage = blockRendererProperties.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_MESSAGE);
                if (defaultMessage != null)
                    filterHtml.getFilterControl().setMessage(defaultMessage);
            } else {
                _browser = new EJRWTHtmlView(group, SWT.NONE, textSelection) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void action(String method, JsonObject parameters) {
                        if ("eselect".equals(method)) {
                            final Object arg1 = parameters.get("0").asString();
                            if (arg1 instanceof String) {
                                EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg1));
                                if (currentRec != recordAt) {
                                    currentRec = recordAt;
                                    if (currentRec != null)
                                        _block.newRecordInstance(currentRec);
                                }
                            }
                        } else if ("eaction".equals(method)) {
                            final Object arg1 = parameters.get("0").asString();
                            Object arg2 = parameters.get("1").asString();
                            if (arg1 instanceof String) {
                                if (arg2 instanceof String) {
                                    EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg2));
                                    if (currentRec != recordAt) {
                                        currentRec = recordAt;
                                        if (currentRec != null)
                                            _block.newRecordInstance(currentRec);
                                    }
                                }
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        try {
                                            _block.executeActionCommand((String) arg1, EJScreenType.MAIN);
                                        } catch (EJApplicationException exception) {
                                            _block.getFrameworkManager().handleException(exception);
                                        }
                                    }
                                });
                            }
                        } else if ("esort".equals(method)) {
                            handleSort(parameters);
                        }
                    }
                };
            }
        } else {
            if (filtered) {
                filterHtml = new EJRWTAbstractFilteredHtml(scrollComposite, SWT.NONE, textSelection) {

                    @Override
                    public void filter(String filter) {
                        _filteredContentProvider.setFilter(filter);
                        createHTML();
                    }

                    @Override
                    protected EJRWTHtmlView doCreateTableViewer(Composite parent, int style, boolean textSelection) {
                        return new EJRWTHtmlView(parent, SWT.NONE, textSelection) {

                            private static final long serialVersionUID = 1L;

                            @Override
                            public void action(String method, JsonObject parameters) {
                                if ("eselect".equals(method)) {
                                    final Object arg1 = parameters.get("0").asString();
                                    if (arg1 instanceof String) {
                                        EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg1));
                                        if (currentRec != recordAt) {
                                            currentRec = recordAt;
                                            if (currentRec != null)
                                                _block.newRecordInstance(currentRec);
                                        }
                                    }
                                } else if ("eaction".equals(method)) {
                                    final Object arg1 = parameters.get("0").asString();
                                    Object arg2 = parameters.get("1").asString();
                                    if (arg1 instanceof String) {
                                        if (arg2 instanceof String) {
                                            EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg2));
                                            if (currentRec != recordAt) {
                                                currentRec = recordAt;
                                                if (currentRec != null)
                                                    _block.newRecordInstance(currentRec);
                                            }
                                        }
                                        Display.getDefault().asyncExec(new Runnable() {

                                            @Override
                                            public void run() {
                                                try {
                                                    _block.executeActionCommand((String) arg1, EJScreenType.MAIN);
                                                } catch (EJApplicationException exception) {
                                                    _block.getFrameworkManager().handleException(exception);
                                                }
                                            }
                                        });
                                    }
                                } else if ("esort".equals(method)) {
                                    handleSort(parameters);
                                }
                            }
                        };
                    }
                };
                _browser = filterHtml.getViewer();
                defaultMessage = blockRendererProperties.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_MESSAGE);
                if (defaultMessage != null)
                    filterHtml.getFilterControl().setMessage(defaultMessage);
                scrollComposite.setContent(filterHtml);
                scrollComposite.setLayoutData(gridData);
            } else {
                filterHtml = null;
                _browser = new EJRWTHtmlView(scrollComposite, SWT.BORDER, textSelection) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void action(String method, JsonObject parameters) {
                        if ("eselect".equals(method)) {
                            final Object arg1 = parameters.get("0").asString();
                            if (arg1 instanceof String) {
                                EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg1));
                                if (currentRec != recordAt) {
                                    currentRec = recordAt;
                                    if (currentRec != null)
                                        _block.newRecordInstance(currentRec);
                                }
                            }
                        } else if ("eaction".equals(method)) {
                            final Object arg1 = parameters.get("0").asString();
                            Object arg2 = parameters.get("1").asString();
                            if (arg1 instanceof String) {
                                if (arg2 instanceof String) {
                                    EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg2));
                                    if (currentRec != recordAt) {
                                        currentRec = recordAt;
                                        if (currentRec != null)
                                            _block.newRecordInstance(currentRec);
                                    }
                                }
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        try {
                                            _block.executeActionCommand((String) arg1, EJScreenType.MAIN);
                                        } catch (EJApplicationException exception) {
                                            _block.getFrameworkManager().handleException(exception);
                                        }
                                    }
                                });
                            }
                        } else if ("esort".equals(method)) {
                            handleSort(parameters);
                        }
                    }
                };
                scrollComposite.setContent(_browser);
                scrollComposite.setLayoutData(gridData);
            }
        }
    } else {
        if (filtered) {
            filterHtml = new EJRWTAbstractFilteredHtml(scrollComposite, SWT.NONE, textSelection) {

                @Override
                public void filter(String filter) {
                    _filteredContentProvider.setFilter(filter);
                    createHTML();
                }

                @Override
                protected EJRWTHtmlView doCreateTableViewer(Composite parent, int style, boolean textSelection) {
                    return new EJRWTHtmlView(parent, SWT.NONE, textSelection) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void action(String method, JsonObject parameters) {
                            if ("eselect".equals(method)) {
                                final Object arg1 = parameters.get("0").asString();
                                if (arg1 instanceof String) {
                                    EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg1));
                                    if (currentRec != recordAt) {
                                        currentRec = recordAt;
                                        if (currentRec != null)
                                            _block.newRecordInstance(currentRec);
                                    }
                                }
                            } else if ("eaction".equals(method)) {
                                final Object arg1 = parameters.get("0").asString();
                                Object arg2 = parameters.get("1").asString();
                                if (arg1 instanceof String) {
                                    if (arg2 instanceof String) {
                                        EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg2));
                                        if (currentRec != recordAt) {
                                            currentRec = recordAt;
                                            if (currentRec != null)
                                                _block.newRecordInstance(currentRec);
                                        }
                                    }
                                    Display.getDefault().asyncExec(new Runnable() {

                                        @Override
                                        public void run() {
                                            try {
                                                _block.executeActionCommand((String) arg1, EJScreenType.MAIN);
                                            } catch (EJApplicationException exception) {
                                                _block.getFrameworkManager().handleException(exception);
                                            }
                                        }
                                    });
                                }
                            } else if ("esort".equals(method)) {
                                handleSort(parameters);
                            }
                        }
                    };
                }
            };
            _browser = filterHtml.getViewer();
            scrollComposite.setContent(filterHtml);
            scrollComposite.setLayoutData(gridData);
            defaultMessage = blockRendererProperties.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_MESSAGE);
            if (defaultMessage != null)
                filterHtml.getFilterControl().setMessage(defaultMessage);
        } else {
            filterHtml = null;
            _browser = new EJRWTHtmlView(scrollComposite, SWT.NONE, textSelection) {

                private static final long serialVersionUID = 1L;

                @Override
                public void action(String method, JsonObject parameters) {
                    if ("eselect".equals(method)) {
                        final Object arg1 = parameters.get("0").asString();
                        if (arg1 instanceof String) {
                            EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg1));
                            if (currentRec != recordAt) {
                                currentRec = recordAt;
                                if (currentRec != null)
                                    _block.newRecordInstance(currentRec);
                            }
                        }
                    } else if ("eaction".equals(method)) {
                        final Object arg1 = parameters.get("0").asString();
                        Object arg2 = parameters.get("1").asString();
                        if (arg1 instanceof String) {
                            if (arg2 instanceof String) {
                                EJDataRecord recordAt = getRecordAt(Integer.valueOf((String) arg2));
                                if (currentRec != recordAt) {
                                    currentRec = recordAt;
                                    if (currentRec != null)
                                        _block.newRecordInstance(currentRec);
                                }
                            }
                            Display.getDefault().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    try {
                                        _block.executeActionCommand((String) arg1, EJScreenType.MAIN);
                                    } catch (EJApplicationException exception) {
                                        _block.getFrameworkManager().handleException(exception);
                                    }
                                }
                            });
                        }
                    } else if ("esort".equals(method)) {
                        handleSort(parameters);
                    }
                }
            };
            scrollComposite.setContent(_browser);
            scrollComposite.setLayoutData(gridData);
            hookKeyListener(scrollComposite);
        }
    }
    _browser.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = 1L;

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

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

        private static final long serialVersionUID = 1L;

        @Override
        public void mouseDown(MouseEvent arg0) {
            setHasFocus(true);
        }
    });
    if (_items.isEmpty()) {
        Collection<EJItemGroupProperties> allItemGroupProperties = _block.getProperties().getScreenItemGroupContainer(EJScreenType.MAIN).getAllItemGroupProperties();
        int cellSpacing = blockProperties.getBlockRendererProperties().getIntProperty(CELL_SPACING_PROPERTY, 0);
        int cellPadding = blockProperties.getBlockRendererProperties().getIntProperty(CELL_PADDING_PROPERTY, 0);
        String paddingStyle = "";
        if (cellPadding > 0) {
            String str = String.valueOf(cellPadding);
            paddingStyle += String.format("padding: %spx %spx %spx %spx; ", str, str, str, str);
        }
        StringBuilder header = new StringBuilder("<thead><tr>");
        boolean rowSelection = blockProperties.getBlockRendererProperties().getBooleanProperty(ROW_SELECTION, false);
        String selectionTD = "<th width=1 ></td>";
        if (rowSelection) {
            header.append(selectionTD);
        }
        for (EJItemGroupProperties groupProperties : allItemGroupProperties) {
            Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
            for (EJScreenItemProperties screenItemProperties : itemProperties) {
                EJCoreMainScreenItemProperties itemProps = (EJCoreMainScreenItemProperties) screenItemProperties;
                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);
                    _items.add(itemProps);
                    _itemLabelProviders.put(itemProps.getReferencedItemName(), labelProvider);
                    if (addHeader) {
                        String styleClass = "default_all";
                        EJFrameworkExtensionProperties rendererProperties = item.getReferencedItemProperties().getItemRendererProperties();
                        EJFrameworkExtensionProperties extentionProperties = itemProps.getBlockRendererRequiredProperties();
                        int width = -1;
                        if (width == -1) {
                            width = extentionProperties.getIntProperty(DISPLAY_WIDTH_PROPERTY, 0);
                        }
                        header.append("<th ");
                        if (width > 0) {
                            Font font = labelProvider.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)));
                                    }
                                }
                            }
                            header.append(String.format(" width=%s ", width));
                        }
                        header.append(" ");
                        String alignment = null;
                        String alignmentProperty = rendererProperties.getStringProperty(PROPERTY_ALIGNMENT);
                        if (alignmentProperty == null) {
                            alignmentProperty = rendererProperties.getStringProperty("ALLIGNMENT");
                        }
                        alignment = getComponentAlignment(alignmentProperty);
                        SortInfo sortInfo = null;
                        if (extentionProperties.getBooleanProperty(ALLOW_ROW_SORTING, true)) {
                            EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
                            if (columnSorter != null) {
                                _itemSortProviders.put(itemProps.getReferencedItemName(), columnSorter);
                                sortInfo = new SortInfo();
                                sortInfo.columnName = itemProps.getReferencedItemName();
                                _sortContext.put(sortInfo.id, sortInfo);
                            }
                        }
                        String functionDef = null;
                        if (sortInfo != null) {
                            functionDef = String.format("em='esort' earg='%s' ", sortInfo.id);
                        }
                        String valueVA = blockProperties.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));
                        }
                        if (itemProps.getHint() != null && !itemProps.getHint().isEmpty()) {
                            header.append(String.format(" title=\'%s\'", itemProps.getHint()));
                        }
                        header.append("> ");
                        if (itemProps.getLabel() != null) {
                            if (functionDef != null) {
                                header.append(String.format("<ejl><u %s class=\"%s, %s\"  ", "style=\"line-height: 100%\"", ("default_all".equals(styleClass) ? "default_link_fg" : "default_link"), styleClass));
                                header.append(functionDef).append(">");
                            }
                            header.append(!(extentionProperties.getBooleanProperty(ENABLE_MARKUP, false) || rendererProperties.getBooleanProperty("HTML_FORMAT", false)) ? ignoreHtml(itemProps.getLabel()) : itemProps.getLabel());
                            if (sortInfo != null)
                                header.append(String.format("<esh %s/>", sortInfo.id));
                        }
                        header.append("</th>");
                    }
                }
            }
        }
        if (addHeader) {
            header.append("</tr></thead>");
            _headerTag = header.toString();
        }
    }
    hookKeyListener(_browser);
    final EJRWTAbstractFilteredHtml _filterHtml = filterHtml;
    _filteredContentProvider = new FilteredContentProvider() {

        boolean matchItem(EJDataRecord rec) {
            if (filter != null && filter.trim().length() > 0) {
                for (ColumnLabelProvider filterTextProvider : _itemLabelProviders.values()) {
                    String text = filterTextProvider.getText(rec);
                    if (text != null && text.toLowerCase().contains(filter.toLowerCase())) {
                        return true;
                    }
                }
                // if no match try to match Numeric value
                try {
                    double parseDouble = Double.parseDouble(filter);
                    for (String item : _itemLabelProviders.keySet()) {
                        Object value = rec.getValue(item);
                        if (value instanceof Number) {
                            if (((Number) value).doubleValue() == parseDouble) {
                                return true;
                            }
                        }
                    }
                } catch (NumberFormatException e) {
                // ignore
                }
            }
            return false;
        }

        @Override
        public void setFilter(String filter) {
            if (getFilter() != null && getFilter().equals(filter))
                return;
            super.setFilter(filter);
            _tableBaseRecords.clear();
            if (filter == null || filter.trim().length() == 0) {
                if (_filterHtml != null) {
                    _filterHtml.clearText();
                }
                _tableBaseRecords.addAll(_block.getBlock().getRecords());
            } else {
                for (EJDataRecord record : _block.getBlock().getRecords()) {
                    if (matchItem(record)) {
                        _tableBaseRecords.add(record);
                    }
                }
            }
        }
    };
    createHTML();
}
Also used : Group(org.eclipse.swt.widgets.Group) EJItemGroupProperties(org.entirej.framework.core.properties.interfaces.EJItemGroupProperties) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) JsonObject(org.eclipse.rap.json.JsonObject) FocusEvent(org.eclipse.swt.events.FocusEvent) Font(org.eclipse.swt.graphics.Font) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) HtmlBaseColumnLabelProvider(org.entirej.applicationframework.rwt.table.HtmlBaseColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) EJCoreFrameworkExtensionPropertyList(org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList) EJRWTAbstractTableSorter(org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) MouseAdapter(org.eclipse.swt.events.MouseAdapter) EJApplicationException(org.entirej.framework.core.EJApplicationException) EJRWTHtmlView(org.entirej.applicationframework.rwt.component.EJRWTHtmlView) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) FilteredContentProvider(org.entirej.applicationframework.rwt.renderers.html.EJRWTAbstractFilteredHtml.FilteredContentProvider) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJBlockProperties(org.entirej.framework.core.properties.interfaces.EJBlockProperties) GridData(org.eclipse.swt.layout.GridData) JsonObject(org.eclipse.rap.json.JsonObject) EJMainScreenProperties(org.entirej.framework.core.properties.interfaces.EJMainScreenProperties) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) FocusListener(org.eclipse.swt.events.FocusListener)

Example 2 with EJCoreFrameworkExtensionPropertyList

use of org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList in project rap by entirej.

the class EJRWTApplicationLauncher method createEntryPoint.

public void createEntryPoint(final Application configuration) {
    configuration.setOperationMode(getOperationMode());
    Map<String, String> properties = new HashMap<String, String>();
    if (this.getClass().getClassLoader().getResource("application.ejprop") != null) {
        EJFrameworkInitialiser.initialiseFramework("application.ejprop");
    } else if (this.getClass().getClassLoader().getResource("EntireJApplication.properties") != null) {
        EJFrameworkInitialiser.initialiseFramework("EntireJApplication.properties");
    } else {
        throw new RuntimeException("application.ejprop not found");
    }
    final EJCoreProperties coreProperties = EJCoreProperties.getInstance();
    EJCoreLayoutContainer layoutContainer = coreProperties.getLayoutContainer();
    properties.put(WebClient.PAGE_TITLE, layoutContainer.getTitle());
    String favicon = getFavicon();
    if (favicon == null) {
        favicon = ICONS_FAVICON_ICO;
    }
    properties.put(WebClient.FAVICON, favicon);
    properties.put(WebClient.BODY_HTML, getBodyHtml());
    properties.put(WebClient.THEME_ID, THEME_DEFAULT);
    addOtherResources(configuration);
    configuration.addResource(favicon, new FileResource());
    configuration.addResource(getLoadingImage(), new FileResource());
    configuration.addStyleSheet(THEME_DEFAULT, "resource/theme/default.css");
    String baseThemeCSSLocation = getBaseThemeCSSLocation();
    if (baseThemeCSSLocation == null) {
        baseThemeCSSLocation = THEME_DEFAULT_CSS;
    }
    configuration.addStyleSheet(THEME_DEFAULT, baseThemeCSSLocation);
    properties.put(WebClient.PAGE_OVERFLOW, "scrollY");
    configuration.addResource(baseThemeCSSLocation, new FileResource());
    if (getThemeCSSLocation() != null) {
        configuration.addStyleSheet(THEME_DEFAULT, getThemeCSSLocation());
        configuration.addResource(getThemeCSSLocation(), new FileResource());
    }
    configuration.addEntryPoint(String.format("/%s", getWebPathContext()), new EntryPointFactory() {

        public EntryPoint create() {
            try {
                RWT.getServiceManager().registerServiceHandler(VACSSServiceHandler.SERVICE_HANDLER, new VACSSServiceHandler());
                RWT.getServiceManager().registerServiceHandler(EJRWTFileDownload.SERVICE_HANDLER, EJRWTFileDownload.newServiceHandler());
                registerServiceHandlers();
            } catch (java.lang.IllegalArgumentException e) {
            // ignore if already registered
            }
            registerWidgetHandlers();
            final EntryPoint wrapped = newEntryPoint();
            return new EntryPoint() {

                public int createUI() {
                    BrowserNavigation service = RWT.getClient().getService(BrowserNavigation.class);
                    BrowserNavigationListener listener = new BrowserNavigationListener() {

                        @Override
                        public void navigated(BrowserNavigationEvent event) {
                            EJRWTContext.getPageContext().setState(event.getState());
                        }
                    };
                    service.addBrowserNavigationListener(listener);
                    int createUI = wrapped.createUI();
                    return createUI;
                }
            };
        }

        private EntryPoint newEntryPoint() {
            return new EntryPoint() {

                public int createUI() {
                    {
                        // connect BaseURL
                        StringBuffer url = new StringBuffer();
                        url.append(RWT.getRequest().getContextPath());
                        url.append(RWT.getRequest().getServletPath());
                        String encodeURL = RWT.getResponse().encodeURL(url.toString());
                        if (encodeURL.contains("jsessionid")) {
                            encodeURL = encodeURL.substring(0, encodeURL.indexOf("jsessionid"));
                        }
                        int patchIndex = encodeURL.lastIndexOf(getWebPathContext());
                        if (patchIndex > -1) {
                            encodeURL = encodeURL.substring(0, patchIndex);
                        }
                        _baseURL = encodeURL;
                    }
                    RWTUtils.patchClient(getWebPathContext(), getTimeoutUrl());
                    EJRWTImageRetriever.setGraphicsProvider(new EJRWTGraphicsProvider() {

                        @Override
                        public void promptFileUpload(final EJFileUpload fileUpload, final Callable<Object> callable) {
                            if (fileUpload.isMultiSelection()) {
                                EJRWTFileUpload.promptMultipleFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {

                                    @Override
                                    public void select(String[] files) {
                                        try {
                                            fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
                                            callable.call();
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                    }
                                });
                            } else {
                                EJRWTFileUpload.promptFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {

                                    @Override
                                    public void select(String[] files) {
                                        try {
                                            fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
                                            callable.call();
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                    }
                                });
                            }
                        }

                        public Image getImage(String name, ClassLoader loader) {
                            return RWTUtils.getImage(name, loader);
                        }

                        @Override
                        public void open(final String output, String outputName) {
                            EJRWTFileDownload.download(output, outputName);
                            RWT.getUISession().addUISessionListener(new UISessionListener() {

                                private static final long serialVersionUID = 1L;

                                @Override
                                public void beforeDestroy(UISessionEvent arg0) {
                                    File f = new File(output);
                                    if (f.exists()) {
                                        f.delete();
                                    }
                                }
                            });
                        }

                        public float getAvgCharWidth(Font font) {
                            return RWTUtils.getAvgCharWidth(font);
                        }

                        public int getCharHeight(Font font) {
                            return RWTUtils.getCharHeight(font);
                        }

                        public void rendererSection(final Section section) {
                            section.removeListener(SWT.Dispose, section.getListeners(SWT.Dispose)[0]);
                            section.removeListener(SWT.Resize, section.getListeners(SWT.Resize)[0]);
                            section.setFont(section.getParent().getFont());
                            section.setForeground(section.getParent().getForeground());
                            Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
                            IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
                            gfxAdapter.setRoundedBorder(1, section.getTitleBarBackground(), 2, 2, 0, 0);
                            Listener listener = new Listener() {

                                public void handleEvent(Event e) {
                                    Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
                                    IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
                                    Color[] gradientColors = new Color[] { section.getTitleBarBorderColor(), section.getBackground(), section.getTitleBarBackground(), section.getBackground(), section.getBackground() };
                                    int gradientPercent = 0;
                                    Rectangle bounds = section.getClientArea();
                                    if (bounds.height != 0) {
                                        gradientPercent = 30 * 100 / bounds.height;
                                        if (gradientPercent > 100) {
                                            gradientPercent = 100;
                                        }
                                    }
                                    int[] percents = new int[] { 0, 1, 2, gradientPercent, 100 };
                                    gfxAdapter.setBackgroundGradient(gradientColors, percents, true);
                                    gfxAdapter.setRoundedBorder(1, section.getBackground(), 4, 4, 0, 0);
                                }
                            };
                            section.addListener(SWT.Dispose, listener);
                            section.addListener(SWT.Resize, listener);
                        }
                    });
                    final EJRWTApplicationManager applicationManager;
                    if (this.getClass().getClassLoader().getResource("application.ejprop") != null) {
                        applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("application.ejprop");
                    } else if (this.getClass().getClassLoader().getResource("EntireJApplication.properties") != null) {
                        applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("EntireJApplication.properties");
                    } else {
                        throw new RuntimeException("application.ejprop not found");
                    }
                    EJRWTContext.getPageContext().setManager(applicationManager);
                    getContext().getUISession().setAttribute("ej.applicationManager", applicationManager);
                    EJCoreLayoutContainer layoutContainer = EJCoreProperties.getInstance().getLayoutContainer();
                    // Now build the application container
                    EJRWTApplicationContainer appContainer = new EJRWTApplicationContainer(layoutContainer);
                    // Add the application menu and status bar to the app
                    // container
                    EJMessenger messenger = applicationManager.getApplicationMessenger();
                    if (messenger == null) {
                        throw new NullPointerException("The ApplicationComponentProvider must provide an Messenger via method: getApplicationMessenger()");
                    }
                    Display display = Display.getDefault();
                    if (display.isDisposed())
                        display = new Display();
                    Shell shell = new Shell(display, SWT.NO_TRIM);
                    // check test mode
                    StartupParameters service = RWT.getClient().getService(StartupParameters.class);
                    if (service != null && Boolean.valueOf(service.getParameter("TEST_MODE"))) {
                        EJ_RWT.setTestMode(true);
                    }
                    try {
                        preApplicationBuild(applicationManager);
                    } finally {
                        applicationManager.getConnection().close();
                    }
                    applicationManager.buildApplication(appContainer, shell);
                    final EJRWTApplicationManager appman = applicationManager;
                    Display.getCurrent().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                postApplicationBuild(appman);
                            } finally {
                                appman.getConnection().close();
                            }
                        }
                    });
                    shell.layout();
                    shell.setMaximized(true);
                    // disable due to RWT bug
                    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=410895
                    // ExitConfirmation confirmation =
                    // RWT.getClient().getService(ExitConfirmation.class);
                    // String message = getDefaultTabCloseMessage();
                    // if ("__DEFAULT__".equals(message))
                    // {
                    // confirmation.setMessage(String.format("Do you want to close %s ?",
                    // EJCoreProperties.getInstance().getLayoutContainer().getTitle()));
                    // }
                    // else if (message != null)
                    // {
                    // confirmation.setMessage(message);
                    // }
                    final ServerPushSession pushSession = new ServerPushSession();
                    RWT.getUISession().addUISessionListener(new UISessionListener() {

                        public void beforeDestroy(UISessionEvent event) {
                            if (applicationManager.getApplicationActionProcessor() != null)
                                try {
                                    applicationManager.getApplicationActionProcessor().whenApplicationEnd(applicationManager);
                                } catch (EJActionProcessorException e) {
                                    e.printStackTrace();
                                }
                            pushSession.stop();
                        }
                    });
                    if (applicationManager.getApplicationActionProcessor() != null)
                        try {
                            applicationManager.getApplicationActionProcessor().whenApplicationStart(applicationManager);
                        } catch (EJActionProcessorException e) {
                            e.printStackTrace();
                        }
                    EJFrameworkExtensionProperties definedProperties = coreProperties.getApplicationDefinedProperties();
                    if (definedProperties != null && definedProperties.getBooleanProperty("LIVE_CONNECTION", false))
                        pushSession.start();
                    return openShell(display, shell);
                }
            };
        }
    }, properties);
    // services
    {
        final String SERVICE = "SERVICE";
        final String SERVICE_LIST = "SERVICE_LIST";
        final String SERVICE_PATH = "SERVICE_PATH";
        final String SERVICE_FORM = "SERVICE_FORM";
        final String SERVICE_NAME = "SERVICE_NAME";
        EJFrameworkExtensionProperties definedProperties = coreProperties.getApplicationDefinedProperties();
        if (canLoadServices() && definedProperties != null) {
            EJFrameworkExtensionProperties group = definedProperties.getPropertyGroup(SERVICE);
            if (group != null && group.getPropertyList(SERVICE_LIST) != null) {
                EJCoreFrameworkExtensionPropertyList list = group.getPropertyList(SERVICE_LIST);
                List<EJFrameworkExtensionPropertyListEntry> allListEntries = list.getAllListEntries();
                for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
                    final String formId = entry.getProperty(SERVICE_FORM);
                    HashMap<String, String> srvproperties = new HashMap<String, String>(properties);
                    srvproperties.put(WebClient.PAGE_TITLE, entry.getProperty(SERVICE_NAME));
                    if (entry.getProperty(SERVICE_PATH) != null && formId != null && formId != null) {
                        configuration.addEntryPoint(String.format("/%s", entry.getProperty(SERVICE_PATH)), new EntryPointFactory() {

                            public EntryPoint create() {
                                try {
                                    RWT.getServiceManager().registerServiceHandler(VACSSServiceHandler.SERVICE_HANDLER, new VACSSServiceHandler());
                                    RWT.getServiceManager().registerServiceHandler(EJRWTFileDownload.SERVICE_HANDLER, EJRWTFileDownload.newServiceHandler());
                                    registerServiceHandlers();
                                } catch (java.lang.IllegalArgumentException e) {
                                // ignore if already registered
                                }
                                registerWidgetHandlers();
                                final EntryPoint wrapped = newServiceEntryPoint(formId);
                                return new EntryPoint() {

                                    public int createUI() {
                                        BrowserNavigation service = RWT.getClient().getService(BrowserNavigation.class);
                                        BrowserNavigationListener listener = new BrowserNavigationListener() {

                                            @Override
                                            public void navigated(BrowserNavigationEvent event) {
                                                EJRWTContext.getPageContext().setState(event.getState());
                                            }
                                        };
                                        service.addBrowserNavigationListener(listener);
                                        int createUI = wrapped.createUI();
                                        return createUI;
                                    }
                                };
                            }

                            private EntryPoint newServiceEntryPoint(String serviceFormID) {
                                return new EntryPoint() {

                                    public int createUI() {
                                        RWTUtils.patchClient(getWebPathContext(), null);
                                        EJRWTImageRetriever.setGraphicsProvider(new EJRWTGraphicsProvider() {

                                            @Override
                                            public void promptFileUpload(final EJFileUpload fileUpload, final Callable<Object> callable) {
                                                if (fileUpload.isMultiSelection()) {
                                                    EJRWTFileUpload.promptMultipleFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {

                                                        @Override
                                                        public void select(String[] files) {
                                                            try {
                                                                fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
                                                                callable.call();
                                                            } catch (Exception e) {
                                                                e.printStackTrace();
                                                            }
                                                        }
                                                    });
                                                } else {
                                                    EJRWTFileUpload.promptFileUpload(fileUpload.getTitle(), fileUpload.getUploadSizeLimit(), fileUpload.getUploadTimeLimit(), fileUpload.getFileExtensions().toArray(new String[0]), new FileSelectionCallBack() {

                                                        @Override
                                                        public void select(String[] files) {
                                                            try {
                                                                fileUpload.setFilePaths(files != null ? Arrays.asList(files) : null);
                                                                callable.call();
                                                            } catch (Exception e) {
                                                                e.printStackTrace();
                                                            }
                                                        }
                                                    });
                                                }
                                            }

                                            public Image getImage(String name, ClassLoader loader) {
                                                return RWTUtils.getImage(name, loader);
                                            }

                                            @Override
                                            public void open(final String output, String outputName) {
                                                EJRWTFileDownload.download(output, outputName);
                                                RWT.getUISession().addUISessionListener(new UISessionListener() {

                                                    private static final long serialVersionUID = 1L;

                                                    @Override
                                                    public void beforeDestroy(UISessionEvent arg0) {
                                                        File f = new File(output);
                                                        if (f.exists()) {
                                                            f.delete();
                                                        }
                                                    }
                                                });
                                            }

                                            public float getAvgCharWidth(Font font) {
                                                return RWTUtils.getAvgCharWidth(font);
                                            }

                                            public int getCharHeight(Font font) {
                                                return RWTUtils.getCharHeight(font);
                                            }

                                            public void rendererSection(final Section section) {
                                                section.removeListener(SWT.Dispose, section.getListeners(SWT.Dispose)[0]);
                                                section.removeListener(SWT.Resize, section.getListeners(SWT.Resize)[0]);
                                                section.setFont(section.getParent().getFont());
                                                section.setForeground(section.getParent().getForeground());
                                                Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
                                                IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
                                                gfxAdapter.setRoundedBorder(1, section.getTitleBarBackground(), 2, 2, 0, 0);
                                                Listener listener = new Listener() {

                                                    public void handleEvent(Event e) {
                                                        Object adapter = section.getAdapter(IWidgetGraphicsAdapter.class);
                                                        IWidgetGraphicsAdapter gfxAdapter = (IWidgetGraphicsAdapter) adapter;
                                                        Color[] gradientColors = new Color[] { section.getTitleBarBorderColor(), section.getBackground(), section.getTitleBarBackground(), section.getBackground(), section.getBackground() };
                                                        int gradientPercent = 0;
                                                        Rectangle bounds = section.getClientArea();
                                                        if (bounds.height != 0) {
                                                            gradientPercent = 30 * 100 / bounds.height;
                                                            if (gradientPercent > 100) {
                                                                gradientPercent = 100;
                                                            }
                                                        }
                                                        int[] percents = new int[] { 0, 1, 2, gradientPercent, 100 };
                                                        gfxAdapter.setBackgroundGradient(gradientColors, percents, true);
                                                        gfxAdapter.setRoundedBorder(1, section.getBackground(), 4, 4, 0, 0);
                                                    }
                                                };
                                                section.addListener(SWT.Dispose, listener);
                                                section.addListener(SWT.Resize, listener);
                                            }
                                        });
                                        final EJRWTApplicationManager applicationManager;
                                        if (this.getClass().getClassLoader().getResource("application.ejprop") != null) {
                                            applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("application.ejprop");
                                        } else if (this.getClass().getClassLoader().getResource("EntireJApplication.properties") != null) {
                                            applicationManager = (EJRWTApplicationManager) EJFrameworkInitialiser.initialiseFramework("EntireJApplication.properties");
                                        } else {
                                            throw new RuntimeException("application.ejprop not found");
                                        }
                                        EJRWTContext.getPageContext().setManager(applicationManager);
                                        getContext().getUISession().setAttribute("ej.applicationManager", applicationManager);
                                        EJCoreLayoutContainer layoutContainer = EJCoreProperties.getInstance().getLayoutContainer();
                                        // Now build the application container
                                        EJRWTApplicationContainer appContainer = new EJRWTApplicationContainer(layoutContainer);
                                        // Add the application menu and status bar to the app
                                        // container
                                        EJMessenger messenger = applicationManager.getApplicationMessenger();
                                        if (messenger == null) {
                                            throw new NullPointerException("The ApplicationComponentProvider must provide an Messenger via method: getApplicationMessenger()");
                                        }
                                        Display display = Display.getDefault();
                                        if (display.isDisposed())
                                            display = new Display();
                                        Shell shell = new Shell(display, SWT.NO_TRIM);
                                        applicationManager.buildServiceApplication(appContainer, shell, formId);
                                        final EJRWTApplicationManager appman = applicationManager;
                                        Display.getCurrent().asyncExec(new Runnable() {

                                            @Override
                                            public void run() {
                                                try {
                                                    postApplicationBuild(appman);
                                                } finally {
                                                    appman.getConnection().close();
                                                }
                                            }
                                        });
                                        shell.layout();
                                        shell.setMaximized(true);
                                        final ServerPushSession pushSession = new ServerPushSession();
                                        RWT.getUISession().addUISessionListener(new UISessionListener() {

                                            public void beforeDestroy(UISessionEvent event) {
                                                pushSession.stop();
                                            }
                                        });
                                        pushSession.start();
                                        return openShell(display, shell);
                                    }
                                };
                            }
                        }, srvproperties);
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Rectangle(org.eclipse.swt.graphics.Rectangle) EntryPoint(org.eclipse.rap.rwt.application.EntryPoint) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException) EJRWTApplicationManager(org.entirej.applicationframework.rwt.application.EJRWTApplicationManager) Image(org.eclipse.swt.graphics.Image) List(java.util.List) EJCoreFrameworkExtensionPropertyList(org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList) EJCoreLayoutContainer(org.entirej.framework.core.properties.EJCoreLayoutContainer) ServerPushSession(org.eclipse.rap.rwt.service.ServerPushSession) EJRWTApplicationContainer(org.entirej.applicationframework.rwt.application.EJRWTApplicationContainer) BrowserNavigation(org.eclipse.rap.rwt.client.service.BrowserNavigation) EJRWTGraphicsProvider(org.entirej.applicationframework.rwt.application.EJRWTGraphicsProvider) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) Color(org.eclipse.swt.graphics.Color) UISessionEvent(org.eclipse.rap.rwt.service.UISessionEvent) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) IWidgetGraphicsAdapter(org.eclipse.swt.internal.widgets.IWidgetGraphicsAdapter) EntryPointFactory(org.eclipse.rap.rwt.application.EntryPointFactory) EJCoreProperties(org.entirej.framework.core.properties.EJCoreProperties) File(java.io.File) EJFileUpload(org.entirej.framework.core.data.controllers.EJFileUpload) BrowserNavigationListener(org.eclipse.rap.rwt.client.service.BrowserNavigationListener) Listener(org.eclipse.swt.widgets.Listener) UISessionListener(org.eclipse.rap.rwt.service.UISessionListener) FileSelectionCallBack(org.entirej.applicationframework.rwt.file.EJRWTFileUpload.FileSelectionCallBack) UISessionListener(org.eclipse.rap.rwt.service.UISessionListener) Callable(java.util.concurrent.Callable) Font(org.eclipse.swt.graphics.Font) Shell(org.eclipse.swt.widgets.Shell) EJCoreFrameworkExtensionPropertyList(org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList) EJMessenger(org.entirej.framework.core.interfaces.EJMessenger) BrowserNavigationEvent(org.eclipse.rap.rwt.client.service.BrowserNavigationEvent) BrowserNavigationListener(org.eclipse.rap.rwt.client.service.BrowserNavigationListener) Section(org.eclipse.ui.forms.widgets.Section) EntryPoint(org.eclipse.rap.rwt.application.EntryPoint) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException) IOException(java.io.IOException) VACSSServiceHandler(org.entirej.applicationframework.rwt.renderers.html.EJRWTHtmlTableBlockRenderer.VACSSServiceHandler) BrowserNavigationEvent(org.eclipse.rap.rwt.client.service.BrowserNavigationEvent) Event(org.eclipse.swt.widgets.Event) UISessionEvent(org.eclipse.rap.rwt.service.UISessionEvent) StartupParameters(org.eclipse.rap.rwt.client.service.StartupParameters) Display(org.eclipse.swt.widgets.Display)

Example 3 with EJCoreFrameworkExtensionPropertyList

use of org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList in project rap by entirej.

the class EJRWTRadioGroupItemRendererDefinition method getItemControl.

@Override
public EJDevItemRendererDefinitionControl getItemControl(EJDevScreenItemDisplayProperties itemDisplayProperties, Composite parent, FormToolkit toolkit) {
    String orientation = itemDisplayProperties.getBlockItemDisplayProperties().getItemRendererProperties().getStringProperty(ORIENTATION);
    boolean showBorder = itemDisplayProperties.getBlockItemDisplayProperties().getItemRendererProperties().getBooleanProperty(SHOW_BORDER, false);
    final List<Button> buttons = new ArrayList<Button>();
    group = new Composite(parent, SWT.SHADOW_NONE) {

        @Override
        public void addMouseListener(MouseListener listener) {
            super.addMouseListener(listener);
            for (Button button : buttons) {
                button.addMouseListener(listener);
            }
        }
    };
    Composite buttonParent = group;
    if (showBorder) {
        group.setLayout(new FillLayout());
        buttonParent = new Group(group, SWT.NONE);
        if (itemDisplayProperties.getLabel() != null) {
            ((Group) buttonParent).setText(itemDisplayProperties.getLabel());
        }
    }
    if (itemDisplayProperties.getHint() != null) {
        buttonParent.setToolTipText(itemDisplayProperties.getHint());
    }
    if (ORIENTATION_HORIZONTAL.equals(orientation)) {
        buttonParent.setLayout(new RowLayout(SWT.HORIZONTAL));
    } else {
        buttonParent.setLayout(new RowLayout(SWT.VERTICAL));
    }
    EJCoreFrameworkExtensionPropertyList radionButtons = itemDisplayProperties.getBlockItemDisplayProperties().getItemRendererProperties().getPropertyList(RADIO_BUTTONS);
    for (EJFrameworkExtensionPropertyListEntry entry : radionButtons.getAllListEntries()) {
        Button button = new Button(buttonParent, SWT.RADIO);
        button.setText(entry.getProperty(LABEL));
        buttons.add(button);
    }
    return new EJDevItemRendererDefinitionControl(itemDisplayProperties, group, false);
}
Also used : EJDevPropertyDefinitionGroup(org.entirej.framework.dev.properties.EJDevPropertyDefinitionGroup) Group(org.eclipse.swt.widgets.Group) EJPropertyDefinitionGroup(org.entirej.framework.core.properties.definitions.interfaces.EJPropertyDefinitionGroup) Composite(org.eclipse.swt.widgets.Composite) EJDevItemRendererDefinitionControl(org.entirej.framework.dev.renderer.definition.EJDevItemRendererDefinitionControl) ArrayList(java.util.ArrayList) FillLayout(org.eclipse.swt.layout.FillLayout) EJFrameworkExtensionPropertyListEntry(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) EJCoreFrameworkExtensionPropertyList(org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList)

Aggregations

EJCoreFrameworkExtensionPropertyList (org.entirej.framework.core.extensions.properties.EJCoreFrameworkExtensionPropertyList)3 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)3 Font (org.eclipse.swt.graphics.Font)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 JsonObject (org.eclipse.rap.json.JsonObject)1 EntryPoint (org.eclipse.rap.rwt.application.EntryPoint)1 EntryPointFactory (org.eclipse.rap.rwt.application.EntryPointFactory)1 BrowserNavigation (org.eclipse.rap.rwt.client.service.BrowserNavigation)1 BrowserNavigationEvent (org.eclipse.rap.rwt.client.service.BrowserNavigationEvent)1 BrowserNavigationListener (org.eclipse.rap.rwt.client.service.BrowserNavigationListener)1 StartupParameters (org.eclipse.rap.rwt.client.service.StartupParameters)1 ServerPushSession (org.eclipse.rap.rwt.service.ServerPushSession)1