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()]);
}
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;
}
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()]);
}
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;
}
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;
}
Aggregations