From f28005bb5b662a3475d15ebaec5bfbacc4bfb8d4 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 18 May 2009 04:46:04 +0000 Subject: [PATCH] http://sourceforge.net/tracker/?func=detail&aid=2790994&group_id=176962&atid=955896 - refactoring - added support for ZK_BROWSER_ICON - restore eclipse webtool setting in .project --- zkwebui/.project | 4 +- .../org/adempiere/webui/AdempiereWebUI.java | 3 +- .../src/org/adempiere/webui/WLogin.java | 57 +++++++++++++++---- .../src/org/adempiere/webui/theme/ITheme.java | 1 + .../adempiere/webui/theme/ThemeManager.java | 49 ++++++++++++++++ .../adempiere/webui/window/AboutWindow.java | 12 ++-- zkwebui/index.zul | 2 +- zkwebui/theme.zs | 2 + 8 files changed, 108 insertions(+), 22 deletions(-) diff --git a/zkwebui/.project b/zkwebui/.project index a298acbfee..f8a6f10b7f 100644 --- a/zkwebui/.project +++ b/zkwebui/.project @@ -12,7 +12,9 @@ + org.eclipse.wst.common.project.facet.core.nature org.eclipse.jdt.core.javanature - com.sysdeo.eclipse.tomcat.tomcatnature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java b/zkwebui/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java index fef4bb9678..da99fa324e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java @@ -27,6 +27,7 @@ import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.desktop.DefaultDesktop; import org.adempiere.webui.desktop.IDesktop; import org.adempiere.webui.session.SessionManager; +import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.UserPreference; import org.compiere.model.MSession; import org.compiere.model.MSysConfig; @@ -88,7 +89,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient public void onCreate() { - this.getPage().setTitle(MSysConfig.getValue("ZK_BROWSER_TITLE", APP_NAME)); + this.getPage().setTitle(ThemeManager.getBrowserTitle()); Properties ctx = Env.getCtx(); langSession = Env.getContext(ctx, Env.LANGUAGE); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/WLogin.java b/zkwebui/WEB-INF/src/org/adempiere/webui/WLogin.java index b616a127f8..fa8b2a2f54 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/WLogin.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/WLogin.java @@ -16,10 +16,11 @@ package org.adempiere.webui; import org.adempiere.webui.part.AbstractUIPart; import org.adempiere.webui.theme.ITheme; +import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.window.LoginWindow; -import org.compiere.model.MSysConfig; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.UiException; import org.zkoss.zk.ui.metainfo.PageDefinition; import org.zkoss.zkex.zul.Borderlayout; import org.zkoss.zkex.zul.Center; @@ -49,8 +50,6 @@ public class WLogin extends AbstractUIPart protected Component doCreatePart(Component parent) { - String theme = MSysConfig.getValue(ITheme.ZK_THEME, ITheme.ZK_THEME_DEFAULT); - layout = new Borderlayout(); if (parent != null) layout.setParent(parent); @@ -77,36 +76,72 @@ public class WLogin extends AbstractUIPart loginWindow.setParent(vb); try { - String right = ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_RIGHT_PANEL_ZUL; + String right = ThemeManager.getLoginRightPanel(); PageDefinition pageDefintion = Executions.getCurrent().getPageDefinition(right); East east = new East(); east.setSclass(ITheme.LOGIN_EAST_PANEL_CLASS); addContent(east, pageDefintion); - } catch (Exception e) {} + } catch (Exception e) { + //ignore page not found exception + if (e instanceof UiException) { + if (!(e.getMessage() != null && e.getMessage().startsWith("Page not found"))) { + e.printStackTrace(); + } + } else { + e.printStackTrace(); + } + } try { - String left = ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_LEFT_PANEL_ZUL; + String left = ThemeManager.getLoginLeftPanel(); PageDefinition pageDefintion = Executions.getCurrent().getPageDefinition(left); West west = new West(); west.setSclass(ITheme.LOGIN_WEST_PANEL_CLASS); addContent(west, pageDefintion); - } catch (Exception e){} + } catch (Exception e){ + //ignore page not found exception + if (e instanceof UiException) { + if (!(e.getMessage() != null && e.getMessage().startsWith("Page not found"))) { + e.printStackTrace(); + } + } else { + e.printStackTrace(); + } + } try { - String top = ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_TOP_PANEL_ZUL; + String top = ThemeManager.getLoginTopPanel(); PageDefinition pageDefintion = Executions.getCurrent().getPageDefinition(top); North north = new North(); north.setSclass(ITheme.LOGIN_NORTH_PANEL_CLASS); addContent(north, pageDefintion); - } catch (Exception e) {} + } catch (Exception e) { + //ignore page not found exception + if (e instanceof UiException) { + if (!(e.getMessage() != null && e.getMessage().startsWith("Page not found"))) { + e.printStackTrace(); + } + } else { + e.printStackTrace(); + } + } try { - String bottom = ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_BOTTOM_PANEL_ZUL; + String bottom = ThemeManager.getLoginBottomPanel(); PageDefinition pageDefintion = Executions.getCurrent().getPageDefinition(bottom); South south = new South(); south.setSclass(ITheme.LOGIN_SOUTH_PANEL_CLASS); addContent(south, pageDefintion); - } catch (Exception e) {} + } catch (Exception e) { + //ignore page not found exception + if (e instanceof UiException) { + if (!(e.getMessage() != null && e.getMessage().startsWith("Page not found"))) { + e.printStackTrace(); + } + } else { + e.printStackTrace(); + } + } return layout; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ITheme.java b/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ITheme.java index 642a8ff234..23e58f55e1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ITheme.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ITheme.java @@ -55,4 +55,5 @@ public interface ITheme { //logo public static final String LOGIN_LOGO_IMAGE = "/images/login-logo.png"; public static final String HEADER_LOGO_IMAGE = "/images/header-logo.png"; + public static final String BROWSER_ICON_IMAGE= "/images/icon.png"; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java b/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java index 315083557e..507aa1ea26 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/theme/ThemeManager.java @@ -13,6 +13,7 @@ *****************************************************************************/ package org.adempiere.webui.theme; +import org.adempiere.webui.AdempiereWebUI; import org.compiere.model.MSysConfig; /** @@ -49,4 +50,52 @@ public final class ThemeManager { public static String getTheme() { return MSysConfig.getValue(ITheme.ZK_THEME, ITheme.ZK_THEME_DEFAULT); } + + /** + * @return title text for the browser window + */ + public static String getBrowserTitle() { + return MSysConfig.getValue("ZK_BROWSER_TITLE", AdempiereWebUI.APP_NAME); + } + + /** + * @return url for right panel + */ + public static String getLoginRightPanel() { + String theme = getTheme(); + return ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_RIGHT_PANEL_ZUL; + } + + /** + * @return url for left panel + */ + public static String getLoginLeftPanel() { + String theme = getTheme(); + return ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_LEFT_PANEL_ZUL; + } + + /** + * @return url for top panel + */ + public static String getLoginTopPanel() { + String theme = getTheme(); + return ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_TOP_PANEL_ZUL; + } + + /** + * @return url for bottom panel + */ + public static String getLoginBottomPanel() { + String theme = getTheme(); + return ITheme.THEME_PATH_PREFIX + theme + ITheme.LOGIN_BOTTOM_PANEL_ZUL; + } + + /** + * @return url for browser icon + */ + public static String getBrowserIcon() { + String theme = getTheme(); + String def = ITheme.THEME_PATH_PREFIX + theme + ITheme.BROWSER_ICON_IMAGE; + return MSysConfig.getValue("ZK_BROWSER_ICON", def); + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java index 512e055ba5..97ded705ed 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java @@ -30,6 +30,7 @@ import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.Window; import org.adempiere.webui.theme.ITheme; +import org.adempiere.webui.theme.ThemeManager; import org.compiere.Adempiere; import org.compiere.model.MSysConfig; import org.compiere.model.MUser; @@ -78,7 +79,7 @@ public class AboutWindow extends Window implements EventListener { this.setWidth("500px"); this.setHeight("450px"); this.setPosition("center"); - this.setTitle(MSysConfig.getValue("ZK_BROWSER_TITLE", "Adempiere")); + this.setTitle(ThemeManager.getBrowserTitle()); this.setClosable(true); this.setSizable(true); @@ -303,13 +304,8 @@ public class AboutWindow extends Window implements EventListener { vbox.setAlign("center"); vbox.setPack("center"); vbox.setParent(tabPanel); - String logoURL = MSysConfig.getValue("WEBUI_LOGOURL", null); - if (logoURL == null || logoURL.trim().length() == 0) - { - String theme = MSysConfig.getValue(ITheme.ZK_THEME, ITheme.ZK_THEME_DEFAULT); - logoURL = ITheme.THEME_PATH_PREFIX + theme + ITheme.HEADER_LOGO_IMAGE; - } - Image image = new Image(logoURL); + + Image image = new Image(ThemeManager.getSmallLogo()); image.setParent(vbox); Text text = new Text(Adempiere.getSubtitle()); diff --git a/zkwebui/index.zul b/zkwebui/index.zul index cd1c37d5b1..ab63a17354 100644 --- a/zkwebui/index.zul +++ b/zkwebui/index.zul @@ -4,7 +4,7 @@ Copyright (C) 2007 Ashley G Ramdass. --> - + diff --git a/zkwebui/theme.zs b/zkwebui/theme.zs index 8116270bd9..e87effe03c 100644 --- a/zkwebui/theme.zs +++ b/zkwebui/theme.zs @@ -1,2 +1,4 @@ import org.compiere.model.MSysConfig; +import org.adempiere.webui.theme.ThemeManager; var theme = MSysConfig.getValue("ZK_THEME", "default"); +var browserIcon = ThemeManager.getBrowserIcon();