Search in sources :

Example 1 with EJTabPageProperties

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

the class EJRWTFormRenderer method createTabCanvas.

private void createTabCanvas(Composite parent, final EJCanvasProperties canvasProperties, final EJCanvasController canvasController) {
    int style = SWT.FLAT;
    EJFrameworkExtensionProperties rendererProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
    if (rendererProp != null) {
        boolean displayBorder = rendererProp.getBooleanProperty("DISPLAY_TAB_BORDER", false);
        if (displayBorder) {
            style = SWT.FLAT | SWT.BORDER;
        }
    }
    switch(canvasProperties.getTabPosition()) {
        case BOTTOM:
            style = style | SWT.BOTTOM;
            break;
        case LEFT:
            style = style | SWT.LEFT;
            break;
        case RIGHT:
            style = style | SWT.RIGHT;
            break;
        default:
            style = style | SWT.TOP;
            break;
    }
    final String name = canvasProperties.getName();
    final EJRWTTrayPane trayPane = new EJRWTTrayPane(parent);
    EJ_RWT.setTestId(trayPane, _form.getProperties().getName() + "." + canvasProperties.getName());
    trayPane.setLayoutData(createCanvasGridData(canvasProperties));
    parent = trayPane;
    ITabFolder folder = null;
    CTabFolder cfolder = new CTabFolder(parent, style);
    cfolder.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_FORM);
    final EJTabFolder tabFolder = new EJTabFolder(this, cfolder, canvasController);
    trayPane.initBase(tabFolder.getFolder());
    cfolder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            canvasController.tabPageChanged(name, tabFolder.getActiveKey());
            EJ_RWT.setAttribute(cfolder, "ej-item-selection", tabFolder.getActiveKey());
        }
    });
    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());
    }
    _tabFolders.put(name, folder);
    folder.getFolder().setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    Collection<EJTabPageProperties> allTabPageProperties = canvasProperties.getTabPageContainer().getAllTabPageProperties();
    int index = 0;
    for (EJTabPageProperties page : allTabPageProperties) {
        ITabFolder.ITab tab = folder.newTab(page);
        if (page.isVisible()) {
            tab.create(index == 0);
        }
        tab.setIndex(index);
        index++;
        folder.put(page.getName(), tab);
    }
    if (_tabFoldersCache.containsKey(name)) {
        folder.showPage(_tabFoldersCache.get(name));
        _tabFoldersCache.remove(name);
    }
    _canvasesIds.add(name);
}
Also used : EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) CTabFolder(org.eclipse.swt.custom.CTabFolder) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EJInternalBlock(org.entirej.framework.core.internal.EJInternalBlock) Point(org.eclipse.swt.graphics.Point) EJTabPageProperties(org.entirej.framework.core.properties.interfaces.EJTabPageProperties) TrayLocation(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayDialog.TrayLocation) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Collection(java.util.Collection) EJRWTTrayPane(org.entirej.applicationframework.rwt.application.form.containers.EJRWTTrayPane)

Aggregations

Collection (java.util.Collection)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)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 EJInternalBlock (org.entirej.framework.core.internal.EJInternalBlock)1 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)1 EJTabPageProperties (org.entirej.framework.core.properties.interfaces.EJTabPageProperties)1