Search in sources :

Example 41 with IPersist

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;
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) ISupportBounds(com.servoy.j2db.persistence.ISupportBounds) Point(java.awt.Point) Point(java.awt.Point)

Example 42 with IPersist

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();
    }
}
Also used : ISupportExtendsID(com.servoy.j2db.persistence.ISupportExtendsID) IPersist(com.servoy.j2db.persistence.IPersist) ArrayList(java.util.ArrayList) AbstractBase(com.servoy.j2db.persistence.AbstractBase)

Example 43 with IPersist

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;
}
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 44 with IPersist

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);
}
Also used : BufferedDataSet(com.servoy.j2db.dataprocessing.BufferedDataSet) Form(com.servoy.j2db.persistence.Form) IPersist(com.servoy.j2db.persistence.IPersist) ISupportName(com.servoy.j2db.persistence.ISupportName) ArrayList(java.util.ArrayList) JSDataSet(com.servoy.j2db.dataprocessing.JSDataSet) ArrayList(java.util.ArrayList) List(java.util.List) IDataSet(com.servoy.j2db.dataprocessing.IDataSet)

Example 45 with IPersist

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);
}
Also used : BaseComponent(com.servoy.j2db.persistence.BaseComponent) IPersist(com.servoy.j2db.persistence.IPersist) Point(java.awt.Point) Point(java.awt.Point) JSSetter(org.mozilla.javascript.annotations.JSSetter)

Aggregations

IPersist (com.servoy.j2db.persistence.IPersist)84 Point (java.awt.Point)26 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)23 Form (com.servoy.j2db.persistence.Form)22 ArrayList (java.util.ArrayList)22 IFormElement (com.servoy.j2db.persistence.IFormElement)20 BaseComponent (com.servoy.j2db.persistence.BaseComponent)19 HashMap (java.util.HashMap)16 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)14 IComponent (com.servoy.j2db.ui.IComponent)13 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)13 Component (org.apache.wicket.Component)13 AbstractBase (com.servoy.j2db.persistence.AbstractBase)12 JSONObject (org.json.JSONObject)10 PropertyDescription (org.sablo.specification.PropertyDescription)10 RepositoryException (com.servoy.j2db.persistence.RepositoryException)8 Tab (com.servoy.j2db.persistence.Tab)8 IPortalComponent (com.servoy.j2db.ui.IPortalComponent)8 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)7 ISupportAnchors (com.servoy.j2db.persistence.ISupportAnchors)7