Search in sources :

Example 16 with IDataRenderer

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

the class DataRendererFactory method getEmptyDataRenderer.

public IDataRenderer getEmptyDataRenderer(String Id, String name, IApplication app, boolean showSelection) {
    DataRenderer dr = new DataRenderer(app, showSelection);
    dr.putClientProperty("Id", Id);
    dr.setName(name);
    return dr;
}
Also used : IDataRenderer(com.servoy.j2db.ui.IDataRenderer)

Example 17 with IDataRenderer

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

the class WebDataRendererFactory method completeRenderers.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.servoy.j2db.IDataRendererFactory#completeRenderers(com.servoy.j2db.IApplication, com.servoy.j2db.persistence.Form,
	 * com.servoy.j2db.IScriptExecuter, java.util.Map, int, boolean, com.servoy.j2db.ControllerUndoManager)
	 */
public Map completeRenderers(IApplication application, Form form, IScriptExecuter scriptExecuter, Map emptyDataRenderers, int width, boolean printing, ControllerUndoManager undoManager, TabSequenceHelper<Component> tabSequence) throws Exception {
    int partHeight = 0;
    Iterator e2 = form.getParts();
    while (e2.hasNext()) {
        Part part = (Part) e2.next();
        Color bg = ComponentFactory.getPartBackground(application, part, form);
        if (bg != null) {
            Pair<IStyleSheet, IStyleRule> formStyle = ComponentFactory.getCSSPairStyleForForm(application, form);
            if (formStyle != null && formStyle.getRight() != null && formStyle.getRight().hasAttribute(CSSName.BACKGROUND_IMAGE.toString())) {
                bg = null;
            }
        }
        if (bg == null && printing)
            bg = Color.white;
        IDataRenderer panel = (IDataRenderer) emptyDataRenderers.get(part);
        if (panel != null) {
            int total = Math.abs(part.getHeight() - partHeight);
            setBasicSettings(panel, bg, new Dimension(width, total), new Point(0, partHeight), printing);
        }
        partHeight = part.getHeight();
    }
    // place all the elements
    return placeElements(application, form, scriptExecuter, emptyDataRenderers, printing, undoManager, tabSequence);
}
Also used : IStyleSheet(com.servoy.j2db.util.IStyleSheet) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) Part(com.servoy.j2db.persistence.Part) Color(java.awt.Color) Iterator(java.util.Iterator) IStyleRule(com.servoy.j2db.util.IStyleRule) Dimension(java.awt.Dimension) Point(java.awt.Point) Point(java.awt.Point)

Example 18 with IDataRenderer

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

the class WebForm method makeElementsScriptObject.

/**
 * @see com.servoy.j2db.IFormUIInternal#makeElementsScriptObject(org.mozilla.javascript.Scriptable, java.util.Map, com.servoy.j2db.ui.IDataRenderer[],
 *      com.servoy.j2db.IView)
 */
public ElementScope makeElementsScriptObject(Scriptable fs, Map<String, Object[]> hmChildrenJavaMembers, IDataRenderer[] dataRenderers, IView v) {
    ElementScope es = new ElementScope(fs);
    int counter = 0;
    for (int i = FormController.FORM_RENDERER + 1; i < dataRenderers.length; i++) {
        IDataRenderer dr = dataRenderers[i];
        if (dr == null)
            continue;
        Object[] comps = null;
        if (dr instanceof WebMarkupContainer) {
            comps = new Object[((WebMarkupContainer) dr).size()];
            Iterator it = ((WebMarkupContainer) dr).iterator();
            int j = 0;
            while (it.hasNext()) {
                comps[j++] = it.next();
            }
        }
        counter = registerComponentsToScope(fs, es, counter, comps, hmChildrenJavaMembers, dr);
    }
    if (v instanceof WebCellBasedView) {
        Object[] comps = ((WebCellBasedView) v).getComponents();
        counter = registerComponentsToScope(fs, es, counter, comps, hmChildrenJavaMembers, v);
    }
    es.setLocked(true);
    return es;
}
Also used : IDataRenderer(com.servoy.j2db.ui.IDataRenderer) ElementScope(com.servoy.j2db.scripting.ElementScope) Iterator(java.util.Iterator) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) WebCellBasedView(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView) Point(java.awt.Point) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 19 with IDataRenderer

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

the class WebForm method initView.

/**
 * @see com.servoy.j2db.IFormUIInternal#initView(com.servoy.j2db.IApplication, com.servoy.j2db.FormController, int)
 */
