Search in sources :

Example 11 with IPersist

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

the class ScrollResponseHeaderContainer method distributeExtraSpace.

private void distributeExtraSpace() {
    int totalDefaultWidth = 0;
    int totalWidthToStretch = 0;
    int stretchedElementsCount = 0;
    for (IPersist element : elementToColumnIdentifierComponent.keySet()) {
        Object scriptobject = elementToColumnIdentifierComponent.get(element);
        if (!((Component) scriptobject).isVisible())
            continue;
        if (scriptobject instanceof IScriptableProvider) {
            scriptobject = ((IScriptableProvider) scriptobject).getScriptObject();
        }
        if (scriptobject instanceof IRuntimeComponent) {
            int width = ((IRuntimeComponent) scriptobject).getWidth();
            totalDefaultWidth += width;
            if (element instanceof ISupportAnchors) {
                int anchors = ((ISupportAnchors) element).getAnchors();
                if (((anchors & IAnchorConstants.EAST) != 0) && ((anchors & IAnchorConstants.WEST) != 0)) {
                    totalWidthToStretch += width;
                    stretchedElementsCount++;
                }
            }
        }
    }
    boolean shouldFillAllHorizSpace = shouldFillAllHorizontalSpace();
    if (shouldFillAllHorizSpace) {
        if (stretchedElementsCount > 0) {
            int delta = getDisplayBodyWidthHint() - totalDefaultWidth;
            distributeExtraSpace(delta, totalWidthToStretch, null, true);
            setHeadersWidth();
        }
    }
}
Also used : ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) IPersist(com.servoy.j2db.persistence.IPersist) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) Point(java.awt.Point)

Example 12 with IPersist

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

the class SortableCellViewHeader method applyStyleChanges.

private void applyStyleChanges(Component c, final Properties changes) {
    StyleAppendingModifier headerStyles = new StyleAppendingModifier(new Model<String>() {

        @Override
        public String getObject() {
            StringBuilder headerStyle = new StringBuilder();
            Iterator<Entry<Object, Object>> headerStyleIte = changes.entrySet().iterator();
            Entry<Object, Object> headerStyleEntry;
            while (headerStyleIte.hasNext()) {
                headerStyleEntry = headerStyleIte.next();
                headerStyle.append(headerStyleEntry.getKey()).append(":").append(headerStyleEntry.getValue()).append(";");
            }
            return headerStyle.toString();
        }
    }) {

        @Override
        public boolean isEnabled(Component c) {
            Iterator<IPersist> it2 = SortableCellViewHeader.this.cellview.getAllObjects();
            while (it2.hasNext()) {
                IPersist element = it2.next();
                if (SortableCellViewHeader.this.id.equals(ComponentFactory.getWebID(SortableCellViewHeader.this.form, element)) && SortableCellViewHeader.this.view.labelsFor.get(((ISupportName) element).getName()) != null) {
                    return false;
                }
            }
            return true;
        }
    };
    c.add(headerStyles);
}
Also used : Entry(java.util.Map.Entry) IPersist(com.servoy.j2db.persistence.IPersist) Iterator(java.util.Iterator) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) Component(org.apache.wicket.Component)

Example 13 with IPersist

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

the class SortableCellViewHeader method setWidth.

