use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class JSPortal method setY.
/**
* @see com.servoy.j2db.scripting.solutionmodel.JSComponent#setY(int)
*/
@Override
@JSSetter
public void setY(int y) {
int yDif = y - getY();
Iterator<IPersist> allObjects = getBaseComponent(true).getAllObjects();
while (allObjects.hasNext()) {
IPersist persist = allObjects.next();
if (persist instanceof BaseComponent) {
BaseComponent baseComponent = (BaseComponent) persist;
Point location = baseComponent.getLocation();
((BaseComponent) persist).setLocation(new Point(location.x, location.y + yDif));
}
}
super.setY(y);
}
use of com.servoy.j2db.persistence.BaseComponent 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(">");
}
use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class FormWrapper method getBodyComponents.
public Collection<BaseComponent> getBodyComponents() {
Part part = getBodyPart();
List<BaseComponent> baseComponents = new ArrayList<>();
if (part == null)
return baseComponents;
int startPos = form.getPartStartYPos(part.getID());
int endPos = part.getHeight();
List<IFormElement> persists = form.getFlattenedObjects(PositionComparator.XY_PERSIST_COMPARATOR);
for (IFormElement persist : persists) {
if (persist instanceof GraphicalComponent && isTableView && ((GraphicalComponent) persist).getLabelFor() != null)
continue;
Point location = CSSPositionUtils.getLocation(persist);
if (startPos <= location.y && endPos > location.y) {
if (isSecurityVisible(persist))
baseComponents.add((BaseComponent) persist);
}
}
return baseComponents;
}
use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class PartWrapper method getBaseComponents.
public static Collection<BaseComponent> getBaseComponents(Part part, Form context, IServoyDataConverterContext converterContext, boolean isDesign, boolean flatten) {
if (!isDesign && part.getPartType() == Part.BODY) {
switch(context.getView()) {
case FormController.TABLE_VIEW:
case FormController.LOCKED_TABLE_VIEW:
case IForm.LIST_VIEW:
case FormController.LOCKED_LIST_VIEW:
return Arrays.asList(new BaseComponent[] { new BodyPortal(context) });
}
}
List<BaseComponent> baseComponents = new ArrayList<>();
int startPos = context.getPartStartYPos(part.getID());
int endPos = part.getHeight();
Comparator<? super IFormElement> comparator = null;
if (context.isResponsiveLayout()) {
comparator = PositionComparator.XY_PERSIST_COMPARATOR;
} else {
comparator = FlattenedForm.FORM_INDEX_WITH_HIERARCHY_COMPARATOR;
}
List<IFormElement> persists = null;
if (flatten) {
persists = context.getFlattenedObjects(comparator);
} else {
persists = new ArrayList(context.getAllObjectsAsList());
Iterator<IFormElement> it = persists.iterator();
while (it.hasNext()) {
IPersist persist = it.next();
if (!(persist instanceof BaseComponent)) {
it.remove();
}
}
Collections.sort(persists, comparator);
}
for (IFormElement persist : persists) {
Point location = CSSPositionUtils.getLocation(persist);
if (startPos <= location.y && endPos > location.y && persist instanceof BaseComponent) {
if (isSecurityVisible(persist, converterContext.getSolution(), context))
baseComponents.add((BaseComponent) persist);
}
}
return baseComponents;
}
use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class CSSPositionPropertyType method toJSON.
private JSONWriter toJSON(JSONWriter writer, String key, CSSPosition object, PropertyDescription pd, DataConversion clientConversion, FormElement formElement, FlattenedSolution fs, Form context) throws JSONException {
JSONUtils.addKeyIfPresent(writer, key);
writer.object();
if (object != null) {
writer.key("position").value("absolute");
String top = object.top;
String bottom = object.bottom;
if (formElement != null && fs != null && context != null && !formElement.isInDesigner()) {
// adjust the top for parts.
IPersist persist = formElement.getPersistIfAvailable();
if (persist instanceof BaseComponent) {
AbstractContainer parentContainer = CSSPositionUtils.getParentContainer((BaseComponent) persist);
Point location = CSSPositionUtils.getLocation(object, parentContainer.getSize());
Form form = fs.getFlattenedForm(context);
Part part = form.getPartAt(location.y);
if (part != null) {
if (isSet(top)) {
int topStart = form.getPartStartYPos(part.getID());
if (topStart > 0) {
if (top.endsWith("px")) {
top = top.substring(0, top.length() - 2);
}
int topInteger = Utils.getAsInteger(top, -1);
if (topInteger != -1) {
top = String.valueOf(topInteger - topStart);
} else {
top = "calc(" + top + " - " + topStart + "px)";
}
}
}
if (isSet(bottom)) {
int extraHeight = form.getSize().height - part.getHeight();
if (extraHeight > 0) {
if (bottom.endsWith("px")) {
bottom = bottom.substring(0, bottom.length() - 2);
}
int bottomInteger = Utils.getAsInteger(bottom, -1);
if (bottomInteger != -1) {
bottom = String.valueOf(bottomInteger - extraHeight);
} else {
bottom = "calc(" + bottom + " - " + extraHeight + "px)";
}
}
}
}
}
}
if (isSet(top))
writer.key("top").value(addPixels(top));
if (isSet(object.left))
writer.key("left").value(addPixels(object.left));
if (isSet(bottom))
writer.key("bottom").value(addPixels(bottom));
if (isSet(object.right))
writer.key("right").value(addPixels(object.right));
if (isSet(object.height)) {
if (isSet(top) && isSet(object.bottom)) {
writer.key("min-height").value(addPixels(object.height));
} else
writer.key("height").value(addPixels(object.height));
}
if (isSet(object.width)) {
if (isSet(object.left) && isSet(object.right)) {
writer.key("min-width").value(addPixels(object.width));
} else
writer.key("width").value(addPixels(object.width));
}
}
writer.endObject();
return writer;
}
Aggregations