Search in sources :

Example 1 with IFlattenedPersistWrapper

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

the class MobileFormLayout method getBodyElementsForRecordView.

public static List<ISupportBounds> getBodyElementsForRecordView(FlattenedSolution editingFlattenedSolution, Form flattenedForm) {
    List<ISupportBounds> elements = new ArrayList<ISupportBounds>();
    Set<String> groups = new HashSet<String>();
    for (IPersist persist : flattenedForm.getAllObjectsAsList()) {
        if (persist instanceof ISupportExtendsID && PersistHelper.isOverrideOrphanElement((ISupportExtendsID) persist)) {
            // skip orphaned overrides
            continue;
        }
        if (persist instanceof IFormElement && persist instanceof AbstractBase) {
            String groupID = ((IFormElement) persist).getGroupID();
            if (groupID == null) {
                if (persist instanceof Portal && ((Portal) persist).isMobileInsetList()) {
                    // inset list
                    elements.add(((Portal) persist));
                } else // tabpanel: list elements or navtab
                if (((AbstractBase) persist).getCustomMobileProperty(IMobileProperties.HEADER_ITEM.propertyName) == null && ((AbstractBase) persist).getCustomMobileProperty(IMobileProperties.FOOTER_ITEM.propertyName) == null) {
                    // regular item
                    elements.add((ISupportBounds) (persist instanceof IFlattenedPersistWrapper ? ((IFlattenedPersistWrapper<?>) persist).getWrappedPersist() : persist));
                }
            } else if (groups.add(groupID)) {
                elements.add(new FormElementGroup(groupID, editingFlattenedSolution, FlattenedForm.getWrappedForm(flattenedForm)));
            }
        }
    }
    // sort by y-position
    Collections.sort(elements, PositionComparator.YX_BOUNDS_COMPARATOR);
    return elements;
}
Also used : ISupportExtendsID(com.servoy.j2db.persistence.ISupportExtendsID) FormElementGroup(com.servoy.j2db.persistence.FormElementGroup) ArrayList(java.util.ArrayList) AbstractBase(com.servoy.j2db.persistence.AbstractBase) ISupportBounds(com.servoy.j2db.persistence.ISupportBounds) IFormElement(com.servoy.j2db.persistence.IFormElement) IFlattenedPersistWrapper(com.servoy.j2db.persistence.IFlattenedPersistWrapper) IPersist(com.servoy.j2db.persistence.IPersist) Portal(com.servoy.j2db.persistence.Portal) JSPortal(com.servoy.j2db.scripting.solutionmodel.JSPortal) HashSet(java.util.HashSet)

Example 2 with IFlattenedPersistWrapper

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

the class PersistHelper method getSuperPersist.

public static IPersist getSuperPersist(final ISupportExtendsID persist) {
    if (persist instanceof IFlattenedPersistWrapper && ((IFlattenedPersistWrapper) persist).getWrappedPersist() instanceof Form) {
        return ((IFlattenedPersistWrapper<Form>) persist).getWrappedPersist().getExtendsForm();
    }
    if (persist instanceof Form) {
        return ((Form) persist).getExtendsForm();
    }
    final int extendsID = persist.getExtendsID();
    if (extendsID > 0) {
        try {
            Form form = (Form) ((AbstractBase) persist).getAncestor(IRepository.FORMS);
            if (form != null) {
                form = form.getExtendsForm();
                while (form != null) {
                    IPersist superPersist = form.getSuperPersist(extendsID);
                    // });
                    if (superPersist != null) {
                        return superPersist;
                    }
                    form = form.getExtendsForm();
                }
            }
        } finally {
        // System.err.println("getting super persist for " + persist.getID() + " extends: " + extendsID + " time " + (System.currentTimeMillis() - time));
        }
    }
    return null;
}
Also used : IFlattenedPersistWrapper(com.servoy.j2db.persistence.IFlattenedPersistWrapper) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) IPersist(com.servoy.j2db.persistence.IPersist) Point(java.awt.Point)

Example 3 with IFlattenedPersistWrapper

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

the class JSBaseContainer method getCorrectIJSParent.

/**
 * When creating a JSWebComponent from a who-knows-how-deeply-nested (in case of responsive forms) webComponent in a form and we only know the form,
 * then we need to get step by step the solution model objects in order to use the correct direct parent for the child SM object creation.
 *
 * @param startingContainer
 * @param possiblyNestedChild nested child component
 * @return the direct parent (IJSParent) of the given webComponent.
 */
private IJSParent<?> getCorrectIJSParent(JSBaseContainer<?> startingContainer, IPersist possiblyNestedChild) {
    ArrayList<ISupportChilds> parentHierarchy = new ArrayList<>();
    ISupportChilds parent = possiblyNestedChild.getParent();
    while (parent != (startingContainer.getContainer() instanceof IFlattenedPersistWrapper<?> ? ((IFlattenedPersistWrapper<?>) startingContainer.getContainer()).getWrappedPersist() : startingContainer.getContainer()) && !(parent instanceof Form)) {
        parentHierarchy.add(parent);
        parent = parent.getParent();
    }
    for (int i = parentHierarchy.size(); --i >= 0; ) {
        ISupportChilds container = parentHierarchy.get(i);
        if (container instanceof LayoutContainer) {
            startingContainer = application.getScriptEngine().getSolutionModifier().createLayoutContainer((IJSParent<?>) startingContainer, (LayoutContainer) container);
        } else {
            // $NON-NLS-1$
            throw new RuntimeException("unexpected parent: " + container);
        }
    }
    return startingContainer;
}
Also used : IFlattenedPersistWrapper(com.servoy.j2db.persistence.IFlattenedPersistWrapper) ISupportChilds(com.servoy.j2db.persistence.ISupportChilds) Form(com.servoy.j2db.persistence.Form) LayoutContainer(com.servoy.j2db.persistence.LayoutContainer) ArrayList(java.util.ArrayList) Point(java.awt.Point)

Aggregations

IFlattenedPersistWrapper (com.servoy.j2db.persistence.IFlattenedPersistWrapper)3 Form (com.servoy.j2db.persistence.Form)2 IPersist (com.servoy.j2db.persistence.IPersist)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 AbstractBase (com.servoy.j2db.persistence.AbstractBase)1 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)1 FormElementGroup (com.servoy.j2db.persistence.FormElementGroup)1 IFormElement (com.servoy.j2db.persistence.IFormElement)1 ISupportBounds (com.servoy.j2db.persistence.ISupportBounds)1 ISupportChilds (com.servoy.j2db.persistence.ISupportChilds)1 ISupportExtendsID (com.servoy.j2db.persistence.ISupportExtendsID)1 LayoutContainer (com.servoy.j2db.persistence.LayoutContainer)1 Portal (com.servoy.j2db.persistence.Portal)1 JSPortal (com.servoy.j2db.scripting.solutionmodel.JSPortal)1 HashSet (java.util.HashSet)1