* More complete about dialog
- show system info - added credit page - add viewing and download of trace log, pending send email option.
This commit is contained in:
parent
f9fc05acb1
commit
d8a3f9b6d3
|
@ -13,6 +13,8 @@ import org.zkoss.zul.ListitemRendererExt;
|
|||
public class SimpleListModel extends AbstractListModel implements ListitemRenderer, ListitemRendererExt {
|
||||
|
||||
private List list;
|
||||
|
||||
private int[] maxLength;
|
||||
|
||||
public SimpleListModel(List list) {
|
||||
this.list = list;
|
||||
|
@ -29,28 +31,52 @@ public class SimpleListModel extends AbstractListModel implements ListitemRender
|
|||
return list.size();
|
||||
}
|
||||
|
||||
protected StringBuffer truncate(String src, int maxLength) {
|
||||
int j = maxLength;
|
||||
while (j > 0 && Character.isWhitespace(src.charAt(j - 1)))
|
||||
--j;
|
||||
return new StringBuffer(j + 3)
|
||||
.append(src.substring(0, j)).append("...");
|
||||
}
|
||||
|
||||
public void render(Listitem item, Object data) throws Exception {
|
||||
if (data instanceof Object[]) {
|
||||
renderArray(item, (Object[])data);
|
||||
} else if (data instanceof Collection) {
|
||||
renderCollection(item, (Collection)data);
|
||||
} else {
|
||||
ListCell listCell = new ListCell(data != null ? data.toString() : "");
|
||||
listCell.setParent(item);
|
||||
String value = data != null ? data.toString() : "";
|
||||
renderCell(0, item, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderCell(int col, Listitem item, String value) {
|
||||
String tooltip = null;
|
||||
if (maxLength != null && maxLength.length > col && maxLength[col] > 0 && value.length() > maxLength[col]) {
|
||||
tooltip = value;
|
||||
value = truncate(value, maxLength[col]).toString();
|
||||
}
|
||||
ListCell listCell = new ListCell(value);
|
||||
listCell.setParent(item);
|
||||
if (tooltip != null)
|
||||
listCell.setTooltiptext(tooltip);
|
||||
}
|
||||
|
||||
private void renderCollection(Listitem item, Collection data) {
|
||||
int i = 0;
|
||||
for (Object col : data) {
|
||||
ListCell listCell = new ListCell(col != null ? col.toString() : "");
|
||||
listCell.setParent(item);
|
||||
String value = (col != null ? col.toString() : "");
|
||||
renderCell(i, item, value);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private void renderArray(Listitem item, Object[] data) {
|
||||
for (Object col : data) {
|
||||
ListCell listCell = new ListCell(col != null ? col.toString() : "");
|
||||
listCell.setParent(item);
|
||||
int i = 0;
|
||||
for (Object col : data) {
|
||||
String value = (col != null ? col.toString() : "");
|
||||
renderCell(i, item, value);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,5 +93,8 @@ public class SimpleListModel extends AbstractListModel implements ListitemRender
|
|||
item.applyProperties();
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public void setMaxLength(int[] maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,10 +94,7 @@ public class HeaderPanel extends Panel implements EventListener
|
|||
public void onEvent(Event event) throws Exception {
|
||||
if (Events.ON_CLICK.equals(event.getName())) {
|
||||
AboutWindow w = new AboutWindow();
|
||||
w.setPage(this.getPage());
|
||||
w.setPosition("center");
|
||||
w.setTitle("About ADempiere");
|
||||
w.setClosable(true);
|
||||
w.setPage(this.getPage());
|
||||
w.doModal();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,94 +1,373 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2008 Low Heng Sin. 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 *
|
||||
* 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.window;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.ListHead;
|
||||
import org.adempiere.webui.component.ListHeader;
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.SimpleListModel;
|
||||
import org.adempiere.webui.component.Tab;
|
||||
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.component.ToolBarButton;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.util.CLogErrorBuffer;
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.zhtml.Pre;
|
||||
import org.zkoss.zhtml.Text;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.SizeEvent;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Filedownload;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Image;
|
||||
import org.zkoss.zul.Separator;
|
||||
import org.zkoss.zul.Vbox;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Low Heng Sin
|
||||
*
|
||||
*/
|
||||
public class AboutWindow extends Window implements EventListener {
|
||||
|
||||
private Checkbox bErrorsOnly;
|
||||
private Listbox logTable;
|
||||
private Tabbox tabbox;
|
||||
private Tabpanels tabPanels;
|
||||
private Button btnDownload;
|
||||
|
||||
public AboutWindow() {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
Text text = new Text("ADempiere ERP & CRM");
|
||||
text.setParent(this);
|
||||
Separator separator = new Separator();
|
||||
separator.setParent(this);
|
||||
this.setWidth("500px");
|
||||
this.setHeight("450px");
|
||||
this.setPosition("center");
|
||||
this.setTitle("ADempiere Zk Web Client");
|
||||
this.setClosable(true);
|
||||
this.setSizable(true);
|
||||
|
||||
text = new Text(Adempiere.MAIN_VERSION + "<br>");
|
||||
text.setParent(this);
|
||||
text = new Text(Adempiere.DB_VERSION +"<br>");
|
||||
text.setParent(this);
|
||||
this.addEventListener(Events.ON_SIZE, this);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(this);
|
||||
ToolBarButton link = new ToolBarButton();
|
||||
link.setLabel("Sourceforge.net Project Site");
|
||||
link.setHref("http://www.sourceforge.net/projects/adempiere");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(this);
|
||||
Vbox layout = new Vbox();
|
||||
layout.setWidth("100%");
|
||||
layout.setParent(this);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(this);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("ADempiere Wiki");
|
||||
link.setHref("http://www.adempiere.com/wiki/index.php");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(this);
|
||||
tabbox = new Tabbox();
|
||||
tabbox.setParent(layout);
|
||||
tabbox.setWidth("490px");
|
||||
tabbox.setHeight("380px");
|
||||
tabbox.setSclass("lite");
|
||||
Tabs tabs = new Tabs();
|
||||
tabs.setParent(tabbox);
|
||||
tabPanels = new Tabpanels();
|
||||
tabPanels.setParent(tabbox);
|
||||
tabPanels.setWidth("490px");
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(this);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("ADempiere Bazaar");
|
||||
link.setHref("http://www.adempiere.org");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(this);
|
||||
//about
|
||||
Tab tab = new Tab();
|
||||
tab.setLabel("About");
|
||||
tab.setParent(tabs);
|
||||
Tabpanel tabPanel = createAbout();
|
||||
tabPanel.setParent(tabPanels);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(this);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("ADempiere.com");
|
||||
link.setHref("http://www.adempiere.com");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(this);
|
||||
//Credit
|
||||
tab = new Tab();
|
||||
tab.setLabel("Credit");
|
||||
tab.setParent(tabs);
|
||||
tabPanel = createCredit();
|
||||
tabPanel.setParent(tabPanels);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setBar(true);
|
||||
separator.setHeight("20px");
|
||||
separator.setParent(this);
|
||||
//Info
|
||||
tab = new Tab();
|
||||
tab.setLabel("Info");
|
||||
tab.setParent(tabs);
|
||||
tabPanel = createInfo();
|
||||
tabPanel.setParent(tabPanels);
|
||||
|
||||
text = new Text("Initial code contributed by: ");
|
||||
text.setParent(this);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Posterita");
|
||||
link.setHref("http://www.posterita.org");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(this);
|
||||
separator = new Separator();
|
||||
separator.setParent(this);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(this);
|
||||
//Trace
|
||||
tab = new Tab();
|
||||
tab.setLabel("Logs");
|
||||
tab.setParent(tabs);
|
||||
tabPanel = createTrace();
|
||||
tabPanel.setParent(tabPanels);
|
||||
|
||||
Hbox hbox = new Hbox();
|
||||
hbox.setParent(layout);
|
||||
hbox.setPack("end");
|
||||
hbox.setWidth("100%");
|
||||
Button btnOk = new Button();
|
||||
btnOk.setLabel("OK");
|
||||
btnOk.setImage("/images/Ok24.gif");
|
||||
btnOk.addEventListener(Events.ON_CLICK, this);
|
||||
btnOk.setParent(this);
|
||||
btnOk.setParent(hbox);
|
||||
|
||||
this.setBorder("normal");
|
||||
}
|
||||
|
||||
private Tabpanel createTrace() {
|
||||
Tabpanel tabPanel = new Tabpanel();
|
||||
Vbox vbox = new Vbox();
|
||||
vbox.setParent(tabPanel);
|
||||
vbox.setWidth("100%");
|
||||
vbox.setHeight("100%");
|
||||
|
||||
Hbox hbox = new Hbox();
|
||||
bErrorsOnly = new Checkbox();
|
||||
bErrorsOnly.setLabel(Msg.getMsg(Env.getCtx(), "ErrorsOnly"));
|
||||
//default only show error
|
||||
bErrorsOnly.setChecked(true);
|
||||
bErrorsOnly.addEventListener(Events.ON_CHECK, this);
|
||||
hbox.appendChild(bErrorsOnly);
|
||||
btnDownload = new Button(Msg.getMsg(Env.getCtx(), "SaveFile"));
|
||||
btnDownload.addEventListener(Events.ON_CLICK, this);
|
||||
hbox.appendChild(btnDownload);
|
||||
vbox.appendChild(hbox);
|
||||
|
||||
Vector columnNames = CLogErrorBuffer.get(true).getColumnNames(Env.getCtx());
|
||||
|
||||
logTable = new Listbox();
|
||||
ListHead listHead = new ListHead();
|
||||
listHead.setParent(logTable);
|
||||
listHead.setSizable(true);
|
||||
for (Object obj : columnNames) {
|
||||
ListHeader header = new ListHeader(obj.toString());
|
||||
header.setWidth("100px");
|
||||
listHead.appendChild(header);
|
||||
}
|
||||
|
||||
vbox.appendChild(logTable);
|
||||
logTable.setWidth("480px");
|
||||
logTable.setHeight("310px");
|
||||
logTable.setVflex(false);
|
||||
|
||||
updateLogTable();
|
||||
|
||||
return tabPanel;
|
||||
}
|
||||
|
||||
private void updateLogTable() {
|
||||
Vector data = CLogErrorBuffer.get(true).getLogData(bErrorsOnly.isChecked());
|
||||
SimpleListModel model = new SimpleListModel(data);
|
||||
model.setMaxLength(new int[]{0, 0, 0, 200, 0, 200});
|
||||
logTable.setItemRenderer(model);
|
||||
logTable.setModel(model);
|
||||
}
|
||||
|
||||
private Tabpanel createInfo() {
|
||||
Tabpanel tabPanel = new Tabpanel();
|
||||
Div div = new Div();
|
||||
div.setParent(tabPanel);
|
||||
div.setHeight("100%");
|
||||
div.setStyle("overflow: auto;");
|
||||
Pre pre = new Pre();
|
||||
pre.setParent(div);
|
||||
Text text = new Text(CLogMgt.getInfo(null).toString());
|
||||
text.setParent(pre);
|
||||
|
||||
return tabPanel;
|
||||
}
|
||||
|
||||
private Tabpanel createCredit() {
|
||||
Tabpanel tabPanel = new Tabpanel();
|
||||
Vbox vbox = new Vbox();
|
||||
vbox.setParent(tabPanel);
|
||||
vbox.setWidth("100%");
|
||||
Hbox hbox = new Hbox();
|
||||
hbox.setParent(vbox);
|
||||
ToolBarButton link = new ToolBarButton();
|
||||
link.setImage("images/Posterita.jpg");
|
||||
link.setParent(hbox);
|
||||
link.setHref("http://www.posterita.org");
|
||||
link.setTarget("_blank");
|
||||
Label label= new Label("Contributed the initial Zk Web Client code.");
|
||||
label.setParent(hbox);
|
||||
|
||||
Separator separator = new Separator();
|
||||
separator.setParent(vbox);
|
||||
|
||||
Div div = new Div();
|
||||
div.setParent(vbox);
|
||||
div.setWidth("100%");
|
||||
Label caption = new Label("Sponsors");
|
||||
caption.setStyle("font-weight: bold;");
|
||||
div.appendChild(caption);
|
||||
separator = new Separator();
|
||||
separator.setBar(true);
|
||||
separator.setParent(div);
|
||||
Vbox content = new Vbox();
|
||||
content.setWidth("100%");
|
||||
content.setParent(div);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Sysnova");
|
||||
link.setHref("http://www.sysnova.com/");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(content);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Idalica");
|
||||
link.setHref("http://www.idalica.com/");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(content);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(vbox);
|
||||
|
||||
div = new Div();
|
||||
div.setParent(vbox);
|
||||
div.setWidth("100%");
|
||||
caption = new Label("Contributors");
|
||||
caption.setStyle("font-weight: bold;");
|
||||
div.appendChild(caption);
|
||||
separator = new Separator();
|
||||
separator.setBar(true);
|
||||
separator.setParent(div);
|
||||
content = new Vbox();
|
||||
content.setWidth("100%");
|
||||
content.setParent(div);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Ashley G Ramdass");
|
||||
link.setHref("http://www.adempiere.com/wiki/index.php/User:Agramdass");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(content);
|
||||
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Carlos Ruiz");
|
||||
link.setHref("http://www.adempiere.com/wiki/index.php/User:CarlosRuiz");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(content);
|
||||
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Low Heng Sin");
|
||||
link.setHref("http://www.adempiere.com/wiki/index.php/User:Hengsin");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(content);
|
||||
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Teo Sarca");
|
||||
link.setHref("http://www.adempiere.com/wiki/index.php/User:Teo_sarca");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(content);
|
||||
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("Trifonnt");
|
||||
link.setHref("http://www.adempiere.com/wiki/index.php/User:Trifonnt");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(content);
|
||||
|
||||
return tabPanel;
|
||||
}
|
||||
|
||||
private Tabpanel createAbout() {
|
||||
Tabpanel tabPanel = new Tabpanel();
|
||||
|
||||
Vbox vbox = new Vbox();
|
||||
vbox.setWidth("100%");
|
||||
vbox.setHeight("100%");
|
||||
vbox.setAlign("center");
|
||||
vbox.setPack("center");
|
||||
vbox.setParent(tabPanel);
|
||||
Image image = new Image("images/AD10030.png");
|
||||
image.setParent(vbox);
|
||||
|
||||
Text text = new Text(Adempiere.getSubtitle());
|
||||
text.setParent(vbox);
|
||||
Separator separator = new Separator();
|
||||
separator.setParent(vbox);
|
||||
|
||||
text = new Text(Adempiere.MAIN_VERSION + "<br>");
|
||||
text.setParent(vbox);
|
||||
text = new Text(Adempiere.DB_VERSION +"<br>");
|
||||
text.setParent(vbox);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(vbox);
|
||||
ToolBarButton link = new ToolBarButton();
|
||||
link.setLabel("Sourceforge.net Project Site");
|
||||
link.setHref("http://www.sourceforge.net/projects/adempiere");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(vbox);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(vbox);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("ADempiere Wiki");
|
||||
link.setHref("http://www.adempiere.com/wiki/index.php");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(vbox);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(vbox);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("ADempiere.org");
|
||||
link.setHref("http://www.adempiere.org");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(vbox);
|
||||
|
||||
separator = new Separator();
|
||||
separator.setParent(vbox);
|
||||
link = new ToolBarButton();
|
||||
link.setLabel("ADempiere.com");
|
||||
link.setHref("http://www.adempiere.com");
|
||||
link.setTarget("_blank");
|
||||
link.setParent(vbox);
|
||||
|
||||
return tabPanel;
|
||||
}
|
||||
|
||||
public void onEvent(Event event) throws Exception {
|
||||
this.detach();
|
||||
if (event.getTarget() == bErrorsOnly) {
|
||||
this.updateLogTable();
|
||||
}
|
||||
else if (event.getTarget() == btnDownload)
|
||||
downloadLog();
|
||||
else if (event instanceof SizeEvent)
|
||||
doResize((SizeEvent)event);
|
||||
else if (Events.ON_CLICK.equals(event.getName()))
|
||||
this.detach();
|
||||
}
|
||||
|
||||
private void doResize(SizeEvent event) {
|
||||
int width = Integer.parseInt(event.getWidth().substring(0, event.getWidth().length() - 2));
|
||||
int height = Integer.parseInt(event.getHeight().substring(0, event.getHeight().length() - 2));
|
||||
|
||||
tabbox.setWidth((width - 10) + "px");
|
||||
tabbox.setHeight((height - 70) + "px");
|
||||
|
||||
tabPanels.setWidth((width - 10) + "px");
|
||||
|
||||
logTable.setHeight((height - 140) + "px");
|
||||
logTable.setWidth((width - 20) + "px");
|
||||
}
|
||||
|
||||
private void downloadLog() {
|
||||
String log = CLogErrorBuffer.get(true).getErrorInfo(Env.getCtx(), bErrorsOnly.isChecked());
|
||||
AMedia media = new AMedia("trace.log", null, "text/plain", log.getBytes());
|
||||
Filedownload.save(media);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue