use of com.servoy.j2db.persistence.FlattenedForm 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.FlattenedForm 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.FlattenedForm in project servoy-client by Servoy.
the class PersistHelper method getFlattenedPersist.
public static ISupportChilds getFlattenedPersist(FlattenedSolution flattenedSolution, Form parent, ISupportChilds persist) {
ISupportChilds flattenedPersist = persist;
if (flattenedPersist instanceof Form) {
flattenedPersist = flattenedSolution.getFlattenedForm(flattenedPersist);
}
if (flattenedPersist instanceof LayoutContainer && !(flattenedPersist instanceof FlattenedLayoutContainer)) {
FlattenedForm ff = flattenedSolution.getFlattenedForm(parent) instanceof FlattenedForm ? (FlattenedForm) flattenedSolution.getFlattenedForm(parent) : flattenedSolution.createFlattenedForm(parent);
flattenedPersist = new FlattenedLayoutContainer(ff, (LayoutContainer) flattenedPersist);
}
return flattenedPersist;
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class FormScope method hasInstance.
/*
* (non-Javadoc)
*
* @see com.servoy.j2db.scripting.DefaultScope#hasInstance(org.mozilla.javascript.Scriptable)
*/
@Override
public boolean hasInstance(Scriptable instance) {
if (instance instanceof FormScope) {
Form instanceForm = ((FormScope) instance).getFormController().getForm();
Form thisForm = getFormController().getForm();
if (thisForm.equals(instanceForm))
return true;
if (instanceForm instanceof FlattenedForm) {
if (thisForm instanceof FlattenedForm) {
thisForm = ((FlattenedForm) thisForm).getForm();
}
return ((FlattenedForm) instanceForm).getAllForms().contains(thisForm);
}
}
return false;
}
use of com.servoy.j2db.persistence.FlattenedForm in project servoy-client by Servoy.
the class FormLayoutGenerator method generateFormElementWrapper.
public static void generateFormElementWrapper(PrintWriter writer, FormElement fe, Form form, boolean isResponsive) {
String designId = getDesignId(fe);
String name = fe.getName();
boolean selectable = fe.isFormComponentChild() ? name.indexOf('$' + FormElement.SVY_NAME_PREFIX) == -1 : true;
if (designId != null) {
writer.print("<div ng-style=\"layout('");
writer.print(designId);
writer.print("')\"");
JSONObject ngClass = new JSONObject();
ngClass.put("invisible_element", "<getDesignFormControllerScope().model('" + designId + "').svyVisible == false<".toString());
// added <> tokens so that we can remove quotes around the values so that angular will evaluate at runtime
ngClass.put("highlight_element", "<getDesignFormControllerScope().highlightElement('" + designId + "') == true<".toString());
if (fe.isFormComponentChild()) {
ngClass.put("formComponentChild", true);
}
writer.print(" ng-class='" + ngClass.toString().replaceAll("\"<", "").replaceAll("<\"", "").replaceAll("'", "\"") + "'");
String cls = "svy-wrapper";
Form currentForm = form;
if (form instanceof FlattenedForm)
currentForm = ((FlattenedForm) form).getForm();
if (fe.getPersistIfAvailable() != null && Utils.isInheritedFormElement(fe.getPersistIfAvailable(), currentForm)) {
cls += !currentForm.equals(fe.getPersistIfAvailable().getAncestor(IRepository.FORMS)) ? " inherited_element" : " override_element";
}
writer.print(" class=\"" + cls + "\" ");
} else {
// calculations during link-phase based on the size of the parent container
if (fe.getPersistIfAvailable() != null && "servoycore-listformcomponent".equals(fe.getTypeName())) {
writer.print("<div svy-ng-style=\"layout.");
} else {
writer.print("<div ng-style=\"layout.");
}
writer.print(name);
writer.print("\" class=\"svy-wrapper\" ");
}
if (!isResponsive && fe.getPersistIfAvailable() instanceof BaseComponent) {
BaseComponent bc = (BaseComponent) fe.getPersistIfAvailable();
String style = "";
if (!form.getUseCssPosition().booleanValue() && !CSSPositionUtils.isInAbsoluteLayoutMode(bc)) {
int anchors = bc.getAnchors();
if (((anchors & IAnchorConstants.EAST) > 0) && ((anchors & IAnchorConstants.WEST) > 0)) {
style += "min-width:" + bc.getSize().width + "px;";
}
if (((anchors & IAnchorConstants.NORTH) > 0) && ((anchors & IAnchorConstants.SOUTH) > 0)) {
style += "min-height:" + bc.getSize().height + "px";
}
}
if (!style.isEmpty()) {
writer.print(" style='");
writer.print(style);
writer.print("'");
}
} else if (fe.getPersistIfAvailable() == null && "servoycore-portal".equals(fe.getTypeName()) && (form.getView() == IForm.LIST_VIEW || form.getView() == IFormConstants.VIEW_TYPE_LIST_LOCKED)) {
writer.print(" style='min-width:");
writer.print(form.getMinWidth());
writer.print("px'");
}
if (designId != null) {
writer.print(" svy-id='");
writer.print(designId);
writer.print("'");
if (!selectable) {
writer.print(" svy-non-selectable='noname'");
}
writer.print(" name='");
writer.print(name);
writer.print("'");
List<String>[] typeAndPropertyNames = fe.getSvyTypesAndPropertiesNames();
if (typeAndPropertyNames[0].size() > 0) {
writer.print(" svy-types='");
writer.print("[" + String.join(",", typeAndPropertyNames[0]) + "]");
writer.print("'");
}
String directEditPropertyName = getDirectEditProperty(fe);
if (directEditPropertyName != null) {
writer.print(" directEditPropertyName='");
writer.print(directEditPropertyName);
writer.print("'");
}
List<String> forbiddenComponentNames = fe.getForbiddenComponentNames();
if (forbiddenComponentNames.size() > 0) {
writer.print(" svy-forbidden-components='");
writer.print("[" + String.join(",", forbiddenComponentNames) + "]");
writer.print("'");
}
if (isNotSelectable(fe))
writer.print(" svy-non-selectable");
}
writer.print(">");
}
Aggregations