public void setWidth(int width) {
    int borderWidth = 0;
    Iterator<IPersist> it2 = cellview.getAllObjects();
    while (it2.hasNext()) {
        IPersist element = it2.next();
        if (id.equals(ComponentFactory.getWebID(form, element))) {
            GraphicalComponent gc = (GraphicalComponent) view.labelsFor.get(((ISupportName) element).getName());
            if (gc != null) {
                TextualStyle styleObj = new TextualStyle();
                BorderAndPadding ins = TemplateGenerator.applyBaseComponentProperties(gc, view.fc.getForm(), styleObj, (Insets) TemplateGenerator.DEFAULT_LABEL_PADDING.clone(), null, application);
                if (ins.border != null)
                    borderWidth = ins.border.left + ins.border.right;
            }
        }
    }
    int headerPadding = TemplateGenerator.SORTABLE_HEADER_PADDING;
    // If there is no label-for, we leave place for the default border placed at the right of headers.
    if (view.labelsFor.size() == 0) {
        int extraWidth = TemplateGenerator.NO_LABELFOR_DEFAULT_BORDER_WIDTH;
        String headerBorder = view.getHeaderBorder();
        if (headerBorder != null) {
            Properties properties = new Properties();
            Insets borderIns = ComponentFactoryHelper.createBorderCSSProperties(headerBorder, properties);
            extraWidth = borderIns.left + borderIns.right;
            headerPadding = 0;
        }
        borderWidth += extraWidth;
    }
    // we have only left padding
    int clientWidth = width - headerPadding - borderWidth;
    // if we have grid_style for the header, then don't change the header width
    this.width = (view.labelsFor.size() == 0 && view.getHeaderBorder() != null) ? width : clientWidth;
    StyleAppendingModifier widthStyleModifier = new StyleAppendingModifier(new Model<String>() {

        @Override
        public String getObject() {
            // $NON-NLS-1$//$NON-NLS-2$
            return "width: " + SortableCellViewHeader.this.width + "px";
        }
    });
    add(widthStyleModifier);
    headerColumnTable.add(widthStyleModifier);
    labelResolver.setWidth(clientWidth - SortableCellViewHeader.ARROW_WIDTH);
    getStylePropertyChanges().setChanged();
}
Also used : Insets(java.awt.Insets) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) ISupportName(com.servoy.j2db.persistence.ISupportName) BorderAndPadding(com.servoy.j2db.server.headlessclient.dataui.TemplateGenerator.BorderAndPadding) Properties(java.util.Properties) TextualStyle(com.servoy.j2db.server.headlessclient.dataui.TemplateGenerator.TextualStyle) IPersist(com.servoy.j2db.persistence.IPersist)

Example 14 with IPersist

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

the class SortableCellViewHeader method applyInlineStyleString.

private void applyInlineStyleString(Component c, final String inlineCSSSting) {
    StyleAppendingModifier headerStyles = new StyleAppendingModifier(new Model<String>() {

        @Override
        public String getObject() {
            return inlineCSSSting;
        }
    }) {

        @Override
        public boolean isEnabled(Component c) {
            Iterator<IPersist> it2 = SortableCellViewHeader.this.cellview.getAllObjects();
            while (it2.hasNext()) {
                IPersist element = it2.next();
                if (SortableCellViewHeader.this.id.equals(ComponentFactory.getWebID(SortableCellViewHeader.this.form, element)) && SortableCellViewHeader.this.view.labelsFor.get(((ISupportName) element).getName()) != null) {
                    return false;
                }
            }
            return true;
        }
    };
    c.add(headerStyles);
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) Component(org.apache.wicket.Component)

Example 15 with IPersist

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

the class SortableCellViewHeaders method isReorderableOrResizable.

private boolean isReorderableOrResizable() {
    if (// $NON-NLS-1$
    Utils.getAsBoolean(application.getRuntimeProperties().get("useAJAX"))) {
        boolean isReorderable = false;
        boolean isResizable = false;
        Iterator<IPersist> iter = cellview.getAllObjects();
        while (iter.hasNext()) {
            IPersist element = iter.next();
            if (element instanceof ISupportAnchors) {
                int anchors = ((ISupportAnchors) element).getAnchors();
                isResizable = ((anchors & IAnchorConstants.EAST) == IAnchorConstants.EAST) && ((anchors & IAnchorConstants.WEST) == IAnchorConstants.WEST);
                isResizable = isResizable && (!(cellview instanceof Portal) || ((Portal) cellview).getResizable());
                if (isResizable)
                    return true;
                isReorderable = !(((anchors & IAnchorConstants.NORTH) == IAnchorConstants.NORTH) && ((anchors & IAnchorConstants.SOUTH) == IAnchorConstants.SOUTH));
                isReorderable = isReorderable && (!(cellview instanceof Portal) || ((Portal) cellview).getReorderable());
                if (isReorderable)
                    return true;
            }
        }
    }
    return false;
}
Also used : ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) IPersist(com.servoy.j2db.persistence.IPersist) Portal(com.servoy.j2db.persistence.Portal)

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