Search in sources :

Example 1 with EJCanvasProperties

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

the class EJRWTCanvasRetriever method addCanvasesFromContainer.

private static void addCanvasesFromContainer(EJCoreFormProperties formProperties, EJCanvasPropertiesContainer container, ArrayList<EJCanvasProperties> canvasList) {
    Iterator<EJCanvasProperties> allCanvases = container.getAllCanvasProperties().iterator();
    while (allCanvases.hasNext()) {
        EJCanvasProperties canvas = allCanvases.next();
        canvasList.add(canvas);
        if (canvas.getType() == EJCanvasType.POPUP) {
            addCanvasesFromContainer(formProperties, canvas.getPopupCanvasContainer(), canvasList);
        } else if (canvas.getType() == EJCanvasType.TAB) {
            Iterator<EJTabPageProperties> allTabPages = canvas.getTabPageContainer().getAllTabPageProperties().iterator();
            while (allTabPages.hasNext()) {
                addCanvasesFromContainer(formProperties, allTabPages.next().getContainedCanvases(), canvasList);
            }
        } else if (canvas.getType() == EJCanvasType.DRAWER) {
            Iterator<EJDrawerPageProperties> allTabPages = canvas.getDrawerPageContainer().getAllDrawerPageProperties().iterator();
            while (allTabPages.hasNext()) {
                addCanvasesFromContainer(formProperties, allTabPages.next().getContainedCanvases(), canvasList);
            }
        } else if (canvas.getType() == EJCanvasType.STACKED) {
            Iterator<EJStackedPageProperties> allStackedPages = canvas.getStackedPageContainer().getAllStackedPageProperties().iterator();
            while (allStackedPages.hasNext()) {
                addCanvasesFromContainer(formProperties, allStackedPages.next().getContainedCanvases(), canvasList);
            }
        } else if (canvas.getType() == EJCanvasType.GROUP) {
            addCanvasesFromContainer(formProperties, canvas.getGroupCanvasContainer(), canvasList);
        } else if (canvas.getType() == EJCanvasType.SPLIT) {
            addCanvasesFromContainer(formProperties, canvas.getSplitCanvasContainer(), canvasList);
        }
    }
}
Also used : Iterator(java.util.Iterator) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties) EJDrawerPageProperties(org.entirej.framework.core.properties.interfaces.EJDrawerPageProperties)

Example 2 with EJCanvasProperties

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

the class EJRWTCanvasRetriever method canvasExists.

/**
 * Checks to see if there is already a canvas existing with the given name
 *
 * @param formProperties
 *            The form to check
 * @param name
 *            The name of the canvas to check for
 * @return <code>true</code> if the canvas exists, otherwise
 *         <code>false</code>
 */
public static boolean canvasExists(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 true;
        }
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties)

Example 3 with EJCanvasProperties

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

the class EJRWTCanvasRetriever method retriveAllFormCanvases.

public static Collection<EJCanvasProperties> retriveAllFormCanvases(EJCoreFormProperties formProperties) {
    ArrayList<EJCanvasProperties> formCanvasProperties = new ArrayList<EJCanvasProperties>();
    Collection<EJCanvasProperties> retriveAllCanvases = retriveAllCanvases(formProperties);
    for (EJCanvasProperties canvasProperties : retriveAllCanvases) {
        if (canvasProperties.getType() == EJCanvasType.FORM) {
            formCanvasProperties.add(canvasProperties);
        }
    }
    return formCanvasProperties;
}
Also used : ArrayList(java.util.ArrayList) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties)

Example 4 with EJCanvasProperties

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

the class EJRWTFormRenderer method createGroupCanvas.

private void createGroupCanvas(Composite parent, final EJCanvasProperties canvasProperties, EJCanvasController canvasController) {
    final EJRWTTrayPane trayPane = new EJRWTTrayPane(parent);
    trayPane.setLayoutData(createCanvasGridData(canvasProperties));
    EJ_RWT.setTestId(trayPane, _form.getProperties().getName() + "." + canvasProperties.getName());
    parent = trayPane;
    String frameTitle = canvasProperties.getGroupFrameTitle();
    if (canvasProperties.getDisplayGroupFrame() && frameTitle != null && frameTitle.length() > 0) {
        Group group = new Group(parent, SWT.NONE);
        group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
        group.setLayout(new FillLayout());
        group.setLayoutData(createCanvasGridData(canvasProperties));
        group.setText(frameTitle);
        trayPane.initBase(group);
        parent = group;
    }
    final EJRWTEntireJGridPane groupPane = new EJRWTEntireJGridPane(parent, canvasProperties.getNumCols(), canvasProperties.getDisplayGroupFrame() && (frameTitle == null || frameTitle.length() == 0) ? SWT.BORDER : SWT.NONE);
    groupPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
    if (canvasProperties.getDisplayGroupFrame()) {
    // .cleanLayoutTop();
    } else {
    // groupPane.cleanLayout();
    }
    groupPane.setPaneName(canvasProperties.getName());
    if (!(canvasProperties.getDisplayGroupFrame() && frameTitle != null && frameTitle.length() > 0)) {
        groupPane.setLayoutData(createCanvasGridData(canvasProperties));
        trayPane.initBase(groupPane);
    }
    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) {
            EJRWTAppBlockRenderer blockRenderer = (EJRWTAppBlockRenderer) block.getRendererController().getRenderer();
            if (blockRenderer == null) {
                throw new EJApplicationException(new EJMessage("Block " + block.getProperties().getName() + " has a canvas defined but no renderer. A block cannot be rendererd if no canvas has been defined."));
            }
            blockRenderer.buildGuiComponent(groupPane);
            trayPane.setLayoutData(groupPane.getLayoutData());
        }

        @Override
        public EJCanvasType getType() {
            return EJCanvasType.BLOCK;
        }
    };
    _canvases.put(groupPane.getPaneName(), canvasHandler);
    _canvasesIds.add(groupPane.getPaneName());
    EJInternalBlock block = _blocks.get(groupPane.getPaneName());
    if (block != null) {
        canvasHandler.add(block);
    }
    if (!canvasProperties.getCloseableMessagePane()) {
        canvasHandler.setCanvasMessages(Collections.<EJMessage>emptyList());
    }
    if (canvasProperties.getType() == EJCanvasType.GROUP) {
        for (EJCanvasProperties containedCanvas : canvasProperties.getGroupCanvasContainer().getAllCanvasProperties()) {
            switch(containedCanvas.getType()) {
                case BLOCK:
                case GROUP:
                    createGroupCanvas(groupPane, containedCanvas, canvasController);
                    break;
                case FORM:
                    createFormCanvas(groupPane, containedCanvas, canvasController);
                    break;
                case SEPARATOR:
                    createSeparatorCanvas(groupPane, containedCanvas);
                    break;
                case SPLIT:
                    createSplitCanvas(groupPane, containedCanvas, canvasController);
                    break;
                case STACKED:
                    createStackedCanvas(groupPane, containedCanvas, canvasController);
                    break;
                case TAB:
                    createTabCanvas(groupPane, containedCanvas, canvasController);
                    break;
                case DRAWER:
                    createDrawerCanvas(groupPane, containedCanvas, canvasController);
                    break;
                case POPUP:
                    throw new AssertionError();
            }
        }
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) EJInternalBlock(org.entirej.framework.core.internal.EJInternalBlock) EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties) EJApplicationException(org.entirej.framework.core.EJApplicationException) FillLayout(org.eclipse.swt.layout.FillLayout) EJRWTAppBlockRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppBlockRenderer) EJMessage(org.entirej.framework.core.EJMessage) TrayLocation(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation) Collection(java.util.Collection) EJRWTTrayPane(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)

Example 5 with EJCanvasProperties

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

the class EJRWTFormRenderer method initialiseForm.

@Override
public void initialiseForm(EJInternalForm form) {
    EJParameterChecker.checkNotNull(form, "initialiseForm", "formController");
    _form = form;
    // build all form canvases
    Collection<EJCanvasProperties> allFormCanvases = EJRWTCanvasRetriever.retriveAllFormCanvases(_form.getProperties());
    for (EJCanvasProperties formCanvas : allFormCanvases) {
        if (formCanvas.getReferredFormId() != null && formCanvas.getReferredFormId().length() > 0) {
            final String name = formCanvas.getName();
            _form.addEmbeddedForm(formCanvas.getReferredFormId(), name, null);
        }
    }
}
Also used : EJCanvasProperties(org.entirej.framework.core.properties.interfaces.EJCanvasProperties)

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