use of org.entirej.framework.core.properties.interfaces.EJStackedPageProperties in project rap by entirej.
the class EJRWTFormRenderer method createStackedCanvas.
private void createStackedCanvas(Composite parent, final EJCanvasProperties canvasProperties, final EJCanvasController canvasController) {
final String name = canvasProperties.getName();
final EJRWTTrayPane trayPane = new EJRWTTrayPane(parent);
trayPane.setLayoutData(createCanvasGridData(canvasProperties));
parent = trayPane;
final EJRWTEntireJStackedPane stackedPane = new EJRWTEntireJStackedPane(parent);
trayPane.initBase(stackedPane);
stackedPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
stackedPane.setLayoutData(createCanvasGridData(canvasProperties));
_stackedPanes.put(name, stackedPane);
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) {
}
@Override
public EJCanvasType getType() {
return EJCanvasType.STACKED;
}
};
_canvases.put(canvasProperties.getName(), canvasHandler);
if (!canvasProperties.getCloseableMessagePane()) {
canvasHandler.setCanvasMessages(Collections.<EJMessage>emptyList());
}
for (final EJStackedPageProperties page : canvasProperties.getStackedPageContainer().getAllStackedPageProperties()) {
stackedPane.add(page.getName(), new EJRWTEntireJStackedPane.StackedPage() {
Control control;
@Override
public String getKey() {
return page.getName();
}
@Override
public Control getControl() {
if (control != null && !control.isDisposed()) {
return control;
}
final ScrolledComposite scrollComposite = new EJRWTScrolledComposite(stackedPane, SWT.V_SCROLL | SWT.H_SCROLL);
control = scrollComposite;
final EJRWTEntireJGridPane pagePane = new EJRWTEntireJGridPane(scrollComposite, page.getNumCols());
pagePane.cleanLayout();
int width = 0;
int height = 0;
for (EJCanvasProperties properties : page.getContainedCanvases().getAllCanvasProperties()) {
createCanvas(pagePane, properties, canvasController);
int width2 = properties.getWidth();
int height2 = properties.getHeight();
if (properties.getBlockProperties() != null) {
width2 = properties.getBlockProperties().getMainScreenProperties().getWidth();
height2 = properties.getBlockProperties().getMainScreenProperties().getHeight();
}
if (width < width2) {
width = width2;
}
if (height < height2) {
height = height2;
}
}
scrollComposite.setContent(pagePane);
scrollComposite.setMinSize(width, height);
scrollComposite.setExpandHorizontal(true);
scrollComposite.setExpandVertical(true);
scrollComposite.setContent(pagePane);
stackedPane.layout();
return control;
}
});
}
if (canvasProperties.getInitialStackedPageName() != null) {
stackedPane.showPane(canvasProperties.getInitialStackedPageName());
}
if (_stackedPanesCache.containsKey(name)) {
stackedPane.showPane(_stackedPanesCache.get(name));
_stackedPanesCache.remove(name);
}
_canvasesIds.add(name);
}
Aggregations