Search in sources :

Example 1 with EJRWTAbstractPanelAction

use of org.entirej.applicationframework.rwt.application.components.EJRWTAbstractPanelAction in project rap by entirej.

the class EJRWTStackedItemRenderer method createComponent.

@Override
public void createComponent(Composite composite) {
    String alignmentProperty = _rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
    if (alignmentProperty == null) {
        alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
    }
    _numberType = getNumberType(_baseValue);
    _decimalFormatter = createFormatter(_numberType, null);
    _dateFormat = new MultiDateFormater(DateFormat.getDateInstance(DateFormat.SHORT, _item.getForm().getFrameworkManager().getCurrentLocale()));
    String hint = _screenItemProperties.getHint();
    {
        final String alignmentProp = alignmentProperty;
        _actionControl = new EJRWTAbstractPanelAction(composite) {

            @Override
            public Composite createPanel(Composite parent) {
                stackedPane = new EJRWTEntireJStackedPane(parent);
                // _textField.setData(EJ_RWT.CUSTOM_VARIANT, getCSSKey());
                // String customCSSKey =
                // _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
                // 
                // if (customCSSKey != null && customCSSKey.trim().length()
                // > 0)
                // {
                // _textField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
                // }
                buildStackUI(stackedPane);
                return stackedPane;
            }

            @Override
            public Control createCustomActionLabel(Composite parent) {
                return createCustomButtonControl(parent);
            }

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

                    private static final long serialVersionUID = 529634857284996692L;

                    @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";
                }
                String[] keys = new String[] { lovKey, "ENTER", "RETURN", "CR" };
                label.setData(EJ_RWT.ACTIVE_KEYS, keys);
                return label;
            }
        };
        if (hint != null && hint.trim().length() > 0) {
            updateStackHint(hint);
        }
        _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();
        setInitialValue(_baseValue);
    }
}
Also used : MultiDateFormater(org.entirej.applicationframework.rwt.renderers.item.EJRWTDateItemRenderer.MultiDateFormater) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) EJRWTEntireJStackedPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJStackedPane) MouseListener(org.eclipse.swt.events.MouseListener) EJRWTAbstractPanelAction(org.entirej.applicationframework.rwt.application.components.EJRWTAbstractPanelAction) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration)

Aggregations

ControlDecoration (org.eclipse.jface.fieldassist.ControlDecoration)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseListener (org.eclipse.swt.events.MouseListener)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 EJRWTAbstractPanelAction (org.entirej.applicationframework.rwt.application.components.EJRWTAbstractPanelAction)1 EJRWTEntireJStackedPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJStackedPane)1 MultiDateFormater (org.entirej.applicationframework.rwt.renderers.item.EJRWTDateItemRenderer.MultiDateFormater)1 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)1