Search in sources :

Example 1 with EJCoreLayoutItem

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

the class EJRWTApplicationContainer method createSplitLayout.

private void createSplitLayout(Composite parent, EJCoreLayoutItem.SplitGroup group) {
    SashForm layoutBody = new SashForm(parent, group.getOrientation() == ORIENTATION.HORIZONTAL ? SWT.HORIZONTAL : SWT.VERTICAL);
    layoutBody.setLayoutData(createGridData(group));
    EJ_RWT.setTestId(layoutBody, group.getName());
    List<EJCoreLayoutItem> items = group.getItems();
    if (items.size() > 0) {
        int[] weights = new int[items.size()];
        for (EJCoreLayoutItem item : items) {
            weights[items.indexOf(item)] = item.getHintWidth() + 1;
            switch(item.getType()) {
                case GROUP:
                    createGroupLayout(layoutBody, (LayoutGroup) item);
                    break;
                case SPACE:
                    createSpace(layoutBody, (LayoutSpace) item);
                    break;
                case COMPONENT:
                    createComponent(layoutBody, (LayoutComponent) item);
                    break;
                case SPLIT:
                    createSplitLayout(layoutBody, (SplitGroup) item);
                    break;
                case TAB:
                    createTabLayout(layoutBody, (TabGroup) item);
                    break;
            }
        }
        layoutBody.setWeights(weights);
    } else {
        layoutBody.setLayout(new GridLayout());
        Label compLabel = new Label(layoutBody, SWT.NONE);
        compLabel.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    layoutBody.setBackground(parent.getBackground());
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) EJCoreLayoutItem(org.entirej.framework.core.properties.EJCoreLayoutItem) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 2 with EJCoreLayoutItem

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

the class EJRWTApplicationContainer method createTabLayout.

private void createTabLayout(Composite parent, final EJCoreLayoutItem.TabGroup group) {
    final CTabFolder layoutBody = new CTabFolder(parent, SWT.BORDER | (group.getOrientation() == TabGroup.ORIENTATION.TOP ? SWT.TOP : SWT.BOTTOM));
    final EJAppTabFolder appTabFolder = new EJAppTabFolder(this, layoutBody);
    _tabFolders.put(group.getName(), appTabFolder);
    EJ_RWT.setTestId(layoutBody, group.getName());
    layoutBody.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            EJApplicationActionProcessor applicationActionProcessor = _applicationManager.getApplicationActionProcessor();
            if (applicationActionProcessor != null) {
                CTabItem selection = layoutBody.getSelection();
                if (selection == null) {
                    return;
                }
                try {
                    String pageName = (String) selection.getData("TAB_KEY");
                    applicationActionProcessor.preShowTabPage(_applicationManager.getFrameworkManager(), group.getName(), pageName);
                } catch (EJActionProcessorException e1) {
                    if (appTabFolder.getLastSelection() != null) {
                        appTabFolder.showPage(appTabFolder.getLastSelection());
                    }
                    if (e1.getFrameworkMessage() != null)
                        _applicationManager.handleMessage(e1.getFrameworkMessage());
                    return;
                }
                try {
                    String pageName = (String) selection.getData("TAB_KEY");
                    appTabFolder.setLastSelection(pageName);
                    applicationActionProcessor.tabPageChanged(_applicationManager.getFrameworkManager(), group.getName(), pageName);
                } catch (EJActionProcessorException e1) {
                    e1.printStackTrace();
                }
            }
        }
    });
    layoutBody.setLayoutData(createGridData(group));
    List<EJCoreLayoutItem> items = group.getItems();
    for (EJCoreLayoutItem item : items) {
        CTabItem tabItem = new CTabItem(layoutBody, SWT.NONE);
        appTabFolder.put(item.getName(), tabItem);
        Composite composite = new Composite(layoutBody, SWT.NO_FOCUS);
        composite.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
        composite.setData("TAB_ITEM", tabItem);
        composite.setData("TAB_KEY", item.getName());
        EJ_RWT.setTestId(tabItem, group.getName() + "." + item.getName());
        tabItem.setData("TAB_KEY", item.getName());
        composite.setLayout(new GridLayout());
        tabItem.setControl(composite);
        tabItem.setText(item.getTitle() != null ? item.getTitle() : item.getName());
        switch(item.getType()) {
            case GROUP:
                createGroupLayout(composite, (LayoutGroup) item);
                break;
            case SPACE:
                createSpace(composite, (LayoutSpace) item);
                break;
            case COMPONENT:
                createComponent(composite, (LayoutComponent) item);
                break;
            case SPLIT:
                createSplitLayout(composite, (SplitGroup) item);
                break;
            case TAB:
                createTabLayout(composite, (TabGroup) item);
                break;
        }
    }
    if (items.size() > 0) {
        layoutBody.setSelection(0);
    }
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException) CTabItem(org.eclipse.swt.custom.CTabItem) GridLayout(org.eclipse.swt.layout.GridLayout) EJApplicationActionProcessor(org.entirej.framework.core.actionprocessor.interfaces.EJApplicationActionProcessor) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EJCoreLayoutItem(org.entirej.framework.core.properties.EJCoreLayoutItem)

Example 3 with EJCoreLayoutItem

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

the class EJRWTApplicationContainer method buildApplicationContainer.

protected void buildApplicationContainer() {
    GridLayout gridLayout = new GridLayout(_layoutContainer.getColumns(), false);
    _mainPane.setLayout(gridLayout);
    List<EJCoreLayoutItem> items = _layoutContainer.getItems();
    for (EJCoreLayoutItem item : items) {
        switch(item.getType()) {
            case GROUP:
                createGroupLayout(_mainPane, (LayoutGroup) item);
                break;
            case SPACE:
                createSpace(_mainPane, (LayoutSpace) item);
                break;
            case COMPONENT:
                createComponent(_mainPane, (LayoutComponent) item);
                break;
            case SPLIT:
                createSplitLayout(_mainPane, (SplitGroup) item);
                break;
            case TAB:
                createTabLayout(_mainPane, (TabGroup) item);
                break;
        }
    }
    _mainPane.layout();
    if (_formContainer != null) {
        for (EJRWTApplicationComponent applicationComponent : _addedComponents) {
            if (applicationComponent instanceof EJRWTFormSelectedListener) {
                _formContainer.addFormSelectedListener(applicationComponent);
            }
        }
    }
    for (EJRWTSingleFormContainer singleFormContainer : _singleFormContainers) {
        if (singleFormContainer.getForm() != null) {
            fireFormOpened(singleFormContainer.getForm());
        }
    }
}
Also used : EJRWTSingleFormContainer(org.entirej.applicationframework.rwt.application.form.containers.EJRWTSingleFormContainer) GridLayout(org.eclipse.swt.layout.GridLayout) EJCoreLayoutItem(org.entirej.framework.core.properties.EJCoreLayoutItem) EJRWTFormSelectedListener(org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener) EJRWTApplicationComponent(org.entirej.applicationframework.rwt.application.interfaces.EJRWTApplicationComponent)

Example 4 with EJCoreLayoutItem

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

the class EJRWTApplicationContainer method createGroupLayout.

private void createGroupLayout(Composite parent, EJCoreLayoutItem.LayoutGroup group) {
    Composite layoutBody = new Composite(parent, SWT.NO_FOCUS | (group.isBorder() ? SWT.BORDER : SWT.NONE));
    layoutBody.setLayoutData(createGridData(group));
    layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
    EJ_RWT.setTestId(layoutBody, group.getName());
    List<EJCoreLayoutItem> items = group.getItems();
    if (items.size() > 0) {
        GridLayout gridLayout = new GridLayout(group.getColumns(), false);
        if (group.isHideMargin()) {
            gridLayout.marginHeight = 0;
            gridLayout.marginWidth = 0;
        }
        layoutBody.setLayout(gridLayout);
        for (EJCoreLayoutItem item : items) {
            switch(item.getType()) {
                case GROUP:
                    createGroupLayout(layoutBody, (LayoutGroup) item);
                    break;
                case SPACE:
                    createSpace(layoutBody, (LayoutSpace) item);
                    break;
                case COMPONENT:
                    createComponent(layoutBody, (LayoutComponent) item);
                    break;
                case SPLIT:
                    createSplitLayout(layoutBody, (SplitGroup) item);
                    break;
                case TAB:
                    createTabLayout(layoutBody, (TabGroup) item);
                    break;
            }
        }
    } else {
        layoutBody.setLayout(new GridLayout());
        Label compLabel = new Label(layoutBody, SWT.NONE);
        compLabel.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJCoreLayoutItem(org.entirej.framework.core.properties.EJCoreLayoutItem) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Aggregations

GridLayout (org.eclipse.swt.layout.GridLayout)4 EJCoreLayoutItem (org.entirej.framework.core.properties.EJCoreLayoutItem)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 EJRWTScrolledComposite (org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite)2 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 SashForm (org.eclipse.swt.custom.SashForm)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 EJRWTSingleFormContainer (org.entirej.applicationframework.rwt.application.form.containers.EJRWTSingleFormContainer)1 EJRWTApplicationComponent (org.entirej.applicationframework.rwt.application.interfaces.EJRWTApplicationComponent)1 EJRWTFormSelectedListener (org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener)1 EJActionProcessorException (org.entirej.framework.core.EJActionProcessorException)1 EJApplicationActionProcessor (org.entirej.framework.core.actionprocessor.interfaces.EJApplicationActionProcessor)1