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;
}
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;
}
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;
}
Aggregations