IDEMPIERE-144 Performance: Remove the use of zk event thread. This will break things but it is a necessary step to improve the performance and scalability of the zk client. This is also the first step require to implement clustering support.

This commit is contained in:
Heng Sin Low 2012-08-15 07:26:55 +08:00
parent b92a635945
commit 09d73d1486
49 changed files with 1215 additions and 730 deletions

View File

@ -76,7 +76,7 @@ public interface IProcessUI {
* @param message * @param message
* @param callback * @param callback
*/ */
public void ask(String message, Callback<String> callback); public void ask(String message, Callback<Boolean> callback);
/** /**
* add to list of file available for download after process end * add to list of file available for download after process end

View File

@ -346,12 +346,7 @@ public final class ProcessUtil {
public static MWFProcess startWorkFlow(Properties ctx, ProcessInfo pi, int AD_Workflow_ID) { public static MWFProcess startWorkFlow(Properties ctx, ProcessInfo pi, int AD_Workflow_ID) {
MWorkflow wf = MWorkflow.get (ctx, AD_Workflow_ID); MWorkflow wf = MWorkflow.get (ctx, AD_Workflow_ID);
MWFProcess wfProcess = null; MWFProcess wfProcess = wf.start(pi, pi.getTransactionName());
if (pi.isBatch())
wfProcess = wf.start(pi, pi.getTransactionName()); // may return null
else {
wfProcess = wf.startWait(pi); // may return null
}
log.fine(pi.toString()); log.fine(pi.toString());
return wfProcess; return wfProcess;
} }

View File

@ -710,6 +710,16 @@ public class MWorkflow extends X_AD_Workflow
if (localTrx != null) if (localTrx != null)
localTrx.close(); localTrx.close();
} }
if (retValue != null)
{
String summary = retValue.getProcessMsg();
StateEngine state = retValue.getState();
if (summary == null || summary.trim().length() == 0)
summary = state.toString();
pi.setSummary(summary, state.isTerminated() || state.isAborted());
}
return retValue; return retValue;
} // MWFProcess } // MWFProcess

View File

@ -2972,10 +2972,10 @@ public final class APanel extends CPanel
} // updateToolBarAndMenuWithRestriction } // updateToolBarAndMenuWithRestriction
@Override @Override
public void ask(String message, Callback<String> callback) { public void ask(String message, Callback<Boolean> callback) {
boolean b = ADialog.ask(m_curWindowNo, this, message); boolean b = ADialog.ask(m_curWindowNo, this, message);
if (callback != null) { if (callback != null) {
callback.onCallback(b ? "OK" : "CANCEL"); callback.onCallback(b);
} }
} }

View File

@ -526,10 +526,10 @@ public class ProcessDialog extends CFrame
} }
@Override @Override
public void ask(String message, Callback<String> callback) { public void ask(String message, Callback<Boolean> callback) {
boolean b = ADialog.ask(m_WindowNo, this, message); boolean b = ADialog.ask(m_WindowNo, this, message);
if (callback != null) { if (callback != null) {
callback.onCallback(b ? "OK" : "CANCEL"); callback.onCallback(b);
} }
} }

View File

@ -389,10 +389,10 @@ public class VGenPanel extends CPanel implements ActionListener, ChangeListener,
} }
@Override @Override
public void ask(String message, Callback<String> callback) { public void ask(String message, Callback<Boolean> callback) {
boolean b = ADialog.ask(m_WindowNo, this, message); boolean b = ADialog.ask(m_WindowNo, this, message);
if (callback != null) { if (callback != null) {
callback.onCallback(b ? "OK" : "CANCEL"); callback.onCallback(b);
} }
} }

View File

@ -448,10 +448,10 @@ public class VPaySelect extends PaySelect implements FormPanel, ActionListener,
} }
@Override @Override
public void ask(String message, Callback<String> callback) { public void ask(String message, Callback<Boolean> callback) {
boolean b = ADialog.ask(m_WindowNo, null, message); boolean b = ADialog.ask(m_WindowNo, null, message);
if (callback != null) { if (callback != null) {
callback.onCallback(b ? "OK" : "CANCEL"); callback.onCallback(b);
} }
} }

View File

@ -905,10 +905,10 @@ public class VInOutInvoiceGen extends CPanel
} }
@Override @Override
public void ask(String message, Callback<String> callback) { public void ask(String message, Callback<Boolean> callback) {
boolean b = ADialog.ask(m_WindowNo, this, message); boolean b = ADialog.ask(m_WindowNo, this, message);
if (callback != null) { if (callback != null) {
callback.onCallback(b ? "OK" : "CANCEL"); callback.onCallback(b);
} }
} }

View File

@ -102,6 +102,8 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
private static final String CLIENT_INFO = "client.info"; private static final String CLIENT_INFO = "client.info";
private static boolean eventThreadEnabled = false;
public AdempiereWebUI() public AdempiereWebUI()
{ {
this.addEventListener(Events.ON_CLIENT_INFO, this); this.addEventListener(Events.ON_CLIENT_INFO, this);
@ -133,6 +135,8 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Executions.getCurrent().getDesktop().addListener(new DrillCommand()); Executions.getCurrent().getDesktop().addListener(new DrillCommand());
Executions.getCurrent().getDesktop().addListener(new TokenCommand()); Executions.getCurrent().getDesktop().addListener(new TokenCommand());
Executions.getCurrent().getDesktop().addListener(new ZoomCommand()); Executions.getCurrent().getDesktop().addListener(new ZoomCommand());
eventThreadEnabled = Executions.getCurrent().getDesktop().getWebApp().getConfiguration().isEventThreadEnabled();
} }
public void onOk() public void onOk()
@ -393,4 +397,8 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
public UserPreference getUserPreference() { public UserPreference getUserPreference() {
return userPreference; return userPreference;
} }
public static boolean isEventThreadEnabled() {
return eventThreadEnabled;
}
} }

View File

@ -67,9 +67,9 @@ public class ValuePreference extends Window implements EventListener
* @param aValue value * @param aValue value
* @return ValuePreference or null * @return ValuePreference or null
*/ */
public static ValuePreference start (GridField mField, Object aValue) public static void start (GridField mField, Object aValue)
{ {
return start (mField, aValue, null); start (mField, aValue, null);
} // start } // start
/** /**
@ -79,12 +79,12 @@ public class ValuePreference extends Window implements EventListener
* @param aDisplayValue display value * @param aDisplayValue display value
* @return ValuePreference or null * @return ValuePreference or null
*/ */
public static ValuePreference start (GridField mField, Object aValue, String aDisplayValue) public static void start (GridField mField, Object aValue, String aDisplayValue)
{ {
if (!mField.isEditable(false)) if (!mField.isEditable(false))
{ {
log.info("Field not editable (R/O)"); log.info("Field not editable (R/O)");
return null; return;
} }
// Set Value/DisplayValue // Set Value/DisplayValue
@ -116,7 +116,6 @@ public class ValuePreference extends Window implements EventListener
AD_Client_ID, AD_Org_ID, AD_User_ID, AD_Window_ID, AD_Client_ID, AD_Org_ID, AD_User_ID, AD_Window_ID,
Attribute, DisplayAttribute, Value, DisplayValue, Attribute, DisplayAttribute, Value, DisplayValue,
displayType, AD_Reference_ID); displayType, AD_Reference_ID);
return vp;
} // create } // create
/** /**

View File

@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Checkbox; import org.adempiere.webui.component.Checkbox;
@ -1295,8 +1296,14 @@ public class WAcctViewer extends Window implements EventListener
private void actionRePost() private void actionRePost()
{ {
if (m_data.documentQuery if (m_data.documentQuery
&& m_data.AD_Table_ID != 0 && m_data.Record_ID != 0 && m_data.AD_Table_ID != 0 && m_data.Record_ID != 0)
&& FDialog.ask(m_data.WindowNo, this, "PostImmediate?")) {
FDialog.ask(m_data.WindowNo, this, "PostImmediate?", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
//setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); //setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
boolean force = forcePost.isChecked(); boolean force = forcePost.isChecked();
@ -1304,10 +1311,13 @@ public class WAcctViewer extends Window implements EventListener
m_data.AD_Table_ID, m_data.Record_ID, force); m_data.AD_Table_ID, m_data.Record_ID, force);
//setCursor(Cursor.getDefaultCursor()); //setCursor(Cursor.getDefaultCursor());
if (error != null) if (error != null)
FDialog.error(0, this, "PostingError-N", error); FDialog.error(0, WAcctViewer.this, "PostingError-N", error);
actionQuery(); actionQuery();
} }
}
});
}
} // actionRePost } // actionRePost
// Elaine 2009/07/29 // Elaine 2009/07/29

View File

@ -92,15 +92,6 @@ public final class AEnv
SessionManager.getAppDesktop().showWindow(window, "center"); SessionManager.getAppDesktop().showWindow(window, "center");
} // showCenterScreen } // showCenterScreen
/**
* Position window in center of the screen
* @param window Window to position
*/
public static void positionCenterScreen(Window window)
{
showCenterScreen(window);
} // positionCenterScreen
/** /**
* Show in the center of the screen. * Show in the center of the screen.
* (pack, set location and set visibility) * (pack, set location and set visibility)

View File

@ -462,17 +462,17 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
public void onAfterProcess() public void onAfterProcess()
{ {
// //
afterProcessTask(); if (!afterProcessTask()) {
// If the process is a silent one and no errors occured, close the dialog // If the process is a silent one and no errors occured, close the dialog
if(m_ShowHelp != null && m_ShowHelp.equals("S")) if(m_ShowHelp != null && m_ShowHelp.equals("S"))
this.dispose(); this.dispose();
} }
}
/************************************************************************** /**************************************************************************
* Optional Processing Task * Optional Processing Task
*/ */
private void afterProcessTask() private boolean afterProcessTask()
{ {
// something to do? // something to do?
if (m_ids != null && m_ids.length > 0) if (m_ids != null && m_ids.length > 0)
@ -480,11 +480,21 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
log.config(""); log.config("");
// Print invoices // Print invoices
if (m_AD_Process_ID == PROCESS_C_INVOICE_GENERATE) if (m_AD_Process_ID == PROCESS_C_INVOICE_GENERATE)
{
printInvoices(); printInvoices();
else if (m_AD_Process_ID == PROCESS_M_INOUT_GENERATE) return true;
printShipments();
} }
else if (m_AD_Process_ID == PROCESS_M_INOUT_GENERATE)
{
printShipments();
return true;
}
else
{
return false;
}
}
return false;
} // afterProcessTask } // afterProcessTask
/************************************************************************** /**************************************************************************
@ -494,13 +504,17 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
{ {
if (m_ids == null) if (m_ids == null)
return; return;
if (!FDialog.ask(m_WindowNo, this, "PrintShipments")) FDialog.ask(m_WindowNo, this, "PrintShipments", new Callback<Boolean>() {
return; @Override
public void onCallback(Boolean result) {
if (result) {
m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintShipments")).append("</p>"); m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintShipments")).append("</p>");
message.setContent(m_messageText.toString()); message.setContent(m_messageText.toString());
showBusyDialog(); showBusyDialog();
Clients.response(new AuEcho(this, "onPrintShipments", null)); Clients.response(new AuEcho(ProcessDialog.this, "onPrintShipments", null));
}
}
});
} // printInvoices } // printInvoices
public void onPrintShipments() public void onPrintShipments()
@ -559,6 +573,10 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
log.log(Level.SEVERE, e.getLocalizedMessage(), e); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
} }
} }
// If the process is a silent one and no errors occured, close the dialog
if(m_ShowHelp != null && m_ShowHelp.equals("S"))
this.dispose();
} }
/** /**
@ -568,12 +586,19 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
{ {
if (m_ids == null) if (m_ids == null)
return; return;
if (!FDialog.ask(m_WindowNo, this, "PrintInvoices")) FDialog.ask(m_WindowNo, this, "PrintInvoices", new Callback<Boolean>() {
return; @Override
public void onCallback(Boolean result)
{
if (result)
{
m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintInvoices")).append("</p>"); m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintInvoices")).append("</p>");
message.setContent(m_messageText.toString()); message.setContent(m_messageText.toString());
showBusyDialog(); showBusyDialog();
Clients.response(new AuEcho(this, "onPrintInvoices", null)); Clients.response(new AuEcho(ProcessDialog.this, "onPrintInvoices", null));
}
}
});
} // printInvoices } // printInvoices
public void onPrintInvoices() public void onPrintInvoices()
@ -630,6 +655,10 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
log.log(Level.SEVERE, e.getLocalizedMessage(), e); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
} }
} }
// If the process is a silent one and no errors occured, close the dialog
if(m_ShowHelp != null && m_ShowHelp.equals("S"))
this.dispose();
} }
public boolean isValid() { public boolean isValid() {
@ -661,7 +690,7 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
} }
@Override @Override
public void ask(final String message, final Callback<String> callback) { public void ask(final String message, final Callback<Boolean> callback) {
Executions.schedule(getDesktop(), new EventListener<Event>() { Executions.schedule(getDesktop(), new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {

View File

@ -108,7 +108,7 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
if (listener != null) if (listener != null)
{ {
addEventListener(ON_MODAL_CLOSE, listener); addEventListener(ON_WINDOW_CLOSE, listener);
} }
log.info("Process=" + pi.getAD_Process_ID()); log.info("Process=" + pi.getAD_Process_ID());
@ -413,7 +413,6 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
private void onCancel() { private void onCancel() {
m_cancel = true; m_cancel = true;
this.dispose(); this.dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} }
private void onStatusUpdate(Event event) { private void onStatusUpdate(Event event) {
@ -433,7 +432,6 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
Events.postEvent(downloadDialog, new Event(MultiFileDownloadDialog.ON_SHOW)); Events.postEvent(downloadDialog, new Event(MultiFileDownloadDialog.ON_SHOW));
} }
dispose(); dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} }
@Override @Override
@ -488,7 +486,7 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
} }
@Override @Override
public void ask(final String message, final Callback<String> callback) { public void ask(final String message, final Callback<Boolean> callback) {
Executions.schedule(getDesktop(), new EventListener<Event>() { Executions.schedule(getDesktop(), new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {

View File

@ -137,14 +137,12 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
{ {
FDialog.error(windowNo, this, "Error", ex.getLocalizedMessage()); FDialog.error(windowNo, this, "Error", ex.getLocalizedMessage());
} }
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} }
// Cancel // Cancel
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
{ {
isCancel = true; isCancel = true;
dispose(); dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} }
// Select All // Select All
// Trifon // Trifon

View File

@ -31,6 +31,7 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Label;
@ -53,6 +54,7 @@ import org.zkoss.util.media.Media;
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;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center; import org.zkoss.zul.Center;
import org.zkoss.zul.North; import org.zkoss.zul.North;
@ -116,6 +118,7 @@ public class WFileImport extends ADForm implements EventListener
public WFileImport() public WFileImport()
{ {
this.addEventListener(Events.ON_UPLOAD, this);
} }
/** /**
@ -305,6 +308,11 @@ public class WFileImport extends ADForm implements EventListener
SessionManager.getAppDesktop().closeActiveWindow(); SessionManager.getAppDesktop().closeActiveWindow();
return; return;
} }
else if (e instanceof UploadEvent)
{
UploadEvent ue = (UploadEvent) e;
processUploadMedia(ue.getMedia());
}
if (m_data != null && m_data.size() > 0 // file loaded if (m_data != null && m_data.size() > 0 // file loaded
&& m_format != null && m_format.getRowCount() > 0) // format loaded && m_format != null && m_format.getRowCount() > 0) // format loaded
@ -319,10 +327,12 @@ public class WFileImport extends ADForm implements EventListener
private void cmd_loadFile() private void cmd_loadFile()
{ {
Media media = null; Media media = Fileupload.get();
if (AdempiereWebUI.isEventThreadEnabled())
media = Fileupload.get(); processUploadMedia(media);
}
private void processUploadMedia(Media media) {
if (media == null) if (media == null)
return; return;

View File

@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.BusyDialog; import org.adempiere.webui.apps.BusyDialog;
@ -339,11 +340,19 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen
public void onAfterProcess() public void onAfterProcess()
{ {
// OK to print // OK to print
if (FDialog.ask(getWindowNo(), this, genForm.getAskPrintMsg())) FDialog.ask(getWindowNo(), this, genForm.getAskPrintMsg(), new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
Clients.showBusy("Processing..."); Clients.showBusy("Processing...");
Clients.response(new AuEcho(this, "onPrint", null)); Clients.response(new AuEcho(WGenForm.this, "onPrint", null));
} // OK to print }
}
});
} }
public void onPrint() public void onPrint()

View File

@ -18,6 +18,7 @@ package org.adempiere.webui.apps.form;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.apps.BusyDialog; import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Grid;
@ -238,17 +239,29 @@ public class WMerge extends Merge implements IFormController, EventListener
m_msg = Msg.getMsg(Env.getCtx(), "MergeFrom") + " = " + from_Info m_msg = Msg.getMsg(Env.getCtx(), "MergeFrom") + " = " + from_Info
+ "\n" + Msg.getMsg(Env.getCtx(), "MergeTo") + " = " + to_Info; + "\n" + Msg.getMsg(Env.getCtx(), "MergeTo") + " = " + to_Info;
if (!FDialog.ask(m_WindowNo, form, "MergeQuestion", m_msg))
return;
updateDeleteTable(columnName); final String columnNameRef = columnName;
final int fromIdRef = from_ID;
final int toIdRef = to_ID;
FDialog.ask(m_WindowNo, form, "MergeQuestion", m_msg, new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{
updateDeleteTable(columnNameRef);
progressWindow = new BusyDialog(); progressWindow = new BusyDialog();
progressWindow.setPage(form.getPage()); progressWindow.setPage(form.getPage());
progressWindow.doHighlighted(); progressWindow.doHighlighted();
runnable = new MergeRunnable(columnName, from_ID, to_ID); runnable = new MergeRunnable(columnNameRef, fromIdRef, toIdRef);
Clients.response(new AuEcho(form, "runProcess", null)); Clients.response(new AuEcho(form, "runProcess", null));
}
}
});
} // actionPerformed } // actionPerformed
class MergeRunnable implements Runnable { class MergeRunnable implements Runnable {

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
@ -57,6 +58,7 @@ import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.PaymentExport; import org.compiere.util.PaymentExport;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
import org.python.antlr.ast.Call;
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.zul.Borderlayout; import org.zkoss.zul.Borderlayout;
@ -365,12 +367,20 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
FDialog.info(m_WindowNo, form, "Saved", FDialog.info(m_WindowNo, form, "Saved",
Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no); Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
if (FDialog.ask(m_WindowNo, form, "VPayPrintSuccess?")) FDialog.ask(m_WindowNo, form, "VPayPrintSuccess?", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
// int lastDocumentNo = // int lastDocumentNo =
MPaySelectionCheck.confirmPrint (m_checks, m_batch); MPaySelectionCheck.confirmPrint (m_checks, m_batch);
// document No not updated // document No not updated
} }
}
});
} else { } else {
FDialog.error(m_WindowNo, form, "Error", err.toString()); FDialog.error(m_WindowNo, form, "Error", err.toString());
} }
@ -441,6 +451,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
log.log(Level.SEVERE, e.getLocalizedMessage(), e); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return; return;
} }
final SimplePDFViewer chequeViewerRef = chequeViewer;
if (lastDocumentNo != 0) if (lastDocumentNo != 0)
{ {
@ -451,10 +462,15 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
DB.executeUpdate(sb.toString(), null); DB.executeUpdate(sb.toString(), null);
} }
SimplePDFViewer remitViewer = null; FDialog.ask(m_WindowNo, form, "VPayPrintPrintRemittance", new Callback<Boolean>() {
if (FDialog.ask(m_WindowNo, form, "VPayPrintPrintRemittance"))
@Override
public void onCallback(Boolean result)
{ {
pdfList = new ArrayList<File>(); SimplePDFViewer remitViewer = null;
if (result)
{
List<File> pdfList = new ArrayList<File>();
for (int i = 0; i < m_checks.length; i++) for (int i = 0; i < m_checks.length; i++)
{ {
MPaySelectionCheck check = m_checks[i]; MPaySelectionCheck check = m_checks[i];
@ -484,15 +500,17 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
{ {
log.log(Level.SEVERE, e.getLocalizedMessage(), e); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
} }
} // remittance }
dispose(); dispose();
if (chequeViewer != null) if (chequeViewerRef != null)
SessionManager.getAppDesktop().showWindow(chequeViewer); SessionManager.getAppDesktop().showWindow(chequeViewerRef);
if (remitViewer != null) if (remitViewer != null)
SessionManager.getAppDesktop().showWindow(remitViewer); SessionManager.getAppDesktop().showWindow(remitViewer);
}
});
} // cmd_print } // cmd_print

View File

@ -369,25 +369,33 @@ public class WPaySelect extends PaySelect
} }
// Ask to Post it // Ask to Post it
if (!FDialog.ask(m_WindowNo, form, "VPaySelectGenerate?", "(" + m_ps.getName() + ")")) FDialog.ask(m_WindowNo, form, "VPaySelectGenerate?", "(" + m_ps.getName() + ")", new Callback<Boolean>() {
return;
@Override
public void onCallback(Boolean result)
{
if (result)
{
// Prepare Process // Prepare Process
int AD_Proces_ID = PROCESS_C_PAYSELECTION_CREATEPAYMENT; // C_PaySelection_CreatePayment int AD_Proces_ID = PROCESS_C_PAYSELECTION_CREATEPAYMENT; // C_PaySelection_CreatePayment
// Execute Process // Execute Process
ProcessModalDialog dialog = new ProcessModalDialog(this, m_WindowNo, ProcessModalDialog dialog = new ProcessModalDialog(WPaySelect.this, m_WindowNo,
AD_Proces_ID, X_C_PaySelection.Table_ID, m_ps.getC_PaySelection_ID(), false); AD_Proces_ID, X_C_PaySelection.Table_ID, m_ps.getC_PaySelection_ID(), false);
if (dialog.isValid()) { if (dialog.isValid()) {
try { try {
dialog.setWidth("500px"); dialog.setWidth("500px");
dialog.setVisible(true); dialog.setVisible(true);
dialog.setPage(form.getPage()); dialog.setPage(form.getPage());
dialog.doModal(); dialog.doHighlighted();
} catch (SuspendNotAllowedException e) { } catch (SuspendNotAllowedException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e); log.log(Level.SEVERE, e.getLocalizedMessage(), e);
} }
} }
}
}
});
} // generatePaySelect } // generatePaySelect
/** /**
@ -447,7 +455,7 @@ public class WPaySelect extends PaySelect
} }
@Override @Override
public void ask(final String message, final Callback<String> callback) { public void ask(final String message, final Callback<Boolean> callback) {
Executions.schedule(form.getDesktop(), new EventListener<Event>() { Executions.schedule(form.getDesktop(), new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {

View File

@ -940,13 +940,6 @@ public class WPayment extends Window
} }
} // actionPerformed } // actionPerformed
@Override
public void dispose() {
super.dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
public void lockUI() { public void lockUI() {
if (m_isLocked) return; if (m_isLocked) return;

View File

@ -19,6 +19,7 @@ package org.adempiere.webui.apps.form;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Checkbox; import org.adempiere.webui.component.Checkbox;
@ -388,7 +389,14 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
*/ */
private void action_treeAddAll() private void action_treeAddAll()
{ {
if (FDialog.ask(m_WindowNo, null, "TreeAddAllItems")) { // idempiere-85 // idempiere-85
FDialog.ask(m_WindowNo, null, "TreeAddAllItems", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{
log.info(""); log.info("");
ListModel model = centerList.getModel(); ListModel model = centerList.getModel();
int size = model.getSize(); int size = model.getSize();
@ -399,6 +407,8 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
action_treeAdd(item); action_treeAdd(item);
} }
} }
}
});
} // action_treeAddAll } // action_treeAddAll
/** /**
@ -407,7 +417,14 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
private void action_treeDeleteAll() private void action_treeDeleteAll()
{ {
log.info(""); log.info("");
if (FDialog.ask(m_WindowNo, null, "TreeRemoveAllItems")) { // idempiere-85 // idempiere-85
FDialog.ask(m_WindowNo, null, "TreeRemoveAllItems", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{
ListModel model = centerList.getModel(); ListModel model = centerList.getModel();
int size = model.getSize(); int size = model.getSize();
int index = -1; int index = -1;
@ -417,6 +434,9 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
action_treeDelete(item); action_treeDelete(item);
} }
} }
}
});
} // action_treeDeleteAll } // action_treeDeleteAll
public ADForm getForm() public ADForm getForm()

View File

@ -27,6 +27,8 @@ import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.ListboxFactory; import org.adempiere.webui.component.ListboxFactory;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.component.ToolBar;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.panel.ADForm;
import org.compiere.apps.wf.WFGraphLayout; import org.compiere.apps.wf.WFGraphLayout;
import org.compiere.apps.wf.WFNodeWidget; import org.compiere.apps.wf.WFNodeWidget;
@ -62,7 +64,6 @@ import org.zkoss.zul.Separator;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
import org.zkoss.zul.Toolbarbutton; import org.zkoss.zul.Toolbarbutton;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
import org.zkoss.zul.Window;
/** /**
* *
@ -208,15 +209,14 @@ public class WFEditor extends ADForm {
w.onClose(); w.onClose();
} }
}); });
try {
w.setWidth("250px"); w.setWidth("250px");
w.setBorder("normal"); w.setBorder("normal");
w.setPage(this.getPage()); w.setPage(this.getPage());
w.doModal(); w.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
} catch (SuspendNotAllowedException e) {
e.printStackTrace();
}
@Override
public void onEvent(Event event) throws Exception {
String name = text.getText(); String name = text.getText();
if (name != null && name.length() > 0) if (name != null && name.length() > 0)
{ {
@ -227,6 +227,9 @@ public class WFEditor extends ADForm {
reload(m_wf.getAD_Workflow_ID()); reload(m_wf.getAD_Workflow_ID());
} }
} }
});
w.doHighlighted();
}
void reload(int workflowId) { void reload(int workflowId) {
center.removeChild(table); center.removeChild(table);

View File

@ -26,6 +26,7 @@ import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.zkoss.zhtml.Text; import org.zkoss.zhtml.Text;
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;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -63,8 +64,7 @@ public class Messagebox extends Window implements EventListener<Event>
private Image img = new Image(); private Image img = new Image();
private int returnValue; private int returnValue;
private Callback<String> callback; private Callback<Integer> callback;
private String callbackValue;
/** A OK button. */ /** A OK button. */
public static final int OK = 0x0001; public static final int OK = 0x0001;
@ -199,7 +199,12 @@ public class Messagebox extends Window implements EventListener<Event>
return show(message, title, buttons, icon, null); return show(message, title, buttons, icon, null);
} }
public int show(String message, String title, int buttons, String icon, Callback<String> callback) public int show(String message, String title, int buttons, String icon, Callback<Integer> callback)
{
return show(message, title, buttons, icon, callback, false);
}
public int show(String message, String title, int buttons, String icon, Callback<Integer> callback, boolean modal)
{ {
this.msg = message; this.msg = message;
this.imgSrc = icon; this.imgSrc = icon;
@ -239,10 +244,7 @@ public class Messagebox extends Window implements EventListener<Event>
this.setTitle(title); this.setTitle(title);
this.setPosition("center"); this.setPosition("center");
this.setClosable(true); this.setClosable(true);
if (Events.inEventListener()) this.setAttribute(Window.MODE_KEY, modal ? Window.MODE_MODAL : Window.MODE_HIGHLIGHTED);
this.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
else
this.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
this.setSizable(true); this.setSizable(true);
this.setVisible(true); this.setVisible(true);
@ -251,16 +253,21 @@ public class Messagebox extends Window implements EventListener<Event>
return returnValue; return returnValue;
} }
public static int showDialog(String message, String title, int buttons, String icon) throws InterruptedException public static int showDialog(String message, String title, int buttons, String icon)
{ {
return showDialog(message, title, buttons, icon, null); return showDialog(message, title, buttons, icon, null);
} }
public static int showDialog(String message, String title, int buttons, String icon, Callback<String> callback) throws InterruptedException public static int showDialog(String message, String title, int buttons, String icon, Callback<Integer> callback)
{
return showDialog(message, title, buttons, icon, callback, false);
}
public static int showDialog(String message, String title, int buttons, String icon, Callback<Integer> callback, boolean modal)
{ {
Messagebox msg = new Messagebox(); Messagebox msg = new Messagebox();
return msg.show(message, title, buttons, icon, callback); return msg.show(message, title, buttons, icon, callback, modal);
} }
public void onEvent(Event event) throws Exception public void onEvent(Event event) throws Exception
@ -268,53 +275,44 @@ public class Messagebox extends Window implements EventListener<Event>
if (event == null) if (event == null)
return; return;
callbackValue = null;
if (event.getTarget() == btnOk) if (event.getTarget() == btnOk)
{ {
returnValue = OK; returnValue = OK;
callbackValue = "OK";
} }
else if (event.getTarget() == btnCancel) else if (event.getTarget() == btnCancel)
{ {
returnValue = CANCEL; returnValue = CANCEL;
callbackValue = "CANCEL";
} }
else if (event.getTarget() == btnYes) else if (event.getTarget() == btnYes)
{ {
returnValue = YES; returnValue = YES;
callbackValue = "YES";
} }
else if (event.getTarget() == btnNo) else if (event.getTarget() == btnNo)
{ {
returnValue = NO; returnValue = NO;
callbackValue = "NO";
} }
else if (event.getTarget() == btnAbort) else if (event.getTarget() == btnAbort)
{ {
returnValue = ABORT; returnValue = ABORT;
callbackValue = "ABORT";
} }
else if (event.getTarget() == btnRetry) else if (event.getTarget() == btnRetry)
{ {
returnValue = RETRY; returnValue = RETRY;
callbackValue = "RETRY";
} }
else if (event.getTarget() == btnIgnore) else if (event.getTarget() == btnIgnore)
{ {
returnValue = IGNORE; returnValue = IGNORE;
callbackValue = "IGNORE";
} }
this.detach(); this.detach();
} }
@Override @Override
public void detach() { public void onPageDetached(Page page) {
super.detach(); super.onPageDetached(page);
if (callback != null) if (callback != null)
{ {
callback.onCallback(callbackValue); callback.onCallback(returnValue);
} }
} }
} }

