use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class WebDataRenderer method createDataAdapter.
void createDataAdapter(IApplication app, IDataProviderLookup dataProviderLookup, IScriptExecuter el, ControllerUndoManager undoManager) throws Exception {
dataAdapterList = new DataAdapterList(app, dataProviderLookup, fieldComponents, el.getFormController(), null, undoManager);
// make it really fields only
HashMap<IPersist, IDisplay> f = new HashMap<IPersist, IDisplay>();
Iterator<Map.Entry<IPersist, IDisplay>> it = fieldComponents.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<IPersist, IDisplay> element = it.next();
if (element.getValue() instanceof IDisplayData) {
// String id = ((IDisplayData)element.getValue()).getDataProviderID();
// if (dataProviderLookup.getDataProvider(id) instanceof ScriptVariable)
// {
// globalFields.add(element.getValue());
// }
f.put(element.getKey(), element.getValue());
}
}
fieldComponents = f;
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method updateXLocationForColumns.
private void updateXLocationForColumns(List<Component> orderedHeaderCopy) {
int startX = 0;
for (Component c : orderedHeaderCopy) {
for (IPersist p : elementToColumnHeader.keySet()) {
if (elementToColumnHeader.get(p).equals(c)) {
Component columnIdentifierComponent = elementToColumnIdentifierComponent.get(p);
Point oldLocation = ((IComponent) columnIdentifierComponent).getLocation();
if (oldLocation == null) {
oldLocation = ((ISupportBounds) p).getLocation();
}
((IComponent) columnIdentifierComponent).setLocation(new Point(startX, (int) oldLocation.getY()));
startX += ((IComponent) columnIdentifierComponent).getSize().width;
}
}
}
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method distributeExtraSpace.
/**
* Distributes an amount of horizontal free space to some or the columns of the table.
*
* Can be called in two situations:
*
* 1. When the browser windows is resized.
*
* In this case the positive/negative extra space gets distributed to those columns that are
* anchored left + right.
*
* 2. When a column is resized
*
* In this case the positive/negative extra space gets distributed to all other columns,
* regardless of their anchoring.
*
* In both scenarios the extra space is distributed proportionally to the sizes of the
* involved columns.
*/
private void distributeExtraSpace(int delta, int totalWidthToStretch, IPersist dontTouchThis, boolean onlyAnchoredColumns) {
if (totalWidthToStretch == 0)
return;
int consumedDelta = 0;
IRuntimeComponent lastStretched = null;
for (IPersist element : elementToColumnIdentifierComponent.keySet()) {
boolean distributeToThisColumn = true;
if (dontTouchThis != null && element.equals(dontTouchThis))
distributeToThisColumn = false;
if (distributeToThisColumn && onlyAnchoredColumns) {
if (element instanceof ISupportAnchors) {
int anchors = ((ISupportAnchors) element).getAnchors();
if (((anchors & IAnchorConstants.EAST) == 0) || ((anchors & IAnchorConstants.WEST) == 0))
distributeToThisColumn = false;
} else
distributeToThisColumn = false;
}
if (distributeToThisColumn) {
Component c = elementToColumnIdentifierComponent.get(element);
if (c instanceof IScriptableProvider && ((IScriptableProvider) c).getScriptObject() instanceof IRuntimeComponent && c.isVisible()) {
IRuntimeComponent ic = (IRuntimeComponent) ((IScriptableProvider) c).getScriptObject();
int thisDelta = delta * ic.getWidth() / totalWidthToStretch;
consumedDelta += thisDelta;
int newWidth = ic.getWidth() + thisDelta;
int height = ic.getHeight();
Iterator<Component> alreadyAddedComponents = cellToElement.keySet().iterator();
if (alreadyAddedComponents.hasNext()) {
Component firstAddedComponent = alreadyAddedComponents.next();
if ((firstAddedComponent instanceof IComponent))
height = ((IComponent) firstAddedComponent).getSize().height;
}
ic.setSize(newWidth, height);
lastStretched = ic;
}
}
}
// we can have some leftover due to rounding errors, just put it into the last stretched column.
if ((delta - consumedDelta != 0) && (lastStretched != null)) {
lastStretched.setSize(lastStretched.getWidth() + delta - consumedDelta, lastStretched.getHeight());
}
updateXLocationForColumns(getOrderedHeaders());
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method updateHeaders.
private void updateHeaders() {
Iterator<IPersist> it = elementToColumnHeader.keySet().iterator();
while (it.hasNext()) {
IPersist element = it.next();
Component columnHeader = elementToColumnHeader.get(element);
Component columnIdentifier = elementToColumnIdentifierComponent.get(element);
updateHeader(columnHeader, columnIdentifier);
}
}
use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.
the class DesignFormLayoutStructureGenerator method generateLayoutContainer.
public static void generateLayoutContainer(LayoutContainer container, Form form, FlattenedSolution fs, PrintWriter writer, int nested) {
WebLayoutSpecification spec = null;
if (container.getPackageName() != null) {
PackageSpecification<WebLayoutSpecification> pkg = WebComponentSpecProvider.getSpecProviderState().getLayoutSpecifications().get(container.getPackageName());
if (pkg != null) {
spec = pkg.getSpecification(container.getSpecName());
}
}
writer.print("<");
writer.print(container.getTagType());
if (container.getName() != null) {
writer.print(" svy-name='");
writer.print(container.getName());
writer.print("' ");
}
if (container.getElementId() != null) {
writer.print(" id='");
writer.print(container.getElementId());
writer.print("' ");
}
Map<String, String> attributes = new HashMap<String, String>(container.getMergedAttributes());
if (spec != null) {
for (String propertyName : spec.getAllPropertiesNames()) {
PropertyDescription pd = spec.getProperty(propertyName);
if (pd.getDefaultValue() != null && !attributes.containsKey(propertyName)) {
attributes.put(propertyName, pd.getDefaultValue().toString());
}
}
}
for (Entry<String, String> entry : attributes.entrySet()) {
writer.print(" ");
try {
StringEscapeUtils.ESCAPE_ECMASCRIPT.translate(entry.getKey(), writer);
if (entry.getValue() != null && entry.getValue().length() > 0) {
writer.print("=\"");
StringEscapeUtils.ESCAPE_ECMASCRIPT.translate(entry.getValue(), writer);
writer.print("\"");
}
} catch (IOException e) {
Debug.error(e);
}
}
writer.print(" svy-id='");
writer.print(container.getID());
writer.print("'");
writer.print(">\n");
Iterator<IPersist> components = container.getAllObjects(PositionComparator.XY_PERSIST_COMPARATOR);
while (components.hasNext()) {
int count = 0;
while (count++ < nested) {
writer.print('\t');
}
IPersist component = components.next();
if (component instanceof LayoutContainer) {
generateLayoutContainer((LayoutContainer) component, form, fs, writer, nested + 1);
} else if (component instanceof IFormElement) {
generateFormElement(writer, (IFormElement) component, form, fs);
}
}
int count = 1;
while (count++ < nested) {
writer.print('\t');
}
writer.print("</");
writer.print(container.getTagType());
writer.print(">\n");
}
Aggregations