Search in sources :

Example 1 with LOVSupportConfig

use of org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig.LOVSupportConfig in project rap by entirej.

the class EJRWTStackedItemRenderer method extractValuetoUi.

private void extractValuetoUi() {
    if (!controlState(stackedPane))
        return;
    try {
        enableLovActivation(false);
        _item.setItemLovMapping(null);
        _actionControl.setCustomActionVisible(_baseValue != null && _baseValue.getConfig().getType() == EJRWTStackedItemRendererType.DATE);
        if (_baseValue != null) {
            if (controlState(_label) && !(_baseValue.getConfig().getType() == EJRWTStackedItemRendererType.SPACER || _baseValue.getConfig().getType() == EJRWTStackedItemRendererType.CHECKBOX || _baseValue.getConfig().getType() == EJRWTStackedItemRendererType.BUTTON)) {
                if (_baseValue.getConfig().getLabel() != null) {
                    setLabel(_baseValue.getConfig().getLabel());
                } else {
                    setLabel(_screenItemProperties.getLabel() == null ? "" : _screenItemProperties.getLabel());
                }
            }
            if (_baseValue.getConfig().getType() == EJRWTStackedItemRendererType.COMBO) {
                EJRWTStackedItemRendererConfig.Combo config = (EJRWTStackedItemRendererConfig.Combo) _baseValue.getConfig();
                Combo control = (Combo) stackedPane.getControl(_baseValue.getConfig().getType().name());
                if (control.getData("CONFIG") != config) {
                    List<ComboBoxValue> loadComboBoxValues = loadComboBoxValues(config);
                    ((ComboViewer) control.getData("VIEW")).setInput(loadComboBoxValues);
                    control.setData("CONFIG", config);
                    if (config.getVisibleItemCount() > 5) {
                        control.setVisibleItemCount(config.getVisibleItemCount());
                    }
                }
            }
            if (_baseValue.getConfig().getTooltip() != null) {
                setHint(_baseValue.getConfig().getLabel());
            } else {
                setHint(_screenItemProperties.getHint() == null ? "" : _screenItemProperties.getHint());
            }
            stackedPane.showPane(_baseValue.getConfig().getType().name());
            if (_baseValue.getConfig().getExpandHorizontally() != null) {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    if (_actionControl.getData("data.ExpandH") == null)
                        _actionControl.setData("data.ExpandH", data.grabExcessHorizontalSpace);
                    if (_actionControl.getData("data.HA") == null)
                        _actionControl.setData("data.HA", data.horizontalAlignment);
                    data.grabExcessHorizontalSpace = _baseValue.getConfig().getExpandHorizontally();
                    data.horizontalAlignment = data.grabExcessHorizontalSpace ? SWT.FILL : SWT.BEGINNING;
                }
            } else {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    if (_actionControl.getData("data.ExpandH") != null) {
                        data.grabExcessHorizontalSpace = (Boolean) _actionControl.getData("data.ExpandH");
                        data.horizontalAlignment = (Integer) _actionControl.getData("data.HA");
                        _actionControl.setData("data.ExpandH", null);
                        _actionControl.setData("data.HA", null);
                    }
                }
            }
            if (_baseValue.getConfig().getExpandVertically() != null) {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    if (_actionControl.getData("data.ExpandV") == null)
                        _actionControl.setData("data.ExpandV", data.grabExcessVerticalSpace);
                    if (_actionControl.getData("data.VA") == null)
                        _actionControl.setData("data.VA", data.verticalAlignment);
                    data.grabExcessVerticalSpace = _baseValue.getConfig().getExpandVertically();
                    data.verticalAlignment = data.grabExcessVerticalSpace ? SWT.FILL : SWT.TOP;
                }
                if (_label != null) {
                    layoutData = _label.getLayoutData();
                    if (layoutData instanceof GridData) {
                        GridData data = (GridData) layoutData;
                        if (_label.getData("data.VA") == null)
                            _label.setData("data.VA", data.verticalAlignment);
                        if (_label.getData("data.VI") == null)
                            _label.setData("data.VI", data.verticalIndent);
                        data.verticalIndent = 2;
                        data.verticalAlignment = SWT.TOP;
                    }
                }
            } else {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    if (_actionControl.getData("data.ExpandV") != null) {
                        data.grabExcessVerticalSpace = (Boolean) _actionControl.getData("data.ExpandV");
                        data.verticalAlignment = (Integer) _actionControl.getData("data.VA");
                        _actionControl.setData("data.ExpandV", null);
                        _actionControl.setData("data.VA", null);
                    }
                }
                if (_label != null) {
                    layoutData = _label.getLayoutData();
                    if (layoutData instanceof GridData) {
                        GridData data = (GridData) layoutData;
                        if (_label.getData("data.VA") != null)
                            data.verticalAlignment = (Integer) _label.getData("data.VA");
                        if (_label.getData("data.VI") != null)
                            data.verticalIndent = (Integer) _label.getData("data.VI");
                    }
                }
            }
            if (_baseValue.getConfig().getXSpan() != EJRWTStackedItemRendererConfig.DEFUALT) {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    if (_actionControl.getData("data.xspan") == null)
                        _actionControl.setData("data.xspan", data.horizontalSpan);
                    data.horizontalSpan = _baseValue.getConfig().getXSpan();
                }
            } else {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    if (_actionControl.getData("data.xspan") != null) {
                        data.horizontalSpan = (Integer) _actionControl.getData("data.xspan");
                        _actionControl.setData("data.xspan", null);
                    }
                }
            }
            if (_baseValue.getConfig().getYSpan() != EJRWTStackedItemRendererConfig.DEFUALT) {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    if (_actionControl.getData("data.yspan") == null)
                        _actionControl.setData("data.yspan", data.verticalSpan);
                    data.verticalSpan = _baseValue.getConfig().getYSpan();
                }
            } else {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    if (_actionControl.getData("data.yspan") != null) {
                        data.verticalSpan = (Integer) _actionControl.getData("data.yspan");
                        _actionControl.setData("data.yspan", null);
                    }
                }
            }
            if (_baseValue.getConfig().getWidth() != EJRWTStackedItemRendererConfig.DEFUALT) {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    Control control = stackedPane.getControl(_baseValue.getConfig().getType().name());
                    float avgCharHeight = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(control.getFont());
                    if (_actionControl.getData("data.widthHint") == null)
                        _actionControl.setData("data.widthHint", data.widthHint);
                    data.widthHint = (int) (avgCharHeight * (_baseValue.getConfig().getWidth() + 1));
                }
            } else {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    if (_actionControl.getData("data.widthHint") != null) {
                        data.widthHint = (Integer) _actionControl.getData("data.widthHint");
                        _actionControl.setData("data.widthHint", null);
                    }
                }
            }
            if (_baseValue.getConfig().getType() == EJRWTStackedItemRendererType.TEXT_AREA) {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    EJRWTStackedItemRendererConfig.TextArea config = (TextArea) _baseValue.getConfig();
                    Control control = stackedPane.getControl(_baseValue.getConfig().getType().name());
                    float avgCharHeight = EJRWTImageRetriever.getGraphicsProvider().getCharHeight(control.getFont());
                    // add padding
                    if (config.getLines() > 0) {
                        if (_actionControl.getData("data.heightHint") == null)
                            _actionControl.setData("data.heightHint", data.heightHint);
                        data.heightHint = (int) ((config.getLines() + 1) * avgCharHeight);
                    }
                }
                if (_label != null) {
                    layoutData = _label.getLayoutData();
                    if (layoutData instanceof GridData) {
                        GridData data = (GridData) layoutData;
                        if (_label.getData("data.VA") == null)
                            _label.setData("data.VA", data.verticalAlignment);
                        if (_label.getData("data.VI") == null)
                            _label.setData("data.VI", data.verticalIndent);
                        data.verticalIndent = 2;
                        data.verticalAlignment = SWT.TOP;
                    }
                }
            } else if (_baseValue.getConfig().getHeight() != EJRWTStackedItemRendererConfig.DEFUALT) {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    Control control = stackedPane.getControl(_baseValue.getConfig().getType().name());
                    float avgCharHeight = EJRWTImageRetriever.getGraphicsProvider().getCharHeight(control.getFont());
                    if (_actionControl.getData("data.heightHint") == null)
                        _actionControl.setData("data.heightHint", data.heightHint);
                    data.heightHint = (int) (avgCharHeight * (_baseValue.getConfig().getHeight() + 1));
                }
                if (_label != null) {
                    layoutData = _label.getLayoutData();
                    if (layoutData instanceof GridData) {
                        GridData data = (GridData) layoutData;
                        if (_label.getData("data.VA") == null)
                            _label.setData("data.VA", data.verticalAlignment);
                        if (_label.getData("data.VI") == null)
                            _label.setData("data.VI", data.verticalIndent);
                        data.verticalIndent = 2;
                        data.verticalAlignment = SWT.TOP;
                    }
                }
            } else {
                Object layoutData = _actionControl.getLayoutData();
                if (layoutData instanceof GridData) {
                    GridData data = (GridData) layoutData;
                    // add padding
                    if (_actionControl.getData("data.heightHint") != null) {
                        data.heightHint = (Integer) _actionControl.getData("data.heightHint");
                        _actionControl.setData("data.heightHint", null);
                    }
                }
                if (_label != null) {
                    layoutData = _label.getLayoutData();
                    if (layoutData instanceof GridData) {
                        GridData data = (GridData) layoutData;
                        if (_label.getData("data.VA") != null)
                            data.verticalAlignment = (Integer) _label.getData("data.VA");
                        if (_label.getData("data.VI") != null)
                            data.verticalIndent = (Integer) _label.getData("data.VI");
                    }
                }
            }
            // setLOV mapping
            if (_baseValue.getConfig() instanceof EJRWTStackedItemRendererConfig.ActionSupportConfig) {
                if (_item.getProperties() instanceof EJCoreInsertScreenItemProperties) {
                    ((EJCoreInsertScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
                } else if (_item.getProperties() instanceof EJCoreQueryScreenItemProperties) {
                    ((EJCoreQueryScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
                } else if (_item.getProperties() instanceof EJCoreUpdateScreenItemProperties) {
                    ((EJCoreUpdateScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
                } else if (_item.getProperties() instanceof EJCoreMainScreenItemProperties) {
                    ((EJCoreMainScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
                }
            }
            if (_baseValue.getConfig() instanceof EJRWTStackedItemRendererConfig.LOVSupportConfig) {
                EJRWTStackedItemRendererConfig.LOVSupportConfig lovMapping = (LOVSupportConfig) _baseValue.getConfig();
                _item.getProperties().enableLovNotification(lovMapping.isLovEnabled());
                _item.setItemLovMapping(lovMapping.getLovMapping());
                _item.getProperties().enableLovValidation(lovMapping.isValidateLov());
                enableLovActivation(lovMapping.isLovEnabled());
            }
            setStackValue();
        } else {
            // switch
            stackedPane.showPane(EJRWTStackedItemRendererType.SPACER.name());
            Object layoutData = _actionControl.getLayoutData();
            if (layoutData instanceof GridData) {
                GridData data = (GridData) layoutData;
                if (_actionControl.getData("data.heightHint") != null) {
                    data.heightHint = (Integer) _actionControl.getData("data.heightHint");
                    _actionControl.setData("data.heightHint", null);
                }
                if (_actionControl.getData("data.xspan") != null) {
                    data.horizontalSpan = (Integer) _actionControl.getData("data.xspan");
                    _actionControl.setData("data.xspan", null);
                }
                if (_actionControl.getData("data.yspan") != null) {
                    data.verticalSpan = (Integer) _actionControl.getData("data.yspan");
                    _actionControl.setData("data.yspan", null);
                }
                if (_actionControl.getData("data.ExpandV") != null) {
                    data.grabExcessVerticalSpace = (Boolean) _actionControl.getData("data.ExpandV");
                    data.verticalAlignment = (Integer) _actionControl.getData("data.VA");
                    _actionControl.setData("data.ExpandV", null);
                    _actionControl.setData("data.VA", null);
                }
                if (_actionControl.getData("data.ExpandH") != null) {
                    data.grabExcessHorizontalSpace = (Boolean) _actionControl.getData("data.ExpandH");
                    data.horizontalAlignment = (Integer) _actionControl.getData("data.HA");
                    _actionControl.setData("data.ExpandH", null);
                    _actionControl.setData("data.HA", null);
                }
                if (_label != null) {
                    layoutData = _label.getLayoutData();
                    if (layoutData instanceof GridData) {
                        GridData ldata = (GridData) layoutData;
                        if (_label.getData("data.VA") != null)
                            ldata.verticalAlignment = (Integer) _label.getData("data.VA");
                        if (_label.getData("data.VI") != null)
                            ldata.verticalIndent = (Integer) _label.getData("data.VI");
                    }
                }
            }
        // to
        // empty
        }
    } finally {
        _actionControl.getParent().layout();
    }
}
Also used : EJCoreQueryScreenItemProperties(org.entirej.framework.core.properties.EJCoreQueryScreenItemProperties) TextArea(org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig.TextArea) EJCoreInsertScreenItemProperties(org.entirej.framework.core.properties.EJCoreInsertScreenItemProperties) TextArea(org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig.TextArea) EJCoreMainScreenItemProperties(org.entirej.framework.core.properties.EJCoreMainScreenItemProperties) Combo(org.eclipse.swt.widgets.Combo) EJCoreUpdateScreenItemProperties(org.entirej.framework.core.properties.EJCoreUpdateScreenItemProperties) Control(org.eclipse.swt.widgets.Control) LOVSupportConfig(org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig.LOVSupportConfig) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) LOVSupportConfig(org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig.LOVSupportConfig) EJRWTStackedItemRendererConfig(org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig)

Aggregations

ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 GridData (org.eclipse.swt.layout.GridData)1 Combo (org.eclipse.swt.widgets.Combo)1 Control (org.eclipse.swt.widgets.Control)1 EJRWTStackedItemRendererConfig (org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig)1 LOVSupportConfig (org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig.LOVSupportConfig)1 TextArea (org.entirej.applicationframework.rwt.renderers.stack.EJRWTStackedItemRendererConfig.TextArea)1 EJCoreInsertScreenItemProperties (org.entirej.framework.core.properties.EJCoreInsertScreenItemProperties)1 EJCoreMainScreenItemProperties (org.entirej.framework.core.properties.EJCoreMainScreenItemProperties)1 EJCoreQueryScreenItemProperties (org.entirej.framework.core.properties.EJCoreQueryScreenItemProperties)1 EJCoreUpdateScreenItemProperties (org.entirej.framework.core.properties.EJCoreUpdateScreenItemProperties)1