Search in sources :

Example 21 with EJMessage

use of org.entirej.framework.core.EJMessage in project rap by entirej.

the class EJRWTCheckBoxItemRenderer method initialise.

@Override
public void initialise(EJScreenItemController item, EJScreenItemProperties screenItemProperties) {
    super.initialise(item, screenItemProperties);
    final String checkedValue = _rendererProps.getStringProperty(EJRWTCheckBoxRendererDefinitionProperties.CHECKED_VALUE);
    final String uncheckedValue = _rendererProps.getStringProperty(EJRWTCheckBoxRendererDefinitionProperties.UNCHECKED_VALUE);
    final String otherValueMapping = _rendererProps.getStringProperty(EJRWTCheckBoxRendererDefinitionProperties.OTHER_VALUE_MAPPING);
    if (checkedValue == null || uncheckedValue == null) {
        throw new EJApplicationException(new EJMessage("A checked and unchecked value must be specified for the Check Box Renderer for item: " + _itemProperties.getBlockName() + "." + _rendererProps.getName()));
    }
    // set 3 state checkBox
    if (_item.getScreenType() == EJScreenType.QUERY) {
        _useTriStateChaeckBox = _rendererProps.getBooleanProperty(EJRWTCheckBoxRendererDefinitionProperties.TRI_STATE, false);
    }
    _checkedValue = getValueAsObject(_itemProperties.getDataTypeClass(), checkedValue);
    _uncheckedValue = getValueAsObject(_itemProperties.getDataTypeClass(), uncheckedValue);
    _otherValueMappingValue = !EJRWTCheckBoxRendererDefinitionProperties.UNCHECKED.equals(otherValueMapping);
    _defaultValue = _itemProperties.getItemRendererProperties().getStringProperty(EJRWTCheckBoxRendererDefinitionProperties.DEFAULT_VALUE);
}
Also used : EJApplicationException(org.entirej.framework.core.EJApplicationException) EJMessage(org.entirej.framework.core.EJMessage)

Example 22 with EJMessage

use of org.entirej.framework.core.EJMessage in project rap by entirej.

the class EJRWTComboItemRenderer method connectLOVItems.