View File

@ -17,6 +17,11 @@
package org.adempiere.webui.component; package org.adempiere.webui.component;
import org.adempiere.webui.event.DialogEvents;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.Events;
/** /**
* *
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a> * @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
@ -62,4 +67,15 @@ public class Window extends org.zkoss.zul.Window
{ {
detach(); detach();
} }
/* (non-Javadoc)
* @see org.zkoss.zul.Window#onPageDetached(org.zkoss.zk.ui.Page)
*/
@Override
public void onPageDetached(Page page) {
super.onPageDetached(page);
Events.sendEvent(this, new Event(DialogEvents.ON_WINDOW_CLOSE, this, null));
}
} }

View File

@ -16,14 +16,18 @@ package org.adempiere.webui.desktop;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.ClientInfo; import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.exception.ApplicationException; import org.adempiere.webui.exception.ApplicationException;
import org.adempiere.webui.part.AbstractUIPart; import org.adempiere.webui.part.AbstractUIPart;
import org.compiere.model.MMenu; import org.compiere.model.MMenu;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
/** /**
* Base class for desktop implementation * Base class for desktop implementation
@ -142,17 +146,11 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
* @param win * @param win
* @param pos * @param pos
*/ */
public void showWindow(Window win, String pos) public void showWindow(final Window win, final String pos)
{ {
win.setPage(page);
Object objMode = win.getAttribute(Window.MODE_KEY); Object objMode = win.getAttribute(Window.MODE_KEY);
String mode = Window.MODE_MODAL; final String mode = objMode != null ? objMode.toString() : Window.MODE_HIGHLIGHTED;
if (objMode != null)
{
mode = objMode.toString();
}
if (Window.MODE_MODAL.equals(mode)) if (Window.MODE_MODAL.equals(mode))
{ {
@ -160,7 +158,27 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
win.setPosition(pos); win.setPosition(pos);
showModal(win); showModal(win);
} }
else if (Window.MODE_POPUP.equals(mode)) else
{
if (Executions.getCurrent() != null)
{
showNonModalWindow(win, pos, mode);
}
else
{
Executions.schedule(getComponent().getDesktop(), new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
showNonModalWindow(win, pos, mode);
}
}, new Event("onExecute"));
}
}
}
private void showNonModalWindow(final Window win, final String pos,
final String mode) {
if (Window.MODE_POPUP.equals(mode))
{ {
showPopup(win, pos); showPopup(win, pos);
} }
@ -184,18 +202,47 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
* *
* @param win * @param win
*/ */
protected void showModal(Window win) protected void showModal(final Window win)
{ {
//fall back to highlighted if can't execute doModal if (AdempiereWebUI.isEventThreadEnabled())
if (Events.inEventListener())
{ {
win.setPage(page);
win.doModal(); win.doModal();
} }
else else
{ {
showHighlighted(win, null); if (Executions.getCurrent() != null)
{
throw new RuntimeException("When event thread is disabled, you can only show modal window in background thread that doesn't update Desktop.");
} }
final StringBuffer buffer = new StringBuffer();
win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
buffer.append("*");
}
});
Executions.schedule(this.getComponent().getDesktop(), new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
showHighlighted(win, null);
if (win.getPage() == null) {
buffer.append("*");
}
}
}, new Event("onExecute"));
while(buffer.length() == 0)
{
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Thread.interrupted();
}
}
}
} }
/** /**
@ -210,6 +257,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
else else
win.setPosition(position); win.setPosition(position);
win.setPage(page);
win.doPopup(); win.doPopup();
} }
@ -225,6 +273,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
else else
win.setPosition(position); win.setPosition(position);
win.setPage(page);
win.doOverlapped(); win.doOverlapped();
} }
@ -240,6 +289,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
else else
win.setPosition(position); win.setPosition(position);
win.setPage(page);
win.doHighlighted(); win.doHighlighted();
} }
} }

View File

@ -17,6 +17,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.component.Combinationbox; import org.adempiere.webui.component.Combinationbox;
import org.adempiere.webui.event.ContextMenuEvent; import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ContextMenuListener;
@ -96,9 +97,12 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
{ {
C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID"); C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID");
} }
WAccountDialog ad = new WAccountDialog (gridField.getHeader(), m_mAccount, C_AcctSchema_ID); new WAccountDialog (gridField.getHeader(), m_mAccount, C_AcctSchema_ID, new Callback<Integer>() {
//
Integer newValue = ad.getValue(); @Override
public void onCallback(Integer result) {
Integer newValue = result;
if (newValue == null) if (newValue == null)
return; return;
@ -106,8 +110,11 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
// set & redisplay // set & redisplay
setValue(newValue); setValue(newValue);
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue); ValueChangeEvent changeEvent = new ValueChangeEvent(WAccountEditor.this, getColumnName(), oldValue, newValue);
fireValueChange(changeEvent); fireValueChange(changeEvent);
}
});
//
} // cmd_button } // cmd_button
/** /**

View File

@ -21,13 +21,16 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.FilenameBox; import org.adempiere.webui.component.FilenameBox;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.zkoss.util.media.Media; import org.zkoss.util.media.Media;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zul.Fileupload; import org.zkoss.zul.Fileupload;
/** /**
@ -107,6 +110,12 @@ public class WFilenameEditor extends WEditor
cmd_file(); cmd_file();
newValue = getComponent().getText(); newValue = getComponent().getText();
} }
else if (event instanceof UploadEvent)
{
UploadEvent ue = (UploadEvent) event;
processUploadMedia(ue.getMedia());
return;
}
else else
{ {
return; return;
@ -122,16 +131,30 @@ public class WFilenameEditor extends WEditor
fireValueChange(changeEvent); fireValueChange(changeEvent);
} }
private Component parent = null;
/** /**
* Load file * Load file
*/ */
private void cmd_file() private void cmd_file()
{ {
if (parent == null || getComponent().getParent() != parent)
{
if (parent != null)
{
parent.removeEventListener(Events.ON_UPLOAD, this);
}
parent = getComponent().getParent();
parent.addEventListener(Events.ON_UPLOAD, this);
}
// Show File Open Dialog // Show File Open Dialog
Media file = null; Media media = Fileupload.get(true);
if (AdempiereWebUI.isEventThreadEnabled())
file = Fileupload.get(true); processUploadMedia(media);
} // cmd_file
private void processUploadMedia(Media file) {
if (file == null) if (file == null)
return; return;
@ -173,7 +196,7 @@ public class WFilenameEditor extends WEditor
} }
getComponent().setText(fileName); getComponent().setText(fileName);
} // cmd_file }
public String[] getEvents() public String[] getEvents()
{ {

View File

@ -16,6 +16,7 @@ package org.adempiere.webui.editor;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.window.WImageDialog; import org.adempiere.webui.window.WImageDialog;
import org.compiere.model.GridField; import org.compiere.model.GridField;
@ -24,6 +25,7 @@ import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.zkoss.image.AImage; import org.zkoss.image.AImage;
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.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Image; import org.zkoss.zul.Image;
@ -153,7 +155,11 @@ public class WImageEditor extends WEditor
{ {
if (Events.ON_CLICK.equals(event.getName()) && readwrite) if (Events.ON_CLICK.equals(event.getName()) && readwrite)
{ {
WImageDialog vid = new WImageDialog(m_mImage); final WImageDialog vid = new WImageDialog(m_mImage);
vid.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!vid.isCancel()) { if (!vid.isCancel()) {
int AD_Image_ID = vid.getAD_Image_ID(); int AD_Image_ID = vid.getAD_Image_ID();
Object oldValue = getValue(); Object oldValue = getValue();
@ -164,9 +170,12 @@ public class WImageEditor extends WEditor
m_mImage = null; // force reload m_mImage = null; // force reload
setValue(newValue); // set explicitly setValue(newValue); // set explicitly
// //
ValueChangeEvent vce = new ValueChangeEvent(this, gridField.getColumnName(), oldValue, newValue); ValueChangeEvent vce = new ValueChangeEvent(WImageEditor.this, gridField.getColumnName(), oldValue, newValue);
fireValueChange(vce); fireValueChange(vce);
} }
}
});
} }
} }
} }

