Search in sources :

Example 11 with IDataRenderer

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

the class SwingForm method setTabSeqComponents.

public void setTabSeqComponents(List<Component> tabSequence) {
    IDataRenderer formEditorRenderer = formController.getDataRenderers()[FormController.FORM_EDITOR];
    if (formEditorRenderer instanceof TableView && (tabSequence == null || !tabSequence.contains(formEditorRenderer))) {
        // table view should be added to tab sequence
        ((TableView) formEditorRenderer).setTabSeqComponents(tabSequence);
        if (tabSequence != null && tabSequence.size() > 0) {
            // this means that we have to identify components that are part of the table view and based on where these are located set the view's tabIndex
            // when called from JS tabSequence will only contain table columns, not table view as opposed to initialization when tabSequence only contains the view
            int i;
            for (i = 0; i < tabSequence.size(); i++) {
                if (((TableView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    tabSequence = new ArrayList<Component>(tabSequence);
                    tabSequence.add(i, (Component) formEditorRenderer);
                    break;
                }
            }
            i++;
            while (i < tabSequence.size()) {
                if (((TableView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    tabSequence.remove(i);
                } else {
                    i++;
                }
            }
        }
    }
    this.tabSeqComponentList = tabSequence;
    if (tabSeqComponentList != null) {
        if (tabSeqComponentList.size() > 0) {
            JComponent lastComponent = (JComponent) tabSeqComponentList.get(tabSeqComponentList.size() - 1);
            if (!(lastComponent instanceof SpecialTabPanel)) {
                int modifier = 0;
                if ((lastComponent instanceof TableView))
                    modifier = InputEvent.CTRL_DOWN_MASK;
                if ((lastComponent instanceof DataComboBox) && ((DataComboBox) lastComponent).isEditable())
                    lastComponent = (JComponent) ((DataComboBox) lastComponent).getEditor().getEditorComponent();
                addJumpOutActionToComponent(lastComponent, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, modifier), ACTION_GO_OUT_TO_NEXT, false);
            }
            JComponent firstComponent = (JComponent) tabSeqComponentList.get(0);
            if (!(firstComponent instanceof SpecialTabPanel)) {
                int modifier = 0;
                if ((firstComponent instanceof TableView))
                    modifier = InputEvent.CTRL_DOWN_MASK;
                if ((firstComponent instanceof DataComboBox) && ((DataComboBox) firstComponent).isEditable())
                    firstComponent = (JComponent) ((DataComboBox) firstComponent).getEditor().getEditorComponent();
                addJumpOutActionToComponent(firstComponent, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, modifier | InputEvent.SHIFT_DOWN_MASK), ACTION_GO_OUT_TO_PREV, true);
            }
        }
    }
}
Also used : IDataRenderer(com.servoy.j2db.ui.IDataRenderer) SpecialTabPanel(com.servoy.j2db.smart.dataui.SpecialTabPanel) JComponent(javax.swing.JComponent) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) PortalComponent(com.servoy.j2db.smart.dataui.PortalComponent) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Point(java.awt.Point) DataComboBox(com.servoy.j2db.smart.dataui.DataComboBox)

Example 12 with IDataRenderer

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

the class SwingForm method makeElementsScriptObject.

/**
 * @see com.servoy.j2db.IFormUIInternal#makeElementsScriptObject(org.mozilla.javascript.Scriptable)
 */
public ElementScope makeElementsScriptObject(Scriptable fs, Map<String, Object[]> hmChildrenJavaMembers, IDataRenderer[] dataRenderers, IView controller) {
    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;
        Object[] compsRenderer = null;
        if (dr instanceof DataRenderer) {
            comps = ((DataRenderer) dr).getComponents();
            if (i == FormController.FORM_EDITOR && dataRenderers[FormController.FORM_RENDERER] != null) {
                compsRenderer = ((DataRenderer) dataRenderers[FormController.FORM_RENDERER]).getComponents();
            }
        } else if (dr instanceof TableView) {
            TableView tv = (TableView) dr;
            List<CellAdapter> nonViewableColumns = tv.getNonViewableColumns();
            int componentCount = tv.getColumnCount() + nonViewableColumns.size();
            comps = new Component[componentCount];
            compsRenderer = new Component[componentCount];
            CellAdapter[] tableCellAdapters = new CellAdapter[componentCount];
            for (int j = 0; j < componentCount; j++) {
                tableCellAdapters[j] = (j < tv.getColumnCount()) ? (CellAdapter) tv.getCellEditor(0, j) : nonViewableColumns.get(j - tv.getColumnCount());
                comps[j] = tableCellAdapters[j].getEditor();
                compsRenderer[j] = tableCellAdapters[j].getRenderer();
            }
            for (int j = 0; j < comps.length; j++) {
                if (compsRenderer[j] instanceof Component && !((Component) compsRenderer[j]).isVisible()) {
                    tv.getColumnModel().removeColumn(tableCellAdapters[j]);
                }
            }
        } else 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, compsRenderer, (Component) controller, hmChildrenJavaMembers);
    }
    es.setLocked(true);
    return es;
}
Also used : IDataRenderer(com.servoy.j2db.ui.IDataRenderer) DataRenderer(com.servoy.j2db.smart.dataui.DataRenderer) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) ElementScope(com.servoy.j2db.scripting.ElementScope) TwoNativeJavaObject(com.servoy.j2db.smart.scripting.TwoNativeJavaObject) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) PageList(com.servoy.j2db.printing.PageList) ArrayList(java.util.ArrayList) List(java.util.List) JList(javax.swing.JList) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) PortalComponent(com.servoy.j2db.smart.dataui.PortalComponent) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Point(java.awt.Point) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 13 with IDataRenderer

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

