use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class DebugNGClient method refreshPersists.
@Override
public void refreshPersists(Collection<IPersist> changes) {
if (isShutDown())
return;
// flush the solution model cache of the form element helper when there is a solution copy.
// so that FormComponents are recreated with the latest data once.
Solution solutionCopy = getFlattenedSolution().getSolutionCopy(false);
if (solutionCopy != null)
solutionCopy.setRuntimeProperty(FormElementHelper.SOLUTION_MODEL_CACHE, null);
Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
for (IFormController controller : scopesAndFormsToReload[1]) {
if (controller.getForm() instanceof FlattenedForm) {
FlattenedForm ff = (FlattenedForm) controller.getForm();
ff.reload();
}
}
boolean forcePageReload = false;
if (scopesAndFormsToReload[1] == null || scopesAndFormsToReload[1].size() < 1) {
for (IPersist persist : changes) {
// that one, can also have other css included, using the 'import' statement
if (persist instanceof Media && !PersistHelper.getOrderedStyleSheets(getFlattenedSolution()).isEmpty()) {
String name = ((Media) persist).getName().toLowerCase();
if (name.endsWith(".less") || name.endsWith(".css")) {
forcePageReload = true;
break;
}
}
}
}
refreshForms(scopesAndFormsToReload[1], forcePageReload);
for (IFormController controller : scopesAndFormsToReload[0]) {
controller.getFormScope().reload();
}
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class DebugWebClient method performRefresh.
private void performRefresh(List<IPersist> changes) {
Set<IFormController>[] scopesAndFormsToReload = DebugUtils.getScopesAndFormsToReload(this, changes);
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 FlattenedSolution method getFlattenedForm.
public Form getFlattenedForm(IPersist persist, boolean useCached) {
if (mainSolution == null && loginFlattenedSolution != null) {
return loginFlattenedSolution.getFlattenedForm(persist, useCached);
}
if (persist == null || getSolution() == null) {
return null;
}
Form form = null;
if (persist instanceof FlattenedForm) {
form = ((FlattenedForm) persist).getForm();
} else {
form = (Form) persist.getAncestor(IRepository.FORMS);
}
if (form == null || form.getExtendsID() <= 0) {
// no form or nothing to flatten
return form;
}
// make sure is latest form
form = getForm(form.getID());
// form is already deleted?
if (form == null)
return null;
if (flattenedFormCache == null) {
// no caching
return createFlattenedForm(form);
}
// cache flattened form
FlattenedForm[] flattedFormRef;
synchronized (flattenedFormCache) {
flattedFormRef = flattenedFormCache.get(form);
if (flattedFormRef == null) {
flattenedFormCache.put(form, flattedFormRef = new FlattenedForm[] { null });
}
}
synchronized (flattedFormRef) {
if (flattedFormRef[0] == null || !useCached) {
flattedFormRef[0] = createFlattenedForm(form);
}
return flattedFormRef[0];
}
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class FlattenedSolution method flushFlattendFormCache.
public void flushFlattendFormCache(Form frm, boolean includingSubforms) {
if (flattenedFormCache == null || frm == null)
return;
Form form = frm;
if (frm instanceof FlattenedForm) {
form = ((FlattenedForm) frm).getForm();
}
flattenedFormCache.remove(form);
if (includingSubforms) {
Iterator<Form> formCacheIte = flattenedFormCache.keySet().iterator();
while (formCacheIte.hasNext()) {
if (FlattenedForm.hasFormInHierarchy(formCacheIte.next(), frm)) {
formCacheIte.remove();
}
}
}
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class FlattenedSolution method registerLiveForm.
/**
* @param form
*/
public void registerLiveForm(Form form, String namedInstance) {
synchronized (liveForms) {
if (form instanceof FlattenedForm) {
for (Form f : ((FlattenedForm) form).getAllForms()) {
registerLiveForm(f, namedInstance);
}
} else {
Set<String> instances = liveForms.get(form.getName());
if (instances == null) {
instances = new HashSet<String>();
liveForms.put(form.getName(), instances);
}
instances.add(namedInstance);
}
}
}
Aggregations