IDEMPIERE-2532:issue relate show dialog when run process

show message success event hasn't any m_logs
show message error same success (use ProcessInfoDialog not use FDialog)
This commit is contained in:
hieplq 2015-03-28 06:09:22 +07:00
parent 220d14a3d1
commit b827cbf292
2 changed files with 93 additions and 78 deletions

View File

@ -53,21 +53,46 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
private Button btnOk = ButtonFactory.createNamedButton(ConfirmPanel.A_OK);
private Image img = new Image();
public static final String INFORMATION = "~./zul/img/msgbox/info-btn.png";
public static final String ERROR = "~./zul/img/msgbox/info-btn.png";
/**
* @deprecated Should use {@link #ProcessInfoDialog(String, String, ProcessInfo)} for flexible show message
* @param title
* @param header
* @param m_logs
*/
public ProcessInfoDialog(String title, String header,
ProcessInfoLog[] m_logs) {
init(title, header, m_logs);
init(title, header, null, m_logs);
}
private void init(String title, String header, ProcessInfoLog[] m_logs) {
/**
* show result after run a process
* @param title
* @param header
* @param pi
*/
public ProcessInfoDialog(String title, String header, ProcessInfo pi, boolean needFillLogFromDb) {
if (needFillLogFromDb)
ProcessInfoUtil.setLogFromDB(pi);
init(pi.getTitle(), null, pi, null);
}
/**
*
* @param title
* @param header
* @param m_logs
*/
private void init(String title, String header, ProcessInfo pi, ProcessInfoLog[] m_logs) {
this.setTitle(title);
this.setClosable(true);
this.setSizable(true);
this.setBorder("normal");
this.setContentStyle("background-color:#ffffff;");
this.setId(title);
//this.setId(title);
lblMsg.setEncode(false);
lblMsg.setValue(header);
@ -81,51 +106,23 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
Separator sep = new Separator("horizontal");
pnlMessage.appendChild(sep);
for (int loopCtr = 0; loopCtr < m_logs.length; loopCtr++) {
ProcessInfoLog log = m_logs[loopCtr];
if (log.getP_Msg() != null || log.getP_Date() != null || log.getP_Number() != null) {
SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.DateTime);
StringBuffer sb = new StringBuffer ();
//
if (log.getP_Date() != null)
sb.append(dateFormat.format(log.getP_Date()))
.append(" \t");
//
if (log.getP_Number() != null)
sb.append(log.getP_Number())
.append(" \t");
//
if (log.getP_Msg() != null)
sb.append(Msg.parseTranslation(Env.getCtx(), log.getP_Msg()));
//
if (log.getAD_Table_ID() > 0
&& log.getRecord_ID() > 0) {
DocumentLink recordLink = new DocumentLink(sb.toString(), log.getAD_Table_ID(), log.getRecord_ID());
pnlMessage.appendChild(recordLink);
} else {
Text recordText = new Text(sb.toString());
pnlMessage.appendChild(recordText);
}
pnlMessage.appendChild(new Separator("horizontal"));
}
}
Hbox pnlImage = new Hbox();
img.setSrc(INFORMATION);
img.setSrc((pi != null && pi.isError()) ? ERROR:INFORMATION);
pnlImage.setWidth("72px");
pnlImage.setAlign("center");
pnlImage.setPack("center");
pnlImage.appendChild(img);
Hbox north = new Hbox();
north.setAlign("center");
north.setStyle("margin: 20pt 10pt 20pt 10pt;"); // trbl
this.appendChild(north);
north.appendChild(pnlImage);
pnlMessage.appendChild(new Text(Msg.getMsg(Env.getCtx(), pi.isError()?"Error":"Success")));
pnlMessage.appendChild(new Separator("horizontal"));
north.appendChild(pnlMessage);
Hbox pnlButtons = new Hbox();
pnlButtons.setHeight("52px");
pnlButtons.setAlign("center");
@ -143,9 +140,55 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
south.setWidth("100%");
this.appendChild(south);
south.appendChild(pnlButtons);
if (pi != null){
m_logs = pi.getLogs();
String summary = pi.getSummary();
if (summary != null && summary.indexOf('@') != -1)
summary = Msg.parseTranslation(Env.getCtx(), summary);
if (summary != null && summary.trim().length() > 0 && !summary.trim().equalsIgnoreCase("Report")){
pnlMessage.appendChild(new Text(summary));
}
}
if (m_logs != null && m_logs.length > 0){
separator = new Separator();
separator.setWidth("100%");
separator.setBar(true);
pnlMessage.appendChild(separator);
for (int loopCtr = 0; loopCtr < m_logs.length; loopCtr++) {
ProcessInfoLog log = m_logs[loopCtr];
if (log.getP_Msg() != null || log.getP_Date() != null || log.getP_Number() != null) {
SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.DateTime);
StringBuffer sb = new StringBuffer ();
//
if (log.getP_Date() != null)
sb.append(dateFormat.format(log.getP_Date()))
.append(" \t");
//
if (log.getP_Number() != null)
sb.append(log.getP_Number())
.append(" \t");
//
if (log.getP_Msg() != null)
sb.append(Msg.parseTranslation(Env.getCtx(), log.getP_Msg()));
//
if (log.getAD_Table_ID() > 0
&& log.getRecord_ID() > 0) {
DocumentLink recordLink = new DocumentLink(sb.toString(), log.getAD_Table_ID(), log.getRecord_ID());
pnlMessage.appendChild(recordLink);
} else {
Text recordText = new Text(sb.toString());
pnlMessage.appendChild(recordText);
}
pnlMessage.appendChild(new Separator("horizontal"));
}
}
}
this.setBorder("normal");
this.setContentStyle("background-color:#ffffff;");
}
public void onEvent(Event event) throws Exception {
@ -165,22 +208,13 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
* just pass false, other pass true to avoid duplicate message
*/
public static void showProcessInfo (ProcessInfo pi, int windowNo, final Component comp, boolean needFillLogFromDb) {
// Get Log Info
if (needFillLogFromDb)
ProcessInfoUtil.setLogFromDB(pi);
ProcessInfoLog m_logs[] = pi.getLogs();
if (m_logs != null && m_logs.length > 0) {
ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(Env.getCtx(), windowNo),AEnv.getDialogHeader(Env.getCtx(), windowNo), m_logs);
final ISupportMask supportMask = LayoutUtils.showWindowWithMask(dialog, comp, LayoutUtils.OVERLAP_PARENT);;
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
supportMask.hideMask();
}
});
}
ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(Env.getCtx(), windowNo),AEnv.getDialogHeader(Env.getCtx(), windowNo), pi, needFillLogFromDb);
final ISupportMask supportMask = LayoutUtils.showWindowWithMask(dialog, comp, LayoutUtils.OVERLAP_PARENT);;
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
supportMask.hideMask();
}
});
}
}

