use of com.servoy.j2db.persistence.Form 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.Form 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);
}
}
}
use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class FlattenedSolution method deregisterLiveForm.
/**
* @param form
* @param namedInstance
*/
public void deregisterLiveForm(Form form, String namedInstance) {
synchronized (liveForms) {
if (form instanceof FlattenedForm) {
for (Form f : ((FlattenedForm) form).getAllForms()) {
deregisterLiveForm(f, namedInstance);
}
} else {
flushFlattendFormCache(form);
Set<String> instances = liveForms.get(form.getName());
if (instances != null) {
instances.remove(namedInstance);
if (instances.size() == 0) {
liveForms.remove(form.getName());
}
}
}
// Test forms if they now are ok. (form they build on when they where changed is now destroyed)
ChangedFormData changedFormData = changedForms.get(form.getName());
if (changedFormData != null) {
changedFormData.instances.remove(namedInstance);
if (changedFormData.instances.size() == 0) {
changedForms.remove(form.getName());
}
}
}
}
use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class FlattenedSolution method createFlattenedForm.
/*
* Create a flattened form for the form that is child of the current solution.
*/
public FlattenedForm createFlattenedForm(Form form) {
Form myForm;
Solution solcopy = getSolutionCopy(false);
if (form.getParent() == getSolution() || form.getParent() == solcopy) {
myForm = form;
} else {
myForm = null;
if (solcopy != null) {
myForm = (Form) solcopy.getChild(form.getUUID());
}
if (myForm == null) {
myForm = (Form) getSolution().getChild(form.getUUID());
}
if (myForm == null && modules != null) {
for (Solution mod : modules) {
myForm = (Form) mod.getChild(form.getUUID());
if (myForm != null)
break;
}
}
if (myForm == null) {
throw new RuntimeException("Cannot find form '" + form + "' in solution '" + getSolution() + "'");
}
}
try {
return new FlattenedForm(this, myForm);
} catch (RuntimeException ex) {
Debug.error("Error while creating full hierarchy form (flattened form) for: " + (myForm != null ? myForm.getName() : "<form not found>"), ex);
throw ex;
}
}
use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class FlattenedSolution method revertForm.
public Form revertForm(String name) {
Form form = getForm(name);
if (form == null) {
// then revert the remove/delete
for (IPersist persist : getIndex().getRemoved()) {
if (persist instanceof Form && name.equals(((Form) persist).getName())) {
getIndex().removeRemoved(persist);
flush(persist);
form = getForm(name);
break;
}
}
}
if (form != null) {
deletePersistCopy(form, true);
form = getForm(name);
if (form != null)
registerChangedForm(form);
}
return form;
}
Aggregations