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);
}
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$
}
Aggregations