private void connectLOVItems() {
    String lovDefName = _rendererProps.getStringProperty(EJRWTComboBoxRendererDefinitionProperties.LOV_DEFINITION_NAME);
    if (lovDefName == null || lovDefName.trim().length() == 0) {
        return;
    }
    String defName = lovDefName;
    EJInternalForm form = _item.getForm();
    if (lovDefName.indexOf('.') != -1) {
        defName = lovDefName.substring(0, lovDefName.indexOf('.'));
    } else {
        EJMessage message = new EJMessage("No LovDefinition item has been chosen for the ComboBox renderer properties on item: " + _itemProperties.getName());
        form.getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
        return;
    }
    if (_item.getBlock().getProperties().isReferenceBlock()) {
        defName = String.format("%s.%s", _item.getBlock().getProperties().getName(), defName);
    }
    EJLovDefinitionProperties lovDef = form.getProperties().getLovDefinitionProperties(defName);
    if (lovDef == null) {
        return;
    }
    Collection<EJItemProperties> allItemProperties = lovDef.getBlockProperties().getAllItemProperties();
    for (EJItemProperties ejItemProperties : allItemProperties) {
        String defaultValue = ejItemProperties.getDefaultQueryValue();
        if (defaultValue == null || defaultValue.trim().length() == 0) {
            continue;
        }
        String paramTypeCode = defaultValue.substring(0, defaultValue.indexOf(':'));
        String paramValue = defaultValue.substring(defaultValue.indexOf(':') + 1);
        final Logger logger = LoggerFactory.getLogger(EJRWTComboItemRenderer.class);
        if ("APP_PARAMETER".equals(paramTypeCode)) {
            EJApplicationLevelParameter param = form.getApplicationLevelParameter(paramValue);
            if (param != null) {
                param.addParameterChangedListener(new ParameterChangedListener() {

                    @Override
                    public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
                        logger.debug("APP_PARAMETER:parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                _loadComboBoxValues();
                                refreshCombo();
                            }
                        });
                    }
                });
            }
        } else if ("FORM_PARAMETER".equals(paramTypeCode)) {
            EJFormParameter param = form.getFormParameter(paramValue);
            if (param != null) {
                param.addParameterChangedListener(new ParameterChangedListener() {

                    @Override
                    public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
                        logger.debug("FORM_PARAMETER.parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                _loadComboBoxValues();
                                refreshCombo();
                            }
                        });
                    }
                });
            }
        } else if ("BLOCK_ITEM".equals(paramTypeCode)) {
            final String blockName = paramValue.substring(0, paramValue.indexOf('.'));
            String itemName = paramValue.substring(paramValue.indexOf('.') + 1);
            EJInternalEditableBlock block = form.getBlock(blockName);
            if (block != null) {
                final String itemBlock = _item.getBlock().getProperties().getName();
                _lovInitialiedOnValueSet = true;
                if (!itemBlock.equals(blockName) || _item.getScreenType() == EJScreenType.MAIN) {
                    block.getBlockController().addNewRecordFocusedListener(new EJNewRecordFocusedListener() {

                        @Override
                        public void focusedGained(EJDataRecord focusedRecord) {
                            logger.debug(String.format("BLOCK RECORD Changed %s", blockName));
                            Display.getDefault().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    _loadComboBoxValues();
                                    refreshCombo();
                                }
                            });
                        }
                    });
                }
                block.addDataItemValueChangedListener(itemName, new EJDataItemValueChangedListener() {

                    @Override
                    public void dataItemValueChanged(String itemName, EJDataRecord changedRecord, EJScreenType screenType) {
                        if (blockName.equals(itemBlock)) {
                            if (screenType == _item.getScreenType()) {
                                logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        _loadComboBoxValues();
                                        refreshCombo();
                                    }
                                });
                            }
                        } else {
                            if (screenType == EJScreenType.MAIN) {
                                logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        _loadComboBoxValues();
                                        refreshCombo();
                                    }
                                });
                            }
                        }
                    }
                });
            }
        }
    }
    EJLovController lovController = form.getLovController(defName);
    if (lovController == null) {
        return;
    }
}
Also used : EJScreenType(org.entirej.framework.core.enumerations.EJScreenType) EJFormParameter(org.entirej.framework.core.data.controllers.EJFormParameter) Logger(org.slf4j.Logger) EJApplicationLevelParameter(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter) EJLovController(org.entirej.framework.core.data.controllers.EJLovController) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm) EJMessage(org.entirej.framework.core.EJMessage) EJLovDefinitionProperties(org.entirej.framework.core.properties.interfaces.EJLovDefinitionProperties) ParameterChangedListener(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter.ParameterChangedListener) EJDataItemValueChangedListener(org.entirej.framework.core.renderers.eventhandlers.EJDataItemValueChangedListener) EJInternalEditableBlock(org.entirej.framework.core.internal.EJInternalEditableBlock) EJNewRecordFocusedListener(org.entirej.framework.core.renderers.eventhandlers.EJNewRecordFocusedListener) EJItemProperties(org.entirej.framework.core.properties.interfaces.EJItemProperties) EJDataRecord(org.entirej.framework.core.data.EJDataRecord)

Example 23 with EJMessage

use of org.entirej.framework.core.EJMessage in project rap by entirej.

the class EJRWTMultiRecordBlockRenderer method askToDeleteRecord.

