Search in sources :

Example 1 with DrawerTab

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);
}
Also used : DrawerTab(org.entirej.applicationframework.rwt.renderers.form.EJDrawerFolder.DrawerTab) EJInternalBlock(org.entirej.framework.core.internal.EJInternalBlock) Point(org.eclipse.swt.graphics.Point) TrayLocation(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation) GridData(org.eclipse.swt.layout.GridData) Collection(java.util.Collection) EJRWTTrayPane(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane) EJDrawerPageProperties(org.entirej.framework.core.properties.interfaces.EJDrawerPageProperties)

Aggregations

Collection (java.util.Collection)1 Point (org.eclipse.swt.graphics.Point)1 GridData (org.eclipse.swt.layout.GridData)1 TrayLocation (org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation)1 EJRWTTrayPane (org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane)1 DrawerTab (org.entirej.applicationframework.rwt.renderers.form.EJDrawerFolder.DrawerTab)1 EJInternalBlock (org.entirej.framework.core.internal.EJInternalBlock)1 EJDrawerPageProperties (org.entirej.framework.core.properties.interfaces.EJDrawerPageProperties)1