Search in sources :

Example 1 with EJInternalForm

use of org.entirej.framework.core.internal.EJInternalForm in project rap by entirej.

the class EJRWTApplicationManager method createEmbeddedForm.

public EJInternalForm createEmbeddedForm(String formName, Composite parent) {
    try {
        EJInternalForm form = getFrameworkManager().createInternalForm(formName, null);
        if (form != null) {
            EJRWTFormRenderer renderer = (EJRWTFormRenderer) form.getRenderer();
            renderer.createControl(parent);
            EJRWTEntireJGridPane gridPane = renderer.getGuiComponent();
            gridPane.cleanLayout();
            embeddedForms.add(form);
            return form;
        }
    } catch (Exception e) {
        getApplicationMessenger().handleException(e, true);
    }
    return null;
}
Also used : EJRWTFormRenderer(org.entirej.applicationframework.rwt.renderers.form.EJRWTFormRenderer) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm) EJRWTEntireJGridPane(org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane) EJApplicationException(org.entirej.framework.core.EJApplicationException)

Example 2 with EJInternalForm

use of org.entirej.framework.core.internal.EJInternalForm in project rap by entirej.

the class EJRWTComboItemRenderer method connectLOVItems.

private void connectLOVItems() {
    String lovDefName = _rendererProps.getStringProperty(EJRWTComboBoxRendererDefinitionProperties.LOV_DEFINITION_NAME);
    if (lovDefName == null || lovDefName.trim().length() == 0) {
        return;
    }
    String defName = lovDefName;
    EJInternalForm form = _item.getForm();
    if (lovDefName.indexOf('.') != -1) {
        defName = lovDefName.substring(0, lovDefName.indexOf('.'));
    } else {
        EJMessage message = new EJMessage("No LovDefinition item has been chosen for the ComboBox renderer properties on item: " + _itemProperties.getName());
        form.getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
        return;
    }
    if (_item.getBlock().getProperties().isReferenceBlock()) {
        defName = String.format("%s.%s", _item.getBlock().getProperties().getName(), defName);
    }
    EJLovDefinitionProperties lovDef = form.getProperties().getLovDefinitionProperties(defName);
    if (lovDef == null) {
        return;
    }
    Collection<EJItemProperties> allItemProperties = lovDef.getBlockProperties().getAllItemProperties();
    for (EJItemProperties ejItemProperties : allItemProperties) {
        String defaultValue = ejItemProperties.getDefaultQueryValue();
        if (defaultValue == null || defaultValue.trim().length() == 0) {
            continue;
        }
        String paramTypeCode = defaultValue.substring(0, defaultValue.indexOf(':'));
        String paramValue = defaultValue.substring(defaultValue.indexOf(':') + 1);
        final Logger logger = LoggerFactory.getLogger(EJRWTComboItemRenderer.class);
        if ("APP_PARAMETER".equals(paramTypeCode)) {
            EJApplicationLevelParameter param = form.getApplicationLevelParameter(paramValue);
            if (param != null) {
                param.addParameterChangedListener(new ParameterChangedListener() {

                    @Override
                    public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
                        logger.debug("APP_PARAMETER:parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                _loadComboBoxValues();
                                refreshCombo();
                            }
                        });
                    }
                });
            }
        } else if ("FORM_PARAMETER".equals(paramTypeCode)) {
            EJFormParameter param = form.getFormParameter(paramValue);
            if (param != null) {
                param.addParameterChangedListener(new ParameterChangedListener() {

                    @Override
                    public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
                        logger.debug("FORM_PARAMETER.parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                _loadComboBoxValues();
                                refreshCombo();
                            }
                        });
                    }
                });
            }
        } else if ("BLOCK_ITEM".equals(paramTypeCode)) {
            final String blockName = paramValue.substring(0, paramValue.indexOf('.'));
            String itemName = paramValue.substring(paramValue.indexOf('.') + 1);
            EJInternalEditableBlock block = form.getBlock(blockName);
            if (block != null) {
                final String itemBlock = _item.getBlock().getProperties().getName();
                _lovInitialiedOnValueSet = true;
                if (!itemBlock.equals(blockName) || _item.getScreenType() == EJScreenType.MAIN) {
                    block.getBlockController().addNewRecordFocusedListener(new EJNewRecordFocusedListener() {

                        @Override
                        public void focusedGained(EJDataRecord focusedRecord) {
                            logger.debug(String.format("BLOCK RECORD Changed %s", blockName));
                            Display.getDefault().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    _loadComboBoxValues();
                                    refreshCombo();
                                }
                            });
                        }
                    });
                }
                block.addDataItemValueChangedListener(itemName, new EJDataItemValueChangedListener() {

                    @Override
                    public void dataItemValueChanged(String itemName, EJDataRecord changedRecord, EJScreenType screenType) {
                        if (blockName.equals(itemBlock)) {
                            if (screenType == _item.getScreenType()) {
                                logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        _loadComboBoxValues();
                                        refreshCombo();
                                    }
                                });
                            }
                        } else {
                            if (screenType == EJScreenType.MAIN) {
                                logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
                                Display.getDefault().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        _loadComboBoxValues();
                                        refreshCombo();
                                    }
                                });
                            }
                        }
                    }
                });
            }
        }
    }
    EJLovController lovController = form.getLovController(defName);
    if (lovController == null) {
        return;
    }
}
Also used : EJScreenType(org.entirej.framework.core.enumerations.EJScreenType) EJFormParameter(org.entirej.framework.core.data.controllers.EJFormParameter) Logger(org.slf4j.Logger) EJApplicationLevelParameter(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter) EJLovController(org.entirej.framework.core.data.controllers.EJLovController) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm) EJMessage(org.entirej.framework.core.EJMessage) EJLovDefinitionProperties(org.entirej.framework.core.properties.interfaces.EJLovDefinitionProperties) ParameterChangedListener(org.entirej.framework.core.data.controllers.EJApplicationLevelParameter.ParameterChangedListener) EJDataItemValueChangedListener(org.entirej.framework.core.renderers.eventhandlers.EJDataItemValueChangedListener) EJInternalEditableBlock(org.entirej.framework.core.internal.EJInternalEditableBlock) EJNewRecordFocusedListener(org.entirej.framework.core.renderers.eventhandlers.EJNewRecordFocusedListener) EJItemProperties(org.entirej.framework.core.properties.interfaces.EJItemProperties) EJDataRecord(org.entirej.framework.core.data.EJDataRecord)

