use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class FlattenedSolution method loadStyleForForm.
/**
* Load style for form, look for extend forms in flattenedSolution when possible
* @param flattenedSolution may be null, fallback to f.getSolution() plus repo load
* @param f
*/
public static Style loadStyleForForm(FlattenedSolution flattenedSolution, Form form) {
try {
String style_name = form.getStyleName();
if (!(form instanceof FlattenedForm)) {
Form extendedForm;
int extended_form_id = form.getExtendsID();
List<RootObjectReference> modulesMetaData = null;
// We keep track of visited forms, to avoid infinite loop.
Set<Integer> visited = new HashSet<Integer>();
while (style_name == null && extended_form_id > 0) {
visited.add(new Integer(extended_form_id));
// if this is hit here with a normal (not flattened form) that has an extend.
// and that form is a solution modal form. the f.getSolution() doesn't have to find it.
// because f.getSolution() is the copy solution thats inside the FlattenedSolution.
// that one doesn't have any other forms. But normally all forms should be flattened.
extendedForm = flattenedSolution == null ? form.getSolution().getForm(extended_form_id) : flattenedSolution.getForm(extended_form_id);
if (// check for module form
flattenedSolution == null && extendedForm == null) {
if (modulesMetaData == null) {
modulesMetaData = form.getSolution().getRepository().getActiveSolutionModuleMetaDatas(form.getSolution().getID());
}
for (RootObjectReference moduleMetaData : modulesMetaData) {
Solution module = (Solution) form.getSolution().getRepository().getActiveRootObject(moduleMetaData.getMetaData().getRootObjectId());
extendedForm = module.getForm(extended_form_id);
if (extendedForm != null) {
break;
}
}
}
if (extendedForm == null) {
// in case referring to no longer existing form
break;
}
style_name = extendedForm.getStyleName();
extended_form_id = extendedForm.getExtendsID();
if (visited.contains(new Integer(extended_form_id))) {
// in case of cycle in form inheritance hierarchy
break;
}
}
}
if (style_name == null)
return null;
// preload the style at the server
Style s = (Style) form.getSolution().getRepository().getActiveRootObject(style_name, IRepository.STYLES);
return s;
} catch (Exception e) {
Debug.error(e);
}
return null;
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class FlattenedSolution method formCanBeInstantiated.
/**
* Check whether a form can be instantiated.
*
* @param form
* @return
*/
public boolean formCanBeInstantiated(Form form) {
if (form != null) {
if (form.isResponsiveLayout())
return true;
// forms without parts are abstract
List<Form> formHierarchy = new ArrayList<Form>();
formHierarchy.add(form);
Form f = form;
while (true) {
Iterator<IPersist> allObjects = f.getAllObjects();
while (allObjects.hasNext()) {
if (allObjects.next() instanceof Part) {
return true;
}
}
if (form instanceof FlattenedForm || f.getExtendsID() <= 0) {
// no (more) hierarchy to investigate
break;
}
f = getForm(f.getExtendsID());
if (f == null || formHierarchy.contains(f)) /* prevent cycles */
{
break;
}
formHierarchy.add(f);
}
}
return false;
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class DebugHeadlessClient method performRefresh.
private void performRefresh(List<IPersist> changes) {
Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
refreshI18NMessages(true);
for (IFormController controller : scopesAndFormsToReload[0]) {
if (controller.getForm() instanceof FlattenedForm) {
FlattenedForm ff = (FlattenedForm) controller.getForm();
ff.reload();
}
controller.getFormScope().reload();
}
if (scopesAndFormsToReload[1].size() > 0)
((WebFormManager) getFormManager()).reload((scopesAndFormsToReload[1]).toArray(new FormController[0]));
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class DebugJ2DBClient method refreshPersistsNow.
private void refreshPersistsNow(Collection<IPersist> changes) {
if (shutDown)
return;
Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
for (IFormController controller : scopesAndFormsToReload[1]) {
destroyForm(controller);
}
for (IFormController controller : scopesAndFormsToReload[0]) {
if (controller.getForm() instanceof FlattenedForm) {
FlattenedForm ff = (FlattenedForm) controller.getForm();
ff.reload();
}
if (!controller.isDestroyed()) {
controller.getFormScope().reload();
}
}
}
Aggregations