View File

@ -19,6 +19,7 @@ import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.PAttributebox; import org.adempiere.webui.component.PAttributebox;
import org.adempiere.webui.event.ContextMenuEvent; import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.window.WFieldRecordInfo; import org.adempiere.webui.window.WFieldRecordInfo;
import org.adempiere.webui.window.WPAttributeDialog; import org.adempiere.webui.window.WPAttributeDialog;
@ -31,6 +32,7 @@ import org.compiere.model.SystemIDs;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
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.Events; import org.zkoss.zk.ui.event.Events;
/** /**
@ -150,7 +152,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
{ {
// //
Integer oldValue = (Integer)getValue (); Integer oldValue = (Integer)getValue ();
int oldValueInt = oldValue == null ? 0 : oldValue.intValue (); final int oldValueInt = oldValue == null ? 0 : oldValue.intValue ();
int M_AttributeSetInstance_ID = oldValueInt; int M_AttributeSetInstance_ID = oldValueInt;
int M_Product_ID = 0; int M_Product_ID = 0;
int M_ProductBOM_ID = 0; int M_ProductBOM_ID = 0;
@ -167,7 +169,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
+ ", AD_Column_ID=" + gridField.getAD_Column_ID()); + ", AD_Column_ID=" + gridField.getAD_Column_ID());
// M_Product.M_AttributeSetInstance_ID = 8418 // M_Product.M_AttributeSetInstance_ID = 8418
boolean productWindow = (gridField.getAD_Column_ID() == COLUMN_M_PRODUCT_M_ATTRIBUTESETINSTANCE_ID); // HARDCODED final boolean productWindow = (gridField.getAD_Column_ID() == COLUMN_M_PRODUCT_M_ATTRIBUTESETINSTANCE_ID); // HARDCODED
// Exclude ability to enter ASI // Exclude ability to enter ASI
boolean exclude = true; boolean exclude = true;
@ -183,21 +185,27 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
} }
} }
boolean changed = false;
if (M_ProductBOM_ID != 0) // Use BOM Component if (M_ProductBOM_ID != 0) // Use BOM Component
M_Product_ID = M_ProductBOM_ID; M_Product_ID = M_ProductBOM_ID;
// //
if (!productWindow && (M_Product_ID == 0 || exclude)) if (!productWindow && (M_Product_ID == 0 || exclude))
{ {
changed = true;
getComponent().setText(null); getComponent().setText(null);
M_AttributeSetInstance_ID = 0; M_AttributeSetInstance_ID = 0;
processChanges(oldValueInt, M_AttributeSetInstance_ID);
} }
else else
{ {
WPAttributeDialog vad = new WPAttributeDialog ( final WPAttributeDialog vad = new WPAttributeDialog (
M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID, M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID,
productWindow, gridField.getAD_Column_ID(), m_WindowNo); productWindow, gridField.getAD_Column_ID(), m_WindowNo);
vad.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
boolean changed = false;
int M_AttributeSetInstance_ID = 0;
if (vad.isChanged()) if (vad.isChanged())
{ {
getComponent().setText(vad.getM_AttributeSetInstanceName()); getComponent().setText(vad.getM_AttributeSetInstanceName());
@ -206,6 +214,15 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
m_GridTab.setValue("M_Locator_ID", vad.getM_Locator_ID()); m_GridTab.setValue("M_Locator_ID", vad.getM_Locator_ID());
changed = true; changed = true;
} }
// Set Value
if (changed)
{
processChanges(oldValueInt, M_AttributeSetInstance_ID);
} // change
}
});
} }
/** Selection /** Selection
{ {
@ -244,10 +261,9 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
} }
} }
**/ **/
} // cmd_file
// Set Value private void processChanges(int oldValueInt, int M_AttributeSetInstance_ID) {
if (changed)
{
log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID); log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID);
m_value = new Object(); // force re-query display m_value = new Object(); // force re-query display
if (M_AttributeSetInstance_ID == 0) if (M_AttributeSetInstance_ID == 0)
@ -262,8 +278,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
// force Change - user does not realize that embedded object is already saved. // force Change - user does not realize that embedded object is already saved.
m_GridTab.processFieldChange(gridField); m_GridTab.processFieldChange(gridField);
} }
} // change }
} // cmd_file
public String[] getEvents() public String[] getEvents()
{ {

View File

@ -28,6 +28,7 @@ import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Searchbox; import org.adempiere.webui.component.Searchbox;
import org.adempiere.webui.event.ContextMenuEvent; import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.factory.InfoManager; import org.adempiere.webui.factory.InfoManager;
@ -46,6 +47,7 @@ import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
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.Events; import org.zkoss.zk.ui.event.Events;
/** /**
@ -476,9 +478,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
* - Window closed -> ignore => result == null && !cancalled * - Window closed -> ignore => result == null && !cancalled
*/ */
Object result[] = null;
boolean cancelled = false;
// Zoom / Validation // Zoom / Validation
String whereClause = getWhereClause(); String whereClause = getWhereClause();
@ -493,16 +492,18 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
if (m_tableName == null) // sets table name & key column if (m_tableName == null) // sets table name & key column
getDirectAccessSQL("*"); getDirectAccessSQL("*");
InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, queryValue, false, whereClause); final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, queryValue, false, whereClause);
ip.setVisible(true); ip.setVisible(true);
ip.setStyle("border: 2px"); ip.setStyle("border: 2px");
ip.setClosable(true); ip.setClosable(true);
ip.setAttribute("mode", "modal");
ip.addValueChangeListener(this); ip.addValueChangeListener(this);
infoPanel = ip; infoPanel = ip;
AEnv.showWindow(ip); ip.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
cancelled = ip.isCancelled();
result = ip.getSelectedKeys(); @Override
public void onEvent(Event event) throws Exception {
boolean cancelled = ip.isCancelled();
Object[] result = ip.getSelectedKeys();
infoPanel = null; infoPanel = null;
// Result // Result
@ -523,7 +524,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
{ {
log.config(getColumnName() + " - Result = null (not cancelled)"); log.config(getColumnName() + " - Result = null (not cancelled)");
} }
}
});
AEnv.showWindow(ip);
} }
/** /**

View File

@ -21,8 +21,8 @@ package org.adempiere.webui.event;
public interface DialogEvents { public interface DialogEvents {
/** /**
* on modal close event, use this for highlight mode modal dialog to perform action after the modal dialog closed. * on window close event, use this for highlight mode window to simulate modal window
*/ */
public final static String ON_MODAL_CLOSE = "onModalClose"; public final static String ON_WINDOW_CLOSE = "onWindowClose";
} }

