Search in sources :

Example 6 with EJInternalBlock

use of org.entirej.framework.core.internal.EJInternalBlock 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)

Example 7 with EJInternalBlock

use of org.entirej.framework.core.internal.EJInternalBlock in project rap by entirej.

the class EJRWTFormRenderer method createSplitCanvas.

private void createSplitCanvas(Composite parent, final EJCanvasProperties canvasProperties, EJCanvasController canvasController) {
    final EJRWTTrayPane trayPane = new EJRWTTrayPane(parent);
    EJ_RWT.setTestId(trayPane, _form.getProperties().getName() + "." + canvasProperties.getName());
    trayPane.setLayoutData(createCanvasGridData(canvasProperties));
    parent = trayPane;
    SashForm layoutBody = new SashForm(parent, canvasProperties.getSplitOrientation() == EJCanvasSplitOrientation.HORIZONTAL ? SWT.HORIZONTAL : SWT.VERTICAL);
    trayPane.initBase(layoutBody);
    layoutBody.setLayoutData(createCanvasGridData(canvasProperties));
    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.SPLIT;
        }
    };
    _canvases.put(canvasProperties.getName(), canvasHandler);
    if (!canvasProperties.getCloseableMessagePane()) {
        canvasHandler.setCanvasMessages(Collections.<EJMessage>emptyList());
    }
    layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
    if (canvasProperties.getType() == EJCanvasType.SPLIT) {
        List<EJCanvasProperties> items = new ArrayList<EJCanvasProperties>(canvasProperties.getSplitCanvasContainer().getAllCanvasProperties());
        int[] weights = new int[items.size()];
        for (EJCanvasProperties containedCanvas : items) {
            if (containedCanvas.getType() == EJCanvasType.BLOCK && containedCanvas.getBlockProperties() != null && containedCanvas.getBlockProperties().getMainScreenProperties() != null) {
                weights[items.indexOf(containedCanvas)] = canvasProperties.getSplitOrientation() == EJCanvasSplitOrientation.HORIZONTAL ? containedCanvas.getBlockProperties().getMainScreenProperties().getWidth() + 1 : containedCanvas.getBlockProperties().getMainScreenProperties().getHeight() + 1;
                EJCoreMainScreenProperties mainScreenProperties = (EJCoreMainScreenProperties) containedCanvas.getBlockProperties().getMainScreenProperties();
                mainScreenProperties.setExpandHorizontally(true);
                mainScreenProperties.setExpandVertically(true);
            } else {
                weights[items.indexOf(containedCanvas)] = canvasProperties.getSplitOrientation() == EJCanvasSplitOrientation.HORIZONTAL ? containedCanvas.getWidth() + 1 : containedCanvas.getHeight() + 1;
                EJCoreCanvasProperties coreCanvasProperties = (EJCoreCanvasProperties) containedCanvas;
                coreCanvasProperties.setExpandHorizontally(true);
                coreCanvasProperties.setExpandVertically(true);
            }
            switch(containedCanvas.getType()) {
                case BLOCK:
                case GROUP:
                    createGroupCanvas(layoutBody, containedCanvas, canvasController);
                    break;
                case FORM:
                    createFormCanvas(layoutBody, containedCanvas, canvasController);
                    break;
                case SEPARATOR:
                    createSeparatorCanvas(layoutBody, containedCanvas);
                    break;
                case SPLIT:
                    createSplitCanvas(layoutBody, containedCanvas, canvasController);
                    break;
                case STACKED:
                    createStackedCanvas(layoutBody, containedCanvas, canvasController);
                    break;
                case TAB:
                    createTabCanvas(layoutBody, containedCanvas, canvasController);
                    break;
                case DRAWER:
                    createDrawerCanvas(layoutBody, containedCanvas, canvasController);
                    break;
                case POPUP:
                    throw new AssertionError();
            }
        }
        layoutBody.setWeights(weights);
    }
}
Also used : EJCoreMainScreenProperties(org.entirej.framework.core.properties.EJCoreMainScreenProperties) EJInternalBlock(org.entirej.framework.core.internal.EJInternalBlock) ArrayList(java.util.ArrayList) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties) EJCoreCanvasProperties(org.entirej.framework.core.properties.EJCoreCanvasProperties) SashForm(org.eclipse.swt.custom.SashForm) TrayLocation(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation) Collection(java.util.Collection) EJRWTTrayPane(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane)

Aggregations

Collection (java.util.Collection)7 EJInternalBlock (org.entirej.framework.core.internal.EJInternalBlock)7 TrayLocation (org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation)6 EJRWTTrayPane (org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane)6 EJCanvasProperties (org.entirej.framework.core.properties.interfaces.EJCanvasProperties)4 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 Point (org.eclipse.swt.graphics.Point)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 GridData (org.eclipse.swt.layout.GridData)2 EJRWTScrolledComposite (org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite)2 ArrayList (java.util.ArrayList)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 SashForm (org.eclipse.swt.custom.SashForm)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1