Search in sources :

Example 36 with EJFrameworkExtensionProperties

use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.

the class EJRWTListRecordBlockRenderer method createScreenItem.

public ColumnLabelProvider createScreenItem(EJRWTTableViewerColumnFactory factory, EJCoreMainScreenItemProperties itemProps) {
    if (itemProps.isSpacerItem()) {
        return null;
    }
    EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
    EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
    if (renderer != null) {
        EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
        ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
        if (labelProvider != null) {
            EJFrameworkExtensionProperties blockProperties = itemProps.getBlockRendererRequiredProperties();
            String visualAttribute = blockProperties.getStringProperty(EJRWTListRecordBlockDefinitionProperties.VISUAL_ATTRIBUTE_PROPERTY);
            if (visualAttribute != null) {
                EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
                if (va != null)
                    itemRenderer.setInitialVisualAttribute(va);
            }
        }
        return labelProvider;
    }
    return null;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 37 with EJFrameworkExtensionProperties

use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.

the class EJRWTApplicationContainer method buildServiceApplicationContainer.

protected void buildServiceApplicationContainer(final String fromID) {
    GridLayout gridLayout = new GridLayout(1, false);
    _mainPane.setLayout(gridLayout);
    EJRWTSingleFormContainer container = new EJRWTSingleFormContainer() {

        @Override
        protected String getFormId(EJFrameworkExtensionProperties rendererprop) {
            return fromID;
        }
    };
    container.createContainer(_applicationManager, _mainPane, null);
    container.getGuiComponent().setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    _singleFormContainers.add(container);
    _mainPane.layout();
    for (EJRWTSingleFormContainer singleFormContainer : _singleFormContainers) {
        if (singleFormContainer.getForm() != null) {
            fireFormOpened(singleFormContainer.getForm());
        }
    }
}
Also used : EJRWTSingleFormContainer(org.entirej.applicationframework.rwt.application.form.containers.EJRWTSingleFormContainer) GridLayout(org.eclipse.swt.layout.GridLayout) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) GridData(org.eclipse.swt.layout.GridData)

Example 38 with EJFrameworkExtensionProperties

use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.

the class EJRWTMultiRecordBlockRenderer method createScreenItem.

public ColumnLabelProvider createScreenItem(EJRWTTableViewerColumnFactory factory, EJCoreMainScreenItemProperties itemProps) {
    if (itemProps.isSpacerItem()) {
        return null;
    }
    EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
    EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
    if (renderer != null) {
        EJFrameworkExtensionProperties blockProperties = itemProps.getBlockRendererRequiredProperties();
        EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
        ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
        if (labelProvider != null) {
            String labelOrientation = blockProperties.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
            int displayedWidth = blockProperties.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
            // width
            if (displayedWidth == 0) {
                if (itemProps.getLabel() != null) {
                    // add offset
                    displayedWidth = itemProps.getLabel().length() + 2;
                } else {
                    displayedWidth = 5;
                }
            }
            String visualAttribute = blockProperties.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.VISUAL_ATTRIBUTE_PROPERTY);
            if (visualAttribute != null) {
                EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
                if (va != null) {
                    itemRenderer.setInitialVisualAttribute(va);
                }
            }
            if (item.getProperties().getVisualAttributeProperties() != null) {
                renderer.setVisualAttribute(item.getProperties().getVisualAttributeProperties());
            }
            TableViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), displayedWidth, labelProvider, getComponentStyle(labelOrientation));
            TableColumn column = viewerColumn.getColumn();
            EJ_RWT.setTestId(column, blockProperties.getName() + "." + itemProps.getReferencedItemName());
            column.setData("KEY", itemProps.getReferencedItemName());
            column.setData("ITEM", item);
            column.setToolTipText(itemProps.getHint());
            ColumnInfo info = new ColumnInfo();
            column.setData("INFO", info);
            column.setMoveable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
            column.setResizable(info.resizable = blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_RESIZE, true));
            if (blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_ROW_SORTING, true)) {
                EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
                if (columnSorter != null) {
                    new EJRWTTableSortSelectionListener(_tableViewer, column, columnSorter, SWT.UP, false);
                }
            }
            // ensure that the width property of the table column is in
            // Characters
            Font font = labelProvider.getFont(new Object());
            if (font == null) {
                font = _tableViewer.getTable().getFont();
            }
            if (font != null) {
                float avgCharWidth = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(font);
                if (avgCharWidth > 0) {
                    // add + 1 padding
                    column.setWidth(info.width = ((int) ((column.getWidth() + 1) * avgCharWidth)));
                }
            }
            if (!item.isVisible()) {
                column.setWidth(0);
                column.setResizable(false);
            }
            return labelProvider;
        }
    }
    return null;
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) TableColumn(org.eclipse.swt.widgets.TableColumn) EJRWTAppItemRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) HtmlBaseColumnLabelProvider(org.entirej.applicationframework.rwt.table.HtmlBaseColumnLabelProvider) EJScreenItemController(org.entirej.framework.core.interfaces.EJScreenItemController) EJManagedItemRendererWrapper(org.entirej.framework.core.renderers.EJManagedItemRendererWrapper) EJRWTTableSortSelectionListener(org.entirej.applicationframework.rwt.table.EJRWTTableSortSelectionListener) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties) EJRWTAbstractTableSorter(org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter)

