Search in sources :

Example 6 with ISupportTabSeq

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

the class FormElementHelper method addFormComponentProperties.

private void addFormComponentProperties(Collection<PropertyDescription> formComponentProperties, IFormElement formElement, FlattenedSolution flattenedSolution, Map<TabSeqProperty, Integer> cachedTabSeq, List<TabSeqProperty> selected, List<TabSeqProperty> listFormComponentElements, boolean design, Set<String> recursionCheck) {
    if (formComponentProperties != null && formComponentProperties.size() > 0) {
        boolean isListFormComponent = isListFormComponent(formComponentProperties);
        // avoid infinite cycle here
        FormElement formComponentEl = FormElementHelper.INSTANCE.getFormElement(formElement, flattenedSolution, null, design);
        for (PropertyDescription property : formComponentProperties) {
            Object frmValue = formComponentEl.getPropertyValue(property.getName());
            Form frm = FormComponentPropertyType.INSTANCE.getForm(frmValue, flattenedSolution);
            if (frm == null)
                continue;
            if (!recursionCheck.add(frm.getName())) {
                // $NON-NLS-1$
                Debug.error("recursive reference found between (List)FormComponents: " + recursionCheck);
                continue;
            }
            // do not use the formcomponentcache, we do not want formelement with wrong tabseq to be cached, must caclulate first the sequence
            List<IFormElement> elements = generateFormComponentPersists(formComponentEl, property, (JSONObject) frmValue, frm, flattenedSolution);
            for (IFormElement element : elements) {
                if (element instanceof ISupportTabSeq) {
                    if (isListFormComponent && listFormComponentElements != null) {
                        listFormComponentElements.add(new TabSeqProperty(element, StaticContentSpecLoader.PROPERTY_TABSEQ.getPropertyName()));
                    } else if (((ISupportTabSeq) element).getTabSeq() >= 0) {
                        selected.add(new TabSeqProperty(element, StaticContentSpecLoader.PROPERTY_TABSEQ.getPropertyName(), CSSPositionUtils.getLocation(formElement)));
                    } else {
                        cachedTabSeq.put(new TabSeqProperty(element, StaticContentSpecLoader.PROPERTY_TABSEQ.getPropertyName()), Integer.valueOf(-2));
                    }
                } else if (FormTemplateGenerator.isWebcomponentBean(element)) {
                    String nestedDomponentType = FormTemplateGenerator.getComponentTypeName(element);
                    WebObjectSpecification nestedSpecification = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(nestedDomponentType);
                    if (nestedSpecification != null) {
                        Collection<PropertyDescription> nestedProperties = nestedSpecification.getProperties(NGTabSeqPropertyType.NG_INSTANCE);
                        if (nestedProperties != null && nestedProperties.size() > 0) {
                            IBasicWebComponent webComponent = (IBasicWebComponent) element;
                            for (PropertyDescription tabSeqProperty : nestedProperties) {
                                int tabseq = Utils.getAsInteger(webComponent.getProperty(tabSeqProperty.getName()));
                                if (tabseq >= 0 && isListFormComponent && listFormComponentElements != null) {
                                    // all elements will have the tabseq of the list
                                    listFormComponentElements.add(new TabSeqProperty(element, tabSeqProperty.getName()));
                                } else if (tabseq >= 0) {
                                    selected.add(new TabSeqProperty(element, tabSeqProperty.getName(), CSSPositionUtils.getLocation(formElement)));
                                } else {
                                    cachedTabSeq.put(new TabSeqProperty(element, tabSeqProperty.getName()), Integer.valueOf(-2));
                                }
                            }
                        }
                        nestedProperties = nestedSpecification.getProperties(FormComponentPropertyType.INSTANCE);
                        addFormComponentProperties(nestedProperties, element, flattenedSolution, cachedTabSeq, selected, listFormComponentElements, design, recursionCheck);
                    }
                }
            }
            recursionCheck.remove(frm.getName());
        }
    }
}
Also used : WebObjectSpecification(org.sablo.specification.WebObjectSpecification) Form(com.servoy.j2db.persistence.Form) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) IFormElement(com.servoy.j2db.persistence.IFormElement) PropertyDescription(org.sablo.specification.PropertyDescription) IFormElement(com.servoy.j2db.persistence.IFormElement) Collection(java.util.Collection) IBasicWebObject(com.servoy.j2db.persistence.IBasicWebObject) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) IChildWebObject(com.servoy.j2db.persistence.IChildWebObject) IBasicWebComponent(com.servoy.j2db.persistence.IBasicWebComponent)

Aggregations

ISupportTabSeq (com.servoy.j2db.persistence.ISupportTabSeq)6 IBasicWebComponent (com.servoy.j2db.persistence.IBasicWebComponent)3 IFormElement (com.servoy.j2db.persistence.IFormElement)3 Point (java.awt.Point)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 PropertyDescription (org.sablo.specification.PropertyDescription)3 WebObjectSpecification (org.sablo.specification.WebObjectSpecification)3 IDisplay (com.servoy.j2db.dataprocessing.IDisplay)2 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)2 Field (com.servoy.j2db.persistence.Field)2 Form (com.servoy.j2db.persistence.Form)2 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)2 IDataProviderLookup (com.servoy.j2db.persistence.IDataProviderLookup)2 IPersist (com.servoy.j2db.persistence.IPersist)2 ISupportPrinting (com.servoy.j2db.persistence.ISupportPrinting)2 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)2 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2