IDEMPIERE-2058 - ** New Report ** - improve for handling Forms too (#1335)

* IDEMPIERE-2058 - ** New Report ** - improve for handling Forms too

* IDEMPIERE-2058 - error fixed

* IDEMPIERE-2058 - dialogs added

* IDEMPIERE-2058 - latest WIP commit until final design stated

* IDEMPIERE-2058 - added cancel button, mandatory handling
This commit is contained in:
Peter Takács 2022-06-25 15:07:07 +02:00 committed by GitHub
parent 06c41d2c68
commit 1f9955fcc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 257 additions and 45 deletions

View File

@ -0,0 +1,35 @@
-- IDEMPIERE-2058
SELECT register_migration_script('202205181247_IDEMPIERE-2058.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- May 18, 2022, 12:47:47 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Copy Report',0,0,'Y',TO_TIMESTAMP('2022-05-18 12:47:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-18 12:47:47','YYYY-MM-DD HH24:MI:SS'),100,200752,'CopyReport','D','829ae7a6-b716-4969-b95a-8440666032c2')
;
-- May 23, 2022, 10:45:29 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','You selected the Copy Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views',0,0,'Y',TO_TIMESTAMP('2022-05-23 10:45:29','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-23 10:45:29','YYYY-MM-DD HH24:MI:SS'),100,200753,'CreateCopyReport?','D','c482066a-d3bf-40d1-8525-1e303c49e586')
;
-- May 23, 2022, 10:47:59 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','You selected the New Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views',0,0,'Y',TO_TIMESTAMP('2022-05-23 10:47:59','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-23 10:47:59','YYYY-MM-DD HH24:MI:SS'),100,200754,'CreateNewReport?','D','fa925848-3e7b-45ed-9300-cb2e2b8fda97')
;
-- May 24, 2022, 4:08:19 PM CEST
UPDATE AD_Message SET MsgText='You selected the New Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views<br />
Print Format Name:', Value='CreateNewPrintFormat',Updated=TO_TIMESTAMP('2022-05-24 16:08:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200754
;
-- May 24, 2022, 4:08:39 PM CEST
UPDATE AD_Message SET MsgText='You selected the Copy Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views<br />
Print Format Name:', Value='CreatePrintFormatCopy',Updated=TO_TIMESTAMP('2022-05-24 16:08:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200753
;
-- May 24, 2022, 4:09:21 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Create Print Format Copy',0,0,'Y',TO_TIMESTAMP('2022-05-24 16:09:21','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-24 16:09:21','YYYY-MM-DD HH24:MI:SS'),100,200755,'CreatePrintFormatCopyTitle','D','d82387a5-6663-4733-a098-ec6a00357277')
;
-- May 24, 2022, 4:09:48 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Create New Print Format',0,0,'Y',TO_TIMESTAMP('2022-05-24 16:09:48','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-24 16:09:48','YYYY-MM-DD HH24:MI:SS'),100,200756,'CreateNewPrintFormatTitle','D','d2c8213e-95e2-476d-a745-601115e16b30')
;

View File

@ -0,0 +1,32 @@
-- IDEMPIERE-2058
SELECT register_migration_script('202205181247_IDEMPIERE-2058.sql') FROM dual;
-- May 18, 2022, 12:47:47 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Copy Report',0,0,'Y',TO_TIMESTAMP('2022-05-18 12:47:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-18 12:47:47','YYYY-MM-DD HH24:MI:SS'),100,200752,'CopyReport','D','829ae7a6-b716-4969-b95a-8440666032c2')
;
-- May 23, 2022, 10:45:29 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','You selected the Copy Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views',0,0,'Y',TO_TIMESTAMP('2022-05-23 10:45:29','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-23 10:45:29','YYYY-MM-DD HH24:MI:SS'),100,200753,'CreateCopyReport?','D','c482066a-d3bf-40d1-8525-1e303c49e586')
;
-- May 23, 2022, 10:47:59 AM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','You selected the New Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views',0,0,'Y',TO_TIMESTAMP('2022-05-23 10:47:59','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-23 10:47:59','YYYY-MM-DD HH24:MI:SS'),100,200754,'CreateNewReport?','D','fa925848-3e7b-45ed-9300-cb2e2b8fda97')
;
-- May 24, 2022, 4:08:19 PM CEST
UPDATE AD_Message SET MsgText='You selected the New Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views<br />
Print Format Name:', Value='CreateNewPrintFormat',Updated=TO_TIMESTAMP('2022-05-24 16:08:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200754
;
-- May 24, 2022, 4:08:39 PM CEST
UPDATE AD_Message SET MsgText='You selected the Copy Report function. It creates a brand new Print Format which you can modify, update, change. This is usually used for improving reporting to get additional information views<br />
Print Format Name:', Value='CreatePrintFormatCopy',Updated=TO_TIMESTAMP('2022-05-24 16:08:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200753
;
-- May 24, 2022, 4:09:21 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Create Print Format Copy',0,0,'Y',TO_TIMESTAMP('2022-05-24 16:09:21','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-24 16:09:21','YYYY-MM-DD HH24:MI:SS'),100,200755,'CreatePrintFormatCopyTitle','D','d82387a5-6663-4733-a098-ec6a00357277')
;
-- May 24, 2022, 4:09:48 PM CEST
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Create New Print Format',0,0,'Y',TO_TIMESTAMP('2022-05-24 16:09:48','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-05-24 16:09:48','YYYY-MM-DD HH24:MI:SS'),100,200756,'CreateNewPrintFormatTitle','D','d2c8213e-95e2-476d-a745-601115e16b30')
;

View File

@ -39,9 +39,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -388,11 +386,7 @@ public class ReportEngine implements PrintServiceAttributeListener
if(Util.isEmpty(processFileNamePattern)) { if(Util.isEmpty(processFileNamePattern)) {
Calendar cal = Calendar.getInstance(); m_name = (m_name = m_printFormat.get_Translation(m_printFormat.getName())) != null ? m_name : m_printFormat.getName();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String dt = sdf.format(cal.getTime());
m_name = m_printFormat.get_Translation("Name") + "_" + dt;
} else { } else {

View File

@ -17,6 +17,8 @@
package org.adempiere.webui.component; package org.adempiere.webui.component;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.adempiere.util.Callback; import org.adempiere.util.Callback;
@ -25,6 +27,8 @@ import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WStringEditor; import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
@ -35,6 +39,7 @@ import org.compiere.util.Util;
import org.zkoss.zhtml.Text; import org.zkoss.zhtml.Text;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -73,6 +78,8 @@ public class Messagebox extends Window implements EventListener<Event>
private Button btnRetry; private Button btnRetry;
private Button btnIgnore; private Button btnIgnore;
private WEditor inputField; private WEditor inputField;
private boolean isInputMandatory;
private boolean isExceptionThrown = false;
private Image img = new Image(); private Image img = new Image();
@ -259,10 +266,10 @@ public class Messagebox extends Window implements EventListener<Event>
public int show(String message, String title, int buttons, String icon, Callback<?> callback, boolean modal) public int show(String message, String title, int buttons, String icon, Callback<?> callback, boolean modal)
{ {
return show(message, title, buttons, icon, null, callback, modal); return show(message, title, buttons, icon, null, false, callback, modal);
} }
public int show(String message, String title, int buttons, String icon, WEditor editor, Callback<?> callback, boolean modal) public int show(String message, String title, int buttons, String icon, WEditor editor, boolean isInputMandatory, Callback<?> callback, boolean modal)
{ {
this.msg = message; this.msg = message;
this.imgSrc = icon; this.imgSrc = icon;
@ -271,7 +278,8 @@ public class Messagebox extends Window implements EventListener<Event>
inputField = new WStringEditor(); inputField = new WStringEditor();
else else
inputField = editor; inputField = editor;
this.isInputMandatory = isInputMandatory;
init(); init();
btnOk.setVisible(false); btnOk.setVisible(false);
@ -307,6 +315,13 @@ public class Messagebox extends Window implements EventListener<Event>
if ((buttons & INPUT) != 0) { if ((buttons & INPUT) != 0) {
inputField.setVisible(true); inputField.setVisible(true);
isInput = true; isInput = true;
inputField.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent evt) {
isExceptionThrown = false;
}
});
} }
this.setTitle(title); this.setTitle(title);
@ -347,13 +362,17 @@ public class Messagebox extends Window implements EventListener<Event>
public static int showDialog(String message, String title, int buttons, String icon, Callback<?> callback, boolean modal) public static int showDialog(String message, String title, int buttons, String icon, Callback<?> callback, boolean modal)
{ {
return showDialog(message, title, buttons, icon, null, callback, modal); return showDialog(message, title, buttons, icon, null, false, callback, modal);
} }
public static int showDialog(String message, String title, int buttons, String icon, WEditor editor, Callback<?> callback, boolean modal) public static int showDialog(String message, String title, int buttons, String icon, WEditor editor, Callback<?> callback, boolean modal) {
return showDialog(message, title, buttons, icon, editor, false, callback, modal);
}
public static int showDialog(String message, String title, int buttons, String icon, WEditor editor, boolean isInputMandatory, Callback<?> callback, boolean modal)
{ {
Messagebox msg = new Messagebox(); Messagebox msg = new Messagebox();
return msg.show(message, title, buttons, icon, editor, callback, modal); return msg.show(message, title, buttons, icon, editor, isInputMandatory, callback, modal);
} }
// Andreas Sumerauer IDEMPIERE 4702 // Andreas Sumerauer IDEMPIERE 4702
@ -398,7 +417,13 @@ public class Messagebox extends Window implements EventListener<Event>
{ {
returnValue = IGNORE; returnValue = IGNORE;
} }
close(); if ((returnValue == CANCEL) || !isInputMandatory || (isInputMandatory && !Util.isEmpty(String.valueOf(inputField.getValue()))))
close();
else {
isExceptionThrown = true;
returnValue = 0;
throw new WrongValueException(inputField.getComponent(), Msg.getMsg(Env.getCtx(), "PrintFormatMandatory"));
}
} }
private void close() { private void close() {
@ -417,8 +442,12 @@ public class Messagebox extends Window implements EventListener<Event>
if (callback != null && !isInput) if (callback != null && !isInput)
{ {
callback.onCallback(returnValue); callback.onCallback(returnValue);
} else if (callback != null && isInput) { } else if (callback != null && isInput && !btnCancel.isVisible() && !btnNo.isVisible()) {
callback.onCallback(inputField.getValue()); callback.onCallback(inputField.getValue());
} else if (callback != null && isInput && (btnCancel.isVisible() || btnNo.isVisible())) {
Map<Boolean, Object> map = new HashMap<Boolean, Object>();
map.put(returnValue == OK || returnValue == YES, isExceptionThrown ? "" : inputField.getValue());
callback.onCallback(map.entrySet().iterator().next());
} }
} }
} }

