Search in sources :

Example 56 with IPersist

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;
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) HashMap(java.util.HashMap) DataAdapterList(com.servoy.j2db.dataprocessing.DataAdapterList) IDisplay(com.servoy.j2db.dataprocessing.IDisplay) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) Map(java.util.Map) HashMap(java.util.HashMap)

Example 57 with IPersist

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;
            }
        }
    }
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) IComponent(com.servoy.j2db.ui.IComponent) Point(java.awt.Point) IComponent(com.servoy.j2db.ui.IComponent) AbstractRuntimeBaseComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Point(java.awt.Point)

Example 58 with IPersist

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());
}
Also used : ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) IPersist(com.servoy.j2db.persistence.IPersist) IComponent(com.servoy.j2db.ui.IComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IComponent(com.servoy.j2db.ui.IComponent) AbstractRuntimeBaseComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) Point(java.awt.Point)

Example 59 with IPersist

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);
    }
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) IComponent(com.servoy.j2db.ui.IComponent) AbstractRuntimeBaseComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Example 60 with IPersist

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");
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) PropertyDescription(org.sablo.specification.PropertyDescription) WebLayoutSpecification(org.sablo.specification.WebLayoutSpecification) IFormElement(com.servoy.j2db.persistence.IFormElement) IPersist(com.servoy.j2db.persistence.IPersist) LayoutContainer(com.servoy.j2db.persistence.LayoutContainer)

Aggregations

IPersist (com.servoy.j2db.persistence.IPersist)84 Point (java.awt.Point)26 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)23 Form (com.servoy.j2db.persistence.Form)22 ArrayList (java.util.ArrayList)22 IFormElement (com.servoy.j2db.persistence.IFormElement)20 BaseComponent (com.servoy.j2db.persistence.BaseComponent)19 HashMap (java.util.HashMap)16 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)14 IComponent (com.servoy.j2db.ui.IComponent)13 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)13 Component (org.apache.wicket.Component)13 AbstractBase (com.servoy.j2db.persistence.AbstractBase)12 JSONObject (org.json.JSONObject)10 PropertyDescription (org.sablo.specification.PropertyDescription)10 RepositoryException (com.servoy.j2db.persistence.RepositoryException)8 Tab (com.servoy.j2db.persistence.Tab)8 IPortalComponent (com.servoy.j2db.ui.IPortalComponent)8 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)7 ISupportAnchors (com.servoy.j2db.persistence.ISupportAnchors)7