Example 39 with EJFrameworkExtensionProperties

use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.

the class EJRWTListItemRenderer method createComponent.

@Override
public void createComponent(Composite composite) {
    _actionControl = new EJRWTAbstractActionList(composite) {

        private static final long serialVersionUID = 2592484612013403481L;

        @Override
        protected boolean hasFilter() {
            return _rendererProps.getBooleanProperty(FILTER, false);
        }

        @Override
        public void refreshData() {
            refreshList();
        }

        @Override
        public org.eclipse.swt.widgets.List createList(Composite parent) {
            String alignmentProperty = _rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
            if (alignmentProperty == null) {
                alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
            }
            String hint = _screenItemProperties.getHint();
            int style = SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
            style = getComponentStyle(alignmentProperty, style);
            _listField = new org.eclipse.swt.widgets.List(parent, style);
            _listField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LIST);
            String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
            String imageItem = _rendererProps.getStringProperty(COLUMN_IMAGE_ITEM);
            if (customCSSKey != null && customCSSKey.trim().length() > 0) {
                _listField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
            }
            if (imageItem != null && imageItem.trim().length() > 0) {
                _listField.setData(EJ_RWT.MARKUP_ENABLED, true);
            }
            if (hint != null && hint.trim().length() > 0) {
                _listField.setToolTipText(hint);
            }
            _listField.setData(_item.getReferencedItemProperties().getName());
            _listField.addFocusListener(EJRWTListItemRenderer.this);
            _listField.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (isValid()) {
                        Object old = _baseValue;
                        ListBoxValue value = getListBoxValue();
                        if (value != null && _activeEvent) {
                            value.populateReturnItems(_item.getBlock().getBlockController(), _item.getScreenType());
                        }
                        if (_activeEvent) {
                            _item.itemValueChaged(value.getItemValue());
                        }
                        setMandatoryBorder(_mandatory);
                    } else {
                        _isValid = true;
                    }
                    if (_activeEvent) {
                        _item.executeActionCommand();
                    }
                }
            });
            return _listField;
        }

        @Override
        public Control createActionLabel(Composite parent) {
            Label label = new Label(parent, SWT.NONE);
            label.setImage(EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_FIND_LOV));
            label.addFocusListener(EJRWTListItemRenderer.this);
            label.addMouseListener(new MouseListener() {

                @Override
                public void mouseUp(MouseEvent arg0) {
                    _item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
                }

                @Override
                public void mouseDown(MouseEvent arg0) {
                }

                @Override
                public void mouseDoubleClick(MouseEvent arg0) {
                }
            });
            final EJFrameworkExtensionProperties rendererProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
            final EJFrameworkExtensionProperties propertyGroup = rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
            String lovKey = "SHIFT+ARROW_DOWN";
            if (propertyGroup != null) {
                lovKey = propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_LOV_KEY);
            }
            if (lovKey == null) {
                lovKey = "SHIFT+ARROW_DOWN";
            }
            label.setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
            getListControl().setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
            addKeyListener(new KeyListener() {

                @Override
                public void keyReleased(KeyEvent arg0) {
                    if ((arg0.stateMask & SWT.SHIFT) != 0 && arg0.keyCode == SWT.ARROW_DOWN && isLovActivated()) {
                        _item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
                    }
                }

                @Override
                public void keyPressed(KeyEvent arg0) {
                }
            });
            return label;
        }
    };
    _visualContext = new EJRWTItemRendererVisualContext(_listField.getBackground(), _listField.getForeground(), _listField.getFont());
    _mandatoryDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
    _errorDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
    _errorDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_ERROR));
    _mandatoryDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_REQUIRED));
    _mandatoryDecoration.setShowHover(true);
    _mandatoryDecoration.setDescriptionText(_screenItemProperties.getLabel() == null || _screenItemProperties.getLabel().isEmpty() ? "Required Item" : String.format("%s is required", _screenItemProperties.getLabel()));
    if (_isValid) {
        _errorDecoration.hide();
    }
    if (message != null) {
        setMessage(message);
    }
    _mandatoryDecoration.hide();
    refreshList();
    setInitialValue(_baseValue);
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) KeyEvent(org.eclipse.swt.events.KeyEvent) Control(org.eclipse.swt.widgets.Control) MouseListener(org.eclipse.swt.events.MouseListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) EJRWTAbstractActionList(org.entirej.applicationframework.rwt.application.components.EJRWTAbstractActionList) List(java.util.List) EJFrameworkExtensionPropertyList(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList) ArrayList(java.util.ArrayList) KeyListener(org.eclipse.swt.events.KeyListener) EJRWTAbstractActionList(org.entirej.applicationframework.rwt.application.components.EJRWTAbstractActionList) EJRWTItemRendererVisualContext(org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext)

