use of com.servoy.j2db.persistence.ISupportExtendsID 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.ISupportExtendsID in project servoy-client by Servoy.
the class JSBase method getOverridePersistIfNeeded.
public static AbstractBase getOverridePersistIfNeeded(AbstractBase persist, AbstractBase finalPersist, IJSParent parent) {
AbstractBase baseComponent = finalPersist;
if (persist != null && persist.getAncestor(IRepository.FORMS) != null) {
IJSParent<?> jsparent = parent;
while (jsparent != null) {
if (jsparent.getSupportChild() instanceof Form)
break;
jsparent = jsparent.getJSParent();
}
if (jsparent != null && jsparent.getSupportChild() instanceof Form && !jsparent.getSupportChild().getUUID().equals(persist.getAncestor(IRepository.FORMS).getUUID())) {
// inherited persist
try {
IPersist parentPersist = persist;
while (PersistHelper.getSuperPersist((ISupportExtendsID) parentPersist) != null) {
parentPersist = PersistHelper.getSuperPersist((ISupportExtendsID) parentPersist);
}
// first check if the override persist already exists, and return it in that case
List<IPersist> children = PersistHelper.getHierarchyChildren((AbstractBase) parent.getSupportChild());
IPersist form = parent.getSupportChild() instanceof Form ? parent.getSupportChild() : parent.getSupportChild().getAncestor(IRepository.FORMS);
if (form != null) {
for (IPersist p : children) {
if (parentPersist.getID() == ((ISupportExtendsID) p).getExtendsID() && form.equals(p.getAncestor(IRepository.FORMS))) {
return (AbstractBase) p;
}
}
} else {
// should not happen
Debug.error("Cannot find form of persist " + parent.getSupportChild());
}
baseComponent = (AbstractBase) persist.cloneObj(parent.getSupportChild(), false, null, false, false, false);
baseComponent.copyPropertiesMap(null, true);
((ISupportExtendsID) baseComponent).setExtendsID(parentPersist.getID());
} catch (Exception ex) {
Debug.error(ex);
}
}
}
return baseComponent;
}
use of com.servoy.j2db.persistence.ISupportExtendsID in project servoy-client by Servoy.
the class PersistHelper method getHierarchyChildren.
public static List<IPersist> getHierarchyChildren(AbstractBase parent) {
if (parent instanceof ISupportExtendsID) {
List<IPersist> children = new ArrayList<IPersist>();
List<AbstractBase> parentHierarchy = new ArrayList<AbstractBase>();
List<Integer> existingIDs = new ArrayList<Integer>();
AbstractBase element = parent;
while (element != null && !parentHierarchy.contains(element)) {
parentHierarchy.add(element);
element = (AbstractBase) PersistHelper.getSuperPersist((ISupportExtendsID) element);
}
for (AbstractBase temp : parentHierarchy) {
for (IPersist child : temp.getAllObjectsAsList()) {
if (!(child instanceof ISupportExtendsID))
continue;
Integer extendsID = new Integer(((ISupportExtendsID) child).getExtendsID());
if (!existingIDs.contains(new Integer(child.getID())) && !existingIDs.contains(extendsID)) {
if (PersistHelper.isOverrideOrphanElement((ISupportExtendsID) child)) {
// some deleted element
continue;
}
existingIDs.add(child.getID());
children.add(child);
}
if (extendsID.intValue() > 0 && !existingIDs.contains(extendsID)) {
existingIDs.add(extendsID);
}
}
}
return children;
} else {
return parent.getAllObjectsAsList();
}
}
use of com.servoy.j2db.persistence.ISupportExtendsID in project servoy-client by Servoy.
the class PersistHelper method hasOverrideChildren.
/**
* Example if a superform has a tabPanel with a tab, and a derived form adds another tab to the tabpannel then hasOverrideChildren(derivedTabPanel) returns true
*/
public static boolean hasOverrideChildren(IPersist persist) {
if (persist instanceof ISupportChilds && persist instanceof ISupportExtendsID) {
ISupportChilds p = (ISupportChilds) persist;
ISupportChilds superPersist = (ISupportChilds) PersistHelper.getSuperPersist((ISupportExtendsID) persist);
if (superPersist == null) {
return false;
}
for (IPersist child : Utils.iterate(p.getAllObjects())) {
if (child instanceof ISupportExtendsID && !PersistHelper.isOverrideElement((ISupportExtendsID) child)) {
// is is an etra child element compared to it's super child elements
return true;
} else if (((AbstractBase) child).hasOverrideProperties()) {
return true;
}
}
}
return false;
}
use of com.servoy.j2db.persistence.ISupportExtendsID in project servoy-client by Servoy.
the class PersistHelper method getBasePersist.
/**
* Get highest super persist.
*
* @param persist
* @return
*/
public static IPersist getBasePersist(ISupportExtendsID persist) {
ISupportExtendsID p = persist;
while (true) {
ISupportExtendsID superp = (ISupportExtendsID) PersistHelper.getSuperPersist(p);
if (superp == null) {
return p;
}
p = superp;
}
}
Aggregations