Search in sources :

Example 11 with FormController

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

the class ScrollResponseHeaderContainer method getListItemBgColor.

private String getListItemBgColor(ListItem<IRecordInternal> listItem, boolean isSelected, boolean asInlineCssString) {
    String color = null;
    final IRecordInternal rec = listItem.getModelObject();
    String rowBGColorProvider = getRowBGColorScript();
    Row rawData = null;
    if (rec != null && (rawData = rec.getRawData()) != null) {
        color = getStyleAttributeForListItem(listItem, isSelected, ISupportRowStyling.ATTRIBUTE.BGCOLOR, asInlineCssString);
        if (rowBGColorProvider != null) {
            Object c = color;
            // TODO type and name should be get somehow if this is possible, we have to know the specific cell/column for that.
            // (renderer instanceof IScriptBaseMethods) ? ((IScriptBaseMethods)renderer).js_getElementType() : null;
            String type = null;
            // (renderer instanceof IScriptBaseMethods) ? ((IScriptBaseMethods)renderer).js_getName() : null;
            String cellName = null;
            if (rawData.containsCalculation(rowBGColorProvider)) {
                // TODO this should be done better....
                // isEdited is always false
                Record.VALIDATE_CALCS.set(Boolean.FALSE);
                try {
                    c = rec.getParentFoundSet().getCalculationValue(rec, rowBGColorProvider, Utils.arrayMerge(new Object[] { new Integer(listItem.getIndex()), new Boolean(isSelected), type, cellName, Boolean.FALSE }, Utils.parseJSExpressions(getRowBGColorArgs())), null);
                } finally {
                    Record.VALIDATE_CALCS.set(null);
                }
            } else {
                try {
                    FormController currentForm = dal.getFormController();
                    c = currentForm.executeFunction(rowBGColorProvider, Utils.arrayMerge(new Object[] { new Integer(listItem.getIndex()), new Boolean(isSelected), type, cellName, currentForm.getName(), rec, Boolean.FALSE }, Utils.parseJSExpressions(getRowBGColorArgs())), false, null, true, null);
                } catch (Exception ex) {
                    Debug.error(ex);
                }
            }
            if (asInlineCssString) {
                String bgColor = null;
                if (c instanceof String)
                    bgColor = (String) c;
                else if (c instanceof Color)
                    bgColor = PersistHelper.createColorString((Color) c);
                if (bgColor != null)
                    color = new StringBuilder(CSS.Attribute.BACKGROUND_COLOR.toString()).append(':').append(color).append(';').toString();
            }
        }
    }
    return color;
}
Also used : FormController(com.servoy.j2db.FormController) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) Color(java.awt.Color) Row(com.servoy.j2db.dataprocessing.Row) RepositoryException(com.servoy.j2db.persistence.RepositoryException)

Example 12 with FormController

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

the class ScrollResponseHeaderContainer method createScriptEvent.

public JSDNDEvent createScriptEvent(EventType type, IComponent dragSource, Point xy, int modifiers) {
    JSDNDEvent jsEvent = new JSDNDEvent();
    jsEvent.setType(type);
    jsEvent.setFormName(getDragFormName());
    if (dragSource instanceof IDataRenderer) {
        IDataRenderer dr = (IDataRenderer) dragSource;
        FormController fct = dr.getDataAdapterList().getFormController();
        jsEvent.setSource(fct.getFormScope());
    } else {
        jsEvent.setSource(dragSource);
        if (dragSource != null) {
            if (dragSource instanceof Component) {
                WebCellBasedViewListItem listItem = ((Component) dragSource).findParent(WebCellBasedViewListItem.class);
                if (listItem != null) {
                    IRecordInternal dragRecord = listItem.getModelObject();
                    if (dragRecord instanceof Record)
                        jsEvent.setRecord((Record) dragRecord);
                }
            }
            String dragSourceName = dragSource.getName();
            if (dragSourceName == null)
                dragSourceName = dragSource.getId();
            jsEvent.setElementName(dragSourceName);
        }
    }
    if (xy != null)
        jsEvent.setLocation(xy);
    jsEvent.setModifiers(modifiers);
    return jsEvent;
}
Also used : FormController(com.servoy.j2db.FormController) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) JSDNDEvent(com.servoy.j2db.dnd.JSDNDEvent) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) Record(com.servoy.j2db.dataprocessing.Record) 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 13 with FormController

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

