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 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

View File

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

View File

@ -710,6 +710,16 @@ public class MWorkflow extends X_AD_Workflow
if (localTrx != null)
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;
} // MWFProcess

View File

@ -2972,10 +2972,10 @@ public final class APanel extends CPanel
} // updateToolBarAndMenuWithRestriction
@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);
if (callback != null) {
callback.onCallback(b ? "OK" : "CANCEL");
callback.onCallback(b);
}
}

View File

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

View File

@ -905,10 +905,10 @@ public class VInOutInvoiceGen extends CPanel
}
@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);
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 boolean eventThreadEnabled = false;
public AdempiereWebUI()
{
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 TokenCommand());
Executions.getCurrent().getDesktop().addListener(new ZoomCommand());
eventThreadEnabled = Executions.getCurrent().getDesktop().getWebApp().getConfiguration().isEventThreadEnabled();
}
public void onOk()
@ -393,4 +397,8 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
public UserPreference getUserPreference() {
return userPreference;
}
public static boolean isEventThreadEnabled() {
return eventThreadEnabled;
}
}

View File

@ -67,9 +67,9 @@ public class ValuePreference extends Window implements EventListener
* @param aValue value
* @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
/**
@ -79,12 +79,12 @@ public class ValuePreference extends Window implements EventListener
* @param aDisplayValue display value
* @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))
{
log.info("Field not editable (R/O)");
return null;
return;
}
// 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,
Attribute, DisplayAttribute, Value, DisplayValue,
displayType, AD_Reference_ID);
return vp;
} // create
/**

View File

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

View File

@ -92,15 +92,6 @@ public final class AEnv
SessionManager.getAppDesktop().showWindow(window, "center");
} // 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.
* (pack, set location and set visibility)

View File

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

View File

@ -108,7 +108,7 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
if (listener != null)
{
addEventListener(ON_MODAL_CLOSE, listener);
addEventListener(ON_WINDOW_CLOSE, listener);
}
log.info("Process=" + pi.getAD_Process_ID());
@ -413,7 +413,6 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
private void onCancel() {
m_cancel = true;
this.dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
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));
}
dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
@Override
@ -488,7 +486,7 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
}
@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>() {
@Override
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());
}
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
// Cancel
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
{
isCancel = true;
dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
// Select All
// Trifon

View File

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

View File

@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.BusyDialog;
@ -339,11 +340,19 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen
public void onAfterProcess()
{
// 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.response(new AuEcho(this, "onPrint", null));
} // OK to print
Clients.response(new AuEcho(WGenForm.this, "onPrint", null));
}
}
});
}
public void onPrint()

View File

@ -18,6 +18,7 @@ package org.adempiere.webui.apps.form;
import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.component.ConfirmPanel;
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
+ "\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.setPage(form.getPage());
progressWindow.doHighlighted();
runnable = new MergeRunnable(columnName, from_ID, to_ID);
runnable = new MergeRunnable(columnNameRef, fromIdRef, toIdRef);
Clients.response(new AuEcho(form, "runProcess", null));
}
}
});
} // actionPerformed
class MergeRunnable implements Runnable {

View File

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

View File

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

View File

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

View File

@ -19,6 +19,7 @@ package org.adempiere.webui.apps.form;
import java.util.ArrayList;
import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Checkbox;
@ -388,7 +389,14 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
*/
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("");
ListModel model = centerList.getModel();
int size = model.getSize();
@ -399,6 +407,8 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
action_treeAdd(item);
}
}
}
});
} // action_treeAddAll
/**
@ -407,7 +417,14 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
private void action_treeDeleteAll()
{
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();
int size = model.getSize();
int index = -1;
@ -417,6 +434,9 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
action_treeDelete(item);
}
}
}
});
} // action_treeDeleteAll
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.Textbox;
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.compiere.apps.wf.WFGraphLayout;
import org.compiere.apps.wf.WFNodeWidget;
@ -62,7 +64,6 @@ import org.zkoss.zul.Separator;
import org.zkoss.zul.Space;
import org.zkoss.zul.Toolbarbutton;
import org.zkoss.zul.Vbox;
import org.zkoss.zul.Window;
/**
*
@ -208,15 +209,14 @@ public class WFEditor extends ADForm {
w.onClose();
}
});
try {
w.setWidth("250px");
w.setBorder("normal");
w.setPage(this.getPage());
w.doModal();
} catch (SuspendNotAllowedException e) {
e.printStackTrace();
}
w.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
String name = text.getText();
if (name != null && name.length() > 0)
{
@ -227,6 +227,9 @@ public class WFEditor extends ADForm {
reload(m_wf.getAD_Workflow_ID());
}
}
});
w.doHighlighted();
}
void reload(int workflowId) {
center.removeChild(table);

View File

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

View File

@ -17,6 +17,11 @@
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>
@ -62,4 +67,15 @@ public class Window extends org.zkoss.zul.Window
{
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.List;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.exception.ApplicationException;
import org.adempiere.webui.part.AbstractUIPart;
import org.compiere.model.MMenu;
import org.compiere.util.CLogger;
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
@ -142,17 +146,11 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
* @param win
* @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);
String mode = Window.MODE_MODAL;
if (objMode != null)
{
mode = objMode.toString();
}
final String mode = objMode != null ? objMode.toString() : Window.MODE_HIGHLIGHTED;
if (Window.MODE_MODAL.equals(mode))
{
@ -160,7 +158,27 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
win.setPosition(pos);
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);
}
@ -184,18 +202,47 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
*
* @param win
*/
protected void showModal(Window win)
protected void showModal(final Window win)
{
//fall back to highlighted if can't execute doModal
if (Events.inEventListener())
if (AdempiereWebUI.isEventThreadEnabled())
{
win.setPage(page);
win.doModal();
}
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
win.setPosition(position);
win.setPage(page);
win.doPopup();
}
@ -225,6 +273,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
else
win.setPosition(position);
win.setPage(page);
win.doOverlapped();
}
@ -240,6 +289,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
else
win.setPosition(position);
win.setPage(page);
win.doHighlighted();
}
}