Example 40 with EJFrameworkExtensionProperties

use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.

the class EJRWTDateItemRenderer method createDateFormat.

protected static MultiDateFormater createDateFormat(EJScreenItemController item) {
    MultiDateFormater dateFormat;
    Locale defaultLocale = item.getForm().getFrameworkManager().getCurrentLocale();
    if (defaultLocale == null) {
        defaultLocale = Locale.getDefault();
    }
    EJFrameworkExtensionProperties rendererProps = item.getReferencedItemProperties().getItemRendererProperties();
    String format = rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_FORMAT);
    if (format == null || format.length() == 0) {
        format = rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_LOCALE_FORMAT);
        if (format == null || format.length() == 0) {
            dateFormat = new MultiDateFormater(DateFormat.getDateInstance(DateFormat.SHORT, defaultLocale));
        } else {
            DateFormats formats = DateFormats.valueOf(format);
            switch(formats) {
                case DATE_FULL:
                    dateFormat = new MultiDateFormater(DateFormat.getDateInstance(DateFormat.FULL, defaultLocale));
                    break;
                case DATE_LONG:
                    dateFormat = new MultiDateFormater(DateFormat.getDateInstance(DateFormat.LONG, defaultLocale));
                    break;
                case DATE_MEDIUM:
                    dateFormat = new MultiDateFormater(DateFormat.getDateInstance(DateFormat.MEDIUM, defaultLocale));
                    break;
                case DATE_SHORT:
                    dateFormat = new MultiDateFormater(DateFormat.getDateInstance(DateFormat.SHORT, defaultLocale));
                    break;
                case DATE_TIME_FULL:
                    dateFormat = new MultiDateFormater(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, defaultLocale));
                    break;
                case DATE_TIME_LONG:
                    dateFormat = new MultiDateFormater(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, defaultLocale));
                    break;
                case DATE_TIME_MEDIUM:
                    dateFormat = new MultiDateFormater(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, defaultLocale));
                    break;
                case DATE_TIME_SHORT:
                    dateFormat = new MultiDateFormater(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, defaultLocale));
                    break;
                case TIME_FULL:
                    dateFormat = new MultiDateFormater(DateFormat.getTimeInstance(DateFormat.FULL, defaultLocale));
                    break;
                case TIME_LONG:
                    dateFormat = new MultiDateFormater(DateFormat.getTimeInstance(DateFormat.LONG, defaultLocale));
                    break;
                case TIME_MEDIUM:
                    dateFormat = new MultiDateFormater(DateFormat.getTimeInstance(DateFormat.MEDIUM, defaultLocale));
                    break;
                case TIME_SHORT:
                    dateFormat = new MultiDateFormater(DateFormat.getTimeInstance(DateFormat.SHORT, defaultLocale));
                    break;
                default:
                    dateFormat = new MultiDateFormater(DateFormat.getDateInstance());
                    break;
            }
        }
    } else {
        String[] split = format.split("\\|");
        SimpleDateFormat[] formats = new SimpleDateFormat[split.length];
        for (int i = 0; i < split.length; i++) {
            formats[i] = new SimpleDateFormat(split[i], defaultLocale);
        }
        dateFormat = new MultiDateFormater(formats);
    }
    return dateFormat;
}
Also used : Locale(java.util.Locale) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) SimpleDateFormat(java.text.SimpleDateFormat) Point(org.eclipse.swt.graphics.Point)

Aggregations

EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)49 Composite (org.eclipse.swt.widgets.Composite)23 Group (org.eclipse.swt.widgets.Group)20 Section (org.eclipse.ui.forms.widgets.Section)19 EJScreenItemController (org.entirej.framework.core.interfaces.EJScreenItemController)17 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)14 MouseEvent (org.eclipse.swt.events.MouseEvent)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 GridLayout (org.eclipse.swt.layout.GridLayout)14 KeyEvent (org.eclipse.swt.events.KeyEvent)13 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)13 EJManagedItemRendererWrapper (org.entirej.framework.core.renderers.EJManagedItemRendererWrapper)13 GridData (org.eclipse.swt.layout.GridData)12 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)12 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)12 EJBlockProperties (org.entirej.framework.core.properties.interfaces.EJBlockProperties)12 Label (org.eclipse.swt.widgets.Label)11 EJRWTAppItemRenderer (org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer)11 EJCoreVisualAttributeProperties (org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)11 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)11