Example 14 with FormController

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

the class WebRuntimeWindow method getSizeAndLocation.

private Rectangle getSizeAndLocation(Rectangle r, IMainContainer container, final FormController fp) {
    int navid = fp.getForm().getNavigatorID();
    Dimension size = new Dimension(fp.getForm().getSize());
    if (navid == Form.NAVIGATOR_DEFAULT && fp.getForm().getView() != FormController.TABLE_VIEW && fp.getForm().getView() != FormController.LOCKED_TABLE_VIEW) {
        size.width += WebDefaultRecordNavigator.DEFAULT_WIDTH;
        if (size.height < WebDefaultRecordNavigator.DEFAULT_HEIGHT_WEB)
            size.height = WebDefaultRecordNavigator.DEFAULT_HEIGHT_WEB;
    } else if (navid != Form.NAVIGATOR_NONE) {
        FormController currentNavFC = container.getNavigator();
        if (currentNavFC != null) {
            size.width += currentNavFC.getForm().getSize().width;
            int navHeight = currentNavFC.getForm().getSize().height;
            if (size.height < navHeight)
                size.height = navHeight;
        }
    }
    // "div.wicket-modal div.w_right_1" brings 2px through "border" property (1px from left and 1px from right)
    if (!isUndecorated())
        size.width += 22;
    Border b = fp.getFormUI().getBorder();
    if (b != null) {
        Insets bIns = ComponentFactoryHelper.getBorderInsetsForNoComponent(b);
        size.height = size.height + bIns.top + bIns.bottom;
        size.width = size.width + bIns.left + bIns.right;
    }
    Rectangle r2 = new Rectangle(size);
    if (r != null) {
        if (r.height > 0) {
            r2.height = r.height;
        }
        if (r.width > 0) {
            r2.width = r.width;
        }
        r2.x = r.x;
        r2.y = r.y;
    }
    return r2;
}
Also used : FormController(com.servoy.j2db.FormController) Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) Border(javax.swing.border.Border)

Example 15 with FormController

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

the class WebDataRenderer method createScriptEvent.

private JSDNDEvent createScriptEvent(EventType type, IComponent dragSource, Point xy, int modifiers) {
    JSDNDEvent jsEvent = new JSDNDEvent();
    jsEvent.setType(type);
    jsEvent.setFormName(getDragFormName());
    IRecordInternal dragRecord = getDragRecord(xy);
    if (dragRecord instanceof Record)
        jsEvent.setRecord((Record) dragRecord);
    if (dragSource instanceof IDataRenderer) {
        IDataRenderer dr = (IDataRenderer) dragSource;
        FormController fct = dr.getDataAdapterList().getFormController();
        jsEvent.setSource(fct.getFormScope());
    } else {
        jsEvent.setSource(dragSource);
        if (dragSource != null) {
            String dragSourceName = dragSource.getName();
            if (dragSourceName == null)
                dragSourceName = dragSource.getId();
            jsEvent.setElementName(dragSourceName);
        }
    }
    if (xy != null)
        jsEvent.setLocation(xy);
    jsEvent.setModifiers(modifiers);
    return jsEvent;
}
Also used : FormController(com.servoy.j2db.FormController) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) JSDNDEvent(com.servoy.j2db.dnd.JSDNDEvent) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) Record(com.servoy.j2db.dataprocessing.Record)

Aggregations

FormController (com.servoy.j2db.FormController)70 FormManager (com.servoy.j2db.FormManager)15 Form (com.servoy.j2db.persistence.Form)13 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)12 RepositoryException (com.servoy.j2db.persistence.RepositoryException)10 Point (java.awt.Point)10 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)9 ArrayList (java.util.ArrayList)9 IFormController (com.servoy.j2db.IFormController)8 BasicFormController (com.servoy.j2db.BasicFormController)7 IForm (com.servoy.j2db.IForm)7 WebForm (com.servoy.j2db.server.headlessclient.WebForm)7 FlattenedSolution (com.servoy.j2db.FlattenedSolution)6 IFormUIInternal (com.servoy.j2db.IFormUIInternal)5 IDataProvider (com.servoy.j2db.persistence.IDataProvider)5 List (java.util.List)5 ApplicationException (com.servoy.j2db.ApplicationException)4 IMainContainer (com.servoy.j2db.IMainContainer)4 PrototypeState (com.servoy.j2db.dataprocessing.PrototypeState)4 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)4