use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class JSBaseContainer method getLastPosition.
private int getLastPosition() {
int position = 0;
Iterator<IPersist> components = getFlattenedContainer().getAllObjects();
while (components.hasNext()) {
IPersist component = components.next();
if (component instanceof ISupportBounds) {
Point location = ((ISupportBounds) component).getLocation();
if (location != null) {
if (location.x > position) {
position = location.x;
}
if (location.y > position) {
position = location.y;
}
}
}
}
return position + 1;
}
use of com.servoy.j2db.persistence.IPersist 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.IPersist 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.IPersist in project servoy-client by Servoy.
the class JSSecurity method js_getElementUUIDs.
/**
* Returns the form elements UUID's as dataset, the one with no name is the form itself.
*
* @sample var formElementsUUIDDataSet = security.getElementUUIDs('orders_form');
*
* @param formname the formname to retieve the dataset for
* @return dataset with element info
*/
public // return dataset with name, uuid (note: null name is form uuid)
JSDataSet js_getElementUUIDs(// return dataset with name, uuid (note: null name is form uuid)
String formname) {
Form f = application.getFlattenedSolution().getForm(formname);
if (f == null)
f = application.getFormManager().getPossibleForm(formname);
if (f != null) {
List elements = new ArrayList();
elements.add(new Object[] { null, f.getUUID() });
Iterator<? extends IPersist> it = f.isResponsiveLayout() ? f.getFlattenedObjects(NameComparator.INSTANCE).iterator() : f.getAllObjects();
while (it.hasNext()) {
IPersist elem = it.next();
int type = elem.getTypeID();
if (type == IRepository.GRAPHICALCOMPONENTS || type == IRepository.FIELDS || type == IRepository.PORTALS || type == IRepository.RECTSHAPES || type == IRepository.SHAPES || type == IRepository.BEANS || type == IRepository.TABPANELS || type == IRepository.WEBCOMPONENTS) {
if (elem instanceof ISupportName && ((ISupportName) elem).getName() != null) {
elements.add(new Object[] { ((ISupportName) elem).getName(), elem.getUUID() });
}
}
}
IDataSet set = new BufferedDataSet(new String[] { "name", "uuid" }, elements);
return new JSDataSet(application, set);
}
return new JSDataSet(application);
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class JSPortal method setX.
/**
* @see com.servoy.j2db.scripting.solutionmodel.JSComponent#setX(int)
*/
@Override
@JSSetter
public void setX(int x) {
int xDif = x - getX();
Iterator<IPersist> allObjects = getBaseComponent(true).getAllObjects();
while (allObjects.hasNext()) {
IPersist persist = allObjects.next();
if (persist instanceof BaseComponent) {
BaseComponent baseComponent = (BaseComponent) persist;
Point location = baseComponent.getLocation();
((BaseComponent) persist).setLocation(new Point(location.x + xDif, location.y));
}
}
super.setX(x);
}
Aggregations