Search in sources :

Example 1 with ISupplyFocusChildren

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

the class WebForm method setTabSeqComponents.

public void setTabSeqComponents(List<Component> tabSequence) {
    boolean defaultSequence = true;
    if (tabSequence != null && tabSequence.size() > 0) {
        defaultSequence = false;
        IDataRenderer formEditorRenderer = formController.getDataRenderers()[FormController.FORM_EDITOR];
        if (formEditorRenderer instanceof WebCellBasedView && !tabSequence.contains(formEditorRenderer)) {
            // 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 (((WebCellBasedView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    // table view should be added to tab sequence
                    ((WebCellBasedView) formEditorRenderer).setTabSeqComponents(tabSequence);
                    tabSequence = new ArrayList<Component>(tabSequence);
                    tabSequence.add(i, (Component) formEditorRenderer);
                    break;
                }
            }
            i++;
            while (i < tabSequence.size()) {
                if (((WebCellBasedView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    tabSequence.remove(i);
                } else {
                    i++;
                }
            }
        }
        int tabIndex = 1;
        for (Component comp : tabSequence) {
            if (comp instanceof IWebFormContainer) {
                ((IWebFormContainer) comp).setTabSequenceIndex(tabIndex);
                tabIndex = WebDataRendererFactory.getContainerGapIndex(tabIndex + WebDataRendererFactory.CONTAINER_RESERVATION_GAP, tabIndex);
                TabIndexHelper.setUpTabIndexAttributeModifier(comp, ISupportWebTabSeq.SKIP);
            } else if (comp instanceof WebCellBasedView) {
                WebCellBasedView tableView = (WebCellBasedView) comp;
                tableView.setTabSequenceIndex(tabIndex);
                tabIndex += WebDataRendererFactory.MAXIMUM_TAB_INDEXES_ON_TABLEVIEW;
                TabIndexHelper.setUpTabIndexAttributeModifier(comp, ISupportWebTabSeq.SKIP);
            } else {
                TabIndexHelper.setUpTabIndexAttributeModifier(comp, tabIndex);
                tabIndex++;
            }
        }
    }
    IDataRenderer[] dataRenderers = formController.getDataRenderers();
    for (IDataRenderer dr : dataRenderers) {
        if (dr != null) {
            // set attributeModifiers for all components
            if (dr instanceof WebCellBasedView) {
                if (defaultSequence) {
                    // normal focus
                    ((WebCellBasedView) dr).setTabSequenceIndex(ISupportWebTabSeq.DEFAULT);
                    ((WebCellBasedView) dr).setTabSeqComponents(null);
                } else if (!tabSequence.contains(dr)) {
                    // it shouldn't gain focus when tabbing ...
                    ((WebCellBasedView) dr).setTabSequenceIndex(-1);
                    ((WebCellBasedView) dr).setTabSeqComponents(null);
                }
            } else {
                Iterator compIt = dr.getComponentIterator();
                if (compIt != null) {
                    while (compIt.hasNext()) {
                        Object obj = compIt.next();
                        if (obj instanceof ISupplyFocusChildren) {
                            for (Component c : ((ISupplyFocusChildren<Component>) obj).getFocusChildren()) {
                                checkIfDefaultOrSkipFocus(defaultSequence, tabSequence, c);
                            }
                        } else if (obj instanceof Component) {
                            checkIfDefaultOrSkipFocus(defaultSequence, tabSequence, (Component) obj);
                        }
                    }
                }
            }
        }
    }
    tabSeqComponentList = tabSequence;
}
Also used : IDataRenderer(com.servoy.j2db.ui.IDataRenderer) IWebFormContainer(com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer) Iterator(java.util.Iterator) ISupplyFocusChildren(com.servoy.j2db.util.ISupplyFocusChildren) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) WebCellBasedView(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView) 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 2 with ISupplyFocusChildren

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

the class DataRendererFactory method extendTabSequence.

public void extendTabSequence(List<Component> tabSequence, IFormUIInternal containerImpl) {
    SwingForm sf = (SwingForm) containerImpl;
    JComponent west = sf.getWest();
    if (west != null) {
        if (west instanceof ISupplyFocusChildren) {
            ISupplyFocusChildren<Component> s = (ISupplyFocusChildren<Component>) west;
            Component[] fchilds = s.getFocusChildren();
            for (Component element : fchilds) {
                tabSequence.add(element);
            }
        }
    }
}
Also used : JComponent(javax.swing.JComponent) ISupplyFocusChildren(com.servoy.j2db.util.ISupplyFocusChildren) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) SwingForm(com.servoy.j2db.smart.SwingForm)

Aggregations

IFieldComponent (com.servoy.j2db.ui.IFieldComponent)2 ISupplyFocusChildren (com.servoy.j2db.util.ISupplyFocusChildren)2 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)1 IWebFormContainer (com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer)1 WebCellBasedView (com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView)1 SwingForm (com.servoy.j2db.smart.SwingForm)1 IComponent (com.servoy.j2db.ui.IComponent)1 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)1 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)1 Component (java.awt.Component)1 Point (java.awt.Point)1 Iterator (java.util.Iterator)1 JComponent (javax.swing.JComponent)1 Component (org.apache.wicket.Component)1 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)1 ScriptableObject (org.mozilla.javascript.ScriptableObject)1