use of com.servoy.j2db.persistence.AbstractContainer in project servoy-client by Servoy.
the class JSBaseContainer method getWebComponents.
/**
* Returns all JSWebComponents of this form/container.
* If this method is called on a form, then it will return all web components on that form.
* If the form is responsive, it will return the web components from all the containers.
*
* @sample
* var webComponents = myForm.getWebComponents(false);
* for (var i in webComponents)
* {
* if (webComponents[i].name != null)
* application.output(webComponents[i].name);
* }
*
* @param returnInheritedElements boolean true to also return the elements from parent form
* @return the list of all JSWebComponents on this forms
*/
@ServoyClientSupport(mc = false, ng = true, wc = false, sc = false)
@JSFunction
public JSWebComponent[] getWebComponents(boolean returnInheritedElements) {
List<JSWebComponent> webComponents = new ArrayList<JSWebComponent>();
AbstractContainer form2use = returnInheritedElements ? getFlattenedContainer() : getContainer();
Iterator<WebComponent> iterator = form2use.getWebComponents();
while (iterator.hasNext()) {
WebComponent webComponent = iterator.next();
webComponents.add(createWebComponent(getCorrectIJSParent(this, webComponent), webComponent, application, false));
}
return webComponents.toArray(new JSWebComponent[webComponents.size()]);
}
use of com.servoy.j2db.persistence.AbstractContainer in project servoy-client by Servoy.
the class JSBaseContainer method getLayoutContainers.
/**
* Returns all JSLayoutContainers objects of this container
*
* @sample
* var frm = solutionModel.getForm("myForm");
* var containers = frm.getLayoutContainers();
* for (var c in containers)
* {
* var fname = containers[c].name;
* application.output(fname);
* }
*
* @param returnInheritedElements boolean true to also return the elements from parent form
* @return all JSLayoutContainers objects of this container
*/
@ServoyClientSupport(mc = false, ng = true, wc = false, sc = false)
@JSFunction
public JSLayoutContainer[] getLayoutContainers(boolean returnInheritedElements) {
List<JSLayoutContainer> containers = new ArrayList<JSLayoutContainer>();
AbstractContainer container = returnInheritedElements ? getFlattenedContainer() : getContainer();
Iterator<LayoutContainer> iterator = container.getLayoutContainers();
while (iterator.hasNext()) {
containers.add(application.getScriptEngine().getSolutionModifier().createLayoutContainer(this, iterator.next()));
}
return containers.toArray(new JSLayoutContainer[containers.size()]);
}
use of com.servoy.j2db.persistence.AbstractContainer in project servoy-client by Servoy.
the class CSSPositionPropertyType method toJSON.
private JSONWriter toJSON(JSONWriter writer, String key, CSSPosition object, PropertyDescription pd, DataConversion clientConversion, FormElement formElement, FlattenedSolution fs, Form context) throws JSONException {
JSONUtils.addKeyIfPresent(writer, key);
writer.object();
if (object != null) {
writer.key("position").value("absolute");
String top = object.top;
String bottom = object.bottom;
if (formElement != null && fs != null && context != null && !formElement.isInDesigner()) {
// adjust the top for parts.
IPersist persist = formElement.getPersistIfAvailable();
if (persist instanceof BaseComponent) {
AbstractContainer parentContainer = CSSPositionUtils.getParentContainer((BaseComponent) persist);
Point location = CSSPositionUtils.getLocation(object, parentContainer.getSize());
Form form = fs.getFlattenedForm(context);
Part part = form.getPartAt(location.y);
if (part != null) {
if (isSet(top)) {
int topStart = form.getPartStartYPos(part.getID());
if (topStart > 0) {
if (top.endsWith("px")) {
top = top.substring(0, top.length() - 2);
}
int topInteger = Utils.getAsInteger(top, -1);
if (topInteger != -1) {
top = String.valueOf(topInteger - topStart);
} else {
top = "calc(" + top + " - " + topStart + "px)";
}
}
}
if (isSet(bottom)) {
int extraHeight = form.getSize().height - part.getHeight();
if (extraHeight > 0) {
if (bottom.endsWith("px")) {
bottom = bottom.substring(0, bottom.length() - 2);
}
int bottomInteger = Utils.getAsInteger(bottom, -1);
if (bottomInteger != -1) {
bottom = String.valueOf(bottomInteger - extraHeight);
} else {
bottom = "calc(" + bottom + " - " + extraHeight + "px)";
}
}
}
}
}
}
if (isSet(top))
writer.key("top").value(addPixels(top));
if (isSet(object.left))
writer.key("left").value(addPixels(object.left));
if (isSet(bottom))
writer.key("bottom").value(addPixels(bottom));
if (isSet(object.right))
writer.key("right").value(addPixels(object.right));
if (isSet(object.height)) {
if (isSet(top) && isSet(object.bottom)) {
writer.key("min-height").value(addPixels(object.height));
} else
writer.key("height").value(addPixels(object.height));
}
if (isSet(object.width)) {
if (isSet(object.left) && isSet(object.right)) {
writer.key("min-width").value(addPixels(object.width));
} else
writer.key("width").value(addPixels(object.width));
}
}
writer.endObject();
return writer;
}
Aggregations