use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTTreeRecordBlockRenderer method enterUpdate.
@Override
public void enterUpdate(EJDataRecord recordToUpdate) {
if (_block.getUpdateScreenRenderer() == null) {
EJMessage message = new EJMessage("Please define an Update Screen Renderer for this form before an update operation can be performed.");
_block.getForm().getMessenger().handleMessage(message);
} else {
_block.getUpdateScreenRenderer().open(recordToUpdate);
}
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTTreeRecordBlockRenderer method enterQuery.
@Override
public void enterQuery(EJDataRecord queryRecord) {
if (_block.getQueryScreenRenderer() == null) {
EJMessage message = new EJMessage("Please define a Query Screen Renderer for this form before a query operation can be performed.");
_block.getForm().getMessenger().handleMessage(message);
} else {
_block.getQueryScreenRenderer().open(queryRecord);
}
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTStackedItemRenderer method loadComboBoxValues.
private List<ComboBoxValue> loadComboBoxValues(EJRWTStackedItemRendererConfig.Combo config) {
// Initialise both the field and the values.
List<ComboBoxValue> _comboValues = new ArrayList<ComboBoxValue>();
String lovDefName = config.getLovDefinition();
if (lovDefName == null || lovDefName.trim().length() == 0) {
return _comboValues;
}
String defName = lovDefName;
String defItemName = config.getItemName();
if (defItemName == null || defItemName.trim().length() == 0) {
EJMessage message = new EJMessage("No LovDefinition item has been chosen for the ComboBox renderer properties on item: " + _itemProperties.getName());
_item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
return _comboValues;
}
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 _comboValues;
}
EJLovController lovController = _item.getForm().getLovController(defName);
if (lovController == null) {
return _comboValues;
}
try {
lovController.executeQuery(new EJItemLovController(_item.getBlock().getBlockController().getFormController(), _item, ((EJCoreItemProperties) _itemProperties).getLovMappingPropertiesOnUpdate()));
if (!_item.getProperties().isMandatory()) {
ComboBoxValue emptyValue = new ComboBoxValue(null, defItemName, config);
_comboValues.add(emptyValue);
}
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 new ArrayList<ComboBoxValue>();
}
ComboBoxValue comboValue = new ComboBoxValue(ejDataRecord, defItemName, config);
_comboValues.add(comboValue);
}
} catch (Exception e) {
_item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleException(e, true);
}
return _comboValues;
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTStackedItemRenderer method setStackValue.
private void setStackValue() {
Object value = _baseValue.getValue();
try {
_modifyListener.enable = false;
EJRWTStackedItemRendererType[] values = EJRWTStackedItemRendererType.values();
for (EJRWTStackedItemRendererType type : values) {
Control control = stackedPane.getControl(type.name());
if (control != null && controlState(control)) {
if (control instanceof Label) {
((Label) control).setText("");
} else if (control instanceof Text) {
((Text) control).setText("");
} else if (control instanceof Combo) {
((Combo) control).setText("");
} else if (control instanceof Button) {
EJRWTStackedItemRendererConfig config = _baseValue.getConfig();
((Button) control).setText(config.getLabel() == null ? (_item.getProperties().getLabel() == null ? "" : _item.getProperties().getLabel()) : config.getLabel());
((Button) control).setToolTipText(config.getTooltip() == null ? (_item.getProperties().getHint() == null ? "" : _item.getProperties().getHint()) : config.getTooltip());
if (config instanceof EJRWTStackedItemRendererConfig.Button) {
EJRWTStackedItemRendererConfig.Button button = (EJRWTStackedItemRendererConfig.Button) config;
if (button.getImage() != null && button.getImage().trim().length() > 0) {
((Button) control).setImage(EJRWTImageRetriever.get(button.getImage()));
}
}
}
// check_box/combo
}
}
if (value != null) {
switch(_baseValue.getConfig().getType()) {
case LABEL:
{
Label control = (Label) stackedPane.getControl(_baseValue.getConfig().getType().name());
control.setText(value.toString());
break;
}
case TEXT:
case TEXT_AREA:
{
Text control = (Text) stackedPane.getControl(_baseValue.getConfig().getType().name());
control.setText(value.toString());
break;
}
case COMBO:
{
Combo control = (Combo) stackedPane.getControl(_baseValue.getConfig().getType().name());
List<ComboBoxValue> loadComboBoxValues = (List<ComboBoxValue>) ((ComboViewer) control.getData("VIEW")).getInput();
ComboBoxValue boxValue = null;
for (ComboBoxValue val : loadComboBoxValues) {
if (val.getItemValue() == null && value == null) {
boxValue = val;
break;
}
if (val.getItemValue() == null) {
continue;
}
if (!val.getItemValue().getClass().isAssignableFrom(value.getClass())) {
EJMessage message = EJMessageFactory.getInstance().createMessage(EJFrameworkMessage.INVALID_DATA_TYPE_FOR_ITEM, _item.getName(), val.getItemValue().getClass().getName(), value.getClass().getName());
throw new IllegalArgumentException(message.getMessage());
}
if (val.getItemValue().equals(value)) {
boxValue = val;
break;
}
}
if (boxValue != null) {
((ComboViewer) control.getData("VIEW")).setSelection(new StructuredSelection(boxValue));
}
break;
}
case NUMBER:
{
EJRWTStackedItemRendererConfig.Number config = (EJRWTStackedItemRendererConfig.Number) _baseValue.getConfig();
_numberType = getNumberType(_baseValue);
_decimalFormatter = createFormatter(_numberType, config.getFormat());
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());
}
Text control = (Text) stackedPane.getControl(_baseValue.getConfig().getType().name());
control.setText(_decimalFormatter.format(value));
break;
}
case DATE:
{
createDateFormat();
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());
}
Text control = (Text) stackedPane.getControl(_baseValue.getConfig().getType().name());
control.setText(_dateFormat.format(value));
control.setMessage(_dateFormat.toFormatString());
break;
}
case SPACER:
{
setLabel("");
break;
}
case CHECKBOX:
{
setLabel("");
Control control = stackedPane.getControl(_baseValue.getConfig().getType().name());
EJRWTStackedItemRendererConfig.CheckBox config = ((EJRWTStackedItemRendererConfig.CheckBox) _baseValue.getConfig());
((Button) control).setSelection(config.getCheckBoxCheckedValue() == value || (value != null && value.equals(config.getCheckBoxCheckedValue())));
break;
}
case BUTTON:
{
setLabel("");
break;
}
default:
break;
}
} else {
switch(_baseValue.getConfig().getType()) {
case DATE:
createDateFormat();
break;
case NUMBER:
_numberType = getNumberType(_baseValue);
_decimalFormatter = createFormatter(_numberType, ((EJRWTStackedItemRendererConfig.Number) _baseValue.getConfig()).getFormat());
break;
}
}
} finally {
_modifyListener.enable = true;
}
}
use of org.entirej.framework.core.EJMessage in project rap by entirej.
the class EJRWTFormRenderer method createGroupCanvas.
private void createGroupCanvas(Composite parent, final EJCanvasProperties canvasProperties, EJCanvasController canvasController) {
final EJRWTTrayPane trayPane = new EJRWTTrayPane(parent);
trayPane.setLayoutData(createCanvasGridData(canvasProperties));
EJ_RWT.setTestId(trayPane, _form.getProperties().getName() + "." + canvasProperties.getName());
parent = trayPane;
String frameTitle = canvasProperties.getGroupFrameTitle();
if (canvasProperties.getDisplayGroupFrame() && frameTitle != null && frameTitle.length() > 0) {
Group group = new Group(parent, SWT.NONE);
group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
group.setLayout(new FillLayout());
group.setLayoutData(createCanvasGridData(canvasProperties));
group.setText(frameTitle);
trayPane.initBase(group);
parent = group;
}
final EJRWTEntireJGridPane groupPane = new EJRWTEntireJGridPane(parent, canvasProperties.getNumCols(), canvasProperties.getDisplayGroupFrame() && (frameTitle == null || frameTitle.length() == 0) ? SWT.BORDER : SWT.NONE);
groupPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
if (canvasProperties.getDisplayGroupFrame()) {
// .cleanLayoutTop();
} else {
// groupPane.cleanLayout();
}
groupPane.setPaneName(canvasProperties.getName());
if (!(canvasProperties.getDisplayGroupFrame() && frameTitle != null && frameTitle.length() > 0)) {
groupPane.setLayoutData(createCanvasGridData(canvasProperties));
trayPane.initBase(groupPane);
}
CanvasHandler canvasHandler = new CanvasHandler() {
private Collection<EJMessage> msgs;
@Override
public void clearCanvasMessages() {
this.msgs = null;
if (trayPane != null && !trayPane.isDisposed()) {
trayPane.closeTray();
}
}
@Override
public void setCanvasMessages(Collection<EJMessage> messages) {
this.msgs = messages;
if (trayPane != null && !trayPane.isDisposed()) {
if (trayPane.getTray() != null) {
trayPane.closeTray();
}
{
MessageTray messageTray = new MessageTray(canvasProperties.getCloseableMessagePane()) {
@Override
void close() {
if (trayPane != null && !trayPane.isDisposed()) {
trayPane.closeTray();
}
}
};
messageTray.setMessages(msgs);
TrayLocation location = TrayLocation.RIGHT;
switch(canvasProperties.getMessagePosition()) {
case BOTTOM:
location = TrayLocation.BOTTOM;
break;
case LEFT:
location = TrayLocation.LEFT;
break;
case RIGHT:
location = TrayLocation.RIGHT;
break;
case TOP:
location = TrayLocation.TOP;
break;
default:
break;
}
trayPane.openTray(location, messageTray, canvasProperties.getMessagePaneSize());
}
}
}
@Override
public void add(EJInternalBlock block) {
EJRWTAppBlockRenderer blockRenderer = (EJRWTAppBlockRenderer) block.getRendererController().getRenderer();
if (blockRenderer == null) {
throw new EJApplicationException(new EJMessage("Block " + block.getProperties().getName() + " has a canvas defined but no renderer. A block cannot be rendererd if no canvas has been defined."));
}
blockRenderer.buildGuiComponent(groupPane);
trayPane.setLayoutData(groupPane.getLayoutData());
}
@Override
public EJCanvasType getType() {
return EJCanvasType.BLOCK;
}
};
_canvases.put(groupPane.getPaneName(), canvasHandler);
_canvasesIds.add(groupPane.getPaneName());
EJInternalBlock block = _blocks.get(groupPane.getPaneName());
if (block != null) {
canvasHandler.add(block);
}
if (!canvasProperties.getCloseableMessagePane()) {
canvasHandler.setCanvasMessages(Collections.<EJMessage>emptyList());
}
if (canvasProperties.getType() == EJCanvasType.GROUP) {
for (EJCanvasProperties containedCanvas : canvasProperties.getGroupCanvasContainer().getAllCanvasProperties()) {
switch(containedCanvas.getType()) {
case BLOCK:
case GROUP:
createGroupCanvas(groupPane, containedCanvas, canvasController);
break;
case FORM:
createFormCanvas(groupPane, containedCanvas, canvasController);
break;
case SEPARATOR:
createSeparatorCanvas(groupPane, containedCanvas);
break;
case SPLIT:
createSplitCanvas(groupPane, containedCanvas, canvasController);
break;
case STACKED:
createStackedCanvas(groupPane, containedCanvas, canvasController);
break;
case TAB:
createTabCanvas(groupPane, containedCanvas, canvasController);
break;
case DRAWER:
createDrawerCanvas(groupPane, containedCanvas, canvasController);
break;
case POPUP:
throw new AssertionError();
}
}
}
}
Aggregations