use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method setHeadersWidth.
// set headers width according to cell's width
private void setHeadersWidth() {
Iterator<IPersist> columnPersistIte = elementToColumnIdentifierComponent.keySet().iterator();
IPersist columnPersist;
Component columnHeader, columnCell;
while (columnPersistIte.hasNext()) {
columnPersist = columnPersistIte.next();
columnCell = elementToColumnIdentifierComponent.get(columnPersist);
columnHeader = elementToColumnHeader.get(columnPersist);
if (columnCell instanceof IProviderStylePropertyChanges) {
// $NON-NLS-1$
String width = ((IProviderStylePropertyChanges) columnCell).getStylePropertyChanges().getJSProperty("offsetWidth");
if (columnHeader instanceof SortableCellViewHeader) {
SortableCellViewHeader sortableColumnHeader = (SortableCellViewHeader) columnHeader;
if (width != null)
sortableColumnHeader.setWidth(Integer.parseInt(width.substring(0, width.length() - 2)));
else if (columnPersist instanceof BaseComponent)
sortableColumnHeader.setWidth(((BaseComponent) columnPersist).getSize().width);
}
}
}
}
use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class WebForm method getBounds.
public Rectangle getBounds(IComponent component) {
if (// $NON-NLS-1$
component instanceof Component && Utils.getAsBoolean(formController.getApplication().getRuntimeProperties().get("enableAnchors"))) {
IPersist persist = getPersist(((Component) component).getId());
if (persist instanceof ISupportAnchors && ((ISupportAnchors) persist).getAnchors() > 0 && ((ISupportAnchors) persist).getAnchors() != IAnchorConstants.DEFAULT) {
int anchors = ((ISupportAnchors) persist).getAnchors();
IDataRenderer renderer = ((Component) component).findParent(IDataRenderer.class);
int partHeight = 0;
if (renderer != null) {
partHeight = renderer.getSize().height;
}
int designWidth = formController.getForm().getWidth();
int designHeight = 0;
Part part = formController.getForm().getPartAt(((BaseComponent) persist).getLocation().y);
if (part != null) {
int top = formController.getForm().getPartStartYPos(part.getID());
designHeight = part.getHeight() - top;
}
if (partHeight > 0 && formWidth > 0 && designWidth > 0 && designHeight > 0) {
int navid = formController.getForm().getNavigatorID();
int navigatorWidth = 0;
if (navid == Form.NAVIGATOR_DEFAULT && formController.getForm().getView() != FormController.TABLE_VIEW && formController.getForm().getView() != FormController.LOCKED_TABLE_VIEW) {
navigatorWidth = WebDefaultRecordNavigator.DEFAULT_WIDTH;
} else if (navid != Form.NAVIGATOR_NONE) {
ISupportNavigator navigatorSupport = findParent(ISupportNavigator.class);
if (navigatorSupport != null) {
FormController currentNavFC = navigatorSupport.getNavigator();
if (currentNavFC != null) {
navigatorWidth = currentNavFC.getForm().getWidth();
}
}
}
Rectangle bounds = new Rectangle(component.getLocation(), component.getSize());
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) == 0) {
bounds.x += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) == 0) {
bounds.y += partHeight - designHeight;
}
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) != 0 && (formWidth - designWidth - navigatorWidth > 0)) {
bounds.width += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) != 0 && (partHeight - designHeight > 0)) {
bounds.height += partHeight - designHeight;
}
return bounds;
}
}
}
return null;
}
use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class AngularFormGenerator method writePosition.
/**
* @param writer
* @param o
*/
@SuppressWarnings("nls")
public static void writePosition(JSONWriter writer, IPersist o, Form form, WebFormComponent webComponent, boolean isDesigner) {
if (o instanceof BaseComponent && ((BaseComponent) o).getCssPosition() != null) {
CSSPosition position = ((BaseComponent) o).getCssPosition();
if (webComponent != null) {
Object runtimeValue = webComponent.getProperty(IContentSpecConstants.PROPERTY_CSS_POSITION);
if (runtimeValue instanceof CSSPosition) {
position = (CSSPosition) runtimeValue;
}
}
writer.key("position");
writer.object();
if (CSSPositionUtils.isSet(position.left)) {
writer.key("left").value(CSSPositionUtils.getCSSValue(position.left));
}
if (CSSPositionUtils.isSet(position.top)) {
String top = position.top;
if (!isDesigner) {
Point location = CSSPositionUtils.getLocation((BaseComponent) o);
Part prt = form.getPartAt(location.y);
if (prt != null) {
int topStart = form.getPartStartYPos(prt.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)";
}
}
}
}
writer.key("top").value(CSSPositionUtils.getCSSValue(top));
}
if (CSSPositionUtils.isSet(position.bottom)) {
writer.key("bottom").value(CSSPositionUtils.getCSSValue(position.bottom));
}
if (CSSPositionUtils.isSet(position.right)) {
writer.key("right").value(CSSPositionUtils.getCSSValue(position.right));
}
if (CSSPositionUtils.isSet(position.width)) {
if (CSSPositionUtils.isSet(position.left) && CSSPositionUtils.isSet(position.right)) {
writer.key("min-width").value(CSSPositionUtils.getCSSValue(position.width));
} else {
writer.key("width").value(CSSPositionUtils.getCSSValue(position.width));
}
}
if (CSSPositionUtils.isSet(position.height)) {
if (CSSPositionUtils.isSet(position.top) && CSSPositionUtils.isSet(position.bottom)) {
writer.key("min-height").value(CSSPositionUtils.getCSSValue(position.height));
} else {
writer.key("height").value(CSSPositionUtils.getCSSValue(position.height));
}
}
writer.endObject();
} else {
Point location = ((IFormElement) o).getLocation();
Dimension size = ((IFormElement) o).getSize();
if (webComponent != null) {
Object runtimeValue = webComponent.getProperty(IContentSpecConstantsBase.PROPERTY_LOCATION);
if (runtimeValue instanceof Point) {
location = (Point) runtimeValue;
}
runtimeValue = webComponent.getProperty(IContentSpecConstantsBase.PROPERTY_SIZE);
if (runtimeValue instanceof Dimension) {
size = (Dimension) runtimeValue;
}
}
if (location != null && size != null) {
int anchorFlags = ((BaseComponent) o).getAnchors();
boolean anchoredTop = (anchorFlags & IAnchorConstants.NORTH) != 0;
boolean anchoredRight = (anchorFlags & IAnchorConstants.EAST) != 0;
boolean anchoredBottom = (anchorFlags & IAnchorConstants.SOUTH) != 0;
boolean anchoredLeft = (anchorFlags & IAnchorConstants.WEST) != 0;
if (!anchoredLeft && !anchoredRight)
anchoredLeft = true;
if (!anchoredTop && !anchoredBottom)
anchoredTop = true;
writer.key("position");
writer.object();
if (anchoredTop) {
writer.key("top");
writer.value(location.y + "px");
}
if (anchoredBottom) {
writer.key("bottom");
int partHeight = form.getSize().height;
if (!isDesigner) {
// search for element's part using its design time location
Part prt = form.getPartAt(((IFormElement) o).getLocation().y);
if (prt != null) {
int prtEnd = form.getPartEndYPos(prt.getID());
if (prtEnd > form.getSize().height)
prtEnd = form.getSize().height;
partHeight = prtEnd - form.getPartStartYPos(prt.getID());
}
}
writer.value(partHeight - location.y - size.height + "px");
}
if (!anchoredTop || !anchoredBottom) {
writer.key("height");
writer.value(size.height + "px");
}
if (anchoredLeft) {
writer.key("left");
writer.value(location.x + "px");
}
if (anchoredRight) {
writer.key("right");
writer.value((form.getWidth() - location.x - size.width) + "px");
}
if (!anchoredLeft || !anchoredRight) {
writer.key("width");
writer.value(size.width + "px");
}
if (anchoredTop && anchoredBottom) {
writer.key("min-height");
writer.value(size.height + "px");
}
if (anchoredLeft && anchoredRight) {
writer.key("min-width");
writer.value(size.width + "px");
}
writer.endObject();
}
}
}
use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class FormWrapper method getBaseComponents.
public Collection<IFormElement> getBaseComponents() {
if (this.baseComponents != null)
return this.baseComponents;
List<IFormElement> components = new ArrayList<>();
Collection<BaseComponent> excludedComponents = null;
if ((isListView && !design) || isTableView) {
excludedComponents = getBodyComponents();
}
List<IFormElement> persists = form.getFlattenedObjects(Form.FORM_INDEX_COMPARATOR);
for (IFormElement persist : persists) {
if (isSecurityVisible(persist)) {
if ((excludedComponents == null || !excludedComponents.contains(persist)))
components.add(persist);
checkFormComponents(components, FormElementHelper.INSTANCE.getFormElement(persist, context.getSolution(), null, design), new HashSet<String>());
}
}
if ((isListView && !design) || isTableView) {
components.add(new BodyPortal(form));
}
if (form.getNavigatorID() == Form.NAVIGATOR_DEFAULT) {
components.add(DefaultNavigator.INSTANCE);
}
this.baseComponents = components;
return components;
}
use of com.servoy.j2db.persistence.BaseComponent in project servoy-client by Servoy.
the class JSPortal method setX.
/**
* @see com.servoy.j2db.scripting.solutionmodel.JSComponent#setX(int)
*/
@Override
@JSSetter
public void setX(int x) {
int xDif = x - getX();
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 + xDif, location.y));
}
}
super.setX(x);
}
Aggregations