From 9d5e3413b3e7f057e19dcd37d1774b7c6490b726 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sun, 11 Jan 2015 15:08:08 -0500 Subject: [PATCH] IDEMPIERE-2333 Tab title is changed wrongly in some cases --- .../adwindow/AbstractADWindowContent.java | 2 +- .../org/adempiere/webui/desktop/IDesktop.java | 2 +- .../webui/desktop/TabbedDesktop.java | 4 +-- .../adempiere/webui/part/WindowContainer.java | 34 +++++++++++++++++-- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 15df4f3a34..2e6ab1c288 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -1348,7 +1348,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements if (Util.isEmpty(header)) header = AEnv.getDialogHeader(Env.getCtx(), curWindowNo, prefix); - SessionManager.getAppDesktop().setTabTitle(header); + SessionManager.getAppDesktop().setTabTitle(header, curWindowNo); } else if (adTabbox.getSelectedDetailADTabpanel() == null) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java index 42fd01348f..6969a0a626 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java @@ -212,7 +212,7 @@ public interface IDesktop extends UIPart { public boolean isPendingWindow(); - public void setTabTitle(String title); + public void setTabTitle(String title, int windowNo); public void renderHomeTab(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java index 4f6357de6c..5c78ed9b5d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java @@ -397,8 +397,8 @@ public abstract class TabbedDesktop extends AbstractDesktop { } } - public void setTabTitle(String title) { - windowContainer.setTabTitle(title); + public void setTabTitle(String title, int windowNo) { + windowContainer.setTabTitle(title, windowNo); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java index 3c011dfbb1..154b2dc661 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java @@ -21,6 +21,7 @@ import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; +import org.adempiere.webui.desktop.TabbedDesktop; import org.adempiere.webui.panel.IHelpContext; import org.adempiere.webui.session.SessionManager; import org.compiere.model.X_AD_CtxHelp; @@ -265,11 +266,38 @@ public class WindowContainer extends AbstractUIPart return tab; } - public void setTabTitle(String title) { - setTabTitle(title, getSelectedTab()); + public void setTabTitle(String title, int windowNo) { + setTabTitle(title, getTab(windowNo)); + } + + /** + * IDEMPIERE-2333 / getTab - get the tab based on the windowNo + * @param windowNo + * @return org.zkoss.zul.Tab + */ + private org.zkoss.zul.Tab getTab(int windowNo) { + org.zkoss.zul.Tabpanels panels = tabbox.getTabpanels(); + List childrens = panels.getChildren(); + for (Object child : childrens) + { + Tabpanel panel = (Tabpanel) child; + Component component = panel.getFirstChild(); + Object att = component != null ? component.getAttribute(TabbedDesktop.WINDOWNO_ATTRIBUTE) : null; + if (att != null && (att instanceof Integer)) + { + if (windowNo == (Integer)att) + { + org.zkoss.zul.Tab tab = panel.getLinkedTab(); + return tab; + } + } + } + return null; } public void setTabTitle(String title, org.zkoss.zul.Tab tab) { + if (tab == null) + return; title = title.replaceAll("[&]", ""); if (title.length() <= MAX_TITLE_LENGTH) { @@ -278,7 +306,7 @@ public class WindowContainer extends AbstractUIPart else { tab.setTooltiptext(title); - title = title.substring(0, 27) + "..."; + title = title.substring(0, MAX_TITLE_LENGTH-3) + "..."; tab.setLabel(title); } }