From e41477ec3ab2fcf84fc57e28610b845fe92f834f Mon Sep 17 00:00:00 2001 From: Deepak Pansheriya Date: Thu, 11 Oct 2012 14:21:00 +0530 Subject: [PATCH] IDEMPIERE-370 - Removed link shown when there is no table and record id, Also fixed shrinking of messages --- .../adempiere/webui/apps/ProcessDialog.java | 108 +++++++++++------- .../adempiere/webui/apps/form/WGenForm.java | 81 ++++++++----- 2 files changed, 119 insertions(+), 70 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index ebcf6cedd4..dcddfa4d64 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -42,6 +42,7 @@ import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.zhtml.Table; import org.zkoss.zhtml.Td; +import org.zkoss.zhtml.Text; import org.zkoss.zhtml.Tr; import org.zkoss.zk.au.out.AuEcho; import org.zkoss.zk.ui.Component; @@ -466,9 +467,10 @@ public class ProcessDialog extends Window implements EventListener, IProc private void appendRecordLogInfo(ProcessInfoLog[] m_logs) { if (m_logs == null) - return ; - - SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.Date); + return; + + SimpleDateFormat dateFormat = DisplayType + .getDateFormat(DisplayType.Date); logMessageTable = new Table(); logMessageTable.setId("logrecords"); @@ -476,51 +478,73 @@ public class ProcessDialog extends Window implements EventListener, IProc logMessageTable.setDynamicProperty("cellpadding", "0"); logMessageTable.setDynamicProperty("cellspacing", "0"); logMessageTable.setDynamicProperty("width", "100%"); - - this.appendChild(logMessageTable); - for (int i = 0; i < m_logs.length; i++) - { - - Tr tr = new Tr(); - logMessageTable.appendChild(tr); - - ProcessInfoLog log = m_logs[i]; - - if (log.getP_Date() != null){ - Label label = new Label(dateFormat.format(log.getP_Date())); - //label.setStyle("padding-right:100px"); - Td td = new Td(); - td = new Td(); - td.appendChild(label); - tr.appendChild(td); - - } - - if (log.getP_Number() != null){ - Label labelPno= new Label(""+log.getP_Number()); - Td td = new Td(); - td.appendChild(labelPno); - tr.appendChild(td); - } - - A recordLink = null; - if (log.getP_Msg() != null){ - recordLink = new A(); - recordLink.setLabel(log.getP_Msg()); + this.appendChild(logMessageTable); - if (log.getAD_Table_ID() > 0 && log.getRecord_ID()> 0) { - recordLink.setAttribute("Record_ID", String.valueOf(log.getRecord_ID())); - recordLink.setAttribute("AD_Table_ID", String.valueOf(log.getAD_Table_ID())); - recordLink.addEventListener(Events.ON_CLICK, this); - + boolean datePresents = false; + boolean numberPresents = false; + boolean msgPresents = false; + + for (ProcessInfoLog log : m_logs) { + if (log.getP_Date() != null) + datePresents = true; + if (log.getP_Number() != null) + numberPresents = true; + if (log.getP_Msg() != null) + msgPresents = true; + } + + for (int i = 0; i < m_logs.length; i++) { + + Tr tr = new Tr(); + logMessageTable.appendChild(tr); + + ProcessInfoLog log = m_logs[i]; + + if (datePresents) { + Td td = new Td(); + if (log.getP_Date() != null) { + Label label = new Label(dateFormat.format(log.getP_Date())); + td.appendChild(label); + // label.setStyle("padding-right:100px"); } + tr.appendChild(td); + + } + + if (numberPresents) { + Td td = new Td(); - td.appendChild(recordLink); - tr.appendChild(td); + if (log.getP_Number() != null) { + Label labelPno = new Label("" + log.getP_Number()); + td.appendChild(labelPno); + } + tr.appendChild(td); + } + + if (msgPresents) { + Td td = new Td(); + if (log.getP_Msg() != null) { + if (log.getAD_Table_ID() > 0 && log.getRecord_ID() > 0) { + A recordLink = new A(); + recordLink.setLabel(log.getP_Msg()); + recordLink.setAttribute("Record_ID", + String.valueOf(log.getRecord_ID())); + recordLink.setAttribute("AD_Table_ID", + String.valueOf(log.getAD_Table_ID())); + recordLink.addEventListener(Events.ON_CLICK, this); + td.appendChild(recordLink); + } else { + Text t = new Text(); + t.setEncode(false); + t.setValue(log.getP_Msg()); + td.appendChild(t); + } + } + tr.appendChild(td); } } - messageDiv.appendChild(logMessageTable); + messageDiv.appendChild(logMessageTable); } private void restart() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java index ca0a562d40..ab8bd40896 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WGenForm.java @@ -58,6 +58,7 @@ import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.zhtml.Table; import org.zkoss.zhtml.Td; +import org.zkoss.zhtml.Text; import org.zkoss.zhtml.Tr; import org.zkoss.zk.au.out.AuEcho; import org.zkoss.zk.ui.event.Event; @@ -484,6 +485,20 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen this.appendChild(logMessageTable); + boolean datePresents = false; + boolean numberPresents = false; + boolean msgPresents = false; + + for (ProcessInfoLog log : m_logs) { + if (log.getP_Date() != null) + datePresents = true; + if (log.getP_Number() != null) + numberPresents = true; + if (log.getP_Msg() != null) + msgPresents = true; + } + + for (int i = 0; i < m_logs.length; i++) { @@ -492,37 +507,47 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen ProcessInfoLog log = m_logs[i]; - if (log.getP_Date() != null){ - Label label = new Label(dateFormat.format(log.getP_Date())); - //label.setStyle("padding-right:100px"); + if (datePresents) { Td td = new Td(); - td = new Td(); - td.appendChild(label); - tr.appendChild(td); - - } - - if (log.getP_Number() != null){ - Label labelPno= new Label(""+log.getP_Number()); - Td td = new Td(); - td.appendChild(labelPno); - tr.appendChild(td); - } - - A recordLink = null; - if (log.getP_Msg() != null){ - recordLink = new A(); - recordLink.setLabel(log.getP_Msg()); - - if (log.getAD_Table_ID() > 0 && log.getRecord_ID()> 0) { - recordLink.setAttribute("Record_ID", String.valueOf(log.getRecord_ID())); - recordLink.setAttribute("AD_Table_ID", String.valueOf(log.getAD_Table_ID())); - recordLink.addEventListener(Events.ON_CLICK, this); - + if (log.getP_Date() != null) { + Label label = new Label(dateFormat.format(log.getP_Date())); + td.appendChild(label); + // label.setStyle("padding-right:100px"); } + tr.appendChild(td); + + } + + if (numberPresents) { + Td td = new Td(); - td.appendChild(recordLink); - tr.appendChild(td); + if (log.getP_Number() != null) { + Label labelPno = new Label("" + log.getP_Number()); + td.appendChild(labelPno); + } + tr.appendChild(td); + } + + if (msgPresents) { + Td td = new Td(); + if (log.getP_Msg() != null) { + if (log.getAD_Table_ID() > 0 && log.getRecord_ID() > 0) { + A recordLink = new A(); + recordLink.setLabel(log.getP_Msg()); + recordLink.setAttribute("Record_ID", + String.valueOf(log.getRecord_ID())); + recordLink.setAttribute("AD_Table_ID", + String.valueOf(log.getAD_Table_ID())); + recordLink.addEventListener(Events.ON_CLICK, this); + td.appendChild(recordLink); + } else { + Text t = new Text(); + t.setEncode(false); + t.setValue(log.getP_Msg()); + td.appendChild(t); + } + } + tr.appendChild(td); } } messageDiv.appendChild(logMessageTable);