Search in sources :

Example 6 with EJCanvasProperties

use of org.entirej.framework.core.properties.interfaces.EJCanvasProperties in project rap by entirej.

the class EJRWTFormRenderer method setupGui.

private void setupGui(final Composite parent) {
    EJFormProperties formProperties = _form.getProperties();
    EJCanvasController canvasController = _form.getCanvasController();
    // Now loop through all the forms blocks and create controllers for them
    for (EJInternalBlock block : _form.getAllBlocks()) {
        String canvasName = block.getProperties().getCanvasName();
        // displayed.
        if (canvasName == null || canvasName.trim().length() == 0) {
            continue;
        }
        _blocks.put(canvasName, block);
    }
    _mainPane = new EJRWTEntireJGridPane(parent, formProperties.getNumCols());
    _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
    for (EJCanvasProperties canvasProperties : formProperties.getCanvasContainer().getAllCanvasProperties()) {
        createCanvas(_mainPane, canvasProperties, canvasController);
    }
    _mainPane.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent event) {
            Collection<CanvasHandler> values = _canvases.values();
            for (CanvasHandler canvasHandler : values) {
                if (canvasHandler instanceof PopupCanvasHandler) {
                    PopupCanvasHandler handler = (PopupCanvasHandler) canvasHandler;
                    if (handler._popupDialog != null && handler._popupDialog.getShell() != null) {
                        handler._popupDialog.getShell().dispose();
                    }
                }
            }
        }
    });
}
Also used : EJFormProperties(org.entirej.framework.core.properties.interfaces.EJFormProperties) DisposeListener(org.eclipse.swt.events.DisposeListener) EJCanvasController(org.entirej.framework.core.data.controllers.EJCanvasController) EJInternalBlock(org.entirej.framework.core.internal.EJInternalBlock) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties) Collection(java.util.Collection) DisposeEvent(org.eclipse.swt.events.DisposeEvent) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Example 7 with EJCanvasProperties

use of org.entirej.framework.core.properties.interfaces.EJCanvasProperties in project rap by entirej.

the class EJRWTCanvasRetriever method getCanvas.

public static EJCanvasProperties getCanvas(EJCoreFormProperties formProperties, String name) {
    ArrayList<EJCanvasProperties> canvasList = new ArrayList<EJCanvasProperties>();
    addCanvasesFromContainer(formProperties, formProperties.getCanvasContainer(), canvasList);
    for (EJCanvasProperties canvas : canvasList) {
        if (canvas.getName().equals(name)) {
            return canvas;
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties)

Example 8 with EJCanvasProperties

use of org.entirej.framework.core.properties.interfaces.EJCanvasProperties 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);
}
Also used : EJInternalBlock(org.entirej.framework.core.internal.EJInternalBlock) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties) EJRWTEntireJStackedPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJStackedPane) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) EJStackedPageProperties(org.entirej.framework.core.properties.interfaces.EJStackedPageProperties) Control(org.eclipse.swt.widgets.Control) TrayLocation(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation) Collection(java.util.Collection) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJRWTTrayPane(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Example 9 with EJCanvasProperties

use of org.entirej.framework.core.properties.interfaces.EJCanvasProperties 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

EJCanvasProperties (org.entirej.framework.core.properties.interfaces.EJCanvasProperties)9 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 EJInternalBlock (org.entirej.framework.core.internal.EJInternalBlock)4 TrayLocation (org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation)3 EJRWTTrayPane (org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane)3 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)3 Iterator (java.util.Iterator)1 SashForm (org.eclipse.swt.custom.SashForm)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Control (org.eclipse.swt.widgets.Control)1 Group (org.eclipse.swt.widgets.Group)1 EJRWTEntireJStackedPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJStackedPane)1 EJRWTScrolledComposite (org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite)1 EJRWTAppBlockRenderer (org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppBlockRenderer)1 EJApplicationException (org.entirej.framework.core.EJApplicationException)1 EJMessage (org.entirej.framework.core.EJMessage)1