use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTDateTimeItemRenderer method setValue.
@Override
public void setValue(Object value) {
if (value != null && !Date.class.isAssignableFrom(value.getClass())) {
EJMessage message = EJMessageFactory.getInstance().createMessage(EJFrameworkMessage.INVALID_DATA_TYPE_FOR_ITEM, _item.getName(), Date.class.getName(), value.getClass().getName());
throw new IllegalArgumentException(message.getMessage());
}
_baseValue = value;
if (_displayValueAsLabel) {
if (controlState(_valueLabel)) {
_valueLabel.setText(value != null ? _dateFormat.format(value) : "");
}
} else {
if (controlState(_textField)) {
setDateTime(_textField, value);
setMandatoryBorder(_mandatory);
}
}
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTListItemRenderer method loadListBoxValues.
private void loadListBoxValues() {
// Initialise both the field and the values.
_lovInitialied = true;
_listValues.clear();
_listKays.clear();
String lovDefName = _rendererProps.getStringProperty(EJRWTListBoxRendererDefinitionProperties.LOV_DEFINITION_NAME);
if (lovDefName == null || lovDefName.trim().length() == 0) {
return;
}
String defName = lovDefName;
String defItemName = "";
if (lovDefName.indexOf('.') != -1) {
defName = lovDefName.substring(0, lovDefName.indexOf('.'));
defItemName = lovDefName.substring(lovDefName.indexOf('.') + 1);
} else {
EJMessage message = new EJMessage("No LovDefinition item has been chosen for the ListBox renderer properties on item: " + _itemProperties.getName());
_item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
return;
}
if (_item.getBlock().getProperties().isReferenceBlock()) {
defName = String.format("%s.%s", _item.getBlock().getProperties().getName(), defName);
}
EJLovDefinitionProperties lovDef = _item.getForm().getProperties().getLovDefinitionProperties(defName);
if (lovDef == null) {
return;
}
EJLovController lovController = _item.getForm().getLovController(defName);
if (lovController == null) {
return;
}
try {
lovController.executeQuery(new EJItemLovController(_item.getBlock().getBlockController().getFormController(), _item, ((EJCoreItemProperties) _itemProperties).getLovMappingPropertiesOnUpdate()));
Collection<EJDataRecord> records = lovController.getRecords();
for (EJDataRecord ejDataRecord : records) {
if (!ejDataRecord.containsItem(defItemName)) {
EJMessage message = new EJMessage("The item name '" + defItemName + "', does not exist within the lov definitions underlying block. Lov Definition: " + defName);
_item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
return;
}
ListBoxValue listValue = new ListBoxValue(ejDataRecord, defItemName);
String itemValueAsString = listValue.getItemValueAsString();
_listValues.put(itemValueAsString, listValue);
_listKays.add(itemValueAsString);
}
} catch (Exception e) {
_item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleException(e, true);
}
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTDateItemRenderer method setValue.
@Override
public void setValue(Object value) {
try {
_modifyListener.enable = false;
if (value != null && !Date.class.isAssignableFrom(value.getClass())) {
EJMessage message = EJMessageFactory.getInstance().createMessage(EJFrameworkMessage.INVALID_DATA_TYPE_FOR_ITEM, _item.getName(), Date.class.getName(), value.getClass().getName());
throw new IllegalArgumentException(message.getMessage());
}
_baseValue = value;
if (_displayValueAsLabel) {
if (controlState(_valueLabel)) {
_valueLabel.setText(value != null ? _dateFormat.format(value) : "");
}
} else {
if (controlState(_textField)) {
_textField.setText(value != null ? _dateFormat.format(value) : "");
setMandatoryBorder(_mandatory);
}
}
} finally {
_modifyListener.enable = true;
}
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTImageItemRenderer method setValue.
@Override
public void setValue(Object value) {
_baseValue = value;
if (_currentImage != null && !_currentImage.isDisposed()) {
_currentImage.dispose();
_currentImage = null;
}
if (_labelField != null && controlState(_labelField)) {
if (value == null) {
_labelField.setImage(_defaultImage);
} else {
if (value instanceof String) {
URL resource = EJRWTImageRetriever.class.getClassLoader().getResource((String) value);
if (resource != null) {
_currentImage = ImageDescriptor.createFromURL(resource).createImage();
} else {
try {
_currentImage = ImageDescriptor.createFromURL((new URL((String) value))).createImage();
} catch (MalformedURLException e) {
EJMessage message = EJMessageFactory.getInstance().createMessage(EJFrameworkMessage.INVALID_DATA_TYPE_FOR_ITEM, _item.getName(), "String should follow URL Spec or Need to be In Classpath", (String) value);
throw new IllegalArgumentException(message.getMessage());
}
}
} else if (value instanceof URL) {
_currentImage = ImageDescriptor.createFromURL((URL) value).createImage();
} else if (value instanceof byte[]) {
_currentImage = new Image(Display.getDefault(), new ByteArrayInputStream((byte[]) value));
} else {
EJMessage message = EJMessageFactory.getInstance().createMessage(EJFrameworkMessage.INVALID_DATA_TYPE_FOR_ITEM, _item.getName(), "URL or byte[] ", value.getClass().getName());
throw new IllegalArgumentException(message.getMessage());
}
_labelField.setImage(_currentImage);
}
}
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTNumberItemRenderer method setValue.
@Override
public void setValue(Object value) {
try {
_modifyListener.enable = false;
if (value != null && !Number.class.isAssignableFrom(value.getClass())) {
EJMessage message = EJMessageFactory.getInstance().createMessage(EJFrameworkMessage.INVALID_DATA_TYPE_FOR_ITEM, _item.getName(), Number.class.getName(), value.getClass().getName());
throw new IllegalArgumentException(message.getMessage());
}
_baseValue = value;
if (_displayValueAsLabel) {
if (controlState(_valueLabel)) {
_valueLabel.setText(value != null ? _decimalFormatter.format(value) : "");
}
} 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 ? _decimalFormatter.format(value) : "");
setMandatoryBorder(_mandatory);
}
}
} finally {
_modifyListener.enable = true;
}
}
Aggregations