Search in sources :

Example 1 with FlattenedForm

use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.

the class DebugNGClient method refreshPersists.

@Override
public void refreshPersists(Collection<IPersist> changes) {
    if (isShutDown())
        return;
    // flush the solution model cache of the form element helper when there is a solution copy.
    // so that FormComponents are recreated with the latest data once.
    Solution solutionCopy = getFlattenedSolution().getSolutionCopy(false);
    if (solutionCopy != null)
        solutionCopy.setRuntimeProperty(FormElementHelper.SOLUTION_MODEL_CACHE, null);
    Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
    for (IFormController controller : scopesAndFormsToReload[1]) {
        if (controller.getForm() instanceof FlattenedForm) {
            FlattenedForm ff = (FlattenedForm) controller.getForm();
            ff.reload();
        }
    }
    boolean forcePageReload = false;
    if (scopesAndFormsToReload[1] == null || scopesAndFormsToReload[1].size() < 1) {
        for (IPersist persist : changes) {
            // that one, can also have other css included, using the 'import' statement
            if (persist instanceof Media && !PersistHelper.getOrderedStyleSheets(getFlattenedSolution()).isEmpty()) {
                String name = ((Media) persist).getName().toLowerCase();
                if (name.endsWith(".less") || name.endsWith(".css")) {
                    forcePageReload = true;
                    break;
                }
            }
        }
    }
    refreshForms(scopesAndFormsToReload[1], forcePageReload);
    for (IFormController controller : scopesAndFormsToReload[0]) {
        controller.getFormScope().reload();
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Set(java.util.Set) IPersist(com.servoy.j2db.persistence.IPersist) Media(com.servoy.j2db.persistence.Media) IFormController(com.servoy.j2db.IFormController) Solution(com.servoy.j2db.persistence.Solution)

Example 2 with FlattenedForm

use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.

the class DebugWebClient method performRefresh.

private void performRefresh(List<IPersist> changes) {
    Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
    for (IFormController controller : scopesAndFormsToReload[0]) {
        if (controller.getForm() instanceof FlattenedForm) {
            FlattenedForm ff = (FlattenedForm) controller.getForm();
            ff.reload();
        }
        controller.getFormScope().reload();
    }
    if (scopesAndFormsToReload[1].size() > 0)
        ((WebFormManager) getFormManager()).reload((scopesAndFormsToReload[1]).toArray(new FormController[0]));
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Set(java.util.Set) IFormController(com.servoy.j2db.IFormController)

Example 3 with FlattenedForm

use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.

the class FlattenedSolution method getFlattenedForm.

public Form getFlattenedForm(IPersist persist, boolean useCached) {
    if (mainSolution == null && loginFlattenedSolution != null) {
        return loginFlattenedSolution.getFlattenedForm(persist, useCached);
    }
    if (persist == null || getSolution() == null) {
        return null;
    }
    Form form = null;
    if (persist instanceof FlattenedForm) {
        form = ((FlattenedForm) persist).getForm();
    } else {
        form = (Form) persist.getAncestor(IRepository.FORMS);
    }
    if (form == null || form.getExtendsID() <= 0) {
        // no form or nothing to flatten
        return form;
    }
    // make sure is latest form
    form = getForm(form.getID());
    // form is already deleted?
    if (form == null)
        return null;
    if (flattenedFormCache == null) {
        // no caching
        return createFlattenedForm(form);
    }
    // cache flattened form
    FlattenedForm[] flattedFormRef;
    synchronized (flattenedFormCache) {
        flattedFormRef = flattenedFormCache.get(form);
        if (flattedFormRef == null) {
            flattenedFormCache.put(form, flattedFormRef = new FlattenedForm[] { null });
        }
    }
    synchronized (flattedFormRef) {
        if (flattedFormRef[0] == null || !useCached) {
            flattedFormRef[0] = createFlattenedForm(form);
        }
        return flattedFormRef[0];
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm)

Example 4 with FlattenedForm

use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.

the class FlattenedSolution method flushFlattendFormCache.

public void flushFlattendFormCache(Form frm, boolean includingSubforms) {
    if (flattenedFormCache == null || frm == null)
        return;
    Form form = frm;
    if (frm instanceof FlattenedForm) {
        form = ((FlattenedForm) frm).getForm();
    }
    flattenedFormCache.remove(form);
    if (includingSubforms) {
        Iterator<Form> formCacheIte = flattenedFormCache.keySet().iterator();
        while (formCacheIte.hasNext()) {
            if (FlattenedForm.hasFormInHierarchy(formCacheIte.next(), frm)) {
                formCacheIte.remove();
            }
        }
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm)

Example 5 with FlattenedForm

use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.

the class FlattenedSolution method registerLiveForm.

/**
 * @param form
 */
public void registerLiveForm(Form form, String namedInstance) {
    synchronized (liveForms) {
        if (form instanceof FlattenedForm) {
            for (Form f : ((FlattenedForm) form).getAllForms()) {
                registerLiveForm(f, namedInstance);
            }
        } else {
            Set<String> instances = liveForms.get(form.getName());
            if (instances == null) {
                instances = new HashSet<String>();
                liveForms.put(form.getName(), instances);
            }
            instances.add(namedInstance);
        }
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm)

Aggregations

FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)14 Form (com.servoy.j2db.persistence.Form)10 IFormController (com.servoy.j2db.IFormController)4 Set (java.util.Set)4 Solution (com.servoy.j2db.persistence.Solution)3 IPersist (com.servoy.j2db.persistence.IPersist)2 ArrayList (java.util.ArrayList)2 IForm (com.servoy.j2db.IForm)1 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)1 IDataSet (com.servoy.j2db.dataprocessing.IDataSet)1 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 FlattenedLayoutContainer (com.servoy.j2db.persistence.FlattenedLayoutContainer)1 ISupportChilds (com.servoy.j2db.persistence.ISupportChilds)1 LayoutContainer (com.servoy.j2db.persistence.LayoutContainer)1 Media (com.servoy.j2db.persistence.Media)1 Part (com.servoy.j2db.persistence.Part)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 RootObjectReference (com.servoy.j2db.persistence.RootObjectReference)1 Style (com.servoy.j2db.persistence.Style)1 RemoteException (java.rmi.RemoteException)1