Search in sources :

Example 1 with IImageDisplay

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

the class WebForm method getFormAnchorInfo.

@SuppressWarnings("unchecked")
public FormAnchorInfo getFormAnchorInfo() {
    formAnchorInfo = new FormAnchorInfo(formController.getName(), formController.getForm().getSize(), formController.getForm().getUUID());
    final Map<String, ISupportAnchors> elements = new HashMap<String, ISupportAnchors>();
    Iterator<IPersist> e1 = formController.getForm().getAllObjects();
    while (e1.hasNext()) {
        IPersist obj = e1.next();
        if (obj instanceof ISupportAnchors && obj instanceof ISupportBounds) {
            elements.put(ComponentFactory.getWebID(formController.getForm(), obj), (ISupportAnchors) obj);
        }
    }
    // In case we are in table view.
    if (view instanceof WebCellBasedView) {
        WebCellBasedView formPart = (WebCellBasedView) view;
        formAnchorInfo.addPart(Part.getDisplayName(Part.BODY), formPart.getMarkupId(), 50);
        formAnchorInfo.isTableView = true;
        formAnchorInfo.bodyContainerId = formPart.getMarkupId();
    }
    // Find the id of the form navigator, if any.
    visitChildren(Component.class, new IVisitor() {

        public Object component(Component component) {
            if (component instanceof WebDefaultRecordNavigator) {
                formAnchorInfo.navigatorWebId = component.getMarkupId();
                return IVisitor.CONTINUE_TRAVERSAL;
            } else if (component instanceof WebTabPanel) {
                return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
            } else
                return IVisitor.CONTINUE_TRAVERSAL;
        }
    });
    visitChildren(WebDataRenderer.class, new IVisitor() {

        public Object component(Component component) {
            WebDataRenderer formPart = (WebDataRenderer) component;
            final FormPartAnchorInfo part = formAnchorInfo.addPart(formPart.getFormPartName(), formPart.getMarkupId(), formPart.getSize().height);
            if (Part.getDisplayName(Part.BODY).equals(formPart.getFormPartName())) {
                Component parent = formPart.getParent();
                formAnchorInfo.bodyContainerId = parent.getMarkupId();
            }
            formPart.visitChildren(ISupportWebBounds.class, new IVisitor() {

                public Object component(Component comp) {
                    String id = comp.getId();
                    ISupportAnchors obj = elements.get(id);
                    if (obj != null) {
                        int anchors = obj.getAnchors();
                        if (((anchors > 0 && anchors != IAnchorConstants.DEFAULT)) || (comp instanceof WebTabPanel) || (comp instanceof IButton)) {
                            Rectangle r = ((ISupportWebBounds) comp).getWebBounds();
                            if (r != null) {
                                if (anchors == 0)
                                    anchors = IAnchorConstants.DEFAULT;
                                int hAlign = -1;
                                int vAlign = -1;
                                if (obj instanceof ISupportTextSetup) {
                                    ISupportTextSetup alignedObj = (ISupportTextSetup) obj;
                                    hAlign = alignedObj.getHorizontalAlignment();
                                    vAlign = alignedObj.getVerticalAlignment();
                                }
                                String imageDisplayURL = null;
                                boolean isRandomParamRemoved = false;
                                if (comp instanceof IImageDisplay) {
                                    Object[] aImageDisplayURL = WebBaseButton.getImageDisplayURL((IImageDisplay) comp, false);
                                    imageDisplayURL = (String) aImageDisplayURL[0];
                                    isRandomParamRemoved = ((Boolean) aImageDisplayURL[1]).booleanValue();
                                }
                                part.addAnchoredElement(comp.getMarkupId(), anchors, r, hAlign, vAlign, comp.getClass(), imageDisplayURL, isRandomParamRemoved);
                            }
                        }
                    }
                    return IVisitor.CONTINUE_TRAVERSAL;
                }
            });
            return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
        }
    });
    return formAnchorInfo;
}
Also used : FormPartAnchorInfo(com.servoy.j2db.server.headlessclient.FormAnchorInfo.FormPartAnchorInfo) WebDataRenderer(com.servoy.j2db.server.headlessclient.dataui.WebDataRenderer) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) IImageDisplay(com.servoy.j2db.server.headlessclient.dataui.IImageDisplay) ISupportTextSetup(com.servoy.j2db.persistence.ISupportTextSetup) Rectangle(java.awt.Rectangle) ISupportBounds(com.servoy.j2db.persistence.ISupportBounds) WebCellBasedView(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView) Point(java.awt.Point) ISupportAnchors(com.servoy.j2db.persistence.ISupportAnchors) ISupportWebBounds(com.servoy.j2db.ui.ISupportWebBounds) IPersist(com.servoy.j2db.persistence.IPersist) WebDefaultRecordNavigator(com.servoy.j2db.server.headlessclient.dataui.WebDefaultRecordNavigator) IButton(com.servoy.j2db.ui.IButton) WebTabPanel(com.servoy.j2db.server.headlessclient.dataui.WebTabPanel) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) 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)

Aggregations

BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 IPersist (com.servoy.j2db.persistence.IPersist)1 ISupportAnchors (com.servoy.j2db.persistence.ISupportAnchors)1 ISupportBounds (com.servoy.j2db.persistence.ISupportBounds)1 ISupportTextSetup (com.servoy.j2db.persistence.ISupportTextSetup)1 FormPartAnchorInfo (com.servoy.j2db.server.headlessclient.FormAnchorInfo.FormPartAnchorInfo)1 IImageDisplay (com.servoy.j2db.server.headlessclient.dataui.IImageDisplay)1 WebCellBasedView (com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView)1 WebDataRenderer (com.servoy.j2db.server.headlessclient.dataui.WebDataRenderer)1 WebDefaultRecordNavigator (com.servoy.j2db.server.headlessclient.dataui.WebDefaultRecordNavigator)1 WebTabPanel (com.servoy.j2db.server.headlessclient.dataui.WebTabPanel)1 IButton (com.servoy.j2db.ui.IButton)1 IComponent (com.servoy.j2db.ui.IComponent)1 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)1 ISupportWebBounds (com.servoy.j2db.ui.ISupportWebBounds)1 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 HashMap (java.util.HashMap)1 WeakHashMap (java.util.WeakHashMap)1