@Override
public void askToDeleteRecord(final EJDataRecord recordToDelete, String msg) {
    if (msg == null) {
        msg = "Are you sure you want to delete the current record?";
    }
    EJMessage message = new EJMessage(msg);
    EJQuestion question = new EJQuestion(new EJForm(_block.getForm()), "DELETE_RECORD", "Delete", message, "Yes", "No") {

        @Override
        public void setAnswer(EJQuestionButton answerButton) {
            super.setAnswer(answerButton);
            if (EJQuestionButton.ONE == answerButton) {
                _block.getBlock().deleteRecord(recordToDelete);
            }
            _block.setRendererFocus(true);
        }
    };
    _block.getForm().getMessenger().askQuestion(question);
}
Also used : EJQuestionButton(org.entirej.framework.core.enumerations.EJQuestionButton) EJQuestion(org.entirej.framework.core.data.controllers.EJQuestion) EJForm(org.entirej.framework.core.EJForm) EJMessage(org.entirej.framework.core.EJMessage)

Example 24 with EJMessage

use of org.entirej.framework.core.EJMessage in project rap by entirej.

the class EJRWTTextItemRenderer method setValue.

@Override
public void setValue(Object value) {
    _baseValue = value;
    _valueChanged = false;
    _oldvalue = null;
    try {
        _modifyListener.enable = false;
        if (_displayValueAsLabel) {
            if (controlState(_valueLabel)) {
                if (value == null) {
                    _valueLabel.setText("");
                    _valueLabel.setToolTipText("");
                } else {
                    _valueLabel.setText(toCaseValue(value.toString()));
                    _valueLabel.setToolTipText(value.toString());
                }
            }
        } else {
            if (controlState(_textField)) {
                if (value != null) {
                    if (_maxLength > 0 && value.toString().length() > _maxLength) {
                        EJMessage message = new EJMessage("The value for item, " + _item.getReferencedItemProperties().getBlockName() + "." + _item.getReferencedItemProperties().getName() + " is too long for its field definition.");
                        throw new EJApplicationException(message);
                    }
                }
                _textField.setText(value == null ? "" : toCaseValue(value.toString()));
                setMandatoryBorder(_mandatory);
            }
        }
    } finally {
        _modifyListener.enable = true;
    }
}
Also used : EJApplicationException(org.entirej.framework.core.EJApplicationException) EJMessage(org.entirej.framework.core.EJMessage)

Example 25 with EJMessage

use of org.entirej.framework.core.EJMessage in project rap by entirej.

the class EJRWTBarChartRecordBlockRenderer method enterInsert.

@Override
public void enterInsert(EJDataRecord record) {
    if (_block.getInsertScreenRenderer() == null) {
        EJMessage message = new EJMessage("Please define an Insert Screen Renderer for this form before an insert operation can be performed.");
        _block.getForm().getMessenger().handleMessage(message);
    } else {
        EJDataRecord focusedRecord = getFocusedRecord();
        if (focusedRecord != null) {
            final String pid = _rendererProp.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.PARENT_ITEM);
            final String rid = _rendererProp.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.RELATION_ITEM);
            record.setValue(rid, focusedRecord.getValue(pid));
        }
        _block.getInsertScreenRenderer().open(record);
    }
}
Also used : EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJMessage(org.entirej.framework.core.EJMessage)

Aggregations

EJMessage (org.entirej.framework.core.EJMessage)44 EJForm (org.entirej.framework.core.EJForm)9 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)9 EJQuestion (org.entirej.framework.core.data.controllers.EJQuestion)9 EJQuestionButton (org.entirej.framework.core.enumerations.EJQuestionButton)9 EJApplicationException (org.entirej.framework.core.EJApplicationException)5 EJLovController (org.entirej.framework.core.data.controllers.EJLovController)4 EJLovDefinitionProperties (org.entirej.framework.core.properties.interfaces.EJLovDefinitionProperties)4 Date (java.util.Date)3 EJItemLovController (org.entirej.framework.core.data.controllers.EJItemLovController)3 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 EJCoreItemProperties (org.entirej.framework.core.properties.EJCoreItemProperties)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 URL (java.net.URL)1 ParseException (java.text.ParseException)1 Collection (java.util.Collection)1 List (java.util.List)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1