Search in sources :

Example 26 with Form

use of com.servoy.j2db.persistence.Form 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 27 with Form

use of com.servoy.j2db.persistence.Form 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)

Example 28 with Form

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

the class FlattenedSolution method deregisterLiveForm.

/**
 * @param form
 * @param namedInstance
 */
public void deregisterLiveForm(Form form, String namedInstance) {
    synchronized (liveForms) {
        if (form instanceof FlattenedForm) {
            for (Form f : ((FlattenedForm) form).getAllForms()) {
                deregisterLiveForm(f, namedInstance);
            }
        } else {
            flushFlattendFormCache(form);
            Set<String> instances = liveForms.get(form.getName());
            if (instances != null) {
                instances.remove(namedInstance);
                if (instances.size() == 0) {
                    liveForms.remove(form.getName());
                }
            }
        }
        // Test forms if they now are ok. (form they build on when they where changed is now destroyed)
        ChangedFormData changedFormData = changedForms.get(form.getName());
        if (changedFormData != null) {
            changedFormData.instances.remove(namedInstance);
            if (changedFormData.instances.size() == 0) {
                changedForms.remove(form.getName());
            }
        }
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm)

Example 29 with Form

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

the class FlattenedSolution method createFlattenedForm.

/*
	 * Create a flattened form for the form that is child of the current solution.
	 */
public FlattenedForm createFlattenedForm(Form form) {
    Form myForm;
    Solution solcopy = getSolutionCopy(false);
    if (form.getParent() == getSolution() || form.getParent() == solcopy) {
        myForm = form;
    } else {
        myForm = null;
        if (solcopy != null) {
            myForm = (Form) solcopy.getChild(form.getUUID());
        }
        if (myForm == null) {
            myForm = (Form) getSolution().getChild(form.getUUID());
        }
        if (myForm == null && modules != null) {
            for (Solution mod : modules) {
                myForm = (Form) mod.getChild(form.getUUID());
                if (myForm != null)
                    break;
            }
        }
        if (myForm == null) {
            throw new RuntimeException("Cannot find form '" + form + "' in solution '" + getSolution() + "'");
        }
    }
    try {
        return new FlattenedForm(this, myForm);
    } catch (RuntimeException ex) {
        Debug.error("Error while creating full hierarchy form (flattened form) for: " + (myForm != null ? myForm.getName() : "<form not found>"), ex);
        throw ex;
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Solution(com.servoy.j2db.persistence.Solution)

Example 30 with Form

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

the class FlattenedSolution method revertForm.

public Form revertForm(String name) {
    Form form = getForm(name);
    if (form == null) {
        // then revert the remove/delete
        for (IPersist persist : getIndex().getRemoved()) {
            if (persist instanceof Form && name.equals(((Form) persist).getName())) {
                getIndex().removeRemoved(persist);
                flush(persist);
                form = getForm(name);
                break;
            }
        }
    }
    if (form != null) {
        deletePersistCopy(form, true);
        form = getForm(name);
        if (form != null)
            registerChangedForm(form);
    }
    return form;
}
Also used : Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) IPersist(com.servoy.j2db.persistence.IPersist)

Aggregations

Form (com.servoy.j2db.persistence.Form)146 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)35 ArrayList (java.util.ArrayList)32 Point (java.awt.Point)26 FlattenedSolution (com.servoy.j2db.FlattenedSolution)24 IPersist (com.servoy.j2db.persistence.IPersist)22 ISMForm (com.servoy.j2db.solutionmodel.ISMForm)20 JSONObject (org.json.JSONObject)20 Solution (com.servoy.j2db.persistence.Solution)16 Dimension (java.awt.Dimension)15 Part (com.servoy.j2db.persistence.Part)14 RepositoryException (com.servoy.j2db.persistence.RepositoryException)14 FormController (com.servoy.j2db.FormController)13 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)12 IMobileSMForm (com.servoy.base.solutionmodel.mobile.IMobileSMForm)11 IForm (com.servoy.j2db.IForm)11 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)11 FormElement (com.servoy.j2db.server.ngclient.FormElement)11 HashMap (java.util.HashMap)11 JSFunction (org.mozilla.javascript.annotations.JSFunction)11