View File

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

View File

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

View File

@ -16,6 +16,7 @@ package org.adempiere.webui.editor;
import java.util.logging.Level;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.window.WImageDialog;
import org.compiere.model.GridField;
@ -24,6 +25,7 @@ import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.zkoss.image.AImage;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Image;
@ -153,7 +155,11 @@ public class WImageEditor extends WEditor
{
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()) {
int AD_Image_ID = vid.getAD_Image_ID();
Object oldValue = getValue();
@ -164,9 +170,12 @@ public class WImageEditor extends WEditor
m_mImage = null; // force reload
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);
}
}
});
}
}
}

View File

@ -19,6 +19,7 @@ import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.PAttributebox;
import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.window.WFieldRecordInfo;
import org.adempiere.webui.window.WPAttributeDialog;
@ -31,6 +32,7 @@ import org.compiere.model.SystemIDs;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
/**
@ -150,7 +152,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
{
//
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_Product_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());
// 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
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
M_Product_ID = M_ProductBOM_ID;
//
if (!productWindow && (M_Product_ID == 0 || exclude))
{
changed = true;
getComponent().setText(null);
M_AttributeSetInstance_ID = 0;
processChanges(oldValueInt, M_AttributeSetInstance_ID);
}
else
{
WPAttributeDialog vad = new WPAttributeDialog (
final WPAttributeDialog vad = new WPAttributeDialog (
M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID,
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())
{
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());
changed = true;
}
// Set Value
if (changed)
{
processChanges(oldValueInt, M_AttributeSetInstance_ID);
} // change
}
});
}
/** Selection
{
@ -244,10 +261,9 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener, S
}
}
**/
} // cmd_file
// Set Value
if (changed)
{
private void processChanges(int oldValueInt, int M_AttributeSetInstance_ID) {
log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID);
m_value = new Object(); // force re-query display
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.
m_GridTab.processFieldChange(gridField);
}
} // change
} // cmd_file
}
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.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.factory.InfoManager;
@ -46,6 +47,7 @@ import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
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
*/
Object result[] = null;
boolean cancelled = false;
// Zoom / Validation
String whereClause = getWhereClause();
@ -493,16 +492,18 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
if (m_tableName == null) // sets table name & key column
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.setStyle("border: 2px");
ip.setClosable(true);
ip.setAttribute("mode", "modal");
ip.addValueChangeListener(this);
infoPanel = ip;
AEnv.showWindow(ip);
cancelled = ip.isCancelled();
result = ip.getSelectedKeys();
ip.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
boolean cancelled = ip.isCancelled();
Object[] result = ip.getSelectedKeys();
infoPanel = null;
// Result
@ -523,7 +524,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
{
log.config(getColumnName() + " - Result = null (not cancelled)");
}
}
});
AEnv.showWindow(ip);
}
/**

View File

@ -21,8 +21,8 @@ package org.adempiere.webui.event;
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;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -55,7 +52,6 @@ import org.compiere.model.DataStatusEvent;
import org.compiere.model.DataStatusListener;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.GridTable;
import org.compiere.model.GridWindow;
import org.compiere.model.MLookup;
import org.compiere.model.MTree;
@ -96,7 +92,7 @@ import org.zkoss.zul.impl.XulElement;
* @author Low Heng Sin
*/
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
DataStatusListener, IADTabpanel, VetoableChangeListener
DataStatusListener, IADTabpanel
{
private static final String ON_DEFER_SET_SELECTED_NODE = "onDeferSetSelectedNode";
@ -152,8 +148,6 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
private Group currentGroup;
private boolean m_vetoActive = false;
public ADTabpanel()
{
init();
@ -251,7 +245,6 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
listPanel.setWindowNo(windowNo);
listPanel.setADWindowPanel(winPanel);
gridTab.getTableModel().addVetoableChangeListener(this);
}
/**
@ -1213,34 +1206,6 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
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
*/

View File

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

View File

@ -271,7 +271,7 @@ public abstract class InfoPanel extends Window implements EventListener, WTableM
{
if (isLookup())
{
setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
setBorder("normal");
setClosable(true);
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.Textbox;
import org.adempiere.webui.component.WListbox;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager;
import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn;
@ -1119,13 +1120,20 @@ public class InfoProductPanel extends InfoPanel implements EventListener
*/
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();
if (m_pAttributeWhere != null)
{
executeQuery();
renderItems();
}
}
});
} // cmdInfoAttribute
/**
@ -1375,12 +1383,19 @@ public class InfoProductPanel extends InfoPanel implements EventListener
M_Warehouse_ID = ((Integer)warehouse.getValue()).intValue();
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);
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_Locator_ID = pai.getM_Locator_ID();
if (m_M_AttributeSetInstance_ID != -1)
dispose(true);
}
});
return;
}
//

View File

@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List;
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.component.Button;
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.Textbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.MAttachment;
import org.compiere.model.MAttachmentEntry;
@ -42,9 +45,11 @@ import org.zkoss.util.media.AMedia;
import org.zkoss.util.media.Media;
import org.zkoss.zk.au.out.AuScript;
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.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
@ -61,7 +66,7 @@ import org.zkoss.zul.Iframe;
* @author Low Heng Sin
*
*/
public class WAttachment extends Window implements EventListener
public class WAttachment extends Window implements EventListener<Event>
{
/**
* generated serial version Id
@ -128,12 +133,32 @@ public class WAttachment extends Window implements EventListener
public WAttachment( int WindowNo, int AD_Attachment_ID,
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();
log.config("ID=" + AD_Attachment_ID + ", Table=" + AD_Table_ID + ", Record=" + Record_ID);
m_WindowNo = WindowNo;
if (eventListener != null)
{
this.addEventListener(DialogEvents.ON_WINDOW_CLOSE, eventListener);
}
try
{
@ -165,7 +190,7 @@ public class WAttachment extends Window implements EventListener
}
//enter modal
doModal();
doHighlighted();
}
catch (Exception e)
{
@ -268,6 +293,8 @@ public class WAttachment extends Window implements EventListener
confirmPanel.appendChild(bOk);
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)
displayData(cbContent.getSelectedIndex(), true);
else if (e instanceof UploadEvent)
{
UploadEvent ue = (UploadEvent) e;
processUploadMedia(ue.getMedia());
}
} // onEvent
@ -511,10 +543,12 @@ public class WAttachment extends Window implements EventListener
preview.setVisible(false);
Media media = null;
media = Fileupload.get(true);
Media media = Fileupload.get(true);
if (AdempiereWebUI.isEventThreadEnabled())
processUploadMedia(media);
}
private void processUploadMedia(Media media) {
if (media != null)
{
// pdfViewer.setContent(media);
@ -554,7 +588,7 @@ public class WAttachment extends Window implements EventListener
clearPreview();
m_change = true;
}
} // getFileName
}
private byte[] getMediaData(Media media) {
byte[] bytes = null;
@ -586,8 +620,17 @@ public class WAttachment extends Window implements EventListener
{
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);
}
}
});
} // deleteAttachment
/**
@ -598,19 +641,26 @@ public class WAttachment extends Window implements EventListener
{
log.info("");
int index = cbContent.getSelectedIndex();
final int index = cbContent.getSelectedIndex();
String fileName = getFileName(index);
if (fileName == null)
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))
cbContent.removeItemAt(index);
m_change = true;
}
}
});
} // deleteAttachment
/**
@ -639,5 +689,4 @@ public class WAttachment extends Window implements EventListener
}
}
} // saveAttachmentToFile
}

View File

@ -90,9 +90,6 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
dynInit();
init();
this.setAttribute("mode","modal");
}
/**
@ -300,13 +297,11 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
m_OKpressed = true;
setValue();
this.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
else if (confirmPanel.getButton("Cancel").equals(event.getTarget()))
{
m_OKpressed = false;
this.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
}
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();
}
@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;
}
try
{
String s = out.toString().replace("\n", "<br>");
Messagebox.showDialog(s, newTitle, Messagebox.OK, Messagebox.EXCLAMATION);
}
catch (InterruptedException exception)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return;
}
@ -233,16 +225,8 @@ public class FDialog
out = constructMessage(adMessage, message);
try
{
String s = out.toString().replace("\n", "<br>");
Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.ERROR);
}
catch (InterruptedException exception)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return;
}
@ -258,6 +242,21 @@ public class FDialog
* @return true, if OK
*/
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();
if (adMessage != null && !adMessage.equals(""))
@ -265,7 +264,7 @@ public class FDialog
if (msg != null && msg.length() > 0)
out.append("\n").append(msg);
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)
{
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
*/
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>");
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);
}
catch (InterruptedException ex)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return true;
}
/**
* Display information with information icon.
@ -356,16 +356,8 @@ public class FDialog
out = constructMessage(adMessage, message);
try
{
String s = out.toString().replace("\n", "<br>");
Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.INFORMATION);
}
catch (InterruptedException exception)
{
// Restore the interrupted status
Thread.currentThread().interrupt();
}
return;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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