Search in sources :

Example 6 with IPersist

use of com.servoy.j2db.persistence.IPersist 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);
            }
        }
    }
}
Also used : AbstractRuntimeBaseComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) IPersist(com.servoy.j2db.persistence.IPersist) IProviderStylePropertyChanges(com.servoy.j2db.ui.IProviderStylePropertyChanges) 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 7 with IPersist

use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method getTabSeqComponentNames.

public List<String> getTabSeqComponentNames() {
    // elementTabIndexes is not sorted. We have to sort the indexes of the tabs first.
    SortedMap<Integer, IPersist> sortedTabIndexes = new TreeMap<Integer, IPersist>();
    for (IPersist key : elementTabIndexes.keySet()) {
        sortedTabIndexes.put(elementTabIndexes.get(key), key);
    }
    List<String> tabSeqNames = new ArrayList<String>();
    for (int i : sortedTabIndexes.keySet()) {
        IPersist key = sortedTabIndexes.get(i);
        if (key instanceof ISupportName) {
            String name = ((ISupportName) key).getName();
            if (name != null) {
                tabSeqNames.add(name);
            }
        }
    }
    return tabSeqNames;
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) ISupportName(com.servoy.j2db.persistence.ISupportName) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) Point(java.awt.Point)

Example 8 with IPersist

use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method resizeColumn.

public void resizeColumn(SortableCellViewHeader headerColumn, int x) {
    int totalWidthToStretch = 0;
    IPersist resizedPersist = null;
    for (IPersist p : elementToColumnHeader.keySet()) {
        Component c = elementToColumnIdentifierComponent.get(p);
        if (c instanceof IScriptableProvider && ((IScriptableProvider) c).getScriptObject() instanceof IRuntimeComponent) {
            IRuntimeComponent ic = (IRuntimeComponent) ((IScriptableProvider) c).getScriptObject();
            if (elementToColumnHeader.get(p).equals(headerColumn)) {
                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(ic.getWidth() + x, height);
                if (ic instanceof IProviderStylePropertyChanges) {
                    resizedComponent = c;
                    // avoid the tableview to render because of this change
                    ((IProviderStylePropertyChanges) ic).getStylePropertyChanges().setRendered();
                }
                resizedPersist = p;
                // set width for all cell of the column
                Iterator<Entry<Component, IPersist>> cellToElementIte = cellToElement.entrySet().iterator();
                Entry<Component, IPersist> cellToElementEntry;
                Component cellComponent;
                while (cellToElementIte.hasNext()) {
                    cellToElementEntry = cellToElementIte.next();
                    cellComponent = cellToElementEntry.getKey();
                    if (p.equals(cellToElementEntry.getValue()) && cellComponent instanceof IScriptableProvider && ((IScriptableProvider) cellComponent).getScriptObject() instanceof IRuntimeComponent) {
                        IRuntimeComponent cellScriptComponent = (IRuntimeComponent) ((IScriptableProvider) cellComponent).getScriptObject();
                        cellScriptComponent.setSize(cellScriptComponent.getWidth() + x, cellScriptComponent.getHeight());
                        if (cellComponent instanceof IProviderStylePropertyChanges) {
                            // avoid the tableview to render because of this change
                            ((IProviderStylePropertyChanges) cellComponent).getStylePropertyChanges().setRendered();
                        }
                    }
                }
            } else {
                totalWidthToStretch += ic.getWidth();
            }
        }
    }
    if (shouldFillAllHorizontalSpace())
        distributeExtraSpace(-x, totalWidthToStretch, resizedPersist, false);
    setHeadersWidth();
}
Also used : Entry(java.util.Map.Entry) IPersist(com.servoy.j2db.persistence.IPersist) IComponent(com.servoy.j2db.ui.IComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IProviderStylePropertyChanges(com.servoy.j2db.ui.IProviderStylePropertyChanges) 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 9 with IPersist

use of com.servoy.j2db.persistence.IPersist in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method createComponents.

private void createComponents(final IApplication app, final Form form, final AbstractBase view, final IDataProviderLookup dataProviderLookup, final IScriptExecuter el, final int viewStartY, final int viewEndY, final ItemAdd output) {
    List<IPersist> elements = ComponentFactory.sortElementsOnPositionAndGroup(view.getAllObjectsAsList());
    int startX = 0;
    for (int i = 0; i < elements.size(); i++) {
        IPersist element = elements.get(i);
        if (element instanceof Field || element instanceof GraphicalComponent || element instanceof Bean) {
            if (!isListViewMode()) {
                if (element instanceof GraphicalComponent && ((GraphicalComponent) element).getLabelFor() != null) {
                    if (isInView(cellview, ((GraphicalComponent) element).getLabelFor())) {
                        labelsFor.put(((GraphicalComponent) element).getLabelFor(), element);
                    }
                    continue;
                }
            }
            Point l = ((IFormElement) element).getLocation();
            if (l == null) {
                // unknown where to add
                continue;
            }
            if (l.y >= viewStartY && l.y < viewEndY) {
                IComponent c = ComponentFactory.createComponent(app, form, element, dataProviderLookup, el, false);
                if (cellview instanceof Portal && c instanceof IScriptableProvider) {
                    IScriptable s = ((IScriptableProvider) c).getScriptObject();
                    if (s instanceof ISupportOnRenderCallback && ((ISupportOnRenderCallback) s).getRenderEventExecutor() != null)
                        ComponentFactoryHelper.addPortalOnRenderCallback((Portal) cellview, ((ISupportOnRenderCallback) s).getRenderEventExecutor(), element, fc != null ? fc.getScriptExecuter() : null);
                }
                initializeComponent((Component) c, view, element);
                output.add(element, (Component) c);
                if (!isListViewMode()) {
                    // reset location.x as defined in this order, elements are ordered by location.x which is modified in drag-n-drop
                    Point loc = c.getLocation();
                    if (loc != null) {
                        c.setLocation(new Point(startX, loc.y));
                    }
                    Dimension csize = c.getSize();
                    startX += (csize != null) ? csize.width : ((IFormElement) element).getSize().width;
                }
            }
        }
    }
}
Also used : IComponent(com.servoy.j2db.ui.IComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) Point(java.awt.Point) Dimension(java.awt.Dimension) Point(java.awt.Point) IScriptable(com.servoy.j2db.scripting.IScriptable) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) Bean(com.servoy.j2db.persistence.Bean) Field(com.servoy.j2db.persistence.Field) IFormElement(com.servoy.j2db.persistence.IFormElement) IPersist(com.servoy.j2db.persistence.IPersist) Portal(com.servoy.j2db.persistence.Portal) RuntimePortal(com.servoy.j2db.ui.scripting.RuntimePortal) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider)

Example 10 with IPersist

use of com.servoy.j2db.persistence.IPersist 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;
}
Also used : FormController(com.servoy.j2db.FormController) ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) BaseComponent(com.servoy.j2db.persistence.BaseComponent) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) IPersist(com.servoy.j2db.persistence.IPersist) ISupportNavigator(com.servoy.j2db.ISupportNavigator) Part(com.servoy.j2db.persistence.Part) Rectangle(java.awt.Rectangle) IComponent(com.servoy.j2db.ui.IComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Point(java.awt.Point)

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