View File

@ -17,9 +17,6 @@
package org.adempiere.webui.panel; package org.adempiere.webui.panel;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -55,7 +52,6 @@ import org.compiere.model.DataStatusEvent;
import org.compiere.model.DataStatusListener; import org.compiere.model.DataStatusListener;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.GridTable;
import org.compiere.model.GridWindow; import org.compiere.model.GridWindow;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MTree; import org.compiere.model.MTree;
@ -96,7 +92,7 @@ import org.zkoss.zul.impl.XulElement;
* @author Low Heng Sin * @author Low Heng Sin
*/ */
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>, public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
DataStatusListener, IADTabpanel, VetoableChangeListener DataStatusListener, IADTabpanel
{ {
private static final String ON_DEFER_SET_SELECTED_NODE = "onDeferSetSelectedNode"; private static final String ON_DEFER_SET_SELECTED_NODE = "onDeferSetSelectedNode";
@ -152,8 +148,6 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
private Group currentGroup; private Group currentGroup;
private boolean m_vetoActive = false;
public ADTabpanel() public ADTabpanel()
{ {
init(); init();
@ -251,7 +245,6 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
listPanel.setWindowNo(windowNo); listPanel.setWindowNo(windowNo);
listPanel.setADWindowPanel(winPanel); listPanel.setADWindowPanel(winPanel);
gridTab.getTableModel().addVetoableChangeListener(this);
} }
/** /**
@ -1213,34 +1206,6 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
return false; return false;
} }
/**
* @param e
* @see VetoableChangeListener#vetoableChange(PropertyChangeEvent)
*/
public void vetoableChange(PropertyChangeEvent e)
throws PropertyVetoException {
// Save Confirmation dialog MTable-RowSave
if (e.getPropertyName().equals(GridTable.PROPERTY))
{
// throw new PropertyVetoException will call this listener again to revert to old value
if (m_vetoActive)
{
//ignore
m_vetoActive = false;
return;
}
if (!Env.isAutoCommit(Env.getCtx(), getWindowNo()) || gridTab.getCommitWarning().length() > 0)
{
if (!FDialog.ask(getWindowNo(), this, "SaveChanges?", gridTab.getCommitWarning()))
{
m_vetoActive = true;
throw new PropertyVetoException ("UserDeniedSave", e);
}
}
return;
} // saveConfirmation
}
/** /**
* @return boolean * @return boolean
*/ */

View File

@ -494,14 +494,14 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{ {
if (!includedMap.containsKey(gTab.getAD_Tab_ID())) if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{ {
setActiveTab(gridWindow.getTabIndex(gTab)); setActiveTab(gridWindow.getTabIndex(gTab), null);
} }
else else
{ {
IADTabpanel parent = includedMap.get(gTab.getAD_Tab_ID()); IADTabpanel parent = includedMap.get(gTab.getAD_Tab_ID());
int pindex = gridWindow.getTabIndex(parent.getGridTab()); int pindex = gridWindow.getTabIndex(parent.getGridTab());
if (pindex >= 0) if (pindex >= 0)
setActiveTab(pindex); setActiveTab(pindex, null);
} }
gTab.navigate(i); gTab.navigate(i);
return true; return true;
@ -707,7 +707,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
where.toString(), findFields, 10, mTab.getAD_Tab_ID()); // no query below 10 where.toString(), findFields, 10, mTab.getAD_Tab_ID()); // no query below 10
if (find.isValid()) if (find.isValid())
{ {
find.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { find.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (!find.isCancel()) if (!find.isCancel())
@ -750,7 +750,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
int curInd = adTab.getSelectedIndex(); int curInd = adTab.getSelectedIndex();
if (curInd < maxInd) if (curInd < maxInd)
{ {
setActiveTab(curInd + 1); setActiveTab(curInd + 1, null);
} }
focusToActivePanel(); focusToActivePanel();
@ -764,7 +764,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
int curInd = adTab.getSelectedIndex(); int curInd = adTab.getSelectedIndex();
if (curInd > 0) if (curInd > 0)
{ {
setActiveTab(curInd - 1); setActiveTab(curInd - 1, null);
} }
focusToActivePanel(); focusToActivePanel();
@ -865,11 +865,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (gridWindow.isTransaction()) if (gridWindow.isTransaction())
{ {
if (curTab.needSave(true, true) && !onSave(false)) final Runnable runnable = new Runnable() {
return; @Override
public void run() {
final WOnlyCurrentDays ocd = new WOnlyCurrentDays(); final WOnlyCurrentDays ocd = new WOnlyCurrentDays();
ocd.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { ocd.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
m_onlyCurrentDays = ocd.getCurrentDays(); m_onlyCurrentDays = ocd.getCurrentDays();
@ -879,6 +879,26 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}); });
AEnv.showWindow(ocd); AEnv.showWindow(ocd);
} }
};
if (curTab.needSave(true, true))
{
onSave(false, new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{
runnable.run();
}
}
});
}
else
{
runnable.run();
}
}
} }
private void history(int onlyCurrentDays) private void history(int onlyCurrentDays)
@ -917,14 +937,19 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return; return;
} }
// Attachment va = EventListener<Event> listener = new EventListener<Event>() {
new WAttachment ( curWindowNo, curTab.getAD_AttachmentID(),
curTab.getAD_Table_ID(), record_ID, null);
@Override
public void onEvent(Event event) throws Exception {
curTab.loadAttachments(); // reload curTab.loadAttachments(); // reload
toolbar.getButton("Attachment").setPressed(curTab.hasAttachment()); toolbar.getButton("Attachment").setPressed(curTab.hasAttachment());
focusToActivePanel(); focusToActivePanel();
} }
};
// Attachment va =
new WAttachment ( curWindowNo, curTab.getAD_AttachmentID(),
curTab.getAD_Table_ID(), record_ID, null, listener);
}
public void onChat() public void onChat()
{ {
@ -953,7 +978,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
String description = infoName + ": " + infoDisplay; String description = infoName + ": " + infoDisplay;
WChat chat = new WChat(curWindowNo, curTab.getCM_ChatID(), curTab.getAD_Table_ID(), recordId, description, null); WChat chat = new WChat(curWindowNo, curTab.getCM_ChatID(), curTab.getAD_Table_ID(), recordId, description, null);
chat.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { chat.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
curTab.loadChats(); curTab.loadChats();
@ -1023,34 +1048,43 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{ {
int newTabIndex = tabList.getSelectedIndex(); int newTabIndex = tabList.getSelectedIndex();
if (setActiveTab(newTabIndex)) final IADTabList tabListRef = tabList;
final int originalTabIndex = curTabIndex;
setActiveTab(newTabIndex, new Callback<Boolean>() {
@Override
public void onCallback(Boolean result) {
if (result)
{ {
//force sync model //force sync model
tabList.refresh(); tabListRef.refresh();
} }
else else
{ {
//reset to original //reset to original
tabList.setSelectedIndex(curTabIndex); tabListRef.setSelectedIndex(originalTabIndex);
} }
}
});
} }
} }
else if (event.getTarget() instanceof ProcessModalDialog) else if (event.getTarget() instanceof ProcessModalDialog)
{ {
ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget(); ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget();
onModalClose(dialog.getProcessInfo()); onModalClose(dialog.getProcessInfo());
onRefresh(false); onRefresh(false, false);
} }
} }
private boolean setActiveTab(int newTabIndex) { private void setActiveTab(final int newTabIndex, final Callback<Boolean> callback) {
boolean back = false;
int oldTabIndex = curTabIndex; final int oldTabIndex = curTabIndex;
if (oldTabIndex == newTabIndex) if (oldTabIndex == newTabIndex)
{ {
return true; if (callback != null)
callback.onCallback(true);
} }
if (curTab != null) if (curTab != null)
@ -1062,6 +1096,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
((ADSortTab)curTabpanel).saveData(); ((ADSortTab)curTabpanel).saveData();
((ADSortTab)curTabpanel).unregisterPanel(); ((ADSortTab)curTabpanel).unregisterPanel();
} }
setActiveTab0(oldTabIndex, newTabIndex, callback);
} }
else if (curTab.needSave(true, false)) else if (curTab.needSave(true, false))
{ {
@ -1075,18 +1110,30 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{ {
showLastError(); showLastError();
// there is a problem, stop here // there is a problem, stop here
return false; if (callback != null)
callback.onCallback(false);
return;
} }
setActiveTab0(oldTabIndex, newTabIndex, callback);
} }
// explicitly ask when changing tabs // explicitly ask when changing tabs
else if (FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", curTab.getCommitWarning())) else
{
FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", curTab.getCommitWarning(), new Callback<Boolean>() {
@Override
public void onCallback(Boolean result) {
if (result)
{ // yes we want to save { // yes we want to save
if (!curTab.dataSave(true)) if (!curTab.dataSave(true))
{ {
showLastError(); showLastError();
// there is a problem, stop here // there is a problem, stop here
return false; if (callback != null)
callback.onCallback(false);
return;
} }
setActiveTab0(oldTabIndex, newTabIndex, callback);
} }
else // Don't save else // Don't save
{ {
@ -1096,19 +1143,40 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
curTab.dataIgnore(); curTab.dataIgnore();
else else
{ {
return false; if (callback != null)
callback.onCallback(false);
return;
} }
} setActiveTab0(oldTabIndex, newTabIndex, callback);
}
else // new record, but nothing changed
curTab.dataIgnore();
} // there is a change
} }
}
});
}
}
else
{
// new record, but nothing changed
curTab.dataIgnore();
setActiveTab0(oldTabIndex, newTabIndex, callback);
}
} // there is a change
else
setActiveTab0(oldTabIndex, newTabIndex, callback);
}
else
setActiveTab0(oldTabIndex, newTabIndex, callback);
}
private void setActiveTab0(int oldTabIndex, int newTabIndex,
final Callback<Boolean> callback) {
boolean back = false;
if (!adTab.updateSelectedIndex(oldTabIndex, newTabIndex)) if (!adTab.updateSelectedIndex(oldTabIndex, newTabIndex))
{ {
FDialog.warn(curWindowNo, "TabSwitchJumpGo", title); FDialog.warn(curWindowNo, "TabSwitchJumpGo", title);
return false; if (callback != null)
callback.onCallback(false);
} }
IADTabpanel oldTabpanel = curTabpanel; IADTabpanel oldTabpanel = curTabpanel;
@ -1164,7 +1232,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
updateToolbar(); updateToolbar();
return true; if (callback != null)
callback.onCallback(true);
} }
private void updateToolbar() private void updateToolbar()
@ -1422,13 +1491,37 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
* refresh all row * refresh all row
* @param fireEvent * @param fireEvent
*/ */
public void onRefresh(boolean fireEvent) public void onRefresh(final boolean fireEvent)
{ {
onSave(false); onRefresh(fireEvent, true);
}
/**
* refresh all row
* @param fireEvent
* @param saveCurrentRow
*/
public void onRefresh(final boolean fireEvent, final boolean saveCurrentRow)
{
if (saveCurrentRow)
{
onSave(false, new Callback<Boolean>() {
@Override
public void onCallback(Boolean result) {
curTab.dataRefreshAll(fireEvent, true); curTab.dataRefreshAll(fireEvent, true);
curTabpanel.dynamicDisplay(0); curTabpanel.dynamicDisplay(0);
focusToActivePanel(); focusToActivePanel();
} }
});
}
else
{
curTab.dataRefreshAll(fireEvent, true);
curTabpanel.dynamicDisplay(0);
focusToActivePanel();
}
}
/** /**
* @see ToolbarListener#onRefresh() * @see ToolbarListener#onRefresh()
@ -1458,10 +1551,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return; return;
} }
if (!autoSave()) { autoSave(new Callback<Boolean>() {
return; @Override
} public void onCallback(Boolean result) {
if (result)
{
newRecord = curTab.dataNew(false); newRecord = curTab.dataNew(false);
if (newRecord) if (newRecord)
{ {
@ -1481,22 +1575,23 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
focusToActivePanel(); focusToActivePanel();
} }
}
});
}
private boolean autoSave() { private void autoSave(Callback<Boolean> callback) {
// has anything changed? // has anything changed?
if (curTab.needSave(true, false)) if (curTab.needSave(true, false))
{ // do we have real change { // do we have real change
if (curTab.needSave(true, true)) if (curTab.needSave(true, true))
{ {
if (!onSave(false)) onSave(false, callback);
{
return false;
}
} }
else // new record, but nothing changed else // new record, but nothing changed
curTab.dataIgnore(); curTab.dataIgnore();
} // there is a change } // there is a change
return true; if (callback != null)
callback.onCallback(true);
} }
// Elaine 2008/11/19 // Elaine 2008/11/19
@ -1540,9 +1635,18 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (curTab == null) if (curTab == null)
return; return;
if (!onSave(false)) onSave(false, new Callback<Boolean>() {
return;
@Override
public void onCallback(Boolean result) {
if (result) {
doOnFind();
}
}
});
}
private void doOnFind() {
// Gets Fields from AD_Field_v // Gets Fields from AD_Field_v
GridField[] findFields = GridField.createFields(ctx, curTab.getWindowNo(), 0,curTab.getAD_Tab_ID()); GridField[] findFields = GridField.createFields(ctx, curTab.getWindowNo(), 0,curTab.getAD_Tab_ID());
final FindWindow find = new FindWindow (curTab.getWindowNo(), curTab.getName(), final FindWindow find = new FindWindow (curTab.getWindowNo(), curTab.getName(),
@ -1556,7 +1660,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return; return;
} }
find.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { find.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (!find.isCancel()) if (!find.isCancel())
@ -1611,7 +1715,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
*/ */
public void onSave() public void onSave()
{ {
if(onSave(true)) onSave(true, new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
String statusLine = statusBar.getStatusLine(); String statusLine = statusBar.getStatusLine();
curTab.dataRefreshAll(true, true); curTab.dataRefreshAll(true, true);
@ -1619,37 +1727,57 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
focusToActivePanel(); focusToActivePanel();
} }
});
}
/** /**
* @param onSaveEvent * @param onSaveEvent
*/ */
private boolean onSave(boolean onSaveEvent) private void onSave(final boolean onSaveEvent, final Callback<Boolean> callback)
{ {
boolean newRecord = (curTab.getRecord_ID() <= 0); final boolean newRecord = (curTab.getRecord_ID() <= 0);
boolean wasChanged = toolbar.isSaveEnable(); final boolean wasChanged = toolbar.isSaveEnable();
if (curTab.isSortTab()) if (curTab.isSortTab())
{ {
((ADSortTab)curTabpanel).saveData(); ((ADSortTab)curTabpanel).saveData();
toolbar.enableSave(false); // set explicitly toolbar.enableSave(false); // set explicitly
toolbar.enableSaveAndCreate(false); toolbar.enableSaveAndCreate(false);
toolbar.enableIgnore(false); toolbar.enableIgnore(false);
return true; if (callback != null)
callback.onCallback(true);
} }
else else
{ {
if (onSaveEvent && curTab.getCommitWarning() != null && curTab.getCommitWarning().trim().length() > 0) if (onSaveEvent && curTab.getCommitWarning() != null && curTab.getCommitWarning().trim().length() > 0)
{ {
if (!FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", curTab.getCommitWarning())) FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", curTab.getCommitWarning(), new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{ {
return false; if (result)
{
doSave(onSaveEvent, newRecord, wasChanged, callback);
} }
} }
});
}
else
{
doSave(onSaveEvent, newRecord, wasChanged, callback);
}
}
}
private void doSave(boolean onSaveEvent, boolean newRecord,
boolean wasChanged, Callback<Boolean> callback) {
boolean retValue = curTab.dataSave(onSaveEvent); boolean retValue = curTab.dataSave(onSaveEvent);
if (!retValue) if (!retValue)
{ {
showLastError(); showLastError();
return false; if (callback != null)
callback.onCallback(false);
} else if (!onSaveEvent) //need manual refresh } else if (!onSaveEvent) //need manual refresh
{ {
curTab.setCurrentRow(curTab.getCurrentRow()); curTab.setCurrentRow(curTab.getCurrentRow());
@ -1690,8 +1818,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
} }
return true; if (callback != null)
} callback.onCallback(true);
} }
private void showLastError() { private void showLastError() {
@ -1708,13 +1836,19 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
*/ */
public void onSaveCreate() public void onSaveCreate()
{ {
boolean retValue = onSave(true); onSave(true, new Callback<Boolean>() {
if(retValue)
@Override
public void onCallback(Boolean result)
{
if(result)
{ {
curTab.dataRefreshAll(true, true); curTab.dataRefreshAll(true, true);
onNew(); onNew();
} }
} }
});
}
/** /**
* @see ToolbarListener#onDelete() * @see ToolbarListener#onDelete()
@ -1726,14 +1860,22 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return; return;
} }
if (FDialog.ask(curWindowNo, null, "DeleteRecord?")) FDialog.ask(curWindowNo, null, "DeleteRecord?", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
//error will be catch in the dataStatusChanged event //error will be catch in the dataStatusChanged event
curTab.dataDelete(); curTab.dataDelete();
}
curTabpanel.dynamicDisplay(0); curTabpanel.dynamicDisplay(0);
focusToActivePanel(); focusToActivePanel();
} }
}
});
}
// Elaine 2008/12/01 // Elaine 2008/12/01
/** /**
@ -1874,7 +2016,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{ {
public void onEvent(Event event) throws Exception public void onEvent(Event event) throws Exception
{ {
if (FDialog.ask(curWindowNo, messagePanel, "DeleteSelection")) FDialog.ask(curWindowNo, messagePanel, "DeleteSelection", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
logger.fine("ok"); logger.fine("ok");
Set<Listitem> selectedValues = listbox.getSelectedItems(); Set<Listitem> selectedValues = listbox.getSelectedItems();
@ -1906,6 +2053,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
logger.fine("cancel"); logger.fine("cancel");
} }
} }
});
}
}); });
hbox.appendChild(btnOk); hbox.appendChild(btnOk);
@ -1933,7 +2083,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
*/ */
public void onPrint() { public void onPrint() {
//Get process defined for this tab //Get process defined for this tab
int AD_Process_ID = curTab.getAD_Process_ID(); final int AD_Process_ID = curTab.getAD_Process_ID();
//log.info("ID=" + AD_Process_ID); //log.info("ID=" + AD_Process_ID);
// No report defined // No report defined
@ -1944,19 +2094,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return; return;
} }
if (!onSave(false)) onSave(false, new Callback<Boolean>() {
return; @Override
public void onCallback(Boolean result) {
if (result) {
// //
int table_ID = curTab.getAD_Table_ID(); int table_ID = curTab.getAD_Table_ID();
int record_ID = curTab.getRecord_ID(); int record_ID = curTab.getRecord_ID();
ProcessModalDialog dialog = new ProcessModalDialog(this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true); ProcessModalDialog dialog = new ProcessModalDialog(AbstractADWindowPanel.this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true);
if (dialog.isValid()) { if (dialog.isValid()) {
dialog.setPosition("center"); dialog.setPosition("center");
dialog.setPage(this.getComponent().getPage()); dialog.setPage(AbstractADWindowPanel.this.getComponent().getPage());
dialog.doHighlighted(); dialog.doHighlighted();
} }
} }
}
});
}
/** /**
* @see ToolbarListener#onReport() * @see ToolbarListener#onReport()
@ -1968,9 +2123,18 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return; return;
} }
if (!onSave(false)) onSave(false, new Callback<Boolean>() {
return;
@Override
public void onCallback(Boolean result) {
if (result) {
doOnReport();
}
}
});
}
private void doOnReport() {
// Query // Query
MQuery query = new MQuery(curTab.getTableName()); MQuery query = new MQuery(curTab.getTableName());
// Link for detail records // Link for detail records
@ -2005,7 +2169,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
new WReport (curTab.getAD_Table_ID(), query, toolbar.getEvent().getTarget(), curWindowNo, curTab.getWhereExtended()); new WReport (curTab.getAD_Table_ID(), query, toolbar.getEvent().getTarget(), curWindowNo, curTab.getWhereExtended());
} }
/** /**
@ -2123,8 +2286,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
logger.info(wButton.toString()); logger.info(wButton.toString());
boolean startWOasking = false; final String col = wButton.getColumnName();
String col = wButton.getColumnName();
// Zoom // Zoom
if (col.equals("Record_ID")) if (col.equals("Record_ID"))
@ -2140,10 +2302,29 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (curTab.needSave(true, false)) if (curTab.needSave(true, false))
{ {
if (!onSave(false)) onSave(false, new Callback<Boolean>() {
return; @Override
public void onCallback(Boolean result) {
if (result) {
actionButton0(col, wButton);
}
}
});
}
else
{
actionButton0(col, wButton);
}
} }
/**************************************************************************
* Start Button Process
* @param col
* @param wButton
*/
private void actionButton0 (String col, final WButtonEditor wButton)
{
boolean startWOasking = false;
final int table_ID = curTab.getAD_Table_ID(); final int table_ID = curTab.getAD_Table_ID();
// Record_ID // Record_ID
@ -2181,13 +2362,19 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (vp.isInitOK()) // may not be allowed if (vp.isInitOK()) // may not be allowed
{ {
vp.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); vp.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
vp.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { vp.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (vp.needSave()) if (vp.needSave())
{ {
onSave(false); onSave(false, new Callback<Boolean>() {
onRefresh(false);
@Override
public void onCallback(Boolean result) {
onRefresh(false, false);
}
});
} }
} }
}); });
@ -2211,7 +2398,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
final int recordIdParam = record_ID; final int recordIdParam = record_ID;
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
win.setPosition("center"); win.setPosition("center");
win.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (!win.isStartProcess()) { if (!win.isStartProcess()) {
return; return;
@ -2238,7 +2425,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{ {
final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow(); final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow();
window.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); window.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
window.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { window.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (!window.isCancel()) { if (!window.isCancel()) {
@ -2288,7 +2475,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
// Check Post Status // Check Post Status
Object ps = curTab.getValue("Posted"); final Object ps = curTab.getValue("Posted");
if (ps != null && ps.equals("Y")) if (ps != null && ps.equals("Y"))
{ {
@ -2297,19 +2484,28 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
else else
{ {
if (FDialog.ask(curWindowNo, null, "PostImmediate?")) final int tableIdRef = tableId;
final int recordIdRef = recordId;
FDialog.ask(curWindowNo, null, "PostImmediate?", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
boolean force = ps != null && !ps.equals ("N"); // force when problems boolean force = ps != null && !ps.equals ("N"); // force when problems
String error = AEnv.postImmediate (curWindowNo, Env.getAD_Client_ID(ctx), String error = AEnv.postImmediate (curWindowNo, Env.getAD_Client_ID(ctx),
tableId, recordId, force); tableIdRef, recordIdRef, force);
if (error != null) if (error != null)
statusBar.setStatusLine(error, true, true); statusBar.setStatusLine(error, true, true);
onRefresh(false); onRefresh(false, false);
} }
} }
});
}
return; return;
} // Posted } // Posted
@ -2318,7 +2514,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} // actionButton } // actionButton
private void executeButtonProcess(final WButtonEditor wButton, private void executeButtonProcess(final WButtonEditor wButton,
boolean startWOasking, int table_ID, int record_ID, final boolean startWOasking, final int table_ID, final int record_ID,
boolean isProcessMandatory) { boolean isProcessMandatory) {
/** /**
* Start Process ---- * Start Process ----
@ -2339,10 +2535,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (curTab.needSave(true, false)) if (curTab.needSave(true, false))
{ {
if (!onSave(false)) onSave(false, new Callback<Boolean>() {
return;
@Override
public void onCallback(Boolean result) {
if (result) {
executeButtonProcess0(wButton, startWOasking, table_ID, record_ID);
}
}
});
}
else
{
executeButtonProcess0(wButton, startWOasking, table_ID, record_ID);
}
} }
private void executeButtonProcess0(final WButtonEditor wButton,
boolean startWOasking, int table_ID, int record_ID) {
// call form // call form
MProcess pr = new MProcess(ctx, wButton.getProcess_ID(), null); MProcess pr = new MProcess(ctx, wButton.getProcess_ID(), null);
int adFormID = pr.getAD_Form_ID(); int adFormID = pr.getAD_Form_ID();
@ -2359,7 +2569,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
form.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED); form.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT); form.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
SessionManager.getAppDesktop().showWindow(form); SessionManager.getAppDesktop().showWindow(form);
onRefresh(false); onRefresh(false, false);
} }
else else
{ {
@ -2375,7 +2585,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
} }
else else
{ {
onRefresh(false); onRefresh(false, false);
} }
} }
} }
@ -2518,7 +2728,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
public void onCustomize() { public void onCustomize() {
ADTabpanel tabPanel = (ADTabpanel) getADTab().getSelectedTabpanel(); ADTabpanel tabPanel = (ADTabpanel) getADTab().getSelectedTabpanel();
Columns columns = tabPanel.getGridView().getListbox().getColumns(); Columns columns = tabPanel.getGridView().getListbox().getColumns();
List columnList = columns.getChildren(); List<Component> columnList = columns.getChildren();
GridField[] fields = tabPanel.getGridView().getFields(); GridField[] fields = tabPanel.getGridView().getFields();
Map<Integer, String> columnsWidth = new HashMap<Integer, String>(); Map<Integer, String> columnsWidth = new HashMap<Integer, String>();
ArrayList<Integer> gridFieldIds = new ArrayList<Integer>(); ArrayList<Integer> gridFieldIds = new ArrayList<Integer>();

View File

@ -271,7 +271,7 @@ public abstract class InfoPanel extends Window implements EventListener, WTableM
{ {
if (isLookup()) if (isLookup())
{ {
setAttribute(Window.MODE_KEY, Window.MODE_MODAL); setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
setBorder("normal"); setBorder("normal");
setClosable(true); setClosable(true);
int height = SessionManager.getAppDesktop().getClientInfo().desktopHeight * 85 / 100; int height = SessionManager.getAppDesktop().getClientInfo().desktopHeight * 85 / 100;

View File

@ -61,6 +61,7 @@ import org.adempiere.webui.component.Tabpanels;
import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.WListbox; import org.adempiere.webui.component.WListbox;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn; import org.compiere.minigrid.IDColumn;
@ -1119,13 +1120,20 @@ public class InfoProductPanel extends InfoPanel implements EventListener
*/ */
private void cmd_InfoPAttribute() private void cmd_InfoPAttribute()
{ {
InfoPAttributePanel ia = new InfoPAttributePanel(this); final InfoPAttributePanel ia = new InfoPAttributePanel(this);
ia.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
m_pAttributeWhere = ia.getWhereClause(); m_pAttributeWhere = ia.getWhereClause();
if (m_pAttributeWhere != null) if (m_pAttributeWhere != null)
{ {
executeQuery(); executeQuery();
renderItems(); renderItems();
} }
}
});
} // cmdInfoAttribute } // cmdInfoAttribute
/** /**
@ -1375,12 +1383,19 @@ public class InfoProductPanel extends InfoPanel implements EventListener
M_Warehouse_ID = ((Integer)warehouse.getValue()).intValue(); M_Warehouse_ID = ((Integer)warehouse.getValue()).intValue();
String title = warehouse.getLabel() + " - " + productName; String title = warehouse.getLabel() + " - " + productName;
InfoPAttributeInstancePanel pai = new InfoPAttributeInstancePanel(this, title, final InfoPAttributeInstancePanel pai = new InfoPAttributeInstancePanel(this, title,
M_Warehouse_ID, 0, productInteger.intValue(), m_C_BPartner_ID); M_Warehouse_ID, 0, productInteger.intValue(), m_C_BPartner_ID);
pai.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID(); m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
m_M_Locator_ID = pai.getM_Locator_ID(); m_M_Locator_ID = pai.getM_Locator_ID();
if (m_M_AttributeSetInstance_ID != -1) if (m_M_AttributeSetInstance_ID != -1)
dispose(true); dispose(true);
}
});
return; return;
} }
// //

View File

@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Label;
@ -32,6 +34,7 @@ import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.window.FDialog; import org.adempiere.webui.window.FDialog;
import org.compiere.model.MAttachment; import org.compiere.model.MAttachment;
import org.compiere.model.MAttachmentEntry; import org.compiere.model.MAttachmentEntry;
@ -42,9 +45,11 @@ import org.zkoss.util.media.AMedia;
import org.zkoss.util.media.Media; import org.zkoss.util.media.Media;
import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.au.out.AuEcho; import org.zkoss.zk.au.out.AuEcho;
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;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center; import org.zkoss.zul.Center;
@ -61,7 +66,7 @@ import org.zkoss.zul.Iframe;
* @author Low Heng Sin * @author Low Heng Sin
* *
*/ */
public class WAttachment extends Window implements EventListener public class WAttachment extends Window implements EventListener<Event>
{ {
/** /**
* generated serial version Id * generated serial version Id
@ -128,12 +133,32 @@ public class WAttachment extends Window implements EventListener
public WAttachment( int WindowNo, int AD_Attachment_ID, public WAttachment( int WindowNo, int AD_Attachment_ID,
int AD_Table_ID, int Record_ID, String trxName) int AD_Table_ID, int Record_ID, String trxName)
{
this(WindowNo, AD_Attachment_ID, AD_Table_ID, Record_ID, trxName, (EventListener<Event>)null);
}
/**
* Constructor.
* loads Attachment, if ID <> 0
* @param WindowNo window no
* @param AD_Attachment_ID attachment
* @param AD_Table_ID table
* @param Record_ID record key
* @param trxName transaction
*/
public WAttachment( int WindowNo, int AD_Attachment_ID,
int AD_Table_ID, int Record_ID, String trxName, EventListener<Event> eventListener)
{ {
super(); super();
log.config("ID=" + AD_Attachment_ID + ", Table=" + AD_Table_ID + ", Record=" + Record_ID); log.config("ID=" + AD_Attachment_ID + ", Table=" + AD_Table_ID + ", Record=" + Record_ID);
m_WindowNo = WindowNo; m_WindowNo = WindowNo;
if (eventListener != null)
{
this.addEventListener(DialogEvents.ON_WINDOW_CLOSE, eventListener);
}
try try
{ {
@ -165,7 +190,7 @@ public class WAttachment extends Window implements EventListener
} }
//enter modal //enter modal
doModal(); doHighlighted();
} }
catch (Exception e) catch (Exception e)
{ {
@ -268,6 +293,8 @@ public class WAttachment extends Window implements EventListener
confirmPanel.appendChild(bOk); confirmPanel.appendChild(bOk);
text.setTooltiptext(Msg.getElement(Env.getCtx(), "TextMsg")); text.setTooltiptext(Msg.getElement(Env.getCtx(), "TextMsg"));
this.addEventListener(Events.ON_UPLOAD, this);
} }
/** /**
@ -498,6 +525,11 @@ public class WAttachment extends Window implements EventListener
else if (e.getTarget() == bRefresh) else if (e.getTarget() == bRefresh)
displayData(cbContent.getSelectedIndex(), true); displayData(cbContent.getSelectedIndex(), true);
else if (e instanceof UploadEvent)
{
UploadEvent ue = (UploadEvent) e;
processUploadMedia(ue.getMedia());
}
} // onEvent } // onEvent
@ -511,10 +543,12 @@ public class WAttachment extends Window implements EventListener
preview.setVisible(false); preview.setVisible(false);
Media media = null; Media media = Fileupload.get(true);
if (AdempiereWebUI.isEventThreadEnabled())
media = Fileupload.get(true); processUploadMedia(media);
}
private void processUploadMedia(Media media) {
if (media != null) if (media != null)
{ {
// pdfViewer.setContent(media); // pdfViewer.setContent(media);
@ -554,7 +588,7 @@ public class WAttachment extends Window implements EventListener
clearPreview(); clearPreview();
m_change = true; m_change = true;
} }
} // getFileName }
private byte[] getMediaData(Media media) { private byte[] getMediaData(Media media) {
byte[] bytes = null; byte[] bytes = null;
@ -586,8 +620,17 @@ public class WAttachment extends Window implements EventListener
{ {
log.info(""); log.info("");
if (FDialog.ask(m_WindowNo, this, "AttachmentDelete?")) FDialog.ask(m_WindowNo, this, "AttachmentDelete?", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{
m_attachment.delete(true); m_attachment.delete(true);
}
}
});
} // deleteAttachment } // deleteAttachment
/** /**
@ -598,19 +641,26 @@ public class WAttachment extends Window implements EventListener
{ {
log.info(""); log.info("");
int index = cbContent.getSelectedIndex(); final int index = cbContent.getSelectedIndex();
String fileName = getFileName(index); String fileName = getFileName(index);
if (fileName == null) if (fileName == null)
return; return;
if (FDialog.ask(m_WindowNo, this, "AttachmentDeleteEntry?")) FDialog.ask(m_WindowNo, this, "AttachmentDeleteEntry?", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{ {
if (m_attachment.deleteEntry(index)) if (m_attachment.deleteEntry(index))
cbContent.removeItemAt(index); cbContent.removeItemAt(index);
m_change = true; m_change = true;
} }
}
});
} // deleteAttachment } // deleteAttachment
/** /**
@ -639,5 +689,4 @@ public class WAttachment extends Window implements EventListener
} }
} }
} // saveAttachmentToFile } // saveAttachmentToFile
} }

View File

@ -90,9 +90,6 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
dynInit(); dynInit();
init(); init();
this.setAttribute("mode","modal");
} }
/** /**
@ -300,13 +297,11 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
m_OKpressed = true; m_OKpressed = true;
setValue(); setValue();
this.detach(); this.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} }
else if (confirmPanel.getButton("Cancel").equals(event.getTarget())) else if (confirmPanel.getButton("Cancel").equals(event.getTarget()))
{ {
m_OKpressed = false; m_OKpressed = false;
this.detach(); this.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} }
} }
else if (Events.ON_SELECT.equals(event.getName())) else if (Events.ON_SELECT.equals(event.getName()))

View File

@ -146,10 +146,4 @@ public class WOnlyCurrentDays extends Window implements EventListener<Event>, Di
this.detach(); this.detach();
} }
@Override
public void detach() {
super.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
} }

View File

@ -134,16 +134,8 @@ public class FDialog
newTitle = title; newTitle = title;
} }
try
{
String s = out.toString().replace("\n", "<br>"); String s = out.toString().replace("\n", "<br>");
Messagebox.showDialog(s, newTitle, Messagebox.OK, Messagebox.EXCLAMATION); Messagebox.showDialog(s, newTitle, Messagebox.OK, Messagebox.EXCLAMATION);
}
catch (InterruptedException exception)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return; return;
} }
@ -233,16 +225,8 @@ public class FDialog
out = constructMessage(adMessage, message); out = constructMessage(adMessage, message);
try
{
String s = out.toString().replace("\n", "<br>"); String s = out.toString().replace("\n", "<br>");
Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.ERROR); Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.ERROR);
}
catch (InterruptedException exception)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return; return;
} }
@ -258,6 +242,21 @@ public class FDialog
* @return true, if OK * @return true, if OK
*/ */
public static boolean ask(int windowNo, Component comp, String adMessage, String msg) public static boolean ask(int windowNo, Component comp, String adMessage, String msg)
{
return ask(windowNo, comp, adMessage, msg, (Callback<Boolean>)null);
}
/**************************************************************************
* Ask Question with question icon and (OK) (Cancel) buttons
*
* @param WindowNo Number of Window
* @param c Container (owner)
* @param AD_Message Message to be translated
* @param msg Additional clear text message
*
* @return true, if OK
*/
public static boolean ask(int windowNo, Component comp, String adMessage, String msg, Callback<Boolean> callback)
{ {
StringBuffer out = new StringBuffer(); StringBuffer out = new StringBuffer();
if (adMessage != null && !adMessage.equals("")) if (adMessage != null && !adMessage.equals(""))
@ -265,7 +264,7 @@ public class FDialog
if (msg != null && msg.length() > 0) if (msg != null && msg.length() > 0)
out.append("\n").append(msg); out.append("\n").append(msg);
String s = out.toString().replace("\n", "<br>"); String s = out.toString().replace("\n", "<br>");
return ask(windowNo, comp, s); return ask(windowNo, comp, s, callback);
} }
/************************************************************************** /**************************************************************************
@ -280,7 +279,7 @@ public class FDialog
public static boolean ask(int windowNo, Component comp, String adMessage) public static boolean ask(int windowNo, Component comp, String adMessage)
{ {
return ask(windowNo, comp, adMessage, (Callback<String>)null); return ask(windowNo, comp, adMessage, (Callback<Boolean>)null);
} }
/************************************************************************** /**************************************************************************
@ -293,24 +292,25 @@ public class FDialog
* @return true, if OK * @return true, if OK
*/ */
public static boolean ask(int windowNo, Component comp, String adMessage, Callback<String> callback) public static boolean ask(int windowNo, Component comp, String adMessage, final Callback<Boolean> callback)
{ {
try Callback<Integer> msgCallback = null;
if (callback != null)
{ {
msgCallback = new Callback<Integer>() {
@Override
public void onCallback(Integer result) {
boolean b = result != null && result.intValue() == Messagebox.OK;
callback.onCallback(b);
}
};
}
String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "<br>"); String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "<br>");
int response = Messagebox.showDialog(s, AEnv.getDialogHeader(Env.getCtx(), windowNo), int response = Messagebox.showDialog(s, AEnv.getDialogHeader(Env.getCtx(), windowNo),
Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, callback); Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, msgCallback, (msgCallback == null));
return (response == Messagebox.OK); return (response == Messagebox.OK);
} }
catch (InterruptedException ex)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return true;
}
/** /**
* Display information with information icon. * Display information with information icon.
@ -356,16 +356,8 @@ public class FDialog
out = constructMessage(adMessage, message); out = constructMessage(adMessage, message);
try
{
String s = out.toString().replace("\n", "<br>"); String s = out.toString().replace("\n", "<br>");
Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.INFORMATION); Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.INFORMATION);
}
catch (InterruptedException exception)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return; return;
} }

View File

@ -1326,7 +1326,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
super.dispose(); super.dispose();
isvalid = false; isvalid = false;
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} // dispose } // dispose
/** /**

View File

@ -21,6 +21,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Grid;
@ -54,6 +55,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
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;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -77,6 +79,7 @@ public final class WAccountDialog extends Window
{ {
private static final long serialVersionUID = 7999516267209766287L; private static final long serialVersionUID = 7999516267209766287L;
private Callback<Integer> m_callback;
/** /**
* Constructor * Constructor
@ -85,7 +88,7 @@ public final class WAccountDialog extends Window
* @param C_AcctSchema_ID as * @param C_AcctSchema_ID as
*/ */
public WAccountDialog (String title, public WAccountDialog (String title,
MAccountLookup mAccount, int C_AcctSchema_ID) MAccountLookup mAccount, int C_AcctSchema_ID, Callback<Integer> callback)
{ {
super (); super ();
this.setTitle(title); this.setTitle(title);
@ -96,6 +99,7 @@ public final class WAccountDialog extends Window
+ ", C_ValidCombination_ID=" + mAccount.C_ValidCombination_ID); + ", C_ValidCombination_ID=" + mAccount.C_ValidCombination_ID);
m_mAccount = mAccount; m_mAccount = mAccount;
m_C_AcctSchema_ID = C_AcctSchema_ID; m_C_AcctSchema_ID = C_AcctSchema_ID;
m_callback = callback;
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this); m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
try try
{ {
@ -242,7 +246,6 @@ public final class WAccountDialog extends Window
this.setBorder("normal"); this.setBorder("normal");
this.setClosable(false); this.setClosable(false);
this.setAttribute("modal", Boolean.TRUE);
this.setSizable(true); this.setSizable(true);
} // jbInit } // jbInit
@ -581,6 +584,18 @@ public final class WAccountDialog extends Window
this.onClose(); this.onClose();
} // dispose } // dispose
/* (non-Javadoc)
* @see org.adempiere.webui.component.Window#onPageDetached(org.zkoss.zk.ui.Page)
*/
@Override
public void onPageDetached(Page page) {
super.onPageDetached(page);
if (m_callback != null) {
m_callback.onCallback(getValue());
}
}
/** /**
* Save Selection * Save Selection
*/ */

View File

@ -351,9 +351,4 @@ public class WChat extends Window implements EventListener<Event>, DialogEvents
actionPerformed(event); actionPerformed(event);
} }
@Override
public void detach() {
super.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
} // AChat } // AChat

