Search in sources :

Example 1 with ISupportNavigator

use of com.servoy.j2db.ISupportNavigator 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

FormController (com.servoy.j2db.FormController)1 ISupportNavigator (com.servoy.j2db.ISupportNavigator)1 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 IPersist (com.servoy.j2db.persistence.IPersist)1 ISupportAnchors (com.servoy.j2db.persistence.ISupportAnchors)1 Part (com.servoy.j2db.persistence.Part)1 IComponent (com.servoy.j2db.ui.IComponent)1 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)1 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)1 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 Component (org.apache.wicket.Component)1