use of com.servoy.j2db.server.headlessclient.dataui.WebTabPanel in project servoy-client by Servoy.
the class WebForm method onBeforeRender.
/**
* @see org.apache.wicket.Component#onBeforeRender()
*/
@Override
protected void onBeforeRender() {
super.onBeforeRender();
Component container = (Component) findParent(IWebFormContainer.class);
if (container == null) {
container = getParent();
}
if (previousParent != null && previousParent != container) {
// we show this form in another container, we must refresh the size
formWidth = 0;
}
previousParent = container;
// if recreateUI is called on a form in a tabpannel the tabs bar flickers if the background collor isnot the same as the form containing the tab pannel ... So the form in the tab is shown after rearrageTabsInTabPanel() is done
if (isUIRecreated() && getParent() instanceof WebTabPanel) {
hiddenBeforeShow.setEnabled(true);
} else {
hiddenBeforeShow.setEnabled(false);
}
}
use of com.servoy.j2db.server.headlessclient.dataui.WebTabPanel 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.WebTabPanel in project servoy-client by Servoy.
the class WebForm method renderHead.
@SuppressWarnings("nls")
@Override
public void renderHead(HtmlHeaderContainer headercontainer) {
super.renderHead(headercontainer);
Response response = headercontainer.getHeaderResponse().getResponse();
response.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
StringBuilder sb = new StringBuilder();
sb.append(UrlUtils.rewriteToContextRelative("servoy-webclient/formcss/", RequestCycle.get().getRequest()));
sb.append(formController.getForm().getSolution().getName());
sb.append("/");
sb.append(formController.getName());
sb.append("_t");
long prevLMT = lastModifiedTime;
if (lastModifiedTime == 0 || isUIRecreated()) {
lastModifiedTime = System.currentTimeMillis();
}
sb.append(Long.toString(lastModifiedTime));
sb.append("t.css");
response.write(RequestCycle.get().getOriginalResponse().encodeURL(sb));
response.write("\" id=\"formcss_");
response.write(formController.getName());
response.write(Long.toString(lastModifiedTime));
response.write("\"");
getResponse().println(" />");
if (isUIRecreated()) {
if (this.getParent() instanceof WebTabPanel) {
String tabPanelId = this.getParent().getMarkupId();
String showWebFormjs = "$('#" + getMarkupId() + "').css('visibility','" + (isVisible() ? "inherit" : "hidden") + "');";
// show WebForm after rearrangeTabsInTabPanel() is done
String jsCall = "rearrageTabsInTabPanel('" + tabPanelId + "');" + showWebFormjs;
headercontainer.getHeaderResponse().renderOnLoadJavascript(jsCall);
}
StringBuffer cssRef = new StringBuffer();
cssRef.append("Servoy.Utils.removeFormCssLink('formcss_");
cssRef.append(formController.getName());
cssRef.append(prevLMT);
cssRef.append("');");
headercontainer.getHeaderResponse().renderJavascript(cssRef, null);
}
if (isFormInWindow()) {
List<Component> componentz = getTabSeqComponents();
int max = -1;
int min = Integer.MAX_VALUE;
String maxTabIndexElemId = null;
String minTabIndexElemId = null;
for (Component c : componentz) {
int tabIndex = TabIndexHelper.getTabIndex(c);
if (tabIndex > max) {
max = tabIndex;
maxTabIndexElemId = c.getMarkupId();
}
if (tabIndex != -1 && tabIndex < min) {
min = tabIndex;
minTabIndexElemId = c.getMarkupId();
}
}
if (minTabIndexElemId != null && maxTabIndexElemId != null) {
headercontainer.getHeaderResponse().renderOnLoadJavascript("Servoy.TabCycleHandling.registerListeners('" + minTabIndexElemId + "','" + maxTabIndexElemId + "');");
}
}
if (isFormInFormPopup()) {
TreeMap<String, String> tm = new TreeMap<String, String>();
for (Component c : getTabSeqComponents()) {
tm.put(String.valueOf(TabIndexHelper.getTabIndex(c)), c.getMarkupId());
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("Servoy.TabCycleHandling.forceTabbingSequence([");
for (Map.Entry<String, String> entry : tm.entrySet()) {
stringBuffer.append("'" + entry.getValue() + "',");
}
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
stringBuffer.append("]);");
headercontainer.getHeaderResponse().renderOnLoadJavascript(stringBuffer.toString());
}
}
use of com.servoy.j2db.server.headlessclient.dataui.WebTabPanel in project servoy-client by Servoy.
the class WebForm method getFormAnchorInfo.
@SuppressWarnings("unchecked")
public FormAnchorInfo getFormAnchorInfo() {
formAnchorInfo = new FormAnchorInfo(formController.getName(), formController.getForm().getSize(), formController.getForm().getUUID());
final Map<String, ISupportAnchors> elements = new HashMap<String, ISupportAnchors>();
Iterator<IPersist> e1 = formController.getForm().getAllObjects();
while (e1.hasNext()) {
IPersist obj = e1.next();
if (obj instanceof ISupportAnchors && obj instanceof ISupportBounds) {
elements.put(ComponentFactory.getWebID(formController.getForm(), obj), (ISupportAnchors) obj);
}
}
// In case we are in table view.
if (view instanceof WebCellBasedView) {
WebCellBasedView formPart = (WebCellBasedView) view;
formAnchorInfo.addPart(Part.getDisplayName(Part.BODY), formPart.getMarkupId(), 50);
formAnchorInfo.isTableView = true;
formAnchorInfo.bodyContainerId = formPart.getMarkupId();
}
// Find the id of the form navigator, if any.
visitChildren(Component.class, new IVisitor() {
public Object component(Component component) {
if (component instanceof WebDefaultRecordNavigator) {
formAnchorInfo.navigatorWebId = component.getMarkupId();
return IVisitor.CONTINUE_TRAVERSAL;
} else if (component instanceof WebTabPanel) {
return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
} else
return IVisitor.CONTINUE_TRAVERSAL;
}
});
visitChildren(WebDataRenderer.class, new IVisitor() {
public Object component(Component component) {
WebDataRenderer formPart = (WebDataRenderer) component;
final FormPartAnchorInfo part = formAnchorInfo.addPart(formPart.getFormPartName(), formPart.getMarkupId(), formPart.getSize().height);
if (Part.getDisplayName(Part.BODY).equals(formPart.getFormPartName())) {
Component parent = formPart.getParent();
formAnchorInfo.bodyContainerId = parent.getMarkupId();
}
formPart.visitChildren(ISupportWebBounds.class, new IVisitor() {
public Object component(Component comp) {
String id = comp.getId();
ISupportAnchors obj = elements.get(id);
if (obj != null) {
int anchors = obj.getAnchors();
if (((anchors > 0 && anchors != IAnchorConstants.DEFAULT)) || (comp instanceof WebTabPanel) || (comp instanceof IButton)) {
Rectangle r = ((ISupportWebBounds) comp).getWebBounds();
if (r != null) {
if (anchors == 0)
anchors = IAnchorConstants.DEFAULT;
int hAlign = -1;
int vAlign = -1;
if (obj instanceof ISupportTextSetup) {
ISupportTextSetup alignedObj = (ISupportTextSetup) obj;
hAlign = alignedObj.getHorizontalAlignment();
vAlign = alignedObj.getVerticalAlignment();
}
String imageDisplayURL = null;
boolean isRandomParamRemoved = false;
if (comp instanceof IImageDisplay) {
Object[] aImageDisplayURL = WebBaseButton.getImageDisplayURL((IImageDisplay) comp, false);
imageDisplayURL = (String) aImageDisplayURL[0];
isRandomParamRemoved = ((Boolean) aImageDisplayURL[1]).booleanValue();
}
part.addAnchoredElement(comp.getMarkupId(), anchors, r, hAlign, vAlign, comp.getClass(), imageDisplayURL, isRandomParamRemoved);
}
}
}
return IVisitor.CONTINUE_TRAVERSAL;
}
});
return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
}
});
return formAnchorInfo;
}
use of com.servoy.j2db.server.headlessclient.dataui.WebTabPanel in project servoy-client by Servoy.
the class WebForm method setComponentEnabled.
public void setComponentEnabled(final boolean b) {
enableChanged = Boolean.TRUE;
if (enabled != b) {
enabled = b;
visitChildren(IScriptableProvider.class, new WicketCompVisitorMarker2(markedEnabledComponents, enabled));
if (enabled) {
markedEnabledComponents.clear();
}
} else {
visitChildren(WebForm.class, new WicketCompVisitorMarker2(markedEnabledComponents, b));
}
// setEnabled(enabled);
// visitChildren(WebForm.class, new WicketCompVisitorMarker2(markedEnabledComponents, b));
// if form is in a tabpanel, mark parent tabpanel as changed
MarkupContainer parent = getParent();
if (parent instanceof WebTabPanel && ((WebTabPanel) parent).getOrient() != TabPanel.HIDE && ((WebTabPanel) parent).getOrient() != TabPanel.SPLIT_HORIZONTAL && ((WebTabPanel) parent).getOrient() != TabPanel.SPLIT_VERTICAL) {
((WebTabPanel) getParent()).getStylePropertyChanges().setChanged();
} else {
// check if form is in an accordeon panel
WebAccordionPanel accPanel = findParent(WebAccordionPanel.class);
if (accPanel != null) {
accPanel.getStylePropertyChanges().setChanged();
}
}
}
Aggregations