View File

@ -19,6 +19,7 @@ package org.adempiere.webui.window;
import java.io.InputStream; import java.io.InputStream;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
@ -34,6 +35,7 @@ import org.zkoss.util.media.Media;
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;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center; import org.zkoss.zul.Center;
import org.zkoss.zul.North; import org.zkoss.zul.North;
@ -50,7 +52,7 @@ import org.zkoss.zul.Separator;
* @author Low Heng Sin * @author Low Heng Sin
* *
*/ */
public class WImageDialog extends Window implements EventListener public class WImageDialog extends Window implements EventListener<Event>
{ {
/** /**
* *
@ -148,12 +150,20 @@ public class WImageDialog extends Window implements EventListener
// //
fileButton.addEventListener(Events.ON_CLICK, this); fileButton.addEventListener(Events.ON_CLICK, this);
confirmPanel.addActionListener(Events.ON_CLICK, this); confirmPanel.addActionListener(Events.ON_CLICK, this);
addEventListener(Events.ON_UPLOAD, this);
} // init } // init
public void onEvent(Event e) throws Exception { public void onEvent(Event e) throws Exception {
if (e.getTarget() == fileButton) if (e instanceof UploadEvent)
{
UploadEvent ue = (UploadEvent) e;
processUploadMedia(ue.getMedia());
}
else if (e.getTarget() == fileButton)
{
cmd_file(); cmd_file();
}
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
{ {
if (image.getContent() != null) if (image.getContent() != null)
@ -192,10 +202,12 @@ public class WImageDialog extends Window implements EventListener
private void cmd_file() private void cmd_file()
{ {
// Show File Open Dialog // Show File Open Dialog
Media imageFile = null; Media media = Fileupload.get();
if (AdempiereWebUI.isEventThreadEnabled())
imageFile = Fileupload.get(); processUploadMedia(media);
} // cmd_file
private void processUploadMedia(Media imageFile) {
if (imageFile == null) if (imageFile == null)
return; return;
@ -230,7 +242,7 @@ public class WImageDialog extends Window implements EventListener
m_mImage.setBinaryData(image.getContent().getByteData()); m_mImage.setBinaryData(image.getContent().getByteData());
else else
m_mImage.setBinaryData(null); m_mImage.setBinaryData(null);
} // cmd_file }
/** /**
* Get Image ID * Get Image ID

View File

@ -21,6 +21,7 @@ import java.sql.Clob;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
@ -33,6 +34,7 @@ import org.zkoss.util.media.Media;
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;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center; import org.zkoss.zul.Center;
import org.zkoss.zul.North; import org.zkoss.zul.North;
@ -47,7 +49,7 @@ import org.zkoss.zul.Iframe;
* @author Low Heng Sin * @author Low Heng Sin
* *
*/ */
public class WMediaDialog extends Window implements EventListener public class WMediaDialog extends Window implements EventListener<Event>
{ {
/** /**
* *
@ -186,6 +188,8 @@ public class WMediaDialog extends Window implements EventListener
confirmPanel.appendChild(bCancel); confirmPanel.appendChild(bCancel);
confirmPanel.appendChild(bOk); confirmPanel.appendChild(bOk);
addEventListener(Events.ON_UPLOAD, this);
} }
/** /**
@ -307,6 +311,11 @@ public class WMediaDialog extends Window implements EventListener
{ {
save(); save();
} }
else if (e instanceof UploadEvent)
{
UploadEvent ue = (UploadEvent) e;
processUploadMedia(ue.getMedia());
}
} // onEvent } // onEvent
/************************************************************************** /**************************************************************************
@ -315,12 +324,12 @@ public class WMediaDialog extends Window implements EventListener
private void loadFile() private void loadFile()
{ {
log.info(""); Media media = Fileupload.get();
if (AdempiereWebUI.isEventThreadEnabled())
Media media = null; processUploadMedia(media);
} // getFileName
media = Fileupload.get();
private void processUploadMedia(Media media) {
if (media == null) if (media == null)
return; return;
@ -330,8 +339,7 @@ public class WMediaDialog extends Window implements EventListener
m_change = true; m_change = true;
m_data = media.getByteData(); m_data = media.getByteData();
displayData(); displayData();
}
} // getFileName
/** /**
* download * download

View File

@ -39,6 +39,7 @@ import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.compiere.model.MAttribute; import org.compiere.model.MAttribute;
import org.compiere.model.MAttributeInstance; import org.compiere.model.MAttributeInstance;
@ -101,7 +102,6 @@ public class WPAttributeDialog extends Window implements EventListener, SystemID
{ {
super (); super ();
this.setTitle(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID")); this.setTitle(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"));
this.setAttribute("modal", Boolean.TRUE);
this.setBorder("normal"); this.setBorder("normal");
this.setWidth("500px"); this.setWidth("500px");
this.setHeight("600px"); this.setHeight("600px");
@ -627,8 +627,7 @@ public class WPAttributeDialog extends Window implements EventListener, SystemID
// Select Instance // Select Instance
if (e.getTarget() == bSelect) if (e.getTarget() == bSelect)
{ {
if (cmd_select()) cmd_select();
dispose();
} }
// New/Edit // New/Edit
else if (e.getTarget() == cbNewEdit) else if (e.getTarget() == cbNewEdit)
@ -778,7 +777,7 @@ public class WPAttributeDialog extends Window implements EventListener, SystemID
* Instance Selection Button * Instance Selection Button
* @return true if selected * @return true if selected
*/ */
private boolean cmd_select() private void cmd_select()
{ {
log.config(""); log.config("");
@ -826,17 +825,22 @@ public class WPAttributeDialog extends Window implements EventListener, SystemID
rs = null; pstmt = null; rs = null; pstmt = null;
} }
// //
WPAttributeInstance pai = new WPAttributeInstance(title, final WPAttributeInstance pai = new WPAttributeInstance(title,
M_Warehouse_ID, M_Locator_ID, m_M_Product_ID, m_C_BPartner_ID); M_Warehouse_ID, M_Locator_ID, m_M_Product_ID, m_C_BPartner_ID);
pai.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (pai.getM_AttributeSetInstance_ID() != -1) if (pai.getM_AttributeSetInstance_ID() != -1)
{ {
m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID(); m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
m_M_AttributeSetInstanceName = pai.getM_AttributeSetInstanceName(); m_M_AttributeSetInstanceName = pai.getM_AttributeSetInstanceName();
m_M_Locator_ID = pai.getM_Locator_ID(); m_M_Locator_ID = pai.getM_Locator_ID();
m_changed = true; m_changed = true;
return true; dispose();
} }
return false; }
});
} // cmd_select } // cmd_select
/** /**

View File

@ -70,7 +70,6 @@ public class WPAttributeInstance extends Window implements EventListener
{ {
super (); super ();
this.setTitle(Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title); this.setTitle(Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title);
this.setAttribute("modal", Boolean.TRUE);
this.setBorder("normal"); this.setBorder("normal");
this.setWidth("500px"); this.setWidth("500px");
this.setHeight("550px"); this.setHeight("550px");

View File

@ -1039,7 +1039,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
if (!find.isValid()) if (!find.isValid())
return; return;
find.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() { find.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (!find.isCancel()) if (!find.isCancel())

View File

@ -56,7 +56,7 @@
</device-config> </device-config>
<system-config> <system-config>
<disable-event-thread>false</disable-event-thread> <disable-event-thread>true</disable-event-thread>
</system-config> </system-config>
<!-- Configure the progress message to show in the center --> <!-- Configure the progress message to show in the center -->