From 6246c699f2a617087233b8c58ae6357995216a16 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 27 Apr 2009 09:08:53 +0000 Subject: [PATCH] BF [2750447] Translations on Home tab - partial fix --- .../webui/dashboard/DPActivities.java | 67 ++++---- .../webui/desktop/DefaultDesktop.java | 127 +++++++-------- .../webui/desktop/NavBar2Desktop.java | 138 ++++++++--------- .../webui/desktop/NavBarDesktop.java | 144 +++++++++--------- 4 files changed, 242 insertions(+), 234 deletions(-) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/dashboard/DPActivities.java b/zkwebui/WEB-INF/src/org/adempiere/webui/dashboard/DPActivities.java index deada23103..bafea7705a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/dashboard/DPActivities.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/dashboard/DPActivities.java @@ -24,6 +24,7 @@ import org.compiere.model.MRole; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; +import org.compiere.util.Msg; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -39,7 +40,7 @@ import org.zkoss.zul.Vbox; public class DPActivities extends DashboardPanel implements EventListener { private static final long serialVersionUID = 1L; - + private static final CLogger logger = CLogger.getCLogger(DPActivities.class); private Button btnNotice, btnRequest, btnWorkflow; @@ -49,47 +50,47 @@ public class DPActivities extends DashboardPanel implements EventListener { private int noOfRequest; private int noOfWorkflow; - + public DPActivities() { super(); this.appendChild(createActivitiesPanel()); } - + private Box createActivitiesPanel() { Vbox vbox = new Vbox(); - + btnNotice = new Button(); vbox.appendChild(btnNotice); - btnNotice.setLabel("Notice : 0"); - btnNotice.setTooltiptext("Notice"); + btnNotice.setLabel(Msg.translate(Env.getCtx(), "AD_Note_ID") + " : 0"); + btnNotice.setTooltiptext(Msg.translate(Env.getCtx(), "AD_Note_ID")); btnNotice.setImage("/images/GetMail16.png"); int AD_Menu_ID = DB.getSQLValue(null, "SELECT AD_Menu_ID FROM AD_Menu WHERE Name = 'Notice' AND IsSummary = 'N'"); btnNotice.setName(String.valueOf(AD_Menu_ID)); btnNotice.addEventListener(Events.ON_CLICK, this); - + btnRequest = new Button(); vbox.appendChild(btnRequest); - btnRequest.setLabel("Request : 0"); - btnRequest.setTooltiptext("Request"); + btnRequest.setLabel(Msg.translate(Env.getCtx(), "R_Request_ID") + " : 0"); + btnRequest.setTooltiptext(Msg.translate(Env.getCtx(), "R_Request_ID")); btnRequest.setImage("/images/Request16.png"); AD_Menu_ID = DB.getSQLValue(null, "SELECT AD_Menu_ID FROM AD_Menu WHERE Name = 'Request' AND IsSummary = 'N'"); btnRequest.setName(String.valueOf(AD_Menu_ID)); btnRequest.addEventListener(Events.ON_CLICK, this); - + btnWorkflow = new Button(); vbox.appendChild(btnWorkflow); - btnWorkflow.setLabel("Workflow Activities : 0"); - btnWorkflow.setTooltiptext("Workflow Activities"); + btnWorkflow.setLabel(Msg.getMsg (Env.getCtx(), "WorkflowActivities") + " : 0"); + btnWorkflow.setTooltiptext(Msg.getMsg (Env.getCtx(), "WorkflowActivities")); btnWorkflow.setImage("/images/Assignment16.png"); AD_Menu_ID = DB.getSQLValue(null, "SELECT AD_Menu_ID FROM AD_Menu WHERE Name = 'Workflow Activities' AND IsSummary = 'N'"); btnWorkflow.setName(String.valueOf(AD_Menu_ID)); btnWorkflow.addEventListener(Events.ON_CLICK, this); - + return vbox; } - + /** * Get notice count * @return number of notice @@ -99,11 +100,11 @@ public class DPActivities extends DashboardPanel implements EventListener { String sql = "SELECT COUNT(1) FROM AD_Note " + "WHERE AD_Client_ID=? AND AD_User_ID IN (0,?)" + " AND Processed='N'"; - + int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), Env.getAD_User_ID(Env.getCtx())); return retValue; } - + /** * Get request count * @return number of request @@ -115,18 +116,18 @@ public class DPActivities extends DashboardPanel implements EventListener { + " AND (DateNextAction IS NULL OR TRUNC(DateNextAction) <= TRUNC(SysDate))" + " AND (R_Status_ID IS NULL OR R_Status_ID IN (SELECT R_Status_ID FROM R_Status WHERE IsClosed='N'))", "R_Request", false, true); // not qualified - RW - int retValue = DB.getSQLValue(null, sql, Env.getAD_User_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx())); + int retValue = DB.getSQLValue(null, sql, Env.getAD_User_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx())); return retValue; } - + /** * Get workflow activity count * @return number of workflow activity */ - public static int getWorkflowCount() + public static int getWorkflowCount() { int count = 0; - + String sql = "SELECT count(*) FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" // Owner of Activity @@ -166,20 +167,20 @@ public class DPActivities extends DashboardPanel implements EventListener { DB.close(rs, pstmt); rs = null; pstmt = null; } - + return count; } - + @Override public void refresh(ServerPushTemplate template) - { + { noOfNotice = getNoticeCount(); noOfRequest = getRequestCount(); noOfWorkflow = getWorkflowCount(); - + template.execute(this); } - + @Override public void updateUI() { //don't update if not visible @@ -189,31 +190,31 @@ public class DPActivities extends DashboardPanel implements EventListener { return; c = c.getParent(); } - btnNotice.setLabel("Notice : " + noOfNotice); - btnRequest.setLabel("Request : " + noOfRequest); - btnWorkflow.setLabel("Workflow Activities : " + noOfWorkflow); + btnNotice.setLabel(Msg.translate(Env.getCtx(), "AD_Note_ID") + " : " + noOfNotice); + btnRequest.setLabel(Msg.translate(Env.getCtx(), "R_Request_ID") + " : " + noOfRequest); + btnWorkflow.setLabel(Msg.getMsg (Env.getCtx(), "WorkflowActivities") + " : " + noOfWorkflow); } public void onEvent(Event event) { Component comp = event.getTarget(); String eventName = event.getName(); - + if(eventName.equals(Events.ON_CLICK)) { if(comp instanceof Button) { Button btn = (Button) comp; - + int menuId = 0; try { - menuId = Integer.valueOf(btn.getName()); + menuId = Integer.valueOf(btn.getName()); } catch (Exception e) { - + } - + if(menuId > 0) SessionManager.getAppDesktop().onMenuSelected(menuId); } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java index e459ac62b3..e868418029 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java @@ -60,7 +60,7 @@ import org.zkoss.zul.Panel; import org.zkoss.zul.Panelchildren; /** - * + * * Default desktop implementation. * @author Ashley G Ramdass * @author Low Heng Sin @@ -87,19 +87,19 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria private int noOfRequest; private int noOfWorkflow; - + public DefaultDesktop() - { - super(); + { + super(); } - + protected Component doCreatePart(Component parent) { SidePanel pnlSide = new SidePanel(); HeaderPanel pnlHead = new HeaderPanel(); - + pnlSide.getMenuPanel().addMenuListener(this); - + layout = new Borderlayout(); if (parent != null) { @@ -108,16 +108,16 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria layout.setHeight("100%"); layout.setStyle("position: absolute"); } - else + else layout.setPage(page); - + dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this); - + North n = new North(); layout.appendChild(n); n.setCollapsible(false); pnlHead.setParent(n); - + West w = new West(); layout.appendChild(w); w.setWidth("300px"); @@ -126,45 +126,45 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria w.setTitle("Menu"); w.setFlex(true); pnlSide.setParent(w); - + windowArea = new Center(); windowArea.setParent(layout); windowArea.setFlex(true); - - windowContainer.createPart(windowArea); + + windowContainer.createPart(windowArea); createHomeTab(); - + return layout; } - private void createHomeTab() + private void createHomeTab() { Tabpanel homeTab = new Tabpanel(); windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false); - + Portallayout portalLayout = new Portallayout(); portalLayout.setWidth("100%"); portalLayout.setHeight("100%"); portalLayout.setStyle("position: absolute; overflow: auto"); homeTab.appendChild(portalLayout); - + // Dashboard content Portalchildren portalchildren = null; int currentColumnNo = 0; - + String sql = "SELECT COUNT(DISTINCT COLUMNNO) " + "FROM PA_DASHBOARDCONTENT " + "WHERE (AD_CLIENT_ID=0 OR AD_CLIENT_ID=?) AND ISACTIVE='Y'"; - - int noOfCols = DB.getSQLValue(null, sql, + + int noOfCols = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx())); - + int width = noOfCols <= 0 ? 100 : 100/noOfCols; sql = "SELECT x.*, m.AD_MENU_ID " + "FROM PA_DASHBOARDCONTENT x " - + "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID " + + "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID " + "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' " + "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE "; PreparedStatement pstmt = null; @@ -174,9 +174,9 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx())); rs = pstmt.executeQuery(); - - while (rs.next()) - { + + while (rs.next()) + { int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo); if(portalchildren == null || currentColumnNo != columnNo) { @@ -184,26 +184,26 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria portalLayout.appendChild(portalchildren); portalchildren.setWidth(width + "%"); portalchildren.setStyle("padding: 5px"); - + currentColumnNo = columnNo; } - + Panel panel = new Panel(); panel.setStyle("margin-bottom:10px"); panel.setTitle(rs.getString(X_PA_DashboardContent.COLUMNNAME_Name)); - + String description = rs.getString(X_PA_DashboardContent.COLUMNNAME_Description); if(description != null) panel.setTooltiptext(description); - + String collapsible = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsCollapsible); panel.setCollapsible(collapsible.equals("Y")); - + panel.setBorder("normal"); portalchildren.appendChild(panel); Panelchildren content = new Panelchildren(); panel.appendChild(content); - + boolean panelEmpty = true; // HTML content @@ -211,7 +211,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria if(htmlContent != null) { StringBuffer result = new StringBuffer(""); - + URL url = getClass().getClassLoader(). getResource("org/compiere/images/PAPanel.css"); InputStreamReader ins; @@ -219,25 +219,25 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria ins = new InputStreamReader(url.openStream()); BufferedReader bufferedReader = new BufferedReader( ins ); String cssLine; - while ((cssLine = bufferedReader.readLine()) != null) + while ((cssLine = bufferedReader.readLine()) != null) result.append(cssLine + "\n"); } catch (IOException e1) { logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1); } - + result.append("
\n"); - + // if(description != null) // result.append("

" + description + "

\n"); result.append(stripHtml(htmlContent, false) + "
\n"); result.append("
\n\n\n"); - + Html html = new Html(); html.setContent(result.toString()); content.appendChild(html); panelEmpty = false; } - + // Window int AD_Window_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Window_ID); if(AD_Window_ID > 0) @@ -250,13 +250,13 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria content.appendChild(btn); panelEmpty = false; } - + // Goal int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID); if(PA_Goal_ID > 0) { StringBuffer result = new StringBuffer(""); - + URL url = getClass().getClassLoader(). getResource("org/compiere/images/PAPanel.css"); InputStreamReader ins; @@ -264,12 +264,12 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria ins = new InputStreamReader(url.openStream()); BufferedReader bufferedReader = new BufferedReader( ins ); String cssLine; - while ((cssLine = bufferedReader.readLine()) != null) + while ((cssLine = bufferedReader.readLine()) != null) result.append(cssLine + "\n"); } catch (IOException e1) { logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1); } - + result.append("
\n"); result.append(renderGoals(PA_Goal_ID, content)); result.append("
\n\n\n"); @@ -279,14 +279,14 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria content.appendChild(html); panelEmpty = false; } - + // ZUL file url String url = rs.getString(X_PA_DashboardContent.COLUMNNAME_ZulFilePath); if(url != null) { try { Component component = Executions.createComponents(url, content, null); - if(component != null) + if(component != null) { if (component instanceof DashboardPanel) { @@ -307,7 +307,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria logger.log(Level.WARNING, "Failed to create components. zul="+url, e); } } - + if (panelEmpty) panel.detach(); } @@ -317,40 +317,40 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria DB.close(rs, pstmt); } // - + //register as 0 registerWindow(homeTab); - + if (!portalLayout.getDesktop().isServerPushEnabled()) portalLayout.getDesktop().enableServerPush(true); - + dashboardRunnable.refreshDashboard(); - + dashboardThread = new Thread(dashboardRunnable, "UpdateInfo"); dashboardThread.setDaemon(true); dashboardThread.start(); } - + public void onEvent(Event event) { Component comp = event.getTarget(); String eventName = event.getName(); - + if(eventName.equals(Events.ON_CLICK)) { if(comp instanceof ToolBarButton) { ToolBarButton btn = (ToolBarButton) comp; - + int menuId = 0; try { - menuId = Integer.valueOf(btn.getName()); + menuId = Integer.valueOf(btn.getName()); } catch (Exception e) { - + } - + if(menuId > 0) onMenuSelected(menuId); } } @@ -361,12 +361,12 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria noOfNotice = DPActivities.getNoticeCount(); noOfRequest = DPActivities.getRequestCount(); noOfWorkflow = DPActivities.getWorkflowCount(); - + template.execute(this); } - + /** - * + * * @param page */ public void setPage(Page page) { @@ -375,7 +375,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria this.page = page; } } - + /** * Get the root component * @return Component @@ -383,7 +383,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria public Component getComponent() { return layout; } - + public void logout() { if (dashboardThread != null && dashboardThread.isAlive()) { dashboardRunnable.stop(); @@ -393,7 +393,10 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria public void updateUI() { int total = noOfNotice + noOfRequest + noOfWorkflow; - windowContainer.setTabTitle(0, "Home (" + total + ")", - "Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow); + windowContainer.setTabTitle(0, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", "") + + " (" + total + ")", + Msg.translate(Env.getCtx(), "AD_Note_ID") + " : " + noOfNotice + + ", " + Msg.translate(Env.getCtx(), "R_Request_ID") + " : " + noOfRequest + + ", " + Msg.getMsg (Env.getCtx(), "WorkflowActivities") + " : " + noOfWorkflow); } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java index 1e2a5a8d8f..d9c9fc69ff 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2008 Low Heng Sin * - * Copyright (C) 2008 Idalica Corporation * + * Copyright (C) 2008 Idalica Corporation * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * * by the Free Software Foundation. This program is distributed in the hope * @@ -58,7 +58,7 @@ import org.zkoss.zul.Panel; import org.zkoss.zul.Panelchildren; /** - * @author hengsin + * @author hengsin */ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Serializable, EventListener, IServerPushCallback { @@ -88,17 +88,17 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria private int noOfWorkflow; public NavBar2Desktop() - { - super(); + { + super(); } - + protected Component doCreatePart(Component parent) { SidePanel pnlSide = new SidePanel(); HeaderPanel pnlHead = new HeaderPanel(); - + pnlSide.getMenuPanel().addMenuListener(this); - + layout = new Borderlayout(); if (parent != null) { @@ -107,16 +107,16 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria layout.setHeight("100%"); layout.setStyle("position: absolute"); } - else + else layout.setPage(page); - + dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this); - + North n = new North(); layout.appendChild(n); n.setCollapsible(false); pnlHead.setParent(n); - + West w = new West(); layout.appendChild(w); w.setWidth("300px"); @@ -126,16 +126,16 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria w.setFlex(true); pnlSide.setParent(w); w.setOpen(false); - + Center center = new Center(); center.setParent(layout); center.setFlex(true); - + Borderlayout innerLayout = new Borderlayout(); innerLayout.setHeight("100%"); innerLayout.setWidth("100%"); innerLayout.setParent(center); - + West innerW = new West(); innerW.setWidth("200px"); innerW.setCollapsible(true); @@ -143,16 +143,16 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria innerW.setSplittable(true); innerW.setCollapsible(true); innerW.setParent(innerLayout); - + shortcutPanel = new Accordion(); shortcutPanel.setWidth("100%"); shortcutPanel.setHeight("100%"); innerW.appendChild(shortcutPanel); - + Div div = new Div(); Executions.createComponents(FAVOURITES_PATH, div, null); - shortcutPanel.add(div, "Favourites"); - + shortcutPanel.add(div, "Favourites"); + div = new Div(); Component component = Executions.createComponents(ACTIVITIES_PATH, div, null); if (component instanceof DashboardPanel) @@ -161,47 +161,47 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria dashboardRunnable.add(dashboardPanel); } shortcutPanel.add(div, "Activities"); - + shortcutPanel.setSelectedIndex(0); windowArea = new Center(); windowArea.setParent(innerLayout); windowArea.setFlex(true); - - windowContainer.createPart(windowArea); + + windowContainer.createPart(windowArea); createHomeTab(); - + return layout; } - private void createHomeTab() + private void createHomeTab() { Tabpanel homeTab = new Tabpanel(); windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false); - + Portallayout portalLayout = new Portallayout(); portalLayout.setWidth("100%"); portalLayout.setHeight("100%"); portalLayout.setStyle("position: absolute; overflow: auto"); homeTab.appendChild(portalLayout); - + // Dashboard content Portalchildren portalchildren = null; int currentColumnNo = 0; - + String sql = "SELECT COUNT(DISTINCT COLUMNNO) " + "FROM PA_DASHBOARDCONTENT " + "WHERE (AD_CLIENT_ID=0 OR AD_CLIENT_ID=?) AND ISACTIVE='Y'"; - - int noOfCols = DB.getSQLValue(null, sql, + + int noOfCols = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx())); - + int width = noOfCols <= 0 ? 100 : 100/noOfCols; sql = "SELECT x.*, m.AD_MENU_ID " + "FROM PA_DASHBOARDCONTENT x " - + "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID " + + "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID " + "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' " + "AND x.zulfilepath not in (?, ?) " + "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE "; @@ -214,9 +214,9 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria pstmt.setString(2, ACTIVITIES_PATH); pstmt.setString(3, FAVOURITES_PATH); rs = pstmt.executeQuery(); - - while (rs.next()) - { + + while (rs.next()) + { int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo); if(portalchildren == null || currentColumnNo != columnNo) { @@ -224,26 +224,26 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria portalLayout.appendChild(portalchildren); portalchildren.setWidth(width + "%"); portalchildren.setStyle("padding: 5px"); - + currentColumnNo = columnNo; } - + Panel panel = new Panel(); panel.setStyle("margin-bottom:10px"); panel.setTitle(rs.getString(X_PA_DashboardContent.COLUMNNAME_Name)); - + String description = rs.getString(X_PA_DashboardContent.COLUMNNAME_Description); if(description != null) panel.setTooltiptext(description); - + String collapsible = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsCollapsible); panel.setCollapsible(collapsible.equals("Y")); - + panel.setBorder("normal"); portalchildren.appendChild(panel); Panelchildren content = new Panelchildren(); panel.appendChild(content); - + boolean panelEmpty = true; // HTML content @@ -251,7 +251,7 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria if(htmlContent != null) { StringBuffer result = new StringBuffer(""); - + URL url = getClass().getClassLoader(). getResource("org/compiere/images/PAPanel.css"); InputStreamReader ins; @@ -259,25 +259,25 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria ins = new InputStreamReader(url.openStream()); BufferedReader bufferedReader = new BufferedReader( ins ); String cssLine; - while ((cssLine = bufferedReader.readLine()) != null) + while ((cssLine = bufferedReader.readLine()) != null) result.append(cssLine + "\n"); } catch (IOException e1) { logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1); } - + result.append("
\n"); - + // if(description != null) // result.append("

" + description + "

\n"); result.append(stripHtml(htmlContent, false) + "
\n"); result.append("
\n\n\n"); - + Html html = new Html(); html.setContent(result.toString()); content.appendChild(html); panelEmpty = false; } - + // Window int AD_Window_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Window_ID); if(AD_Window_ID > 0) @@ -290,13 +290,13 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria content.appendChild(btn); panelEmpty = false; } - + // Goal int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID); if(PA_Goal_ID > 0) { StringBuffer result = new StringBuffer(""); - + URL url = getClass().getClassLoader(). getResource("org/compiere/images/PAPanel.css"); InputStreamReader ins; @@ -304,12 +304,12 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria ins = new InputStreamReader(url.openStream()); BufferedReader bufferedReader = new BufferedReader( ins ); String cssLine; - while ((cssLine = bufferedReader.readLine()) != null) + while ((cssLine = bufferedReader.readLine()) != null) result.append(cssLine + "\n"); } catch (IOException e1) { logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1); } - + result.append("
\n"); result.append(renderGoals(PA_Goal_ID, content)); result.append("
\n\n\n"); @@ -319,14 +319,14 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria content.appendChild(html); panelEmpty = false; } - + // ZUL file url String url = rs.getString(X_PA_DashboardContent.COLUMNNAME_ZulFilePath); if(url != null) { try { Component component = Executions.createComponents(url, content, null); - if(component != null) + if(component != null) { if (component instanceof DashboardPanel) { @@ -347,7 +347,7 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria logger.log(Level.WARNING, "Failed to create components. zul="+url, e); } } - + if (panelEmpty) panel.detach(); } @@ -357,40 +357,40 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria DB.close(rs, pstmt); } // - + //register as 0 registerWindow(homeTab); - + if (!portalLayout.getDesktop().isServerPushEnabled()) portalLayout.getDesktop().enableServerPush(true); - + dashboardRunnable.refreshDashboard(); - + dashboardThread = new Thread(dashboardRunnable, "UpdateInfo"); dashboardThread.setDaemon(true); dashboardThread.start(); } - + public void onEvent(Event event) { Component comp = event.getTarget(); String eventName = event.getName(); - + if(eventName.equals(Events.ON_CLICK)) { if(comp instanceof ToolBarButton) { ToolBarButton btn = (ToolBarButton) comp; - + int menuId = 0; try { - menuId = Integer.valueOf(btn.getName()); + menuId = Integer.valueOf(btn.getName()); } catch (Exception e) { - + } - + if(menuId > 0) onMenuSelected(menuId); } } @@ -401,12 +401,12 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria noOfNotice = DPActivities.getNoticeCount(); noOfRequest = DPActivities.getRequestCount(); noOfWorkflow = DPActivities.getWorkflowCount(); - + template.execute(this); } - + /** - * + * * @param page */ public void setPage(Page page) { @@ -415,7 +415,7 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria this.page = page; } } - + /** * Get the root component * @return Component @@ -423,7 +423,7 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria public Component getComponent() { return layout; } - + public void logout() { if (dashboardThread != null && dashboardThread.isAlive()) { dashboardRunnable.stop(); @@ -434,6 +434,8 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria public void updateUI() { int total = noOfNotice + noOfRequest + noOfWorkflow; shortcutPanel.setLabel(1, "Activities (" + total + ")"); - shortcutPanel.setTooltiptext(1, "Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow); + shortcutPanel.setTooltiptext(1, Msg.translate(Env.getCtx(), "AD_Note_ID") + " : " + noOfNotice + + ", " + Msg.translate(Env.getCtx(), "R_Request_ID") + " : " + noOfRequest + + ", " + Msg.getMsg (Env.getCtx(), "WorkflowActivities") + " : " + noOfWorkflow); } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java index 5296ca3e08..3af85f3fb5 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2008 Low Heng Sin * - * Copyright (C) 2008 Idalica Corporation * + * Copyright (C) 2008 Idalica Corporation * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * * by the Free Software Foundation. This program is distributed in the hope * @@ -62,7 +62,7 @@ import org.zkoss.zul.Treeitem; import org.zkoss.zul.Treerow; /** - * @author hengsin + * @author hengsin */ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener, IServerPushCallback { @@ -70,7 +70,7 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial private static final String FAVOURITES_PATH = "/zul/favourites.zul"; private static final String ACTIVITIES_PATH = "/zul/activities.zul"; - + private static final String VIEWS_PATH = "/zul/views.zul"; private static final long serialVersionUID = 9056511175189603883L; @@ -96,19 +96,19 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial private int noOfRequest; private int noOfWorkflow; - + public NavBarDesktop() - { - super(); + { + super(); } - + protected Component doCreatePart(Component parent) { SidePanel pnlSide = new SidePanel(); HeaderPanel pnlHead = new HeaderPanel(); - + pnlSide.getMenuPanel().addMenuListener(this); - + layout = new Borderlayout(); if (parent != null) { @@ -117,16 +117,16 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial layout.setHeight("100%"); layout.setStyle("position: absolute"); } - else + else layout.setPage(page); - + dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this); - + North n = new North(); layout.appendChild(n); n.setCollapsible(false); pnlHead.setParent(n); - + leftRegion = new West(); layout.appendChild(leftRegion); leftRegion.setWidth("300px"); @@ -137,20 +137,20 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial navigationPanel = new Accordion(); navigationPanel.setParent(leftRegion); leftRegion.setOpen(true); - + navigationPanel.setWidth("100%"); navigationPanel.setHeight("100%"); navigationPanel.add(pnlSide, "Application Menu"); - + Div div = new Div(); favPanel = (DPFavourites) Executions.createComponents(FAVOURITES_PATH, div, null); navigationPanel.add(div, "Favourites"); - + //setup drag and drop for favourites div = navigationPanel.getHeader(1); div.setDroppable(DPFavourites.FAVOURITE_DROPPABLE); div.addEventListener(Events.ON_DROP, this); - + div = new Div(); Component component = Executions.createComponents(ACTIVITIES_PATH, div, null); if (component instanceof DashboardPanel) @@ -159,51 +159,51 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial dashboardRunnable.add(dashboardPanel); } navigationPanel.add(div, "Activities"); - + div = new Div(); Executions.createComponents(VIEWS_PATH, div, null); - navigationPanel.add(div, "Views"); - + navigationPanel.add(div, Msg.getMsg(Env.getCtx(), "View").replaceAll("&", "")); + navigationPanel.setSelectedIndex(0); windowArea = new Center(); windowArea.setParent(layout); windowArea.setFlex(true); - - windowContainer.createPart(windowArea); + + windowContainer.createPart(windowArea); createHomeTab(); - + return layout; } - private void createHomeTab() + private void createHomeTab() { Tabpanel homeTab = new Tabpanel(); windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false); - + Portallayout portalLayout = new Portallayout(); portalLayout.setWidth("100%"); portalLayout.setHeight("100%"); portalLayout.setStyle("position: absolute; overflow: auto"); homeTab.appendChild(portalLayout); - + // Dashboard content Portalchildren portalchildren = null; int currentColumnNo = 0; - + String sql = "SELECT COUNT(DISTINCT COLUMNNO) " + "FROM PA_DASHBOARDCONTENT " + "WHERE (AD_CLIENT_ID=0 OR AD_CLIENT_ID=?) AND ISACTIVE='Y'"; - - int noOfCols = DB.getSQLValue(null, sql, + + int noOfCols = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx())); - + int width = noOfCols <= 0 ? 100 : 100/noOfCols; sql = "SELECT x.*, m.AD_MENU_ID " + "FROM PA_DASHBOARDCONTENT x " - + "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID " + + "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID " + "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' " + "AND x.zulfilepath not in (?, ?, ?) " + "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE "; @@ -217,9 +217,9 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial pstmt.setString(3, FAVOURITES_PATH); pstmt.setString(4, VIEWS_PATH); rs = pstmt.executeQuery(); - - while (rs.next()) - { + + while (rs.next()) + { int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo); if(portalchildren == null || currentColumnNo != columnNo) { @@ -227,26 +227,26 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial portalLayout.appendChild(portalchildren); portalchildren.setWidth(width + "%"); portalchildren.setStyle("padding: 5px"); - + currentColumnNo = columnNo; } - + Panel panel = new Panel(); panel.setStyle("margin-bottom:10px"); panel.setTitle(rs.getString(X_PA_DashboardContent.COLUMNNAME_Name)); - + String description = rs.getString(X_PA_DashboardContent.COLUMNNAME_Description); if(description != null) panel.setTooltiptext(description); - + String collapsible = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsCollapsible); panel.setCollapsible(collapsible.equals("Y")); - + panel.setBorder("normal"); portalchildren.appendChild(panel); Panelchildren content = new Panelchildren(); panel.appendChild(content); - + boolean panelEmpty = true; // HTML content @@ -254,7 +254,7 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial if(htmlContent != null) { StringBuffer result = new StringBuffer(""); - + URL url = getClass().getClassLoader(). getResource("org/compiere/images/PAPanel.css"); InputStreamReader ins; @@ -262,25 +262,25 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial ins = new InputStreamReader(url.openStream()); BufferedReader bufferedReader = new BufferedReader( ins ); String cssLine; - while ((cssLine = bufferedReader.readLine()) != null) + while ((cssLine = bufferedReader.readLine()) != null) result.append(cssLine + "\n"); } catch (IOException e1) { logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1); } - + result.append("
\n"); - + // if(description != null) // result.append("

" + description + "

\n"); result.append(stripHtml(htmlContent, false) + "
\n"); result.append("
\n\n\n"); - + Html html = new Html(); html.setContent(result.toString()); content.appendChild(html); panelEmpty = false; } - + // Window int AD_Window_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Window_ID); if(AD_Window_ID > 0) @@ -293,13 +293,13 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial content.appendChild(btn); panelEmpty = false; } - + // Goal int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID); if(PA_Goal_ID > 0) { StringBuffer result = new StringBuffer(""); - + URL url = getClass().getClassLoader(). getResource("org/compiere/images/PAPanel.css"); InputStreamReader ins; @@ -307,12 +307,12 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial ins = new InputStreamReader(url.openStream()); BufferedReader bufferedReader = new BufferedReader( ins ); String cssLine; - while ((cssLine = bufferedReader.readLine()) != null) + while ((cssLine = bufferedReader.readLine()) != null) result.append(cssLine + "\n"); } catch (IOException e1) { logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1); } - + result.append("
\n"); result.append(renderGoals(PA_Goal_ID, content)); result.append("
\n\n\n"); @@ -322,14 +322,14 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial content.appendChild(html); panelEmpty = false; } - + // ZUL file url String url = rs.getString(X_PA_DashboardContent.COLUMNNAME_ZulFilePath); if(url != null) { try { Component component = Executions.createComponents(url, content, null); - if(component != null) + if(component != null) { if (component instanceof DashboardPanel) { @@ -350,7 +350,7 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial logger.log(Level.WARNING, "Failed to create components. zul="+url, e); } } - + if (panelEmpty) panel.detach(); } @@ -360,40 +360,40 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial DB.close(rs, pstmt); } // - + //register as 0 registerWindow(homeTab); - + if (!portalLayout.getDesktop().isServerPushEnabled()) portalLayout.getDesktop().enableServerPush(true); - + dashboardRunnable.refreshDashboard(); - + dashboardThread = new Thread(dashboardRunnable, "UpdateInfo"); dashboardThread.setDaemon(true); dashboardThread.start(); } - + public void onEvent(Event event) { Component comp = event.getTarget(); String eventName = event.getName(); - + if(eventName.equals(Events.ON_CLICK)) { if(comp instanceof ToolBarButton) { ToolBarButton btn = (ToolBarButton) comp; - + int menuId = 0; try { - menuId = Integer.valueOf(btn.getName()); + menuId = Integer.valueOf(btn.getName()); } catch (Exception e) { - + } - + if(menuId > 0) onMenuSelected(menuId); } } @@ -401,12 +401,12 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial { DropEvent de = (DropEvent) event; Component dragged = de.getDragged(); - + if(dragged instanceof Treerow) { Treerow treerow = (Treerow) dragged; Treeitem treeitem = (Treeitem) treerow.getParent(); - + favPanel.addItem(treeitem); } } @@ -417,12 +417,12 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial noOfNotice = DPActivities.getNoticeCount(); noOfRequest = DPActivities.getRequestCount(); noOfWorkflow = DPActivities.getWorkflowCount(); - + template.execute(this); } - + /** - * + * * @param page */ public void setPage(Page page) { @@ -431,7 +431,7 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial this.page = page; } } - + /** * Get the root component * @return Component @@ -439,7 +439,7 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial public Component getComponent() { return layout; } - + public void logout() { if (dashboardThread != null && dashboardThread.isAlive()) { dashboardRunnable.stop(); @@ -450,6 +450,8 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial public void updateUI() { int total = noOfNotice + noOfRequest + noOfWorkflow; navigationPanel.setLabel(2, "Activities (" + total + ")"); - navigationPanel.setTooltiptext(2, "Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow); + navigationPanel.setTooltiptext(2, Msg.translate(Env.getCtx(), "AD_Note_ID") + " : " + noOfNotice + + ", " + Msg.translate(Env.getCtx(), "R_Request_ID") + " : " + noOfRequest + + ", " + Msg.getMsg (Env.getCtx(), "WorkflowActivities") + " : " + noOfWorkflow); } }