Search in sources :

Example 1 with WebSplitPane

use of com.servoy.j2db.server.headlessclient.dataui.WebSplitPane 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)

Example 2 with WebSplitPane

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

the class PageContributor method renderHead.

@Override
public void renderHead(HtmlHeaderContainer container) {
    super.renderHead(container);
    IHeaderResponse response = container.getHeaderResponse();
    String djs = getDynamicJavaScript();
    if (djs != null) {
        response.renderOnLoadJavascript(djs);
    }
    addReferences(response);
    Page page = findPage();
    if (page instanceof MainPage) {
        Component focus = ((MainPage) page).getAndResetToFocusComponent();
        if (focus != null) {
            // it can happen before a 'wicket'-dom ready
            if (focus instanceof WebDataHtmlArea) {
                response.renderOnDomReadyJavascript("tinyMCE.activeEditor.focus()");
            } else {
                // $NON-NLS-1$ //$NON-NLS-2$
                response.renderOnDomReadyJavascript("setTimeout(\"requestFocus('" + focus.getMarkupId() + "');\",0);");
            }
        }
    }
    if (formAnchorInfos != null && formAnchorInfos.size() != 0 && WebClientSession.get() != null && WebClientSession.get().getWebClient() != null && // $NON-NLS-1$
    Utils.getAsBoolean(WebClientSession.get().getWebClient().getRuntimeProperties().get("enableAnchors"))) {
        if (anchorInfoChanged) {
            response.renderJavascriptReference(anchorlayout);
            // setTimeout is important here, to let the browser apply CSS styles during Ajax calls //$NON-NLS-1$
            response.renderOnLoadJavascript("setTimeout(\"layoutEntirePage();\", 10);");
            String sb = FormAnchorInfo.generateAnchoringFunctions(formAnchorInfos, getOrientation());
            response.renderJavascript(sb, null);
            anchorInfoChanged = false;
        } else if (componentsThatNeedAnchorRelayout != null && componentsThatNeedAnchorRelayout.length() > 0) {
            response.renderJavascriptReference(anchorlayout);
            response.renderOnLoadJavascript("setTimeout(\"layoutSpecificElements();\", 10);");
            response.renderJavascript("executeLayoutSpecificElements = function()\n{\n" + componentsThatNeedAnchorRelayout.append("\n}"), null);
        }
    }
    if (componentsThatNeedAnchorRelayout != null)
        componentsThatNeedAnchorRelayout.setLength(0);
    if (tabIndexChanges.size() > 0) {
        StringBuffer stringBuffer = new StringBuffer();
        // $NON-NLS-1$
        stringBuffer.append("Servoy.TabCycleHandling.setNewTabIndexes([");
        for (String componentID : tabIndexChanges.keySet()) {
            // $NON-NLS-1$
            stringBuffer.append("['");
            stringBuffer.append(componentID);
            // $NON-NLS-1$
            stringBuffer.append("',");
            stringBuffer.append(tabIndexChanges.get(componentID));
            // $NON-NLS-1$
            stringBuffer.append("]");
            // $NON-NLS-1$
            stringBuffer.append(",");
        }
        stringBuffer.deleteCharAt(stringBuffer.length() - 1);
        // $NON-NLS-1$
        stringBuffer.append("]);");
        response.renderOnLoadJavascript(stringBuffer.toString());
        tabIndexChanges.clear();
    }
    if (splitPanesToUpdateDivider.size() > 0) {
        for (WebSplitPane splitPane : splitPanesToUpdateDivider) {
            if (splitPane.findParent(Page.class) != null && !splitPane.getScriptObject().getChangesRecorder().isChanged() && !splitPane.isParentContainerChanged()) {
                response.renderOnLoadJavascript(// $NON-NLS-1$ //$NON-NLS-2$
                (new StringBuilder("(function() {").append(splitPane.getDividerLocationJSSetter(true).append("}).call();"))).toString());
            }
        }
        splitPanesToUpdateDivider.clear();
    }
// Enable this for Firebug debugging under IE/Safari/etc.
// response.renderJavascriptReference("http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"); //$NON-NLS-1$
}
Also used : WebDataHtmlArea(com.servoy.j2db.server.headlessclient.dataui.WebDataHtmlArea) IHeaderResponse(org.apache.wicket.markup.html.IHeaderResponse) Page(org.apache.wicket.Page) IComponent(com.servoy.j2db.ui.IComponent) Component(org.apache.wicket.Component) WebSplitPane(com.servoy.j2db.server.headlessclient.dataui.WebSplitPane)

Aggregations

WebSplitPane (com.servoy.j2db.server.headlessclient.dataui.WebSplitPane)2 IComponent (com.servoy.j2db.ui.IComponent)2 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 WebDataHtmlArea (com.servoy.j2db.server.headlessclient.dataui.WebDataHtmlArea)1 WebTabFormLookup (com.servoy.j2db.server.headlessclient.dataui.WebTabFormLookup)1 WebTabPanel (com.servoy.j2db.server.headlessclient.dataui.WebTabPanel)1 ITabPanel (com.servoy.j2db.ui.ITabPanel)1 Point (java.awt.Point)1 Component (org.apache.wicket.Component)1 MarkupContainer (org.apache.wicket.MarkupContainer)1 Page (org.apache.wicket.Page)1 IHeaderResponse (org.apache.wicket.markup.html.IHeaderResponse)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)1 ScriptableObject (org.mozilla.javascript.ScriptableObject)1