View File

@ -60,7 +60,6 @@ import org.adempiere.webui.factory.InfoManager;
import org.adempiere.webui.part.ITabOnSelectHandler;
import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.window.FDialog;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
import org.compiere.model.MInfoColumn;
@ -72,8 +71,6 @@ import org.compiere.model.MSysConfig;
import org.compiere.model.MTable;
import org.compiere.model.X_AD_CtxHelp;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ProcessInfoLog;
import org.compiere.process.ProcessInfoUtil;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
@ -1550,27 +1547,11 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
// enable or disable control button rely selected record status
enableButtons();
}else if (m_pi.isError()){
// show error info
ProcessInfoUtil.setLogFromDB(m_pi);
ProcessInfoLog m_logs[] = m_pi.getLogs();
if (m_logs != null && m_logs.length > 0) {
ProcessInfoDialog.showProcessInfo(m_pi, p_WindowNo, InfoPanel.this, false);
}else{
FDialog.error(p_WindowNo, m_pi.getSummary());
}
ProcessInfoDialog.showProcessInfo(m_pi, p_WindowNo, InfoPanel.this, true);
// enable or disable control button rely selected record status
enableButtons();
}else if (!m_pi.isError()){
ProcessInfoUtil.setLogFromDB(m_pi);
ProcessInfoLog m_logs[] = m_pi.getLogs();
if (m_logs != null && m_logs.length > 0) {
ProcessInfoDialog.showProcessInfo(m_pi, p_WindowNo, InfoPanel.this, false);
// when success, show summary if exists
}else if (m_pi.getSummary() != null && m_pi.getSummary().trim().length() > 0){
FDialog.info(p_WindowNo, null, m_pi.getSummary());
}
ProcessInfoDialog.showProcessInfo(m_pi, p_WindowNo, InfoPanel.this, true);
Clients.response(new AuEcho(InfoPanel.this, "onQueryCallback", m_results));
}