View File

@ -17,6 +17,7 @@
package org.adempiere.webui.window; package org.adempiere.webui.window;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -444,6 +445,23 @@ public class FDialog
Messagebox.showDialog(s, Util.isEmpty(title) ? AEnv.getDialogHeader(Env.getCtx(), windowNo) : title, Messagebox.showDialog(s, Util.isEmpty(title) ? AEnv.getDialogHeader(Env.getCtx(), windowNo) : title,
Messagebox.OK | Messagebox.INPUT, Messagebox.QUESTION, msgCallback, (msgCallback == null)); Messagebox.OK | Messagebox.INPUT, Messagebox.QUESTION, msgCallback, (msgCallback == null));
} }
public static void askForInputWithCancel(int windowNo, WEditor weditor, String adMessage, String title, final Callback<Map.Entry<Boolean, Object>> callback)
{
Callback<Map.Entry<Boolean, Object>> msgCallback = null;
if (callback != null)
{
msgCallback = new Callback<Map.Entry<Boolean, Object>>() {
@Override
public void onCallback(Map.Entry<Boolean, Object> result) {
callback.onCallback(result);
}
};
}
String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "<br>");
Messagebox.showDialog(s, Util.isEmpty(title) ? AEnv.getDialogHeader(Env.getCtx(), windowNo) : title,
Messagebox.OK | Messagebox.CANCEL | Messagebox.INPUT, Messagebox.QUESTION, weditor, true, msgCallback, (msgCallback == null));
}
/************************************************************************** /**************************************************************************
* Ask Question with question icon and (OK) (Cancel) buttons * Ask Question with question icon and (OK) (Cancel) buttons

View File

@ -22,6 +22,8 @@ import java.io.StringWriter;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -35,6 +37,7 @@ import javax.servlet.http.HttpServletRequest;
import org.adempiere.base.upload.IUploadService; import org.adempiere.base.upload.IUploadService;
import org.adempiere.exceptions.DBException; import org.adempiere.exceptions.DBException;
import org.adempiere.pdf.Document; import org.adempiere.pdf.Document;
import org.adempiere.util.Callback;
import org.adempiere.util.ContextRunnable; import org.adempiere.util.ContextRunnable;
import org.adempiere.webui.ClientInfo; import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.Extensions; import org.adempiere.webui.Extensions;
@ -53,6 +56,8 @@ import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.desktop.IDesktop; import org.adempiere.webui.desktop.IDesktop;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.editor.WTableDirEditor;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.DrillEvent; import org.adempiere.webui.event.DrillEvent;
@ -101,6 +106,7 @@ import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop; import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
@ -190,6 +196,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
private ToolBarButton bExport = new ToolBarButton(); private ToolBarButton bExport = new ToolBarButton();
private ToolBarButton bWizard = new ToolBarButton(); private ToolBarButton bWizard = new ToolBarButton();
private Listbox comboReport = new Listbox(); private Listbox comboReport = new Listbox();
private Listitem previousSelected = new Listitem();
private WTableDirEditor wLanguage; private WTableDirEditor wLanguage;
private Label labelDrill = new Label(); private Label labelDrill = new Label();
private Listbox comboDrill = new Listbox(); private Listbox comboDrill = new Listbox();
@ -1127,6 +1134,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
{ {
selectValue = pp; selectValue = pp;
if(selectValue != null) if(selectValue != null)
previousSelected = comboReport.getSelectedItem();
comboReport.setSelectedItem(li); comboReport.setSelectedItem(li);
} }
} }
@ -1149,6 +1157,9 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(Env.getCtx(), "NewReport")).append(" **"); StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(Env.getCtx(), "NewReport")).append(" **");
KeyNamePair pp = new KeyNamePair(-1, sb.toString()); KeyNamePair pp = new KeyNamePair(-1, sb.toString());
comboReport.appendItem(pp.getName(), pp.getKey()); comboReport.appendItem(pp.getName(), pp.getKey());
sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "CopyReport")).append(" **");
pp = new KeyNamePair(-2, sb.toString());
comboReport.addItem(pp);
} }
comboReport.addEventListener(Events.ON_SELECT, this); comboReport.addEventListener(Events.ON_SELECT, this);
} // fillComboReport } // fillComboReport
@ -1438,7 +1449,18 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
winExportFile.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); winExportFile.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(winExportFile); AEnv.showWindow(winExportFile);
} // cmd_export } // cmd_export
/**
* Sets AD_PrintFormat_Trl Name to AD_PrintFormat Name
* @param pf
*/
private void resetPrintFormatTrl(MPrintFormat pf) {
String sql = "UPDATE AD_PrintFormat_Trl pf "
+ " SET Name = '" + pf.getName() + "' "
+ " WHERE pf.AD_PrintFormat_ID = " + pf.getAD_PrintFormat_ID();
DB.executeUpdate(sql, null);
}
/** /**
* Report Combo - Start other Report or create new one * Report Combo - Start other Report or create new one
*/ */
@ -1457,38 +1479,120 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
// create new // create new
if (AD_PrintFormat_ID == -1) if (AD_PrintFormat_ID == -1)
{ {
int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID(); WEditor editor = new WStringEditor();
if (AD_ReportView_ID != 0) ZKUpdateUtil.setWidth((HtmlBasedComponent)editor.getComponent(), "98%");
{ FDialog.askForInputWithCancel(m_WindowNo, editor, "CreateNewPrintFormat", Msg.getMsg(m_ctx, "CreateNewPrintFormatTitle"), new Callback<Map.Entry<Boolean, Object>>() {
String name = m_reportEngine.getName(); public void onCallback(Map.Entry<Boolean, Object> result) {
int index = name.lastIndexOf('_'); if((result == null) || (!(result.getValue() instanceof String)) || (!result.getKey())) {
if (index != -1) comboReport.setSelectedItem(previousSelected);
name = name.substring(0,index); return;
pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name); }
} MPrintFormat pf = null;
else if (!Util.isEmpty((String)result.getValue())) {
{ int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID();
int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); if (AD_ReportView_ID != 0)
pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID); {
} String name = (String)result.getValue();
if (pf != null) pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name);
fillComboReport(pf.get_ID()); }
else else
return; {
int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID);
}
if (pf != null) {
pf.setName((String)result.getValue());
if(!pf.save()) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String dt = sdf.format(cal.getTime());
pf.setName(pf.getName() + "_" + dt);
pf.saveEx();
}
resetPrintFormatTrl(pf);
fillComboReport(pf.get_ID());
}
else
return;
// Get Language from previous - thanks Gunther Hoppe
if (m_reportEngine.getPrintFormat() != null)
{
setLanguage();
pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage()); // needs to be re-set - otherwise viewer will be blank
pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage());
}
m_reportEngine.setPrintFormat(pf);
m_reportEngine.initName();
postRenderReportEvent();
}
else {
comboReport.setSelectedItem(previousSelected);
}
}
});
} else if (AD_PrintFormat_ID == -2) {
WEditor editor = new WStringEditor();
ZKUpdateUtil.setWidth((HtmlBasedComponent)editor.getComponent(), "90%");
FDialog.askForInputWithCancel(m_WindowNo, editor, "CreatePrintFormatCopy", Msg.getMsg(m_ctx, "CreatePrintFormatCopyTitle"), new Callback<Map.Entry<Boolean, Object>>() {
public void onCallback(Map.Entry<Boolean, Object> result) {
if((result == null) || (!(result.getValue() instanceof String)) || (!result.getKey())) {
comboReport.setSelectedItem(previousSelected);
return;
}
MPrintFormat pf = null;
if (!Util.isEmpty((String)result.getValue())) {
MPrintFormat current = m_reportEngine.getPrintFormat();
if (current != null) {
pf = MPrintFormat.copyToClient(m_ctx,
current.getAD_PrintFormat_ID(),
Env.getAD_Client_ID(m_ctx));
if (pf != null) {
pf.setName((String)result.getValue());
if(!pf.save()) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String dt = sdf.format(cal.getTime());
pf.setName(pf.getName() + "_" + dt);
pf.saveEx();
}
resetPrintFormatTrl(pf);
fillComboReport(pf.get_ID());
}
else
return;
} else
return;
// Get Language from previous - thanks Gunther Hoppe
if (m_reportEngine.getPrintFormat() != null)
{
setLanguage();
pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage()); // needs to be re-set - otherwise viewer will be blank
pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage());
}
m_reportEngine.initName();
m_reportEngine.setPrintFormat(pf);
postRenderReportEvent();
}
else {
comboReport.setSelectedItem(previousSelected);
}
}
});
} }
else else {
// Get Language from previous - thanks Gunther Hoppe
pf = MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true); pf = MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true);
if (m_reportEngine.getPrintFormat() != null)
// Get Language from previous - thanks Gunther Hoppe {
if (m_reportEngine.getPrintFormat() != null) setLanguage();
{ pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage()); // needs to be re-set - otherwise viewer will be blank
setLanguage(); pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage());
pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage()); // needs to be re-set - otherwise viewer will be blank }
pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage()); m_reportEngine.setPrintFormat(pf);
postRenderReportEvent();
} }
m_reportEngine.setPrintFormat(pf);
postRenderReportEvent();
} // cmd_report } // cmd_report
/** /**