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);
}
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;
}
}
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);
}
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;
}
}
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);
}
}
Aggregations