- refactoring and cleanup
- restore support for WEBUI_LOGOURL, ZK_LOGO_SMALL and ZK_LOGO_LARGE
This commit is contained in:
Heng Sin Low 2009-05-18 03:46:18 +00:00
parent 674f4304ca
commit df50c6a77b
4 changed files with 58 additions and 27 deletions

View File

@ -19,9 +19,8 @@ package org.adempiere.webui.panel;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.theme.ITheme;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.window.AboutWindow;
import org.compiere.model.MSysConfig;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -58,13 +57,7 @@ public class HeaderPanel extends Panel implements EventListener
UserPanel userPanel = new UserPanel();
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.setSrc(logoURL);
image.setSrc(ThemeManager.getSmallLogo());
image.addEventListener(Events.ON_CLICK, this);
image.setStyle("cursor: pointer;");
@ -77,7 +70,6 @@ public class HeaderPanel extends Panel implements EventListener
Vbox vb = new Vbox();
vb.setParent(west);
vb.setHeight("100%");
// vb.setWidth("100%"); // Elaine 2008/11/19 the role and logout links don't work if width is set to 100%
vb.setPack("center");
vb.setAlign("left");
@ -98,15 +90,6 @@ public class HeaderPanel extends Panel implements EventListener
LayoutUtils.addSclass("header-right", center);
//the following doesn't work when declare as part of the header-right style
center.setStyle("background-color: transparent; border: none;");
// East east = new East();
// east.setParent(layout);
// userPanel.setParent(east);
// userPanel.setHeight("100%");
// east.setFlex(true);
// LayoutUtils.addSclass("header-right", east);
// //the following doesn't work when declare as part of the header-right style
// east.setStyle("background-color: transparent; border: none;");
}
public void onEvent(Event event) throws Exception {

View File

@ -35,9 +35,9 @@ import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ITheme;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.UserPreference;
import org.adempiere.webui.window.LoginWindow;
import org.compiere.model.MSysConfig;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
@ -98,8 +98,6 @@ public class LoginPanel extends Window implements EventListener
private void init()
{
String theme = MSysConfig.getValue(ITheme.ZK_THEME, ITheme.ZK_THEME_DEFAULT);
Div div = new Div();
div.setSclass(ITheme.LOGIN_BOX_HEADER_CLASS);
Label label = new Label("Login");
@ -122,7 +120,7 @@ public class LoginPanel extends Window implements EventListener
tr.appendChild(td);
td.setDynamicProperty("colspan", "2");
Image image = new Image();
image.setSrc(ITheme.THEME_PATH_PREFIX+theme+ITheme.LOGIN_LOGO_IMAGE);
image.setSrc(ThemeManager.getLargeLogo());
td.appendChild(image);
tr = new Tr();

View File

@ -35,11 +35,11 @@ import org.adempiere.webui.component.Window;
import org.adempiere.webui.exception.ApplicationException;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ITheme;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.UserPreference;
import org.adempiere.webui.window.LoginWindow;
import org.compiere.db.CConnection;
import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Language;
@ -106,8 +106,6 @@ public class RolePanel extends Window implements EventListener, Deferrable
private void init()
{
String theme = MSysConfig.getValue(ITheme.ZK_THEME, ITheme.ZK_THEME_DEFAULT);
Div div = new Div();
div.setSclass(ITheme.LOGIN_BOX_HEADER_CLASS);
Label label = new Label("Login");
@ -130,7 +128,7 @@ public class RolePanel extends Window implements EventListener, Deferrable
tr.appendChild(td);
td.setDynamicProperty("colspan", "2");
Image image = new Image();
image.setSrc(ITheme.THEME_PATH_PREFIX+theme+ITheme.LOGIN_LOGO_IMAGE);
image.setSrc(ThemeManager.getLargeLogo());
td.appendChild(image);
tr = new Tr();

View File

@ -0,0 +1,52 @@
/******************************************************************************
* Copyright (C) 2009 Low Heng Sin *
* Copyright (C) 2009 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 *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui.theme;
import org.compiere.model.MSysConfig;
/**
*
* @author hengsin
*
*/
public final class ThemeManager {
/**
* @return url for large logo
*/
public static String getLargeLogo() {
String theme = getTheme();
String def = ITheme.THEME_PATH_PREFIX+theme+ITheme.LOGIN_LOGO_IMAGE;
return MSysConfig.getValue("ZK_LOGO_LARGE", def);
}
/**
* @return url for small logo
*/
public static String getSmallLogo() {
String theme = getTheme();
String def = ITheme.THEME_PATH_PREFIX+theme+ITheme.HEADER_LOGO_IMAGE;
String url = MSysConfig.getValue("ZK_LOGO_SMALL", null);
if (url == null)
url = MSysConfig.getValue("WEBUI_LOGOURL", def);
return url;
}
/**
* @return name of active theme
*/
public static String getTheme() {
return MSysConfig.getValue(ITheme.ZK_THEME, ITheme.ZK_THEME_DEFAULT);
}
}