Search in sources :

Example 1 with EJRWTFormSelectedListener

use of org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener 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 2 with EJRWTFormSelectedListener

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

the class EJRWTTabPaneFormContainer method createContainer.

public Composite createContainer(Composite parent) {
    if (_folder != null) {
        _folder.dispose();
        _folder = null;
    }
    int style = SWT.FLAT | SWT.BORDER | getTabOrientation() | SWT.CLOSE;
    _folder = new CTabFolder(parent, style);
    _folder.addCTabFolder2Listener(new CTabFolder2Adapter() {

        @Override
        public void close(CTabFolderEvent event) {
            event.doit = false;
            if (event.item instanceof CTabItem) {
                EJInternalForm form = getFormByTab((CTabItem) event.item);
                if (form != null) {
                    try {
                        form.close();
                    } catch (Exception e) {
                        form.getFrameworkManager().getApplicationManager().handleException(e);
                    }
                }
            }
        }
    });
    _folder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CTabItem selection = _folder.getSelection();
            if (selection != null && selection.getData() instanceof EJInternalForm) {
                final EJInternalForm form = (EJInternalForm) selection.getData();
                EJ_RWT.setAttribute(_folder, "ej-item-selection", form.getProperties().getName());
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        for (EJRWTFormSelectedListener listener : _formSelectedListeners) {
                            listener.fireFormSelected(form);
                        }
                        form.focusGained();
                    }
                });
            }
        }
    });
    return _folder;
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) CTabFolder2Adapter(org.eclipse.swt.custom.CTabFolder2Adapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) EJRWTFormSelectedListener(org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener) CTabItem(org.eclipse.swt.custom.CTabItem) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm)

Example 3 with EJRWTFormSelectedListener

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

the class EJRWTStackedPaneFormContainer method switchToForm.

@Override
public EJInternalForm switchToForm(EJInternalForm aform) {
    for (EJInternalForm form : _stackedPages.keySet()) {
        if (form.equals(aform)) {
            EJRWTFormRenderer renderer = (EJRWTFormRenderer) form.getRenderer();
            _stackPane.showPane(_stackedPages.get(form));
            EJ_RWT.setAttribute(_stackPane, "ej-item-selection", form.getProperties().getName());
            renderer.gainInitialFocus();
            form.focusGained();
            for (EJRWTFormSelectedListener listener : _formSelectedListeners) {
                listener.fireFormSelected(form);
            }
            return form;
        }
    }
    return null;
}
Also used : EJRWTFormRenderer(org.entirej.applicationframework.rwt.renderers.form.EJRWTFormRenderer) EJRWTFormSelectedListener(org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm)

Example 4 with EJRWTFormSelectedListener

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

the class EJRWTSingleFormContainer method createContainer.

@Override
public void createContainer(EJRWTApplicationManager manager, Composite parent, EJFrameworkExtensionProperties rendererprop) {
    String formid = null;
    formid = getFormId(rendererprop);
    if (formid != null) {
        try {
            _form = manager.getFrameworkManager().createInternalForm(formid, null);
            if (_form != null) {
                Composite composite = new Composite(parent, rendererprop.getBooleanProperty("BORDER", true) ? SWT.BORDER : SWT.NONE);
                FillLayout fillLayout = new FillLayout();
                fillLayout.marginHeight = 5;
                fillLayout.marginWidth = 5;
                String style = rendererprop.getStringProperty("CSS");
                if (style != null)
                    composite.setData(EJ_RWT.CUSTOM_VARIANT, style);
                composite.setLayout(fillLayout);
                EJRWTAppFormRenderer renderer = (EJRWTAppFormRenderer) _form.getRenderer();
                renderer.createControl(composite);
                EJRWTEntireJGridPane gridPane = (EJRWTEntireJGridPane) renderer.getGuiComponent();
                gridPane.cleanLayout();
                gridPane.addFocusListener(new FocusListener() {

                    @Override
                    public void focusLost(FocusEvent arg0) {
                    // ignore
                    }

                    @Override
                    public void focusGained(FocusEvent arg0) {
                        for (EJRWTFormSelectedListener listener : _formSelectedListeners) {
                            listener.fireFormSelected(_form);
                        }
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                _form.focusGained();
                            }
                        });
                    }
                });
                _control = composite;
                return;
            }
        } catch (Exception e) {
            manager.getApplicationMessenger().handleException(e, true);
        }
    }
    Label label = new Label(parent, SWT.NONE);
    label.setText("Form could not be found ID#:" + (formid != null ? formid : "<null>"));
    _control = label;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) EJRWTFormSelectedListener(org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener) FillLayout(org.eclipse.swt.layout.FillLayout) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane) EJRWTAppFormRenderer(org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppFormRenderer)

Example 5 with EJRWTFormSelectedListener

use of org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener 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)

Aggregations

EJRWTFormSelectedListener (org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener)7 EJInternalForm (org.entirej.framework.core.internal.EJInternalForm)5 EJRWTFormRenderer (org.entirej.applicationframework.rwt.renderers.form.EJRWTFormRenderer)4 FillLayout (org.eclipse.swt.layout.FillLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Collection (java.util.Collection)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabFolder2Adapter (org.eclipse.swt.custom.CTabFolder2Adapter)1 CTabFolderEvent (org.eclipse.swt.custom.CTabFolderEvent)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Control (org.eclipse.swt.widgets.Control)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