use of org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppBlockRenderer 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