Search in sources :

Example 6 with WrapperContainer

use of com.servoy.j2db.server.headlessclient.WrapperContainer in project servoy-client by Servoy.

the class WebAnchoringHelper method getWrapperComponent.

public static Component getWrapperComponent(Component comp, IFormElement obj, int start, Dimension panelSize, boolean leftToRight, boolean isInListView) {
    MarkupContainer compWrapper = new WrapperContainer(ComponentFactory.getWebID(null, obj) + TemplateGenerator.WRAPPER_SUFFIX, comp);
    Point l = (obj).getLocation();
    if (isInListView) {
        // substract left indicator
        l.x = Math.max(l.x - 3, 0);
    }
    Dimension s = (obj).getSize();
    int anchors = 0;
    if (obj instanceof ISupportAnchors)
        anchors = ((ISupportAnchors) obj).getAnchors();
    int offsetWidth = s.width;
    int offsetHeight = s.height;
    if (comp instanceof ISupportWebBounds) {
        Rectangle b = ((ISupportWebBounds) comp).getWebBounds();
        offsetWidth = b.width;
        offsetHeight = b.height;
    }
    final String styleToReturn = WebAnchoringHelper.computeWrapperDivStyle(l.y, l.x, offsetWidth, offsetHeight, s.width, s.height, anchors, start, start + panelSize.height, panelSize.width, leftToRight);
    // first the default
    compWrapper.add(new StyleAppendingModifier(new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return styleToReturn;
        }
    }));
    // then the style t hat can be set on the wrapped component
    compWrapper.add(StyleAttributeModifierModel.INSTANCE);
    // TODO: this needs to be done in a cleaner way. See what is the relation between
    // margin, padding and border when calculating the websize in ChangesRecorder vs. TemplateGenerator.
    // Looks like one of the three is not taken into account during calculations. For now decided to remove
    // the margin and leave the padding and border.
    comp.add(new StyleAppendingModifier(new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            // $NON-NLS-1$
            return "margin: 0px;";
        }
    }));
    return compWrapper;
}
Also used : WrapperContainer(com.servoy.j2db.server.headlessclient.WrapperContainer) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) MarkupContainer(org.apache.wicket.MarkupContainer) ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) ISupportWebBounds(com.servoy.j2db.ui.ISupportWebBounds) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Dimension(java.awt.Dimension) Point(java.awt.Point)

Aggregations

WrapperContainer (com.servoy.j2db.server.headlessclient.WrapperContainer)6 Component (org.apache.wicket.Component)5 IComponent (com.servoy.j2db.ui.IComponent)4 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)4 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)4 MarkupContainer (org.apache.wicket.MarkupContainer)4 MainPage (com.servoy.j2db.server.headlessclient.MainPage)3 FormComponent (org.apache.wicket.markup.html.form.FormComponent)3 ListItem (org.apache.wicket.markup.html.list.ListItem)3 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)2 IScriptable (com.servoy.j2db.scripting.IScriptable)2 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)2 IProviderStylePropertyChanges (com.servoy.j2db.ui.IProviderStylePropertyChanges)2 ISupportOnRender (com.servoy.j2db.ui.ISupportOnRender)2 ISupportOnRenderCallback (com.servoy.j2db.ui.ISupportOnRenderCallback)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 IVisitor (org.apache.wicket.Component.IVisitor)2 IRecord (com.servoy.j2db.dataprocessing.IRecord)1 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)1