IDEMPIERE-370 Implement link from process ending message to next records.
This commit is contained in:
parent
2afcd4085e
commit
c84aa4c312
|
@ -46,6 +46,7 @@ import org.adempiere.webui.apps.form.WCreateFromFactory;
|
|||
import org.adempiere.webui.apps.form.WCreateFromWindow;
|
||||
import org.adempiere.webui.apps.form.WPayment;
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.ProcessInfoDialog;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.editor.IProcessButton;
|
||||
import org.adempiere.webui.editor.WButtonEditor;
|
||||
|
@ -85,6 +86,7 @@ import org.compiere.model.MRecentItem;
|
|||
import org.compiere.model.MRole;
|
||||
import org.compiere.process.DocAction;
|
||||
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;
|
||||
|
@ -155,8 +157,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
|
||||
private int curWindowNo;
|
||||
|
||||
// private GridTab curTab;
|
||||
|
||||
private boolean m_onlyCurrentRows = true;
|
||||
|
||||
protected ADWindowToolbar toolbar;
|
||||
|
@ -979,13 +979,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
}
|
||||
else if (event.getTarget() instanceof ProcessModalDialog)
|
||||
{
|
||||
Clients.clearBusy(getComponent());
|
||||
ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget();
|
||||
onModalClose(dialog.getProcessInfo());
|
||||
String s = breadCrumb.getStatusLine();
|
||||
boolean b = breadCrumb.getStatusError();
|
||||
ProcessInfoLog[] logs = breadCrumb.getPLogs();
|
||||
onRefresh(true, false);
|
||||
breadCrumb.setStatusLine(s, b);
|
||||
Clients.clearBusy(getComponent());
|
||||
breadCrumb.setStatusLine(s, b, logs);
|
||||
}
|
||||
else if (ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT.equals(event.getName()))
|
||||
{
|
||||
|
@ -2684,9 +2685,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
}
|
||||
}
|
||||
|
||||
private void updateUI(ProcessInfo pi) {
|
||||
|
||||
|
||||
private void updateUI(ProcessInfo pi) {
|
||||
// Timeout
|
||||
if (pi.isTimeout()) // set temporarily to R/O
|
||||
Env.setContext(ctx, curWindowNo, "Processed", "Y");
|
||||
|
@ -2694,13 +2693,24 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
String summary = pi.getSummary();
|
||||
if (summary != null && summary.indexOf('@') != -1)
|
||||
pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary));
|
||||
breadCrumb.setStatusLine(pi.getSummary(), pi.isError());
|
||||
// Get Log Info
|
||||
|
||||
// Get Log Info
|
||||
ProcessInfoUtil.setLogFromDB(pi);
|
||||
String logInfo = pi.getLogInfo();
|
||||
if (logInfo.length() > 0)
|
||||
FDialog.info(curWindowNo, this.getComponent(), Env.getHeader(ctx, curWindowNo),
|
||||
pi.getTitle() + "<br>" + logInfo);
|
||||
ProcessInfoLog m_logs[] = pi.getLogs();
|
||||
breadCrumb.setStatusLine(pi.getSummary(), pi.isError(),m_logs);
|
||||
if (m_logs != null) {
|
||||
ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(ctx, curWindowNo),Env.getHeader(ctx, curWindowNo), m_logs);
|
||||
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Clients.clearBusy(getComponent());
|
||||
}
|
||||
});
|
||||
getComponent().getParent().appendChild(dialog);
|
||||
Clients.showBusy(getComponent(), " ");
|
||||
LayoutUtils.openOverlappedWindow(this.getComponent(),dialog,"middle_center");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,16 +21,17 @@ import java.util.Map;
|
|||
|
||||
import org.adempiere.webui.AdempiereWebUI;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.Menupopup;
|
||||
import org.adempiere.webui.component.ToolBar;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.event.ToolbarListener;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.WRecordInfo;
|
||||
import org.compiere.model.DataStatusEvent;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.process.ProcessInfoLog;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
@ -44,12 +45,14 @@ import org.zkoss.zk.ui.event.EventListener;
|
|||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.KeyEvent;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zul.A;
|
||||
import org.zkoss.zul.Caption;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Hlayout;
|
||||
import org.zkoss.zul.Image;
|
||||
import org.zkoss.zul.Menuitem;
|
||||
import org.zkoss.zul.Separator;
|
||||
import org.zkoss.zul.Space;
|
||||
|
||||
/**
|
||||
|
@ -101,6 +104,8 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
|
||||
private Caption msgPopupCaption;
|
||||
|
||||
private ProcessInfoLog[] pInfoLogs = null;
|
||||
|
||||
protected Menupopup linkPopup;
|
||||
|
||||
/**
|
||||
|
@ -236,7 +241,10 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
|
||||
String title = Msg.getMsg(Env.getCtx(), "Who") + m_text;
|
||||
new WRecordInfo (title, m_dse);
|
||||
} else if (event.getTarget().getParent() == messageContainer) {
|
||||
}else if(event.getTarget() instanceof RecordLink){
|
||||
doZoom((RecordLink)event.getTarget());
|
||||
}
|
||||
else if (event.getTarget().getParent() == messageContainer) {
|
||||
showPopup();
|
||||
} else if (event.getTarget() == btnFirst) {
|
||||
if (toolbarListener != null)
|
||||
|
@ -328,7 +336,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
*/
|
||||
public void setStatusLine (String text)
|
||||
{
|
||||
setStatusLine(text, false);
|
||||
setStatusLine(text, false,null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,8 +344,21 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
* @param error
|
||||
*/
|
||||
public void setStatusLine (String text, boolean error)
|
||||
{
|
||||
Execution execution = Executions.getCurrent();
|
||||
{
|
||||
setStatusLine(text, error, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text
|
||||
* @param error
|
||||
* @param m_logs
|
||||
*/
|
||||
public void setStatusLine (String text, boolean error, ProcessInfoLog[] m_logs)
|
||||
{
|
||||
pInfoLogs = m_logs;
|
||||
Div div = null;
|
||||
|
||||
Execution execution = Executions.getCurrent();
|
||||
if (execution != null) {
|
||||
String key = this.getClass().getName()+"."+getUuid();
|
||||
Object o = execution.getAttribute(key);
|
||||
|
@ -371,21 +392,54 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
}
|
||||
Label label = new Label(labelText);
|
||||
messageContainer.appendChild(label);
|
||||
if (labelText.length() != m_statusText.length()) {
|
||||
image.addEventListener(Events.ON_CLICK, this);
|
||||
image.setStyle("cursor: pointer");
|
||||
label.addEventListener(Events.ON_CLICK, this);
|
||||
label.setStyle("cursor: pointer");
|
||||
|
||||
label = new Label(" ...");
|
||||
label.setStyle("cursor: pointer");
|
||||
messageContainer.appendChild(label);
|
||||
label.addEventListener(Events.ON_CLICK, this);
|
||||
}
|
||||
messageContainer.appendChild(new Space());
|
||||
if (m_logs != null) {
|
||||
div = new Div();
|
||||
for (int i = 0; i < m_logs.length; i++) {
|
||||
if (m_logs[i].getP_Msg() != null) {
|
||||
if (m_logs[i].getAD_Table_ID() > 0
|
||||
&& m_logs[i].getRecord_ID() > 0) {
|
||||
RecordLink recordLink = new RecordLink(m_logs[i].getAD_Table_ID(), m_logs[i].getRecord_ID());
|
||||
recordLink.setLabel(m_logs[i].getP_Msg());
|
||||
recordLink.addEventListener(Events.ON_CLICK, this);
|
||||
if (!div.getChildren().isEmpty())
|
||||
div.appendChild(new Separator("horizontal"));
|
||||
div.appendChild(recordLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createPopupContent();
|
||||
if (labelText.length() != m_statusText.length() || (div != null && div.getChildren().size() > 0)) {
|
||||
image.addEventListener(Events.ON_CLICK, this);
|
||||
image.setStyle("cursor: pointer");
|
||||
label.addEventListener(Events.ON_CLICK, this);
|
||||
label.setStyle("cursor: pointer");
|
||||
|
||||
label = new Label(" ...");
|
||||
label.setStyle("cursor: pointer");
|
||||
messageContainer.appendChild(label);
|
||||
label.addEventListener(Events.ON_CLICK, this);
|
||||
}
|
||||
|
||||
messageContainer.appendChild(new Space());
|
||||
createPopupContent();
|
||||
if(div!=null)
|
||||
{
|
||||
msgPopupCnt.appendChild(div);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void doZoom(RecordLink link) {
|
||||
int Record_ID = 0;
|
||||
int AD_Table_ID = 0;
|
||||
Record_ID = link.recordId;
|
||||
AD_Table_ID = link.tableId;
|
||||
if (Record_ID > 0 && AD_Table_ID > 0) {
|
||||
AEnv.zoom(AD_Table_ID, Record_ID);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildLabelText(String statusText) {
|
||||
if (statusText == null)
|
||||
|
@ -441,7 +495,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
msgPopup.setContentStyle("overflow: auto");
|
||||
msgPopup.setWidth("500px");
|
||||
msgPopup.appendChild(msgPopupCnt);
|
||||
msgPopup.setPage(SessionManager.getAppDesktop().getComponent().getPage());
|
||||
// msgPopup.setPage(SessionManager.getAppDesktop().getComponent().getPage());
|
||||
msgPopup.setShadow(true);
|
||||
msgPopupCaption = new Caption();
|
||||
msgPopup.appendChild(msgPopupCaption);
|
||||
|
@ -449,14 +503,13 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
|
||||
private void showPopup() {
|
||||
msgPopupCaption.setImage(m_statusError ? ERROR_INDICATOR_IMAGE : INFO_INDICATOR_IMAGE);
|
||||
appendChild(msgPopup);
|
||||
LayoutUtils.openOverlappedWindow(messageContainer, msgPopup, "overlap_end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageDetached(Page page) {
|
||||
super.onPageDetached(page);
|
||||
if (msgPopup != null)
|
||||
msgPopup.detach();
|
||||
if (linkPopup != null)
|
||||
linkPopup.detach();
|
||||
}
|
||||
|
@ -473,5 +526,21 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ProcessInfoLog[] getPLogs() {
|
||||
return pInfoLogs;
|
||||
}
|
||||
|
||||
class RecordLink extends A {
|
||||
private static final long serialVersionUID = 3793489614175751401L;
|
||||
|
||||
protected int recordId;
|
||||
protected int tableId;
|
||||
|
||||
protected RecordLink(int AD_Table_ID, int Record_ID) {
|
||||
super();
|
||||
tableId = AD_Table_ID;
|
||||
recordId = Record_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* 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.component;
|
||||
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.compiere.process.ProcessInfoLog;
|
||||
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.zul.A;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Image;
|
||||
import org.zkoss.zul.Separator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author milap.doshi
|
||||
* @author Deepak Pansheriya
|
||||
*/
|
||||
public class ProcessInfoDialog extends Window implements EventListener<Event> {
|
||||
private static final long serialVersionUID = -4957498533838144942L;
|
||||
private static final String MESSAGE_PANEL_STYLE = "text-align:left; word-break: break-all; overflow: auto; max-height: 250pt; min-width: 230pt; max-width: 450pt;";
|
||||
|
||||
private Text lblMsg = new Text();
|
||||
private Button btnOk = new Button();
|
||||
private Image img = new Image();
|
||||
public static final String INFORMATION = "~./zul/img/msgbox/info-btn.png";
|
||||
|
||||
public ProcessInfoDialog(String title, String header,
|
||||
ProcessInfoLog[] m_logs) {
|
||||
init(title, header, m_logs);
|
||||
}
|
||||
|
||||
private void init(String title, String header, ProcessInfoLog[] m_logs) {
|
||||
this.setTitle(title);
|
||||
this.setClosable(true);
|
||||
this.setSizable(true);
|
||||
|
||||
this.setBorder("normal");
|
||||
this.setContentStyle("background-color:#ffffff;");
|
||||
|
||||
this.setId(title);
|
||||
|
||||
lblMsg.setEncode(false);
|
||||
lblMsg.setValue(header);
|
||||
|
||||
btnOk.setImage("/images/Ok16.png");
|
||||
btnOk.addEventListener(Events.ON_CLICK, this);
|
||||
LayoutUtils.addSclass("action-text-button", btnOk);
|
||||
|
||||
Panel pnlMessage = new Panel();
|
||||
pnlMessage.setStyle(MESSAGE_PANEL_STYLE);
|
||||
pnlMessage.appendChild(lblMsg);
|
||||
|
||||
Separator sep = new Separator("horizontal");
|
||||
pnlMessage.appendChild(sep);
|
||||
|
||||
for (int loopCtr = 0; loopCtr < m_logs.length; loopCtr++) {
|
||||
if (m_logs[loopCtr].getP_Msg() != null) {
|
||||
|
||||
if (m_logs[loopCtr].getAD_Table_ID() > 0
|
||||
&& m_logs[loopCtr].getRecord_ID() > 0) {
|
||||
A recordLink = new A();
|
||||
recordLink.setLabel(m_logs[loopCtr].getP_Msg());
|
||||
recordLink.setAttribute("Record_ID",
|
||||
String.valueOf(m_logs[loopCtr].getRecord_ID()));
|
||||
recordLink.setAttribute("AD_Table_ID",
|
||||
String.valueOf(m_logs[loopCtr].getAD_Table_ID()));
|
||||
recordLink.addEventListener(Events.ON_CLICK, this);
|
||||
pnlMessage.appendChild(recordLink);
|
||||
} else {
|
||||
Text recordText = new Text(m_logs[loopCtr].getP_Msg());
|
||||
pnlMessage.appendChild(recordText);
|
||||
}
|
||||
pnlMessage.appendChild(new Separator("horizontal"));
|
||||
}
|
||||
}
|
||||
|
||||
Hbox pnlImage = new Hbox();
|
||||
img.setSrc(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);
|
||||
north.appendChild(pnlMessage);
|
||||
|
||||
Hbox pnlButtons = new Hbox();
|
||||
pnlButtons.setHeight("52px");
|
||||
pnlButtons.setAlign("center");
|
||||
pnlButtons.setPack("end");
|
||||
pnlButtons.appendChild(btnOk);
|
||||
|
||||
Separator separator = new Separator();
|
||||
|
||||
separator.setWidth("100%");
|
||||
separator.setBar(true);
|
||||
this.appendChild(separator);
|
||||
|
||||
Hbox south = new Hbox();
|
||||
south.setPack("end");
|
||||
south.setWidth("100%");
|
||||
this.appendChild(south);
|
||||
south.appendChild(pnlButtons);
|
||||
|
||||
this.setBorder("normal");
|
||||
this.setContentStyle("background-color:#ffffff;");
|
||||
}
|
||||
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (event == null)
|
||||
return;
|
||||
if (event.getTarget() instanceof A) {
|
||||
int Record_ID = 0;
|
||||
int AD_Table_ID = 0;
|
||||
Record_ID = Integer.valueOf((String) event.getTarget()
|
||||
.getAttribute("Record_ID"));
|
||||
AD_Table_ID = Integer.valueOf((String) event.getTarget()
|
||||
.getAttribute("AD_Table_ID"));
|
||||
|
||||
if (Record_ID > 0 && AD_Table_ID > 0) {
|
||||
AEnv.zoom(AD_Table_ID, Record_ID);
|
||||
}
|
||||
} else if (event.getTarget() == btnOk) {
|
||||
this.detach();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue