Search in sources :

Example 1 with EJRWTFormContainer

use of org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormContainer in project rap by entirej.

the class EJRWTApplicationContainer method buildApplication.

void buildApplication(EJRWTApplicationManager applicationManager, Composite mainWindow, String serviceForm) {
    _applicationManager = applicationManager;
    _mainPane = new Composite(mainWindow, SWT.NO_FOCUS);
    _mainPane.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
    mainWindow.setLayout(new FillLayout());
    if (serviceForm == null)
        buildApplicationContainer();
    else
        buildServiceApplicationContainer(serviceForm);
    if (_formContainer == null) {
        _formContainer = new EJRWTFormContainer() {

            EJRWTAbstractDialog _popupDialog;

            EJRWTFormPopUp _formPopup;

            @Override
            public EJInternalForm switchToForm(String key) {
                // ignore
                return null;
            }

            @Override
            public EJInternalForm switchToForm(EJInternalForm form) {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void removeFormSelectedListener(EJRWTFormSelectedListener selectionListener) {
            // ignore
            }

            @Override
            public void popupFormClosed() {
                if (_formPopup != null) {
                    _formPopup.close();
                    _formPopup = null;
                }
            }

            @Override
            public void openPopupForm(EJPopupFormController popupController) {
                _formPopup = new EJRWTFormPopUp(_applicationManager.getShell(), popupController);
                _formPopup.showForm();
            }

            @Override
            public Collection<EJInternalForm> getAllForms() {
                // ignore
                return Collections.emptyList();
            }

            @Override
            public EJInternalForm getActiveForm() {
                // ignore
                return null;
            }

            @Override
            public boolean containsForm(String formName) {
                // ignore
                return false;
            }

            @Override
            public void closeForm(EJInternalForm form) {
                if (_formPopup != null && _formPopup.getPopupController().getPopupForm().equals(form)) {
                    _formPopup.close();
                    _formPopup = null;
                    return;
                }
                if (_popupDialog != null) {
                    _popupDialog.close();
                    _popupDialog = null;
                }
            }

            @Override
            public void addFormSelectedListener(EJRWTFormSelectedListener selectionListener) {
            // ignore
            }

            @Override
            public EJInternalForm addForm(final EJInternalForm form) {
                final int height = form.getProperties().getFormHeight();
                final int width = form.getProperties().getFormWidth();
                final EJRWTFormRenderer formRenderer = (EJRWTFormRenderer) form.getRenderer();
                _popupDialog = new EJRWTAbstractDialog(_applicationManager.getShell()) {

                    private static final long serialVersionUID = -4685316941898120169L;

                    @Override
                    public void createBody(Composite parent) {
                        parent.setLayout(new FillLayout());
                        final ScrolledComposite scrollComposite = new EJRWTScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
                        formRenderer.createControl(scrollComposite);
                        scrollComposite.setContent(formRenderer.getGuiComponent());
                        scrollComposite.setExpandHorizontal(true);
                        scrollComposite.setExpandVertical(true);
                        scrollComposite.setMinSize(form.getProperties().getFormWidth(), form.getProperties().getFormHeight());
                        formRenderer.gainInitialFocus();
                    }

                    @Override
                    public int open() {
                        return super.open();
                    }

                    private void addExtraButton(Composite parent, String label, int id) {
                        if (label == null || label.length() == 0) {
                            return;
                        }
                        createButton(parent, id, label, false);
                    }

                    @Override
                    public boolean close() {
                        return super.close();
                    }
                };
                _popupDialog.create();
                final EJCoreFormProperties coreFormProperties = form.getProperties();
                _popupDialog.getShell().setData("POPUP - " + coreFormProperties.getName());
                _popupDialog.getShell().setText(coreFormProperties.getTitle() == null ? coreFormProperties.getName() : coreFormProperties.getTitle());
                // add dialog border offsets
                _popupDialog.getShell().setSize(width + 80, height + 100);
                _popupDialog.centreLocation();
                _popupDialog.open();
                _popupDialog.activateDialog();
                return form;
            }

            @Override
            public void updateFormTitle(EJInternalForm form) {
            // TODO Auto-generated method stub
            }
        };
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJRWTFormPopUp(org.entirej.applicationframework.rwt.application.form.containers.EJRWTFormPopUp) FillLayout(org.eclipse.swt.layout.FillLayout) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) EJCoreFormProperties(org.entirej.framework.core.properties.EJCoreFormProperties) EJRWTFormContainer(org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormContainer) EJRWTAbstractDialog(org.entirej.applicationframework.rwt.application.form.containers.EJRWTAbstractDialog) Collection(java.util.Collection) EJRWTFormRenderer(org.entirej.applicationframework.rwt.renderers.form.EJRWTFormRenderer) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJRWTFormSelectedListener(org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener) EJPopupFormController(org.entirej.framework.core.data.controllers.EJPopupFormController)

Example 2 with EJRWTFormContainer

use of org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormContainer in project rap by entirej.

the class EJRWTApplicationContainer method createComponent.

private void createComponent(Composite parent, EJCoreLayoutItem.LayoutComponent component) {
    try {
        EJApplicationComponentRenderer applicationComponentRenderer = EJRendererFactory.getInstance().getApplicationComponentRenderer(component.getRenderer());
        if (applicationComponentRenderer instanceof EJRWTFormContainer) {
            if (_formContainer != null) {
                throw new IllegalStateException("Multiple EJRWTFormContainer setup in layout");
            }
            _formContainer = (EJRWTFormContainer) applicationComponentRenderer;
        }
        if (applicationComponentRenderer instanceof EJRWTApplicationStatusbar) {
            if (_statusbar != null) {
                throw new IllegalStateException("Multiple EJRWTApplicationStatusbar setup in layout");
            }
            _statusbar = (EJRWTApplicationStatusbar) applicationComponentRenderer;
        }
        if (applicationComponentRenderer instanceof EJRWTSingleFormContainer) {
            _singleFormContainers.add((EJRWTSingleFormContainer) applicationComponentRenderer);
        }
        if (applicationComponentRenderer instanceof EJRWTApplicationComponent) {
            _addedComponents.add((EJRWTApplicationComponent) applicationComponentRenderer);
        }
        EJRWTAppComponentRenderer renderer = (EJRWTAppComponentRenderer) applicationComponentRenderer;
        renderer.createContainer(_applicationManager, parent, component.getRendereProperties());
        EJ_RWT.setTestId(renderer.getGuiComponent(), component.getName());
        renderer.getGuiComponent().setLayoutData(createGridData(component));
        return;
    } catch (Exception e) {
        _applicationManager.getApplicationMessenger().handleException(e, true);
    }
    // fail over
    Composite layoutBody = new Composite(parent, SWT.NO_FOCUS | SWT.BORDER);
    layoutBody.setLayoutData(createGridData(component));
    layoutBody.setLayout(new GridLayout());
    Label spaceLabel = new Label(layoutBody, SWT.NONE);
    spaceLabel.setText(String.format("<%s>", component.getRenderer() == null || component.getRenderer().length() == 0 ? "<component>" : component.getRenderer()));
    spaceLabel.setLayoutData(createGridData(component));
    spaceLabel.setLayoutData(new GridData(GridData.FILL_BOTH));
}
Also used : EJRWTSingleFormContainer(org.entirej.applicationframework.rwt.application.form.containers.EJRWTSingleFormContainer) GridLayout(org.eclipse.swt.layout.GridLayout) EJRWTFormContainer(org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormContainer) Composite(org.eclipse.swt.widgets.Composite) EJRWTScrolledComposite(org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) EJApplicationComponentRenderer(org.entirej.framework.core.renderers.interfaces.EJApplicationComponentRenderer) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) EJRWTApplicationStatusbar(org.entirej.applicationframework.rwt.application.interfaces.EJRWTApplicationStatusbar) EJRWTApplicationComponent(org.entirej.applicationframework.rwt.application.interfaces.EJRWTApplicationComponent) EJRWTAppComponentRenderer(org.entirej.applicationframework.rwt.application.interfaces.EJRWTAppComponentRenderer) EJActionProcessorException(org.entirej.framework.core.EJActionProcessorException)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 Composite (org.eclipse.swt.widgets.Composite)2 EJRWTFormContainer (org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormContainer)2 EJRWTScrolledComposite (org.entirej.applicationframework.rwt.layout.EJRWTScrolledComposite)2 Collection (java.util.Collection)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Label (org.eclipse.swt.widgets.Label)1 EJRWTAbstractDialog (org.entirej.applicationframework.rwt.application.form.containers.EJRWTAbstractDialog)1 EJRWTFormPopUp (org.entirej.applicationframework.rwt.application.form.containers.EJRWTFormPopUp)1 EJRWTSingleFormContainer (org.entirej.applicationframework.rwt.application.form.containers.EJRWTSingleFormContainer)1 EJRWTAppComponentRenderer (org.entirej.applicationframework.rwt.application.interfaces.EJRWTAppComponentRenderer)1 EJRWTApplicationComponent (org.entirej.applicationframework.rwt.application.interfaces.EJRWTApplicationComponent)1 EJRWTApplicationStatusbar (org.entirej.applicationframework.rwt.application.interfaces.EJRWTApplicationStatusbar)1 EJRWTFormSelectedListener (org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener)1 EJRWTFormRenderer (org.entirej.applicationframework.rwt.renderers.form.EJRWTFormRenderer)1 EJActionProcessorException (org.entirej.framework.core.EJActionProcessorException)1 EJPopupFormController (org.entirej.framework.core.data.controllers.EJPopupFormController)1 EJInternalForm (org.entirej.framework.core.internal.EJInternalForm)1