This commit is contained in:
rob_k 2007-06-11 03:42:50 +00:00
parent ff53d8a60a
commit ed1c8530f3
3 changed files with 91 additions and 50 deletions

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Compiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* 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 *
@ -17,6 +17,8 @@
package org.compiere.util;
import java.io.*;
import java.util.Properties;
import org.apache.ecs.*;
import org.apache.ecs.xhtml.*;
@ -61,10 +63,17 @@ public class WebDoc
public static WebDoc createPopup (String title)
{
WebDoc doc = create (title);
doc.getHead().addElement(new script((Element)null, "window.js"));
doc.getHead().addElement(new link("popup.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/window.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/Calendar-setup.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/calendar.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/table.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/lang/calendar-en.js"));
doc.getHead().addElement(new link("/adempiere/css/window.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.getHead().addElement(new link("/adempiere/css/popup.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.getHead().addElement(new link("/adempiere/css/table.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.getHead().addElement(new link("/adempiere/css/calendar-blue.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.setClasses ("popupTable", "popupHeader");
doc.getTable().setCellSpacing(5);
doc.getTable().setCellSpacing(0);
return doc;
} // createPopup
@ -76,10 +85,17 @@ public class WebDoc
public static WebDoc createWindow (String title)
{
WebDoc doc = create (title);
doc.getHead().addElement(new link("window.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.getHead().addElement(new script((Element)null, "window.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/window.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/Calendar-setup.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/calendar.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/js/table.js"));
doc.getHead().addElement(new script((Element)null, "/adempiere/lang/calendar-en.js"));
doc.getHead().addElement(new link("/adempiere/css/window.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.getHead().addElement(new link("/adempiere/css/calendar-blue.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.getHead().addElement(new link("/adempiere/css/table.css", link.REL_STYLESHEET, link.TYPE_CSS));
doc.setClasses ("windowTable", "windowHeader");
doc.getTable().setCellSpacing(5);
doc.getTable().setCellSpacing(0);
return doc;
} // createWindow
@ -130,34 +146,39 @@ public class WebDoc
// css, js
if (javaClient)
m_head.addElement(new link("http://www.adempiere.com/standard.css", link.REL_STYLESHEET, link.TYPE_CSS));
m_head.addElement(new link("http://www.adempiere.com/css/standard.css", link.REL_STYLESHEET, link.TYPE_CSS));
else
{
m_head.addElement(new link(WebEnv.getStylesheetURL(), link.REL_STYLESHEET, link.TYPE_CSS));
m_head.addElement(new script((Element)null, WebEnv.getBaseDirectory("standard.js")));
m_head.addElement(new script((Element)null, WebEnv.getBaseDirectory("/js/standard.js")));
}
// globalqss - problems with java 6 reported by kisitomomo
// m_head.addElement(new meta().setHttpEquiv("Content-Type", "text/html; charset=UTF-8"));
m_head.addElement(new meta().setName("description", "adempiere HTML UI"));
m_head.addElement(new meta().setHttpEquiv("Content-Type", "text/html; charset=UTF-8"));
m_head.addElement(new meta().setName("description", "Compiere HTML UI"));
m_table = new table("0", "2", "0", "100%", null); // spacing 2
m_table = new table("0", "0", "0", "100%", null); // spacing 2
m_topRow = new tr();
// Title
//Start Modification Rob
m_topLeft = new td();
if (title == null)
m_topLeft.addElement(NBSP);
else
m_topLeft.addElement(new h1(title));
//else
//m_topLeft.addElement(new h1(title));
m_topRow.addElement(m_topLeft);
// Logo
m_topRight = new td().setAlign("right");
/** Removing/modifying the Compiere logo is a violation of the license */
if (javaClient)
m_topRight.addElement(new img("http://www.adempiere.com/images/adempiere64x32.png")
.setAlign(AlignType.RIGHT).setAlt("Adempiere Inc."));
else
m_topRight.addElement(WebEnv.getLogo());
if(title == "")
m_topRight.addElement(WebEnv.getLogo());
else
m_topRight.addElement(new h1(title));
m_topRow.addElement(m_topRight);
m_table.addElement(m_topRow);
m_table.addElement(m_topRow);
//
m_body.addElement(m_table);
} // setUp
@ -279,9 +300,9 @@ public class WebDoc
* Add Popup Close Footer
* @return null or array with left/right td
*/
public td[] addPopupClose()
public td[] addPopupClose(Properties ctx)
{
input button = WebUtil.createClosePopupButton();
input button = WebUtil.createClosePopupButton(ctx);
if (m_table == null)
{
m_body.addElement(button);

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Compiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* 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 *
@ -41,18 +41,18 @@ public class WebEnv
private static CLogger log = CLogger.getCLogger(WebEnv.class);
/**
* Base Directory links <b>http://localhost:8080/adempiere</b>
* to the physical <i>%adempiere_HOME%/tomcat/webroot/adempiere</i> directory
* Base Directory links <b>http://localhost:8080/compiere</b>
* to the physical <i>%COMPIERE_HOME%/tomcat/webroot/compiere</i> directory
*/
public static final String DIR_BASE = "/adempiere"; // /adempiere
/** Image Sub-Directory under BASE */
private static final String DIR_IMAGE = "images"; // /adempiere/images
private static final String DIR_IMAGE = "images"; // /compiere/images
/** Stylesheet Name */
private static final String STYLE_STD = "standard.css"; // /adempiere/standard.css
private static final String STYLE_STD = "/css/standard.css"; // /adempiere/standard.css
/** Small Logo. */
private static final String LOGO = "LogoSmall.gif"; // /adempiere/LogoSmall.gif
/** Store Sub-Directory under BASE */
private static final String DIR_STORE = "store"; // /adempiere/store
private static final String DIR_STORE = "store"; // /compiere/store
/** Frame name for Commands - WCmd */
public static final String TARGET_CMD = "WCmd";
@ -167,7 +167,7 @@ public class WebEnv
/**************************************************************************
* Get Base Directory entrry.
* <br>
* /adempiere/
* /compiere/
* @param entry file entry or path
* @return url to entry in base directory
*/
@ -183,7 +183,7 @@ public class WebEnv
/**
* Get Image Directory entry.
* <br>
* /adempiere/images
* /compiere/images
* @param entry file entry or path
* @return url to entry in image directory
*/
@ -200,7 +200,7 @@ public class WebEnv
/**
* Get Store Directory entry.
* <br>
* /adempiere/store
* /compiere/store
* @param entry file entry or path
* @return url to entry in store directory
*/
@ -216,8 +216,9 @@ public class WebEnv
/**
* Get Logo Path.
* Removing/modifying the Compiere logo is a violation of the license
* <p>
* /adempiere/LogoSmall.gif
* /compiere/LogoSmall.gif
* @return url to logo
*/
public static String getLogoURL()
@ -227,18 +228,23 @@ public class WebEnv
/**
* Get Logo Image HTML tag.
* Removing/modifying the Compiere logo or copyright notice is a violation of the license
* @return Image
*/
public static img getLogo()
{
/** Removing/modifying the Compiere logo is a violation of the license */
return new img(getLogoURL()).setAlign(AlignType.RIGHT)
// Changing the copyright notice in any way violates the license
// and you'll be held liable for any damage claims
//.setAlt("&copy; Jorg Janke/Compiere");
.setAlt("&copy; Jorg Janke/adempiere");
} // getLogo
/**
* Get Stylesheet Path.
* <p>
* /adempiere/standard.css
* /compiere/standard.css
* @return url of Stylesheet
*/
public static String getStylesheetURL()
@ -466,6 +472,8 @@ public class WebEnv
footer.addElement(org.compiere.Adempiere.DATE_VERSION + ": ");
footer.addElement(new a("javascript:diag_window();", "Window Info"));
footer.addElement(" - ");
footer.addElement(new a("javascript:parent.resizeFrame('5,*');", "Menu"));
footer.addElement(" - ");
footer.addElement(new a("javascript:diag_navigator();", "Browser Info"));
footer.addElement(" - ");
footer.addElement(new a("javascript:diag_request();", "Request Info"));

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Product: Compiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* 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 *
@ -109,14 +109,14 @@ public final class WebUtil
b.addElement(new br());
// fini
createResponse (request, response, servlet, null, doc, true);
createResponse (request, response, servlet, null, doc, false);
} // createErrorPage
/**
* Create Exit Page "Log-off".
* <p>
* - End Session
* - Go to start page (e.g. /adempiere/index.html)
* - Go to start page (e.g. /compiere/index.html)
*
* @param request request
* @param response response
@ -151,13 +151,15 @@ public final class WebUtil
* @param ctx context
* @return Button
*/
public static button getLoginButton (Properties ctx)
public static input getLoginButton (Properties ctx)
{
String text = "Login";
if (ctx != null)
text = Msg.getMsg (ctx, "Login");
button button = new button();
button.setType("button").setName("Login").addElement(text);
input button = new input("button", text, " "+text);
button.setID(text);
button.setClass("loginbtn");
StringBuffer cmd = new StringBuffer ("window.top.location.replace('");
cmd.append(WebEnv.getBaseDirectory("index.html"));
cmd.append("');");
@ -242,7 +244,7 @@ public final class WebUtil
outStr.append(inStr.substring(0, i)); // up to &#
inStr = inStr.substring(i+2, inStr.length()); // from &#
int j = inStr.indexOf(';'); // next ;
int j = inStr.indexOf(";"); // next ;
if (j < 0) // no second tag
{
inStr = "&#" + inStr;
@ -508,7 +510,7 @@ public final class WebUtil
if (cookieProperties != null)
{
Cookie cookie = new Cookie (WebEnv.COOKIE_INFO, propertiesEncode(cookieProperties));
cookie.setComment("(c) adempiere, Inc - Jorg Janke");
cookie.setComment("(c) ComPiere, Inc - Jorg Janke");
cookie.setSecure(false);
cookie.setPath("/");
if (cookieProperties.size() == 0)
@ -555,7 +557,10 @@ public final class WebUtil
cmd.append("<!-- clear frame\n")
.append("var d = parent.").append(targetFrame).append(".document;\n")
.append("d.open();\n")
.append("d.write('<link href=\"").append(WebEnv.getStylesheetURL()).append("\" rel=\"stylesheet\">');\n")
.append("d.write('<link href=\"").append(WebEnv.getStylesheetURL()).append("\" type=\"text/css\" rel=\"stylesheet\">');\n")
.append("d.write('<link href=\"/adempiere/css/window.css\" type=\"text/css\" rel=\"stylesheet\">');\n")
.append("d.write('<br><br><br><br><br><br><br>');")
.append("d.write('<div style=\"text-align: center;\"><img class=\"CenterImage\" style=\"vertical-align: middle; filter:alpha(opacity=50); -moz-opacity:0.5;\" src=\"Logo.gif\" /></div>');\n")
.append("d.close();\n")
.append("// -- clear frame -->");
//
@ -683,7 +688,7 @@ public final class WebUtil
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try
{
pp.store(bos, "adempiere"); // Header
pp.store(bos, "Compiere"); // Header
}
catch (IOException e)
{
@ -768,11 +773,11 @@ public final class WebUtil
* @return Option Array
*/
public static option[] convertToOption (NamePair[] list, String default_ID)
{
{
int size = list.length;
option[] retValue = new option[size];
option[] retValue = new option[size];
for (int i = 0; i < size; i++)
{
{
boolean selected = false;
// select first entry
if (i == 0 && (default_ID == null || default_ID.length() == 0))
@ -786,7 +791,7 @@ public final class WebUtil
if (default_ID != null && default_ID.equals(list[i].getID()))
selected = true;
retValue[i].setSelected(selected);
}
}
return retValue;
} // convertToOption
@ -844,11 +849,18 @@ public final class WebUtil
* Get Close PopUp Buton
* @return button
*/
public static input createClosePopupButton()
public static input createClosePopupButton(Properties ctx)
{
input close = new input (input.TYPE_BUTTON, "closePopup", "Close");
String text = "Close";
if (ctx != null)
text = Msg.getMsg (ctx, "Close");
input close = new input("button", text, " "+text);
close.setID(text);
close.setClass("closebtn");
close.setTitle ("Close PopUp"); // Help
close.setOnClick ("closePopup();return false;");
//close.setOnClick ("closePopup();return false;");
close.setOnClick ("self.close();return false;");
return close;
} // getClosePopupButton
@ -987,7 +999,7 @@ public final class WebUtil
public static void deleteCookieWebUser (HttpServletRequest request, HttpServletResponse response, String COOKIE_NAME)
{
Cookie cookie = new Cookie(COOKIE_NAME, " ");
cookie.setComment("adempiere Web User");
cookie.setComment("Compiere Web User");
cookie.setPath(request.getContextPath());
cookie.setMaxAge(1); // second
response.addCookie(cookie);
@ -1046,7 +1058,7 @@ public final class WebUtil
EMail email = wStore.createEMail(to.getEmail(),
subject.toString(), message.toString());
// CC Order
if (msgType.equals(MMailMsg.MAILMSGTYPE_OrderAcknowledgement))
if (msgType == MMailMsg.MAILMSGTYPE_OrderAcknowledgement)
{
String orderEMail = wStore.getWebOrderEMail();
String storeEMail = wStore.getWStoreEMail();
@ -1086,7 +1098,7 @@ public final class WebUtil
public static void addCookieWebUser (HttpServletRequest request, HttpServletResponse response, String webUser, String COOKIE_NAME)
{
Cookie cookie = new Cookie(COOKIE_NAME, webUser);
cookie.setComment("adempiere Web User");
cookie.setComment("Compiere Web User");
cookie.setPath(request.getContextPath());
cookie.setMaxAge(2592000); // 30 days in seconds 60*60*24*30
response.addCookie(cookie);