use of com.servoy.j2db.server.ngclient.FormElement in project servoy-client by Servoy.
the class FormComponentSabloValue method getComponents.
private ComponentTypeSabloValue[] getComponents() {
FormComponentCache formComponentCache = getCache();
if (currentFormComponentCache != formComponentCache) {
List<FormElement> elements = formComponentCache.getFormComponentElements();
List<ComponentTypeSabloValue> componentsList = new ArrayList<ComponentTypeSabloValue>(elements.size());
PropertyPath path = new PropertyPath();
path.add(component.getName());
path.add("containedForm");
path.add("childElements");
JSONObject tags = new JSONObject();
tags.put(ComponentTypeSabloValue.TAG_ADD_TO_ELEMENTS_SCOPE, true);
PropertyDescription compPd = new PropertyDescriptionBuilder().withName(pd.getName()).withType(ComponentPropertyType.INSTANCE).withConfig(pd.getConfig()).withTags(tags).build();
int j = 0;
for (FormElement element : elements) {
path.add(j);
ComponentTypeFormElementValue elementValue = ComponentPropertyType.INSTANCE.getFormElementValue(null, compPd, path, element, dal.getApplication().getFlattenedSolution());
ComponentTypeSabloValue ctsv = ComponentPropertyType.INSTANCE.toSabloComponentValue(elementValue, compPd, element, component, dal);
if (ctsv != null) {
// if it is null then it is probably a child component that was blocked by security (visibility == false); in that case just ignore it (similar to what portal does through .spec setting on comp. array to ignore null values at runtime)
j++;
componentsList.add(ctsv);
}
path.backOneLevel();
if (element.getWebComponentSpec() != null) {
Collection<PropertyDescription> properties = element.getWebComponentSpec().getProperties(FormComponentPropertyType.INSTANCE);
if (properties.size() > 0) {
for (PropertyDescription pd : properties) {
Object propertyValue = element.getPropertyValue(pd.getName());
Form frm = FormComponentPropertyType.INSTANCE.getForm(propertyValue, dal.getApplication().getFlattenedSolution());
if (frm == null)
continue;
FormComponentCache innerCache = FormElementHelper.INSTANCE.getFormComponentCache(element, pd, (JSONObject) propertyValue, frm, dal.getApplication().getFlattenedSolution());
List<FormElement> innerElements = innerCache.getFormComponentElements();
for (FormElement innerElement : innerElements) {
path.add(j);
elementValue = ComponentPropertyType.INSTANCE.getFormElementValue(null, compPd, path, innerElement, dal.getApplication().getFlattenedSolution());
// use main property
ctsv = ComponentPropertyType.INSTANCE.toSabloComponentValue(elementValue, compPd, innerElement, component, dal);
if (ctsv != null) {
// if it is null then it is probably a child component that was blocked by security (visibility == false); in that case just ignore it (similar to what portal does through .spec setting on comp. array to ignore null values at runtime)
j++;
componentsList.add(ctsv);
}
path.backOneLevel();
}
}
}
}
}
// re-attach
if (currentFormComponentCache != null && changeMonitor != null && webObjectContext != null) {
for (ComponentTypeSabloValue componentTypeSabloValue : componentsList) {
componentTypeSabloValue.attachToBaseObject(changeMonitor, webObjectContext);
}
}
currentFormComponentCache = formComponentCache;
components = componentsList.toArray(new ComponentTypeSabloValue[0]);
}
return components;
}
use of com.servoy.j2db.server.ngclient.FormElement in project servoy-client by Servoy.
the class FormWrapper method getAbsoluteLayoutElements.
public List<FormElement> getAbsoluteLayoutElements() {
List<FormElement> elements = new ArrayList<FormElement>();
Collection<IFormElement> components = getBaseComponents();
if (components != null) {
for (IFormElement component : components) {
if (CSSPositionUtils.isInAbsoluteLayoutMode(component)) {
elements.add(FormElementHelper.INSTANCE.getFormElement(component, context.getSolution(), null, design));
}
}
}
return elements;
}
use of com.servoy.j2db.server.ngclient.FormElement in project servoy-client by Servoy.
the class FormWrapper method getProperties.
/**
* @return
*/
public Map<String, Object> getProperties() {
// a copy of form properties
Map<String, Object> properties = form.getFlattenedPropertiesMap();
// form.getSize() computes the form height from form parts so do call it instead of relying on the height from size taken from raw form.getPropertiesMap() - where the height is not kept in sync in developer - we have to call getSize()
properties.put("size", form.getSize());
properties.put("designSize", form.getSize());
properties.put("addMinSize", !form.isResponsiveLayout() && (form.getView() == IForm.RECORD_VIEW || form.getView() == IForm.LOCKED_RECORD_VIEW));
properties.put("hasExtraParts", Boolean.valueOf(FormElementHelper.INSTANCE.hasExtraParts(form)));
HashMap<String, Boolean> absolute = new HashMap<>(formComponentsLayout);
absolute.put("", !form.isResponsiveLayout());
for (FormElement fe : getAbsoluteLayoutElements()) {
absolute.put(fe.getName(), Boolean.TRUE);
}
properties.put("absoluteLayout", absolute);
properties.put(IContentSpecConstants.PROPERTY_USE_CSS_POSITION, getCSSPositionElementNames());
if (design && !form.isResponsiveLayout()) {
properties.put(StaticContentSpecLoader.PROPERTY_SCROLLBARS.getPropertyName(), Integer.valueOf(ISupportScrollbars.HORIZONTAL_SCROLLBAR_NEVER + ISupportScrollbars.VERTICAL_SCROLLBAR_NEVER));
}
if (form.getView() == IForm.LIST_VIEW || form.getView() == IFormConstants.VIEW_TYPE_LIST_LOCKED) {
// handle horizontal scrollbar on form level for listview
int horizontalScrollBars = ISupportScrollbars.HORIZONTAL_SCROLLBAR_AS_NEEDED;
if ((form.getScrollbars() & ISupportScrollbars.HORIZONTAL_SCROLLBAR_ALWAYS) != 0) {
horizontalScrollBars = ISupportScrollbars.HORIZONTAL_SCROLLBAR_ALWAYS;
} else if ((form.getScrollbars() & ISupportScrollbars.HORIZONTAL_SCROLLBAR_NEVER) != 0) {
horizontalScrollBars = ISupportScrollbars.HORIZONTAL_SCROLLBAR_NEVER;
}
int scrollbars = ISupportScrollbars.VERTICAL_SCROLLBAR_NEVER + horizontalScrollBars;
properties.put(StaticContentSpecLoader.PROPERTY_SCROLLBARS.getPropertyName(), Integer.valueOf(scrollbars));
}
removeUnneededFormProperties(properties);
if (properties.containsKey(StaticContentSpecLoader.PROPERTY_BORDERTYPE.getPropertyName())) {
Border border = ComponentFactoryHelper.createBorder((String) properties.get(StaticContentSpecLoader.PROPERTY_BORDERTYPE.getPropertyName()), false);
properties.put(StaticContentSpecLoader.PROPERTY_BORDERTYPE.getPropertyName(), BorderPropertyType.writeBorderToJson(border));
}
return properties;
}
use of com.servoy.j2db.server.ngclient.FormElement in project servoy-client by Servoy.
the class FormWrapper method getContainerSizesString.
public String getContainerSizesString() throws JSONException, IllegalArgumentException {
Map<String, Dimension> sizes = new HashMap<String, Dimension>();
sizes.putAll(formComponentParentSizes);
for (FormElement fe : getAbsoluteLayoutElements()) {
sizes.put(fe.getName(), ((LayoutContainer) fe.getPersistIfAvailable().getParent()).getSize());
}
return JSONUtils.writeDataWithConversions(new JSONStringer().object(), sizes, null, null).endObject().toString();
}
use of com.servoy.j2db.server.ngclient.FormElement in project servoy-client by Servoy.
the class RuntimeWebComponent method isApiFunctionEnabled.
protected boolean isApiFunctionEnabled(String functionName) {
boolean isLocationOrSize = "getLocationX".equals(functionName) || "getLocationY".equals(functionName) || "getWidth".equals(functionName) || "getHeight".equals(functionName);
if (isLocationOrSize) {
// if parent form not visible, don't call api, let it get from the model on the server
Container parent = component.getParent();
while (parent != null) {
if (parent instanceof WebFormUI) {
boolean isFormVisible = false;
IWindow currentWindow = CurrentWindow.safeGet();
if (currentWindow instanceof INGClientWindow) {
isFormVisible = ((INGClientWindow) currentWindow).hasForm(parent.getName());
}
if (isFormVisible) {
// it is reported to be still on the client
// but do check also if it is not about to be hidden, by having
// formVisible already set to false in the controller
isFormVisible = ((WebFormUI) parent).getController().isFormVisible();
}
if (!isFormVisible) {
return false;
}
// if this form is in designer mode then it has to go to the client to get the current size/location
if (((WebFormUI) parent).getController().getDesignModeCallbacks() != null)
return true;
break;
}
parent = parent.getParent();
}
// if it is not table view (it can have columns moved/resize) and not anchored, no need to call api, let it get from the model on the server
FormElement fe = component.getFormElement();
if (fe.isLegacy() && fe.getPersistIfAvailable() instanceof ISupportAnchors && (fe.getForm().getView() != FormController.TABLE_VIEW && fe.getForm().getView() != FormController.LOCKED_TABLE_VIEW)) {
// ((ISupportAnchors)fe.getPersistIfAvailable()).getAnchors();
int anchor = Utils.getAsInteger(component.getProperty(StaticContentSpecLoader.PROPERTY_ANCHORS.getPropertyName()));
if ((anchor == 0 || anchor == (IAnchorConstants.NORTH + IAnchorConstants.WEST))) {
return false;
}
}
}
return true;
}
Aggregations