Search in sources :

Example 1 with WebTabFormLookup

use of com.servoy.j2db.server.headlessclient.dataui.WebTabFormLookup in project servoy-client by Servoy.

the class WebForm method getFormContext.

public JSDataSet getFormContext() {
    WebForm current = this;
    ITabPanel currentTabPanel = null;
    String currentBeanName = null;
    WebSplitPane currentSplitPane = null;
    IDataSet set = new BufferedDataSet(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$
    new String[] { "containername", "formname", "tabpanel/splitpane/accordion/beanname", "tabname", "tabindex", "tabindex1based" }, new ArrayList<Object[]>());
    set.addRow(new Object[] { null, current.formController.getName(), null, null, null, null });
    MarkupContainer parent = getParent();
    while (parent != null) {
        if (parent instanceof WebSplitPane) {
            currentSplitPane = (WebSplitPane) parent;
        } else if (parent instanceof ITabPanel) {
            currentTabPanel = (ITabPanel) parent;
        } else if (parent instanceof IServoyAwareBean && parent instanceof IComponent) {
            currentBeanName = ((IComponent) parent).getName();
        } else if (parent instanceof WebForm) {
            if (currentTabPanel != null) {
                int index = -1;
                String tabName = null;
                if (currentTabPanel instanceof WebTabPanel) {
                    index = ((WebTabPanel) currentTabPanel).getTabIndex(current);
                } else if (currentTabPanel instanceof WebAccordionPanel) {
                    index = ((WebAccordionPanel) currentTabPanel).getTabIndex(current);
                }
                if (index != -1) {
                    // js method so +1
                    tabName = currentTabPanel.getTabNameAt(index);
                }
                current = (WebForm) parent;
                set.addRow(0, new Object[] { null, current.formController.getName(), currentTabPanel.getName(), tabName, new Integer(index), new Integer(index + 1) });
            } else if (currentBeanName != null) {
                current = (WebForm) parent;
                set.addRow(0, new Object[] { null, current.formController.getName(), currentBeanName, null, null, null });
            } else if (currentSplitPane != null) {
                int idx = currentSplitPane.getLeftForm() != null && current.equals(((WebTabFormLookup) currentSplitPane.getLeftForm()).getWebForm()) ? 0 : 1;
                current = (WebForm) parent;
                set.addRow(0, new Object[] { null, current.formController.getName(), currentSplitPane.getName(), currentSplitPane.getTabNameAt(idx), new Integer(idx + 1), new Integer(idx + 1) });
            }
            current = (WebForm) parent;
            currentTabPanel = null;
            currentBeanName = null;
            currentSplitPane = null;
        } else if (parent instanceof MainPage) {
            String containerName = ((MainPage) parent).getContainerName();
            if (containerName != null) {
                for (int i = 0; i < set.getRowCount(); i++) {
                    set.getRow(i)[0] = containerName;
                }
            }
            return new JSDataSet(formController.getApplication(), set);
        }
        parent = parent.getParent();
    }
    return new JSDataSet(formController.getApplication(), set);
}
Also used : MarkupContainer(org.apache.wicket.MarkupContainer) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) IComponent(com.servoy.j2db.ui.IComponent) JSDataSet(com.servoy.j2db.dataprocessing.JSDataSet) ITabPanel(com.servoy.j2db.ui.ITabPanel) WebTabFormLookup(com.servoy.j2db.server.headlessclient.dataui.WebTabFormLookup) WebSplitPane(com.servoy.j2db.server.headlessclient.dataui.WebSplitPane) Point(java.awt.Point) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) BufferedDataSet(com.servoy.j2db.dataprocessing.BufferedDataSet) WebAccordionPanel(com.servoy.j2db.server.headlessclient.dataui.WebAccordionPanel) WebTabPanel(com.servoy.j2db.server.headlessclient.dataui.WebTabPanel) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) IDataSet(com.servoy.j2db.dataprocessing.IDataSet)

Aggregations

BufferedDataSet (com.servoy.j2db.dataprocessing.BufferedDataSet)1 IDataSet (com.servoy.j2db.dataprocessing.IDataSet)1 JSDataSet (com.servoy.j2db.dataprocessing.JSDataSet)1 IServoyAwareBean (com.servoy.j2db.dataui.IServoyAwareBean)1 WebAccordionPanel (com.servoy.j2db.server.headlessclient.dataui.WebAccordionPanel)1 WebSplitPane (com.servoy.j2db.server.headlessclient.dataui.WebSplitPane)1 WebTabFormLookup (com.servoy.j2db.server.headlessclient.dataui.WebTabFormLookup)1 WebTabPanel (com.servoy.j2db.server.headlessclient.dataui.WebTabPanel)1 IComponent (com.servoy.j2db.ui.IComponent)1 ITabPanel (com.servoy.j2db.ui.ITabPanel)1 Point (java.awt.Point)1 MarkupContainer (org.apache.wicket.MarkupContainer)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)1 ScriptableObject (org.mozilla.javascript.ScriptableObject)1