Search in sources :

Example 1 with IWebFormContainer

use of com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer in project servoy-client by Servoy.

the class WebForm method setTabSeqComponents.

public void setTabSeqComponents(List<Component> tabSequence) {
    boolean defaultSequence = true;
    if (tabSequence != null && tabSequence.size() > 0) {
        defaultSequence = false;
        IDataRenderer formEditorRenderer = formController.getDataRenderers()[FormController.FORM_EDITOR];
        if (formEditorRenderer instanceof WebCellBasedView && !tabSequence.contains(formEditorRenderer)) {
            // this means that we have to identify components that are part of the table view and based on where these are located set the view's tabIndex;
            // when called from JS tabSequence will only contain table columns, not table view as opposed to initialization when tabSequence only contains the view
            int i;
            for (i = 0; i < tabSequence.size(); i++) {
                if (((WebCellBasedView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    // table view should be added to tab sequence
                    ((WebCellBasedView) formEditorRenderer).setTabSeqComponents(tabSequence);
                    tabSequence = new ArrayList<Component>(tabSequence);
                    tabSequence.add(i, (Component) formEditorRenderer);
                    break;
                }
            }
            i++;
            while (i < tabSequence.size()) {
                if (((WebCellBasedView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    tabSequence.remove(i);
                } else {
                    i++;
                }
            }
        }
        int tabIndex = 1;
        for (Component comp : tabSequence) {
            if (comp instanceof IWebFormContainer) {
                ((IWebFormContainer) comp).setTabSequenceIndex(tabIndex);
                tabIndex = WebDataRendererFactory.getContainerGapIndex(tabIndex + WebDataRendererFactory.CONTAINER_RESERVATION_GAP, tabIndex);
                TabIndexHelper.setUpTabIndexAttributeModifier(comp, ISupportWebTabSeq.SKIP);
            } else if (comp instanceof WebCellBasedView) {
                WebCellBasedView tableView = (WebCellBasedView) comp;
                tableView.setTabSequenceIndex(tabIndex);
                tabIndex += WebDataRendererFactory.MAXIMUM_TAB_INDEXES_ON_TABLEVIEW;
                TabIndexHelper.setUpTabIndexAttributeModifier(comp, ISupportWebTabSeq.SKIP);
            } else {
                TabIndexHelper.setUpTabIndexAttributeModifier(comp, tabIndex);
                tabIndex++;
            }
        }
    }
    IDataRenderer[] dataRenderers = formController.getDataRenderers();
    for (IDataRenderer dr : dataRenderers) {
        if (dr != null) {
            // set attributeModifiers for all components
            if (dr instanceof WebCellBasedView) {
                if (defaultSequence) {
                    // normal focus
                    ((WebCellBasedView) dr).setTabSequenceIndex(ISupportWebTabSeq.DEFAULT);
                    ((WebCellBasedView) dr).setTabSeqComponents(null);
                } else if (!tabSequence.contains(dr)) {
                    // it shouldn't gain focus when tabbing ...
                    ((WebCellBasedView) dr).setTabSequenceIndex(-1);
                    ((WebCellBasedView) dr).setTabSeqComponents(null);
                }
            } else {
                Iterator compIt = dr.getComponentIterator();
                if (compIt != null) {
                    while (compIt.hasNext()) {
                        Object obj = compIt.next();
                        if (obj instanceof ISupplyFocusChildren) {
                            for (Component c : ((ISupplyFocusChildren<Component>) obj).getFocusChildren()) {
                                checkIfDefaultOrSkipFocus(defaultSequence, tabSequence, c);
                            }
                        } else if (obj instanceof Component) {
                            checkIfDefaultOrSkipFocus(defaultSequence, tabSequence, (Component) obj);
                        }
                    }
                }
            }
        }
    }
    tabSeqComponentList = tabSequence;
}
Also used : IDataRenderer(com.servoy.j2db.ui.IDataRenderer) IWebFormContainer(com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer) Iterator(java.util.Iterator) ISupplyFocusChildren(com.servoy.j2db.util.ISupplyFocusChildren) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) WebCellBasedView(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView) IComponent(com.servoy.j2db.ui.IComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Point(java.awt.Point)

Example 2 with IWebFormContainer

use of com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer in project servoy-client by Servoy.

the class WebForm method uiRecreated.

/**
 * @see com.servoy.j2db.IFormUIInternal#uiRecreated()
 */
public void uiRecreated() {
    // touch the form when recreated so that template generator will flush its css/html cache
    formController.getForm().setLastModified(System.currentTimeMillis());
    // remove the markup from the cache for this webform.
    // ((ServoyMarkupCache)Application.get().getMarkupSettings().getMarkupCache()).removeFromCache(this);
    markup = null;
    uiRecreated = true;
    IWebFormContainer webContainer = findParent(IWebFormContainer.class);
    if (webContainer != null && webContainer.isCurrentForm(this)) {
        webContainer.uiRecreated();
    }
}
Also used : IWebFormContainer(com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer)

Example 3 with IWebFormContainer

use of com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer in project servoy-client by Servoy.

the class WebFormManager method reload.

public void reload(FormController[] fcontrollers) {
    HashSet<MainPage> mainPages = new HashSet<MainPage>();
    for (FormController fc : fcontrollers) {
        WebForm formUI = (WebForm) fc.getFormUI();
        MainPage mp = formUI.findParent(MainPage.class);
        if (mp != null && mainPages.add(mp)) {
            mp.setVersioned(false);
            mp.setMainPageSwitched();
        }
    }
    String navigatorName = null;
    Set<MainPage> parents = new HashSet<MainPage>();
    for (FormController fp : fcontrollers) {
        if (fp != null) {
            boolean formVisible = fp.isFormVisible();
            IFoundSetInternal foundset = fp.getFormModel();
            WebForm wf = (WebForm) fp.getFormUI();
            MarkupContainer wfParent = wf.getParent();
            boolean refresh = false;
            // datasource has changed, but foundset has not
            if (foundset != null && !Utils.equalObjects(foundset.getDataSource(), fp.getDataSource())) {
                try {
                    foundset = (getApplication()).getFoundSetManager().getSharedFoundSet(fp.getDataSource());
                    foundset.loadAllRecords();
                    refresh = true;
                } catch (ServoyException e) {
                    // $NON-NLS-1$
                    Debug.error("Failed to reload foundset.", e);
                }
            }
            MainPage page = wf.findParent(MainPage.class);
            try {
                if (page != null) {
                    page.setTempRemoveMainForm(true);
                }
                fp.destroy();
            } finally {
                if (page != null) {
                    page.setTempRemoveMainForm(false);
                }
            }
            while (wfParent != null && !(wfParent instanceof IWebFormContainer) && !(wfParent.getParent() instanceof MainPage) && !(wfParent.getParent() instanceof WebForm)) {
                wfParent = wfParent.getParent();
            }
            if (wfParent instanceof IWebFormContainer) {
                if (formVisible) {
                    FormController fc = leaseFormPanel(fp.getName());
                    if (fc != null) {
                        // form was deleted in developer?
                        fc.loadData(foundset, null);
                        if (refresh)
                            fc.recreateUI();
                        List<Runnable> runnables = new ArrayList<Runnable>();
                        ((IWebFormContainer) wfParent).notifyVisible(true, runnables);
                        Utils.invokeLater(getApplication(), runnables);
                    }
                }
            } else if (wfParent != null) {
                WebForm parentWF = wfParent.findParent(WebForm.class);
                if (parentWF != null) {
                    if (!Arrays.asList(fcontrollers).contains(parentWF.getController()))
                        parentWF.getController().destroy();
                } else {
                    MainPage parent = wfParent.findParent(MainPage.class);
                    if (parent != null && !parents.contains(parent)) {
                        parents.add(parent);
                        if (parent.getNavigator() == fp) {
                            navigatorName = fp.getName();
                            FormController navigator = getFormController(navigatorName, parent);
                            if (navigator != null) {
                                List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
                                navigator.notifyVisible(true, invokeLaterRunnables);
                                Utils.invokeLater(getApplication(), invokeLaterRunnables);
                                parent.setNavigator(navigator);
                            // parent.triggerBrowserRequestIfNeeded(); // FIXME: this is needed here but currently does nothing because the request target is not yet set
                            }
                        }
                        FormController previousMainShowingForm = (parent != null ? parent.getController() : null);
                        if (previousMainShowingForm != null) {
                            FormController previousNavigator = parent.getNavigator();
                            parent.setController(null);
                            // navigator is not re-applied so apply it manually
                            int navigatorID = previousMainShowingForm.getForm().getNavigatorID();
                            if (navigatorID == Form.NAVIGATOR_IGNORE || (previousNavigator != null && previousNavigator.getForm().getID() == navigatorID)) {
                                parent.setNavigator(previousNavigator);
                            } else if (navigatorID > 0) {
                                Form newNavigator = application.getFlattenedSolution().getForm(navigatorID);
                                if (newNavigator != null) {
                                    parent.setNavigator(leaseFormPanel(newNavigator.getName()));
                                }
                            }
                            showFormInMainPanel(previousMainShowingForm.getName(), parent, null, true, null);
                        // parent.triggerBrowserRequestIfNeeded(); // FIXME: this is needed here but currently does nothing because the request target is not yet set
                        }
                    }
                }
            }
        }
    }
    for (MainPage mainPage : mainPages) {
        mainPage.setVersioned(true);
    }
}
Also used : FormController(com.servoy.j2db.FormController) BasicFormController(com.servoy.j2db.BasicFormController) MarkupContainer(org.apache.wicket.MarkupContainer) Form(com.servoy.j2db.persistence.Form) SwingForm(com.servoy.j2db.smart.SwingForm) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) ArrayList(java.util.ArrayList) ServoyException(com.servoy.j2db.util.ServoyException) IWebFormContainer(com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

IWebFormContainer (com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer)3 BasicFormController (com.servoy.j2db.BasicFormController)1 FormController (com.servoy.j2db.FormController)1 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)1 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 Form (com.servoy.j2db.persistence.Form)1 WebCellBasedView (com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView)1 SwingForm (com.servoy.j2db.smart.SwingForm)1 IComponent (com.servoy.j2db.ui.IComponent)1 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)1 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)1 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)1 ISupplyFocusChildren (com.servoy.j2db.util.ISupplyFocusChildren)1 ServoyException (com.servoy.j2db.util.ServoyException)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Component (org.apache.wicket.Component)1