Search in sources :

Example 1 with EJRWTAbstractActionList

use of org.entirej.applicationframework.rwt.application.components.EJRWTAbstractActionList 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)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ControlDecoration (org.eclipse.jface.fieldassist.ControlDecoration)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 KeyListener (org.eclipse.swt.events.KeyListener)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseListener (org.eclipse.swt.events.MouseListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Label (org.eclipse.swt.widgets.Label)1 EJRWTAbstractActionList (org.entirej.applicationframework.rwt.application.components.EJRWTAbstractActionList)1 EJRWTItemRendererVisualContext (org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext)1 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)1 EJFrameworkExtensionPropertyList (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList)1