Example 3 with EJInternalForm

use of org.entirej.framework.core.internal.EJInternalForm 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 4 with EJInternalForm

use of org.entirej.framework.core.internal.EJInternalForm in project rap by entirej.

the class EJRWTTabPaneFormContainer method switchToForm.

@Override
public EJInternalForm switchToForm(EJInternalForm aform) {
    for (EJInternalForm form : _tabPages.keySet()) {
        if (form.equals(aform)) {
            EJRWTFormRenderer renderer = (EJRWTFormRenderer) form.getRenderer();
            _folder.setSelection(_tabPages.get(form));
            EJ_RWT.setAttribute(_folder, "ej-item-selection", form.getProperties().getName());
            renderer.gainInitialFocus();
            return form;
        }
    }
    return null;
}
Also used : EJRWTFormRenderer(org.entirej.applicationframework.rwt.renderers.form.EJRWTFormRenderer) EJInternalForm(org.entirej.framework.core.internal.EJInternalForm)

Example 5 with EJInternalForm

use of org.entirej.framework.core.internal.EJInternalForm in project rap by entirej.

the class EJRWTDefaultFormContainerToolbar method fireFormClosed.

@Override
public void fireFormClosed(EJInternalForm closedForm) {
    closedForm.removeFormEventListener(this);
    closedForm.removeBlockFocusedListener(this);
    closedForm.removeItemFocusListener(this);
    closedForm.removeItemValueChangedListener(this);
    closedForm.removeNewRecordFocusedListener(this);
    EJInternalForm form = getForm();
    synchronize(form != null ? form.getFocusedBlock().getBlockController() : null);
}
Also used : EJInternalForm(org.entirej.framework.core.internal.EJInternalForm)

Aggregations

EJInternalForm (org.entirej.framework.core.internal.EJInternalForm)13 EJRWTFormRenderer (org.entirej.applicationframework.rwt.renderers.form.EJRWTFormRenderer)7 EJRWTFormSelectedListener (org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormSelectedListener)5 EJInternalEditableBlock (org.entirej.framework.core.internal.EJInternalEditableBlock)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 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 EJRWTAbstractDialog (org.entirej.applicationframework.rwt.application.form.containers.EJRWTAbstractDialog)1 EJRWTFormPopUp (org.entirej.applicationframework.rwt.application.form.containers.EJRWTFormPopUp)1 EJRWTFormContainer (org.entirej.applicationframework.rwt.application.interfaces.EJRWTFormContainer)1 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)1 EJRWTEntireJStackedPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJStackedPane)1