diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/SimpleListModel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/SimpleListModel.java
new file mode 100644
index 0000000000..0bb8ec8872
--- /dev/null
+++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/SimpleListModel.java
@@ -0,0 +1,71 @@
+package org.adempiere.webui.component;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.zkoss.zul.AbstractListModel;
+import org.zkoss.zul.Listbox;
+import org.zkoss.zul.Listcell;
+import org.zkoss.zul.Listitem;
+import org.zkoss.zul.ListitemRenderer;
+import org.zkoss.zul.ListitemRendererExt;
+
+public class SimpleListModel extends AbstractListModel implements ListitemRenderer, ListitemRendererExt {
+
+ private List list;
+
+ public SimpleListModel(List list) {
+ this.list = list;
+ }
+
+ public Object getElementAt(int index) {
+ if (index >= 0 && index < list.size())
+ return list.get(index);
+ else
+ return null;
+ }
+
+ public int getSize() {
+ return list.size();
+ }
+
+ 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);
+ }
+ }
+
+ private void renderCollection(Listitem item, Collection data) {
+ for (Object col : data) {
+ ListCell listCell = new ListCell(col != null ? col.toString() : "");
+ listCell.setParent(item);
+ }
+ }
+
+ private void renderArray(Listitem item, Object[] data) {
+ for (Object col : data) {
+ ListCell listCell = new ListCell(col != null ? col.toString() : "");
+ listCell.setParent(item);
+ }
+ }
+
+ public int getControls() {
+ return DETACH_ON_RENDER;
+ }
+
+ public Listcell newListcell(Listitem item) {
+ return null;
+ }
+
+ public Listitem newListitem(Listbox listbox) {
+ ListItem item = new ListItem();
+ item.applyProperties();
+ return item;
+ }
+
+}
diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java
index 9b5d8228eb..be9486da62 100644
--- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java
+++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/StatusBarPanel.java
@@ -20,10 +20,16 @@ package org.adempiere.webui.panel;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Panel;
+import org.adempiere.webui.window.WRecordInfo;
import org.compiere.model.DataStatusEvent;
+import org.compiere.model.MRole;
+import org.compiere.util.Env;
+import org.compiere.util.Msg;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.EventListener;
+import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
-import org.zkoss.zul.Separator;
import org.zkoss.zul.Vbox;
/**
@@ -34,13 +40,17 @@ import org.zkoss.zul.Vbox;
* @date Mar 12, 2007
* @version $Revision: 0.10 $
*/
-public class StatusBarPanel extends Panel
+public class StatusBarPanel extends Panel implements EventListener
{
private static final long serialVersionUID = 1L;
private Label statusDB;
private Label statusLine;
private Label infoLine;
+
+ private DataStatusEvent m_dse;
+
+ private String m_text;
public StatusBarPanel()
{
@@ -73,7 +83,7 @@ public class StatusBarPanel extends Panel
div.setStyle("text-align: right; ");
div.appendChild(infoLine);
div.appendChild(statusDB);
- statusDB.setStyle("");
+
LayoutUtils.addSclass("status-db", statusDB);
LayoutUtils.addSclass("status-info", infoLine);
vbox = new Vbox();
@@ -83,6 +93,8 @@ public class StatusBarPanel extends Panel
hbox.appendChild(vbox);
this.appendChild(hbox);
+
+ statusDB.addEventListener(Events.ON_CLICK, this);
}
public void setStatusDB (String text)
@@ -102,6 +114,9 @@ public class StatusBarPanel extends Panel
sb.append(text).append(" ");
statusDB.setValue(sb.toString());
}
+
+ m_text = text;
+ m_dse = dse;
}
public void setStatusLine (String text)
@@ -122,4 +137,17 @@ public class StatusBarPanel extends Panel
{
infoLine.setValue(text);
} // setInfo
+
+ public void onEvent(Event event) throws Exception {
+ if (Events.ON_CLICK.equals(event.getName()) && event.getTarget() == statusDB) {
+ if (m_dse == null
+ || m_dse.CreatedBy == null
+ || !MRole.getDefault().isShowPreference())
+ return;
+
+ String title = Msg.getMsg(Env.getCtx(), "Who") + m_text;
+ WRecordInfo info = new WRecordInfo (title, m_dse);
+ }
+
+ }
}
diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java
new file mode 100644
index 0000000000..bf8f4e0477
--- /dev/null
+++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java
@@ -0,0 +1,396 @@
+/******************************************************************************
+// * Product: Adempiere 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 *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.adempiere.webui.window;
+
+import java.math.*;
+import java.sql.*;
+import java.text.*;
+import java.util.*;
+import java.util.logging.*;
+
+import org.adempiere.webui.apps.AEnv;
+import org.adempiere.webui.component.ConfirmPanel;
+import org.adempiere.webui.component.Listbox;
+import org.adempiere.webui.component.SimpleListModel;
+import org.adempiere.webui.component.Window;
+import org.compiere.model.*;
+import org.compiere.util.*;
+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.zkex.zul.Borderlayout;
+import org.zkoss.zkex.zul.Center;
+import org.zkoss.zkex.zul.North;
+import org.zkoss.zkex.zul.South;
+import org.zkoss.zul.Div;
+import org.zkoss.zul.Listhead;
+import org.zkoss.zul.Listheader;
+
+/**
+ * Record Info (Who) With Change History
+ *
+ * Change log:
+ *
+ * - 2007-02-26 - teo_sarca - [ 1666598 ] RecordInfo shows ColumnName instead of name
+ *
+ *
+ * @author Jorg Janke
+ *
+ * Zk Port
+ * @author Low Heng Sin
+ */
+public class WRecordInfo extends Window implements EventListener
+{
+ /**
+ * Record Info
+ * @param title title
+ * @param dse data status event
+ */
+ public WRecordInfo (String title, DataStatusEvent dse)
+ {
+ super ();
+ this.setTitle(title);
+ this.setAttribute("modal", Boolean.TRUE);
+ this.setWidth("500px");
+ this.setHeight("400px");
+ this.setBorder("normal");
+ this.setSizable(true);
+ this.setClosable(true);
+
+ try
+ {
+ init ( dynInit(dse, title) );
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, "", e);
+ }
+ AEnv.showCenterScreen(this);
+ } // RecordInfo
+
+
+ private Listbox table = new Listbox();
+ private ConfirmPanel confirmPanel = new ConfirmPanel (false);
+
+ /** Logger */
+ protected CLogger log = CLogger.getCLogger(getClass());
+ /** The Data */
+ private Vector> m_data = new Vector>();
+ /** Info */
+ private StringBuffer m_info = new StringBuffer();
+
+ /** Date Time Format */
+ private SimpleDateFormat m_dateTimeFormat = DisplayType.getDateFormat
+ (DisplayType.DateTime, Env.getLanguage(Env.getCtx()));
+ /** Date Format */
+ private SimpleDateFormat m_dateFormat = DisplayType.getDateFormat
+ (DisplayType.DateTime, Env.getLanguage(Env.getCtx()));
+ /** Number Format */
+ private DecimalFormat m_numberFormat = DisplayType.getNumberFormat
+ (DisplayType.Number, Env.getLanguage(Env.getCtx()));
+ /** Amount Format */
+ private DecimalFormat m_amtFormat = DisplayType.getNumberFormat
+ (DisplayType.Amount, Env.getLanguage(Env.getCtx()));
+ /** Number Format */
+ private DecimalFormat m_intFormat = DisplayType.getNumberFormat
+ (DisplayType.Integer, Env.getLanguage(Env.getCtx()));
+
+ /**
+ * Static Layout
+ * @throws Exception
+ */
+ private void init (boolean showTable) throws Exception
+ {
+
+ Div div = new Div();
+ div.setStyle("width: 100%; height: 100%");
+ Pre pre = new Pre();
+ Text text = new Text(m_info.toString());
+ text.setParent(pre);
+ pre.setParent(div);
+ //
+
+ Borderlayout layout = new Borderlayout();
+ layout.setParent(this);
+ layout.setWidth("100%");
+ layout.setHeight("100%");
+
+ Center center = new Center();
+ center.setParent(layout);
+ center.setFlex(true);
+ if (showTable)
+ {
+ North north = new North();
+ north.setParent(layout);
+ north.appendChild(div);
+
+ center.appendChild(table);
+ table.setWidth("100%");
+ table.setVflex(true);
+ }
+ else
+ {
+ center.appendChild(div);
+ }
+ //
+ South south = new South();
+ south.setParent(layout);
+ south.appendChild(confirmPanel);
+
+ confirmPanel.addActionListener(Events.ON_CLICK, this);
+ } // jbInit
+
+
+ /**
+ * Dynamic Init
+ * @param dse data status event
+ * @param title title
+ * @return true if table initialized
+ */
+ private boolean dynInit(DataStatusEvent dse, String title)
+ {
+ if (dse.CreatedBy == null)
+ return false;
+ // Info
+ MUser user = MUser.get(Env.getCtx(), dse.CreatedBy.intValue());
+ m_info.append(" ")
+ .append(Msg.translate(Env.getCtx(), "CreatedBy"))
+ .append(": ").append(user.getName())
+ .append(" - ").append(m_dateTimeFormat.format(dse.Created)).append("\n");
+
+ if (!dse.Created.equals(dse.Updated)
+ || !dse.CreatedBy.equals(dse.UpdatedBy))
+ {
+ if (!dse.CreatedBy.equals(dse.UpdatedBy))
+ user = MUser.get(Env.getCtx(), dse.UpdatedBy.intValue());
+ m_info.append(" ")
+ .append(Msg.translate(Env.getCtx(), "UpdatedBy"))
+ .append(": ").append(user.getName())
+ .append(" - ").append(m_dateTimeFormat.format(dse.Updated)).append("\n");
+ }
+ if (dse.Info != null && dse.Info.length() > 0)
+ m_info.append("\n (").append(dse.Info).append(")");
+
+ // Title
+ if (dse.AD_Table_ID != 0)
+ {
+ MTable table1 = MTable.get (Env.getCtx(), dse.AD_Table_ID);
+ setTitle(title + " - " + table1.getName());
+ }
+
+ // Only Client Preference can view Change Log
+ if (!MRole.PREFERENCETYPE_Client.equals(MRole.getDefault().getPreferenceType()))
+ return false;
+
+ int Record_ID = 0;
+ if (dse.Record_ID instanceof Integer)
+ Record_ID = ((Integer)dse.Record_ID).intValue();
+ else
+ log.info("dynInit - Invalid Record_ID=" + dse.Record_ID);
+ if (Record_ID == 0)
+ return false;
+
+ // Data
+ String sql = "SELECT AD_Column_ID, Updated, UpdatedBy, OldValue, NewValue "
+ + "FROM AD_ChangeLog "
+ + "WHERE AD_Table_ID=? AND Record_ID=? "
+ + "ORDER BY Updated DESC";
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = DB.prepareStatement (sql, null);
+ pstmt.setInt (1, dse.AD_Table_ID);
+ pstmt.setInt (2, Record_ID);
+ ResultSet rs = pstmt.executeQuery ();
+ while (rs.next ())
+ {
+ addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3),
+ rs.getString(4), rs.getString(5));
+ }
+ rs.close ();
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, sql, e);
+ }
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ pstmt = null;
+ }
+
+ //
+ Vector columnNames = new Vector();
+ columnNames.add(Msg.translate(Env.getCtx(), "Name"));
+ columnNames.add(Msg.translate(Env.getCtx(), "NewValue"));
+ columnNames.add(Msg.translate(Env.getCtx(), "OldValue"));
+ columnNames.add(Msg.translate(Env.getCtx(), "UpdatedBy"));
+ columnNames.add(Msg.translate(Env.getCtx(), "Updated"));
+ columnNames.add(Msg.translate(Env.getCtx(), "AD_Column_ID"));
+
+ Listhead listhead = new Listhead();
+ listhead.setSizable(true);
+
+ for (int i = 0; i < columnNames.size(); i++)
+ {
+ Listheader listheader = new Listheader(columnNames.get(i));
+ listhead.appendChild(listheader);
+ }
+
+ table.appendChild(listhead);
+ SimpleListModel model = new SimpleListModel(m_data);
+ table.setItemRenderer(model);
+ table.setModel(model);
+
+ return true;
+ } // dynInit
+
+ /**
+ * Add Line
+ * @param AD_Column_ID column
+ * @param Updated updated
+ * @param UpdatedBy user
+ * @param OldValue old
+ * @param NewValue new
+ */
+ private void addLine (int AD_Column_ID, Timestamp Updated, int UpdatedBy,
+ String OldValue, String NewValue)
+ {
+ Vector line = new Vector();
+ // Column
+ MColumn column = MColumn.get (Env.getCtx(), AD_Column_ID);
+ line.add(Msg.translate(Env.getCtx(), column.getColumnName()));
+ //
+ if (OldValue != null && OldValue.equals(MChangeLog.NULL))
+ OldValue = null;
+ String showOldValue = OldValue;
+ if (NewValue != null && NewValue.equals(MChangeLog.NULL))
+ NewValue = null;
+ String showNewValue = NewValue;
+ //
+ try
+ {
+ if (DisplayType.isText (column.getAD_Reference_ID ()))
+ ;
+ else if (column.getAD_Reference_ID() == DisplayType.YesNo)
+ {
+ if (OldValue != null)
+ {
+ boolean yes = OldValue.equals("true") || OldValue.equals("Y");
+ showOldValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N");
+ }
+ if (NewValue != null)
+ {
+ boolean yes = NewValue.equals("true") || NewValue.equals("Y");
+ showNewValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N");
+ }
+ }
+ else if (column.getAD_Reference_ID() == DisplayType.Amount)
+ {
+ if (OldValue != null)
+ showOldValue = m_amtFormat
+ .format (new BigDecimal (OldValue));
+ if (NewValue != null)
+ showNewValue = m_amtFormat
+ .format (new BigDecimal (NewValue));
+ }
+ else if (column.getAD_Reference_ID() == DisplayType.Integer)
+ {
+ if (OldValue != null)
+ showOldValue = m_intFormat.format (new Integer (OldValue));
+ if (NewValue != null)
+ showNewValue = m_intFormat.format (new Integer (NewValue));
+ }
+ else if (DisplayType.isNumeric (column.getAD_Reference_ID ()))
+ {
+ if (OldValue != null)
+ showOldValue = m_numberFormat.format (new BigDecimal (OldValue));
+ if (NewValue != null)
+ showNewValue = m_numberFormat.format (new BigDecimal (NewValue));
+ }
+ else if (column.getAD_Reference_ID() == DisplayType.Date)
+ {
+ if (OldValue != null)
+ showOldValue = m_dateFormat.format (Timestamp.valueOf (OldValue));
+ if (NewValue != null)
+ showNewValue = m_dateFormat.format (Timestamp.valueOf (NewValue));
+ }
+ else if (column.getAD_Reference_ID() == DisplayType.DateTime)
+ {
+ if (OldValue != null)
+ showOldValue = m_dateTimeFormat.format (Timestamp.valueOf (OldValue));
+ if (NewValue != null)
+ showNewValue = m_dateTimeFormat.format (Timestamp.valueOf (NewValue));
+ }
+ else if (DisplayType.isLookup(column.getAD_Reference_ID ()))
+ {
+ MLookup lookup = MLookupFactory.get (Env.getCtx(), 0,
+ AD_Column_ID, column.getAD_Reference_ID(),
+ Env.getLanguage(Env.getCtx()), column.getColumnName(),
+ column.getAD_Reference_Value_ID(),
+ column.isParent(), null);
+ if (OldValue != null)
+ {
+ Object key = OldValue;
+ NamePair pp = lookup.get(key);
+ if (pp != null)
+ showOldValue = pp.getName();
+ }
+ if (NewValue != null)
+ {
+ Object key = NewValue;
+ NamePair pp = lookup.get(key);
+ if (pp != null)
+ showNewValue = pp.getName();
+ }
+ }
+ else if (DisplayType.isLOB (column.getAD_Reference_ID ()))
+ ;
+ }
+ catch (Exception e)
+ {
+ log.log(Level.WARNING, OldValue + "->" + NewValue, e);
+ }
+ //
+ line.add(showNewValue);
+ line.add(showOldValue);
+ // UpdatedBy
+ MUser user = MUser.get(Env.getCtx(), UpdatedBy);
+ line.add(user.getName());
+ // Updated
+ line.add(m_dateFormat.format(Updated));
+ // Column Name
+ line.add(column.getColumnName());
+
+ m_data.add(line);
+ } // addLine
+
+
+ public void onEvent(Event event) throws Exception {
+ this.detach();
+ }
+
+} // WRecordInfo