use of org.entirej.applicationframework.rwt.renderers.form.EJDrawerFolder.DrawerTab in project rap by entirej.
the class EJRWTFormRenderer method createDrawerCanvas.
private void createDrawerCanvas(Composite parent, final EJCanvasProperties canvasProperties, final EJCanvasController canvasController) {
int style = SWT.NONE;
final String name = canvasProperties.getName();
final EJRWTTrayPane trayPane = new EJRWTTrayPane(parent);
trayPane.setLayoutData(createCanvasGridData(canvasProperties));
EJ_RWT.setTestId(trayPane, _form.getProperties().getName() + "." + canvasProperties.getName());
parent = trayPane;
EJDrawerFolder folder = null;
final EJDrawerFolder tabFolder = new EJDrawerFolder(this, canvasController, parent, style) {
@Override
protected void selection(String page) {
canvasController.drawerPageChanged(name, page);
EJ_RWT.setAttribute(getFolder(), "ej-item-selection", page);
}
};
// tabFolder.setDefaultWidth(canvasProperties.getWidth());
tabFolder.setPosition(canvasProperties.getDrawerPosition());
tabFolder.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
trayPane.initBase(tabFolder.getFolder());
folder = tabFolder;
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.TAB;
}
};
_canvases.put(canvasProperties.getName(), canvasHandler);
if (!canvasProperties.getCloseableMessagePane()) {
canvasHandler.setCanvasMessages(Collections.<EJMessage>emptyList());
}
_drawerFolders.put(name, folder);
folder.getFolder().setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
Collection<EJDrawerPageProperties> allTabPageProperties = canvasProperties.getDrawerPageContainer().getAllDrawerPageProperties();
int index = 0;
for (EJDrawerPageProperties page : allTabPageProperties) {
DrawerTab tab = folder.newTab(page);
if (page.isVisible()) {
tab.create(index == 0);
}
tab.setIndex(index);
index++;
folder.put(page.getName(), tab);
}
if (_drawerFoldersCache.containsKey(name)) {
folder.showPage(_drawerFoldersCache.get(name));
_drawerFoldersCache.remove(name);
}
_canvasesIds.add(name);
}
Aggregations