the class TabSequenceHelper method fromAbstractToNamed.

public void fromAbstractToNamed() {
    T tableViewToInsert = null;
    int largestIndexBeforeBody = -1;
    T lastComponentBeforeBody = null;
    LinkedHashMap<T, String> componentGroupsByTabIndex = new LinkedHashMap<T, String>();
    FormController fc = runtimeContainer.getController();
    Form f = fc.getForm();
    Iterator<Part> parts = f.getParts();
    while (parts.hasNext()) {
        Part p = parts.next();
        IDataRenderer dataRenderer = fc.getDataRenderers()[p.getPartType()];
        if (dataRenderer != null) {
            // Later we will insert it in the tab sequence.
            if ((fc.getViewComponent() instanceof IProvideTabSequence) && (p.getPartType() == Part.BODY)) {
                tableViewToInsert = (T) dataRenderer;
            } else {
                SortedMap<ISupportTabSeq, T> dataRendererComponents = abstractTabSequence.get(dataRenderer);
                if (dataRendererComponents != null) {
                    for (ISupportTabSeq supportTabSeq : dataRendererComponents.keySet()) {
                        if (supportTabSeq.getTabSeq() >= 0) {
                            T next = dataRendererComponents.get(supportTabSeq);
                            String name = null;
                            if (supportTabSeq instanceof ISupportName)
                                name = ((ISupportName) supportTabSeq).getName();
                            componentGroupsByTabIndex.put(next, name);
                            if ((p.getPartType() == Part.HEADER) || (p.getPartType() == Part.TITLE_HEADER) || (p.getPartType() == Part.LEADING_GRAND_SUMMARY)) {
                                if (supportTabSeq.getTabSeq() >= largestIndexBeforeBody) {
                                    lastComponentBeforeBody = next;
                                    largestIndexBeforeBody = supportTabSeq.getTabSeq();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    componentsToNames.clear();
    if ((lastComponentBeforeBody == null) && (tableViewToInsert != null))
        componentsToNames.put(tableViewToInsert, null);
    for (T o : componentGroupsByTabIndex.keySet()) {
        componentsToNames.put(o, componentGroupsByTabIndex.get(o));
        if ((tableViewToInsert != null) && (lastComponentBeforeBody != null) && (o.equals(lastComponentBeforeBody)))
            componentsToNames.put(tableViewToInsert, null);
    }
    revertComponentsToNames();
    fromNamedToRuntime();
}
Also used : FormController(com.servoy.j2db.FormController) Form(com.servoy.j2db.persistence.Form) ISupportName(com.servoy.j2db.persistence.ISupportName) ISupportTabSeq(com.servoy.j2db.persistence.ISupportTabSeq) LinkedHashMap(java.util.LinkedHashMap) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) IProvideTabSequence(com.servoy.j2db.IProvideTabSequence) Part(com.servoy.j2db.persistence.Part)

Example 14 with IDataRenderer

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

the class DataRendererFactory method createPortalRenderer.

public IDataRenderer createPortalRenderer(IApplication app, Portal objToRender, Form dataProviderLookup, IScriptExecuter listner, boolean printing, ControllerUndoManager undoManager) throws Exception {
    List<IPersist> allObjectsAsList = objToRender.getAllObjectsAsList();
    List<IFormElement> formElements = new ArrayList<IFormElement>(allObjectsAsList.size());
    for (IPersist persist : allObjectsAsList) {
        if (persist instanceof IFormElement) {
            formElements.add((IFormElement) persist);
        }
    }
    List<IFormElement> children = new SortedList<IFormElement>(new Comparator<IFormElement>() {

        public int compare(IFormElement o1, IFormElement o2) {
            // reverse order, right order for tab sequence
            int result = -PositionComparator.XY_PERSIST_COMPARATOR.compare(o1, o2);
            if (result == 0) {
                return (o1.getFormIndex() - o2.getFormIndex());
            }
            return result;
        }
    }, formElements);
    Iterator<IFormElement> e1 = children.iterator();
    Map emptyDataRenderers = new LinkedHashMap();
    DataRenderer dr = null;
    int height = objToRender.getRowHeight();
    boolean calculateHeight = (height == 0);
    // for safety
    if (height == 0)
        height = 100;
    // int leftBorder = 0;
    // int bottomBorder = 0;
    // if (objToRender.getShowHorizontalLines())
    // {
    // bottomBorder = 1;
    // }
    // if (objToRender.getShowVerticalLines())
    // {
    // leftBorder = 4;
    // }
    boolean showSelection = objToRender.getShowVerticalLines();
    dr = (DataRenderer) getEmptyDataRenderer(ComponentFactory.getWebID(dataProviderLookup, objToRender), "portal_" + objToRender.getName(), app, showSelection);
    setBasicSettings(dr, objToRender.getBackground(), new Dimension(objToRender.getSize().width, height), new Point(0, 0), printing);
    // first is dummy saying is portal
    emptyDataRenderers.put(new Boolean(true), dr);
    dr.setLocation(objToRender.getLocation());
    Border b = ComponentFactoryHelper.createBorder(objToRender.getBorderType());
    Insets ins = new Insets(0, 0, 0, 0);
    if (b != null) {
        ins = ComponentFactoryHelper.getBorderInsetsForNoComponent(b);
    }
    // if (b instanceof EmptyBorder)
    // {
    // ins = ((EmptyBorder)b).getBorderInsets();
    // }
    placeElements(e1, app, dataProviderLookup, listner, emptyDataRenderers, objToRender.getSize().width, -(objToRender.getLocation().x + ins.right), -ins.top, printing, true, undoManager, true, null);
    int biggest_width = 10;
    int biggest_height = calculateHeight ? 0 : height;
    Component[] comps = dr.getComponents();
    boolean hasRowBGColorCalc = objToRender.getRowBGColorCalculation() != null;
    for (Component element : comps) {
        int w = element.getLocation().x + element.getSize().width;
        if (w > biggest_width)
            biggest_width = w;
        if (hasRowBGColorCalc && element instanceof JComponent)
            ((JComponent) element).setOpaque(false);
        if (calculateHeight) {
            int h = element.getLocation().y + element.getSize().height;
            if (h > biggest_height)
                biggest_height = h;
        }
    }
    dr.setSize(new Dimension(biggest_width, biggest_height));
    dr.setPreferredSize(new Dimension(biggest_width, biggest_height));
    if (printing) {
        // sliding inside a multiline portal renderer is nor supported, be we have to attach the springs for resizes
        addSpringsBetweenComponents(app, dr);
    }
    return dr;
}
Also used : Insets(java.awt.Insets) IDataRenderer(com.servoy.j2db.ui.IDataRenderer) ArrayList(java.util.ArrayList) SortedList(com.servoy.j2db.util.SortedList) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension) Point(java.awt.Point) Point(java.awt.Point) LinkedHashMap(java.util.LinkedHashMap) IFormElement(com.servoy.j2db.persistence.IFormElement) IPersist(com.servoy.j2db.persistence.IPersist) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Border(javax.swing.border.Border)

Example 15 with IDataRenderer

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

the class DataRendererFactory method setBasicSettings.

private void setBasicSettings(IDataRenderer panel, Color bg, Dimension size, Point location, boolean printing) {
    DataRenderer dr = (DataRenderer) panel;
    if (dr != null) {
        if (bg != null) {
            dr.setBackground(bg);
        }
        if (printing) {
            dr.setLayout(new FixedSpringLayout());
        } else {
            dr.setLayout(new AnchorLayout(size));
            dr.setPreferredSize(size);
        }
        dr.setSize(size);
        dr.setLocation(location);
    }
}
Also used : AnchorLayout(com.servoy.j2db.util.gui.AnchorLayout) FixedSpringLayout(com.servoy.j2db.util.gui.FixedSpringLayout) IDataRenderer(com.servoy.j2db.ui.IDataRenderer)

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