public IView initView(IApplication app, FormController fp, int viewType) {
    boolean addHeaders = true;
    view = null;
    final Form f = fp.getForm();
    DataRendererRecordModel rendererModel = new DataRendererRecordModel();
    // int viewType = f.getView();
    if (viewType == IForm.LIST_VIEW || viewType == FormController.LOCKED_LIST_VIEW) {
        // list views do not have headers
        addHeaders = false;
    }
    // String orientation = OrientationApplier.getHTMLContainerOrientation(app.getLocale(), app.getSolution().getTextOrientation());
    IDataRenderer[] dataRenderers = fp.getDataRenderers();
    for (int i = 0; i < dataRenderers.length; i++) {
        if (i == Part.TITLE_HEADER || i == Part.HEADER || i == Part.LEADING_GRAND_SUMMARY || i == Part.TRAILING_GRAND_SUMMARY || i == Part.FOOTER) {
            if (dataRenderers[Part.HEADER] != null) {
                addHeaders = false;
            }
            WebDataRenderer dr = (WebDataRenderer) dataRenderers[i];
            if (dr != null) {
                dr.setDefaultModel(rendererModel);
                container.add(dr);
            }
        }
    }
    defaultNavigator = null;
    if (viewType == IForm.RECORD_VIEW || viewType == IForm.LOCKED_RECORD_VIEW) {
        // $NON-NLS-1$
        view = new WebRecordView("View");
        if (f.getNavigatorID() == Form.NAVIGATOR_DEFAULT) {
            defaultNavigator = new WebDefaultRecordNavigator(this);
            ((WebRecordView) view).add(defaultNavigator);
        }
        // Body
        WebDataRenderer body = (WebDataRenderer) dataRenderers[FormController.FORM_EDITOR];
        if (body != null) {
            ((WebRecordView) view).add(body);
            body.setDefaultModel(rendererModel);
            body.setParentView(view);
        } else {
        // ((WebRecordView)view).add(new WebMarkupContainer());
        }
    } else if (viewType == FormController.TABLE_VIEW || viewType == FormController.LOCKED_TABLE_VIEW || viewType == IForm.LIST_VIEW || viewType == FormController.LOCKED_LIST_VIEW) {
        // try
        // {
        // Iterator it = f.getParts();
        // while (it.hasNext())
        // {
        // Part p = (Part) it.next();
        // if (p.getPartType() == Part.HEADER)
        // {
        // addHeaders = false;
        // break;
        // }
        // }
        // }
        // catch (RepositoryException e)
        // {
        // Debug.error(e);
        // }
        Part body = null;
        Iterator<Part> e2 = fp.getForm().getParts();
        while (e2.hasNext()) {
            Part part = e2.next();
            if (part.getPartType() == Part.BODY) {
                body = part;
                break;
            }
        }
        if (body == null) {
            // Special case, form in tableview with no body. just create a default view object.
            // $NON-NLS-1$
            view = new WebRecordView("View");
            return view;
        } else {
            int startY = fp.getForm().getPartStartYPos(body.getID());
            int endY = body.getHeight();
            int sizeHint = endY;
            if (// small body and body is last
            (sizeHint - startY) <= 40 && fp.getForm().getSize().height == sizeHint) {
                sizeHint += Math.max(endY, 200 - sizeHint);
            }
            RuntimePortal viewScriptable = new RuntimePortal(new ChangesRecorder(null, null), app);
            view = new WebCellBasedView("View", app, viewScriptable, f, f, app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), f), fp.getScriptExecuter(), addHeaders, startY, endY, sizeHint, viewType);
            viewScriptable.setComponent((WebCellBasedView) view, f);
            if (dataRenderers[FormController.FORM_EDITOR] != null)
                dataRenderers[FormController.FORM_EDITOR].destroy();
            dataRenderers[FormController.FORM_EDITOR] = (WebCellBasedView) view;
        }
    }
    if (container.get("View") != null) {
        container.replace((WebMarkupContainer) view);
    } else {
        container.add((WebMarkupContainer) view);
    }
    return view;
}
Also used : WebRecordView(com.servoy.j2db.server.headlessclient.dataui.WebRecordView) WebDataRenderer(com.servoy.j2db.server.headlessclient.dataui.WebDataRenderer) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) WebCellBasedView(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView) Point(java.awt.Point) ChangesRecorder(com.servoy.j2db.server.headlessclient.dataui.ChangesRecorder) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) RuntimePortal(com.servoy.j2db.ui.scripting.RuntimePortal) WebDefaultRecordNavigator(com.servoy.j2db.server.headlessclient.dataui.WebDefaultRecordNavigator) Part(com.servoy.j2db.persistence.Part) Iterator(java.util.Iterator)

Aggregations

IDataRenderer (com.servoy.j2db.ui.IDataRenderer)19 Point (java.awt.Point)10 IComponent (com.servoy.j2db.ui.IComponent)8 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)6 FormController (com.servoy.j2db.FormController)5 Part (com.servoy.j2db.persistence.Part)5 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)4 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)4 Component (java.awt.Component)4 JComponent (javax.swing.JComponent)4 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)4 ScriptableObject (org.mozilla.javascript.ScriptableObject)4 Record (com.servoy.j2db.dataprocessing.Record)3 BaseComponent (com.servoy.j2db.persistence.BaseComponent)3 Form (com.servoy.j2db.persistence.Form)3 WebCellBasedView (com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView)3 PortalComponent (com.servoy.j2db.smart.dataui.PortalComponent)3 IStyleRule (com.servoy.j2db.util.IStyleRule)3 IStyleSheet (com.servoy.j2db.util.IStyleSheet)3 ArrayList (java.util.ArrayList)3