use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class JSSolutionModel method getForm.
/**
* Gets the specified form object and returns information about the form (see JSForm node).
*
* @sample
* var myForm = solutionModel.getForm('existingFormName');
* //get the style of the form (for all other properties see JSForm node)
* var styleName = myForm.styleName;
*
* @param name the specified name of the form
*
* @return a JSForm
*/
@JSFunction
public JSForm getForm(String name) {
if (name == null)
return null;
Form form = application.getFormManager().getPossibleForm(name);
if (form == null) {
FlattenedSolution fs = application.getFlattenedSolution();
form = fs.getForm(name);
if (form == null) {
// search ignoring case
Iterator<Form> forms = fs.getForms(false);
String lowerCaseName = Utils.toEnglishLocaleLowerCase(name);
Form f;
while (forms.hasNext() && form == null) {
f = forms.next();
if (Utils.toEnglishLocaleLowerCase(f.getName()).equals(lowerCaseName))
form = f;
}
}
}
if (form != null) {
return instantiateForm(form, false);
}
return null;
}
use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class JSSolutionModel method revertForm.
/**
* Reverts the specified form to the original (blueprint) version of the form; will result in an exception error if the form is not an original form.
*
* NOTE: Make sure you call history.remove first in your Servoy method (script) or call form.controller.recreateUI() before the script ends.
*
* @sample
* // revert the form to the original solution form, removing any changes done to it through the solution model.
* var revertedForm = solutionModel.revertForm('myForm')
* // add a label on a random place.
* revertedForm.newLabel("MyLabel",Math.random()*100,Math.random()*100,80,20);
* // make sure that the ui is up to date.
* forms.myForm.controller.recreateUI();
*
* @param name the specified name of the form to revert
*
* @return a JSForm object
*/
@JSFunction
public JSForm revertForm(String name) {
FlattenedSolution fs = application.getFlattenedSolution();
Form form = fs.revertForm(name);
if (form != null) {
application.getFormManager().addForm(form, false);
return instantiateForm(form, false);
} else {
form = application.getFormManager().getPossibleForm(name);
if (form != null) {
application.getFormManager().removeForm(form);
}
}
return null;
}
use of com.servoy.j2db.persistence.Form 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;
}
use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class RuntimeWindow method showObject.
public void showObject(Object form) throws ServoyException {
String f = null;
if (form instanceof BasicFormController) {
f = ((BasicFormController) form).getName();
} else if (form instanceof FormScope) {
f = ((FormScope) form).getFormController().getName();
} else if (form instanceof FormController.JSForm) {
f = ((FormController.JSForm) form).getFormPanel().getName();
} else if (form instanceof String) {
f = (String) form;
} else if (form instanceof JSForm) {
f = ((JSForm) form).getName();
}
if (f != null) {
Form frm = application.getFlattenedSolution().getForm(f);
IBasicFormManager fm = application.getFormManager();
if (frm == null && fm.isPossibleForm(f))
frm = fm.getPossibleForm(f);
if (!application.getFlattenedSolution().formCanBeInstantiated(frm)) {
// abstract form
throw new ApplicationException(ServoyException.ABSTRACT_FORM, new Object[] { f });
}
show(f);
}
}
use of com.servoy.j2db.persistence.Form 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()]);
}
Aggregations