Search in sources :

Example 11 with Part

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

the class JSForm method getPartsInternal.

private JSPart[] getPartsInternal(int partType) {
    ArrayList<JSPart> lst = new ArrayList<JSPart>();
    Iterator<Part> parts = getForm().getParts();
    while (parts.hasNext()) {
        Part part = parts.next();
        if (part.getPartType() == partType) {
            lst.add(JSPart.createPart(this, part, false));
        }
    }
    return lst.toArray(new JSPart[lst.size()]);
}
Also used : Part(com.servoy.j2db.persistence.Part) ArrayList(java.util.ArrayList)

Example 12 with Part

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

the class JSForm method getPartYOffset.

/**
 * Returns the Y offset of a given part (see JSPart) of the form. This will include
 * all the super forms parts if this form extends a form. Use the height parameter for
 * targetting one of multiple subsummary parts.
 *
 * @sample
 * // get the subform
 * var form = solutionModel.getForm('SubForm');
 * // get the start offset of the body
 * var height = form.getPartYOffset(JSPart.BODY);
 * // place a new button based on the start offset.
 * form.newButton('mybutton',50,50+height,80,20,solutionModel.getGlobalMethod('globals', 'test'));
 *
 * @param type The type of the part whose Y offset will be returned.
 *
 * @param height The height of the part whose Y offset will be returned. This is used when
 *                        one of multiple Leading/Trailing Sumsummary parts is retrieved.
 *
 * @return A number holding the Y offset of the specified form part.
 */
@JSFunction
public int getPartYOffset(int type, int height) {
    Form ff = application.getFlattenedSolution().getFlattenedForm(getForm(), false);
    Iterator<Part> parts = ff.getParts();
    while (parts.hasNext()) {
        Part part = parts.next();
        if (part.getPartType() == type && (height == -1 || part.getHeight() == height)) {
            return ff.getPartStartYPos(part.getID());
        }
    }
    return -1;
}
Also used : Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IMobileSMForm(com.servoy.base.solutionmodel.mobile.IMobileSMForm) Part(com.servoy.j2db.persistence.Part) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 13 with Part

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

the class JSForm method getParts.

/**
 * Gets all the parts from the form (optionally also from the parent form), ordered by there height (lowerbound) property, from top == 0 to bottom.
 *
 * @sample
 * var allParts = form.getParts()
 * for (var i=0; i<allParts.length; i++) {
 *	if (allParts[i].getPartType() == JSPart.BODY)
 *		application.output('body Y offset: ' + allParts[i].getPartYOffset());
 * }
 *
 * @param returnInheritedElements boolean true to also return the parts from parent form
 * @return An array of JSPart instances corresponding to the parts of the form.
 */
@JSFunction
public JSPart[] getParts(boolean returnInheritedElements) {
    List<JSPart> lst = new ArrayList<JSPart>();
    Form form2use = returnInheritedElements ? getFlattenedContainer() : getForm();
    Iterator<Part> parts = form2use.getParts();
    while (parts.hasNext()) {
        lst.add(JSPart.createPart(this, parts.next(), false));
    }
    return lst.toArray(new JSPart[lst.size()]);
}
Also used : Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IMobileSMForm(com.servoy.base.solutionmodel.mobile.IMobileSMForm) Part(com.servoy.j2db.persistence.Part) ArrayList(java.util.ArrayList) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 14 with Part

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

the class JSForm method removePart.

/**
 * Removes a JSPart of the given type. The height parameter is for removing one of multiple subsummary parts.
 *
 * @sample
 * form.removePart(JSPart.HEADER);
 * form.removePart(JSPart.LEADING_SUBSUMMARY, 160);
 *
 * @param type The type of the part that should be removed.
 *
 * @param height The height of the part that should be removed. This parameter is for
 * 					removing one of multiple Leading/Trailing Subsummary parts.
 *
 * @return True if the part is successfully removed, false otherwise.
 */
@JSFunction
public boolean removePart(int type, int height) {
    checkModification();
    Iterator<Part> parts = getForm().getParts();
    while (parts.hasNext()) {
        Part part = parts.next();
        if (part.getPartType() == type && (height == -1 || part.getHeight() == height)) {
            getForm().removeChild(part);
            return true;
        }
    }
    return false;
}
Also used : Part(com.servoy.j2db.persistence.Part) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 15 with Part

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

the class JSForm method removePart.

private boolean removePart(boolean header) {
    checkModification();
    Iterator<Part> parts = getForm().getParts();
    while (parts.hasNext()) {
        Part part = parts.next();
        if ((header && PersistUtils.isHeaderPart(part.getPartType())) || (!header && PersistUtils.isFooterPart(part.getPartType()))) {
            getForm().removeChild(part);
            return true;
        }
    }
    return false;
}
Also used : Part(com.servoy.j2db.persistence.Part)

Aggregations

Part (com.servoy.j2db.persistence.Part)36 Point (java.awt.Point)17 Form (com.servoy.j2db.persistence.Form)14 IPersist (com.servoy.j2db.persistence.IPersist)9 IFormElement (com.servoy.j2db.persistence.IFormElement)8 Dimension (java.awt.Dimension)8 ArrayList (java.util.ArrayList)8 BaseComponent (com.servoy.j2db.persistence.BaseComponent)7 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)6 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)6 IStyleRule (com.servoy.j2db.util.IStyleRule)5 IStyleSheet (com.servoy.j2db.util.IStyleSheet)5 FormController (com.servoy.j2db.FormController)4 IForm (com.servoy.j2db.IForm)4 Color (java.awt.Color)4 Portal (com.servoy.j2db.persistence.Portal)3 IComponent (com.servoy.j2db.ui.IComponent)3 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3