Search in sources :

Example 1 with BasicFormManager

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

the class FormLayoutGenerator method generateRecordViewForm.

public static void generateRecordViewForm(PrintWriter writer, Form form, String realFormName, IServoyDataConverterContext context, boolean design) {
    generateFormStartTag(writer, form, realFormName, false, design);
    Iterator<Part> it = form.getParts();
    if (design) {
        while (it.hasNext()) {
            Part part = it.next();
            if (!Part.rendersOnlyInPrint(part.getPartType())) {
                writer.print("<div ng-style=\"");
                writer.print(PartWrapper.getName(part));
                writer.print("Style\"");
                String partClass = "svy-" + PartWrapper.getName(part);
                if (part.getStyleClass() != null) {
                    partClass += " " + part.getStyleClass();
                }
                writer.print(" class=\"");
                writer.print(partClass);
                writer.print("\">");
                generateEndDiv(writer);
            }
        }
    }
    Map<IPersist, FormElement> cachedElementsMap = new HashMap<IPersist, FormElement>();
    if (context != null && context.getApplication() != null) {
        IFormController controller = ((BasicFormManager) context.getApplication().getFormManager()).getCachedFormController(realFormName);
        if (controller != null && controller.getFormUI() instanceof WebFormUI) {
            List<FormElement> cachedFormElements = ((WebFormUI) controller.getFormUI()).getFormElements();
            for (FormElement fe : cachedFormElements) {
                if (fe.getPersistIfAvailable() != null) {
                    cachedElementsMap.put(fe.getPersistIfAvailable(), fe);
                }
            }
        }
    }
    it = form.getParts();
    while (it.hasNext()) {
        Part part = it.next();
        if (!Part.rendersOnlyInPrint(part.getPartType())) {
            if (!design) {
                writer.print("<div svy-ng-style=\"");
                writer.print(PartWrapper.getName(part));
                writer.print("Style\"");
                String partClass = "svy-" + PartWrapper.getName(part);
                if (part.getStyleClass() != null) {
                    partClass += " " + part.getStyleClass();
                }
                writer.print(" class=\"");
                writer.print(partClass);
                writer.print("\">");
            }
            for (IFormElement bc : PartWrapper.getBaseComponents(part, form, context, design, false)) {
                FormElement fe = null;
                if (cachedElementsMap.containsKey(bc)) {
                    fe = cachedElementsMap.get(bc);
                }
                if (fe == null) {
                    fe = FormElementHelper.INSTANCE.getFormElement(bc, context.getSolution(), null, design);
                }
                generateFormElementWrapper(writer, fe, form, form.isResponsiveLayout());
                generateFormElement(writer, fe, form);
                generateEndDiv(writer);
            }
            if (!design)
                generateEndDiv(writer);
        }
    }
    generateFormEndTag(writer, design);
}
Also used : IFormElement(com.servoy.j2db.persistence.IFormElement) WebFormUI(com.servoy.j2db.server.ngclient.WebFormUI) IPersist(com.servoy.j2db.persistence.IPersist) HashMap(java.util.HashMap) Part(com.servoy.j2db.persistence.Part) BasicFormManager(com.servoy.j2db.BasicFormManager) IFormController(com.servoy.j2db.IFormController) FormElement(com.servoy.j2db.server.ngclient.FormElement) IFormElement(com.servoy.j2db.persistence.IFormElement)

Aggregations

BasicFormManager (com.servoy.j2db.BasicFormManager)1 IFormController (com.servoy.j2db.IFormController)1 IFormElement (com.servoy.j2db.persistence.IFormElement)1 IPersist (com.servoy.j2db.persistence.IPersist)1 Part (com.servoy.j2db.persistence.Part)1 FormElement (com.servoy.j2db.server.ngclient.FormElement)1 WebFormUI (com.servoy.j2db.server.ngclient.WebFormUI)1 HashMap (java.util.HashMap)1