use of com.servoy.j2db.persistence.ISupportExtendsID in project servoy-client by Servoy.
the class PersistHelper method getOverrideHierarchy.
/**
* Get the override hierarchy of this element as list [self, super, super.super, ...]
*/
public static List<AbstractBase> getOverrideHierarchy(ISupportExtendsID persist) {
List<AbstractBase> overrideHierarchy = new ArrayList<AbstractBase>(3);
IPersist superPersist = persist;
while (superPersist instanceof ISupportExtendsID) {
overrideHierarchy.add((AbstractBase) superPersist);
superPersist = getSuperPersist((ISupportExtendsID) superPersist);
}
return overrideHierarchy;
}
use of com.servoy.j2db.persistence.ISupportExtendsID in project servoy-client by Servoy.
the class FormLayoutGenerator method generateFormElement.
// private static boolean canContainComponents(WebComponentSpecification spec)
// {
// Map<String, PropertyDescription> properties = spec.getProperties();
// for (PropertyDescription propertyDescription : properties.values())
// {
// String simpleTypeName = propertyDescription.getType().getName().replaceFirst(spec.getName() + ".", "");
// if (simpleTypeName.equals(ComponentPropertyType.TYPE_NAME)) return true;
// Object configObject = propertyDescription.getConfig();
// if (configObject != null)
// {
// try
// {
// if (configObject instanceof JSONObject && ((JSONObject)configObject).has(DesignerFilter.DROPPABLE))
// {
// Object droppable = ((JSONObject)configObject).get(DesignerFilter.DROPPABLE);
// if (droppable instanceof Boolean && (Boolean)droppable)
// {
// if (simpleTypeName.equals("tab")) return true;
// }
// }
// }
// catch (JSONException e)
// {
// Debug.log(e);
// }
// }
// }
// return false;
// }
public static void generateFormElement(PrintWriter writer, FormElement fe, Form form) {
IPersist fePersist = fe.getPersistIfAvailable();
String name = fe.getName();
boolean selectable = fe.isFormComponentChild() ? name.indexOf('$' + FormElement.SVY_NAME_PREFIX) == -1 : true;
writer.print("<");
writer.print(fe.getTagname());
writer.print(" name='");
writer.print(name);
writer.print("'");
if (Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.ngclient.testingMode", "false"))) {
String elementName = name;
if (elementName.startsWith("svy_") && fePersist != null) {
elementName = "svy_" + fePersist.getUUID().toString();
}
writer.print(" data-svy-name='");
writer.print(form.getName() + "." + elementName);
writer.print("'");
}
String designId = getDesignId(fe);
if (designId != null) {
if (form.isResponsiveLayout()) {
writer.print(" svy-id='");
writer.print(designId);
writer.print("'");
if (fePersist instanceof ISupportBounds) {
writer.print(" svy-location='");
writer.print(((ISupportBounds) fePersist).getLocation().x);
writer.print("'");
}
if (!selectable) {
writer.print(" svy-non-selectable='noname'");
}
writer.print(" svy-formelement-type='");
writer.print(fe.getTypeName());
writer.print("'");
JSONObject ngClass = new JSONObject();
List<String>[] typeAndPropertyNames = fe.getSvyTypesAndPropertiesNames();
if (typeAndPropertyNames[0].size() > 0) {
writer.print(" svy-types='");
writer.print("[" + String.join(",", typeAndPropertyNames[0]) + "]");
writer.print("'");
writer.print(" svy-types-properties='");
writer.print("[" + String.join(",", typeAndPropertyNames[1]) + "]");
writer.print("'");
ngClass.put("drop_highlight", "<canContainDraggedElement('" + fe.getTypeName() + "',['" + String.join("','", typeAndPropertyNames[0]) + "'])<");
}
List<String> forbiddenComponentNames = fe.getForbiddenComponentNames();
if (forbiddenComponentNames.size() > 0) {
writer.print(" svy-forbidden-components='");
writer.print("[" + String.join(",", forbiddenComponentNames) + "]");
writer.print("'");
}
String directEditPropertyName = getDirectEditProperty(fe);
if (directEditPropertyName != null) {
writer.print(" directEditPropertyName='");
writer.print(directEditPropertyName);
writer.print("'");
}
if (// is this inherited or override element?
!fe.getForm().equals(form) || fePersist instanceof ISupportExtendsID && PersistHelper.getSuperPersist((ISupportExtendsID) fePersist) != null) {
ngClass.put("inheritedElement", true);
}
if (fe.isFormComponentChild()) {
ngClass.put("formComponentChild", true);
}
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_child_element", "<design_highlight=='highlight_element'<".toString());
writer.print(" ng-class='" + ngClass.toString().replaceAll("\"<", "").replaceAll("<\"", "").replaceAll("'", "\"") + "'");
}
writer.print(" svy-model=\"model('");
writer.print(designId);
writer.print("')\"");
writer.print(" svy-api=\"api('");
writer.print(designId);
writer.print("')\"");
writer.print(" svy-handlers=\"handlers('");
writer.print(designId);
writer.print("')\"");
writer.print(" svy-servoyApi=\"servoyApi('");
writer.print(designId);
writer.print("')\"");
if (fePersist instanceof IFormElement) {
writer.print(" form-index=" + ((IFormElement) fePersist).getFormIndex() + "");
}
} else {
writer.print(" svy-model='model.");
writer.print(name);
writer.print("'");
writer.print(" svy-api='api.");
writer.print(name);
writer.print("'");
writer.print(" svy-handlers='handlers.");
writer.print(name);
writer.print("'");
writer.print(" svy-servoyApi='handlers.");
writer.print(name);
writer.print(".svy_servoyApi'");
}
writer.print(">");
writer.print("</");
writer.print(fe.getTagname());
writer.print(">");
}
use of com.servoy.j2db.persistence.ISupportExtendsID in project servoy-client by Servoy.
the class FormElement method convertDesignToFormElementValueAndPut.
/**
* Applies 'Conversion 1' (see {@link NGConversions}) to one property value - from design to FormElement value and then puts the value in the given formElementValues map.
*/
protected void convertDesignToFormElementValueAndPut(FlattenedSolution fs, PropertyDescription pd, Map<String, Object> formElementValues, String key, Object value, PropertyPath propertyPath) {
// is it a property
if (pd != null) {
propertyPath.add(key);
// value has the 'merged' value in hierarchy, except for the 'formcomponent' property; do the merge here
if ((pd.getType() instanceof FormComponentPropertyType) && value instanceof JSONObject && getPersistIfAvailable() instanceof ISupportExtendsID) {
// this is a json object, look for super persist for this property to get those values.
List<AbstractBase> hierarchy = PersistHelper.getOverrideHierarchy((ISupportExtendsID) getPersistIfAvailable());
if (hierarchy.size() > 1) {
// there is a super element (or more) so make a copy and copy everything in that.
JSONObject mergedValue = null;
for (int i = hierarchy.size(); --i >= 0; ) {
Object property = hierarchy.get(i).getProperty(key);
if (property instanceof JSONObject) {
if (mergedValue == null) {
mergedValue = new JSONObject();
}
ServoyJSONObject.mergeAndDeepCloneJSON((JSONObject) property, mergedValue);
} else if (property != null) {
mergedValue = null;
break;
}
}
if (mergedValue != null) {
value = mergedValue;
}
}
}
Object convertedValue = NGConversions.INSTANCE.convertDesignToFormElementValue(value, pd, fs, this, propertyPath);
formElementValues.put(key, convertedValue);
propertyPath.backOneLevel();
} else if (StaticContentSpecLoader.PROPERTY_NAME.getPropertyName().equals(key)) {
formElementValues.put(key, value);
}
}
Aggregations