Search in sources :

Example 46 with IPersist

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

the class JSPortal method setY.

/**
 * @see com.servoy.j2db.scripting.solutionmodel.JSComponent#setY(int)
 */
@Override
@JSSetter
public void setY(int y) {
    int yDif = y - getY();
    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, location.y + yDif));
        }
    }
    super.setY(y);
}
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)

Example 47 with IPersist

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

the class JSSolutionModel method getParentContainer.

private IJSParent<?> getParentContainer(IPersist persist) {
    IJSParent<?> parent = null;
    List<AbstractContainer> parentHierarchy = new ArrayList<AbstractContainer>();
    IPersist currentParent = persist.getParent();
    while (currentParent != null) {
        if (currentParent instanceof AbstractContainer) {
            parentHierarchy.add(0, (AbstractContainer) currentParent);
        }
        if (currentParent instanceof Form)
            break;
        currentParent = currentParent.getParent();
    }
    for (AbstractContainer container : parentHierarchy) {
        if (container instanceof LayoutContainer) {
            parent = new JSLayoutContainer(parent, application, (LayoutContainer) persist);
        }
        if (container instanceof Form) {
            parent = instantiateForm((Form) container, false);
        }
    }
    return parent;
}
Also used : AbstractContainer(com.servoy.j2db.persistence.AbstractContainer) IPersist(com.servoy.j2db.persistence.IPersist) Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IBaseSMForm(com.servoy.base.solutionmodel.IBaseSMForm) LayoutContainer(com.servoy.j2db.persistence.LayoutContainer) ArrayList(java.util.ArrayList)

Example 48 with IPersist

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

the class JSTabPanel method getTabs.

/**
 * Returns an array of JSTab instances holding the tabs of the tab panel.
 *
 * @sample
 * var tabPanel = form.newTabPanel('tabs', 10, 10, 620, 460);
 * tabPanel.newTab('tab1', 'Child Two', childOne);
 * tabPanel.newTab('tab2', 'Child Two', childTwo);
 * var tabs = tabPanel.getTabs();
 * for (var i=0; i<tabs.length; i++)
 * 	application.output("Tab " + i + " has text " + tabs[i].text);
 *
 * @return An array of JSTab instances representing all tabs of this tabpanel.
 */
@JSFunction
public JSTab[] getTabs() {
    ArrayList<JSTab> labels = new ArrayList<JSTab>();
    Iterator<IPersist> tabs = getBaseComponent(false).getTabs();
    while (tabs.hasNext()) {
        Tab tab = (Tab) tabs.next();
        labels.add(new JSTab(this, tab, application, false));
    }
    return labels.toArray(new JSTab[labels.size()]);
}
Also used : Tab(com.servoy.j2db.persistence.Tab) IPersist(com.servoy.j2db.persistence.IPersist) ArrayList(java.util.ArrayList) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 49 with IPersist

use of com.servoy.j2db.persistence.IPersist 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;
}
Also used : ISupportChilds(com.servoy.j2db.persistence.ISupportChilds) ISupportExtendsID(com.servoy.j2db.persistence.ISupportExtendsID) IPersist(com.servoy.j2db.persistence.IPersist)

Example 50 with IPersist

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

the class PersistHelper method getOverrideHierarchy.

/**
 * Get the override hierarchy of this element as list [self, super, super.super, ...]
 */
public static List<AbstractBase> getOverrideHierarchy(ISupportExtendsID persist) {
    List<AbstractBase> overrideHierarchy = new ArrayList<AbstractBase>(3);
    IPersist superPersist = persist;
    while (superPersist instanceof ISupportExtendsID) {
        overrideHierarchy.add((AbstractBase) superPersist);
        superPersist = getSuperPersist((ISupportExtendsID) superPersist);
    }
    return overrideHierarchy;
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) ISupportExtendsID(com.servoy.j2db.persistence.ISupportExtendsID) AbstractBase(com.servoy.j2db.persistence.AbstractBase) ArrayList(java.util.ArrayList)

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