IDEMPIERE-144 Performance: Reduce use of modal dialog

This commit is contained in:
Heng Sin Low 2012-06-07 17:40:47 +08:00
parent fff6937a7c
commit 020741dc09
26 changed files with 393 additions and 177 deletions

View File

@ -383,4 +383,9 @@ public class VCreateFromInvoiceUI extends CreateFromInvoice implements ActionLis
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -195,4 +195,9 @@ public class VCreateFromRMAUI extends CreateFromRMA implements VetoableChangeLis
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -547,4 +547,9 @@ public class VCreateFromShipmentUI extends CreateFromShipment implements ActionL
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -339,4 +339,9 @@ public class VCreateFromStatementUI extends CreateFromStatement implements Actio
{
dialog.dispose();
}
@Override
public Object getWindow() {
return dialog;
}
}

View File

@ -30,6 +30,7 @@ import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.VerticalBox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.compiere.process.ProcessInfo;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
@ -58,16 +59,11 @@ import org.zkoss.zul.Html;
* @author arboleda - globalqss
* - Implement ShowHelp option on processes and reports
*/
public class ProcessModalDialog extends Window implements EventListener<Event>, IProcessMonitor
public class ProcessModalDialog extends Window implements EventListener<Event>, IProcessMonitor, DialogEvents
{
private static final String ON_STATUS_UPDATE = "onStatusUpdate";
private static final String ON_COMPLETE = "onComplete";
/**
* on modal close event, use this for highlight mode modal dialog to perform action after the modal dialog closed.
*/
public final static String ON_MODAL_CLOSE = "onModalClose";
/**
* generated serial version ID
*/

View File

@ -49,10 +49,8 @@ import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Space;
public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener, ValueChangeListener, SystemIDs
public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener<Event>, ValueChangeListener, SystemIDs
{
private static final long serialVersionUID = 1L;
private WCreateFromWindow window;
public WCreateFromInvoiceUI(GridTab tab)
@ -379,4 +377,9 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
{
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -42,8 +42,6 @@ import org.zkoss.zul.Center;
public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListener, SystemIDs
{
private static final long serialVersionUID = 1L;
private WCreateFromWindow window;
public WCreateFromRMAUI(GridTab tab)
@ -190,4 +188,9 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
{
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -39,12 +39,10 @@ import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.compiere.grid.CreateFromShipment;
import org.compiere.model.GridTab;
import org.compiere.model.MInvoice;
import org.compiere.model.MLocatorLookup;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MProduct;
import org.compiere.model.MRMA;
import org.compiere.model.SystemIDs;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
@ -58,7 +56,7 @@ import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Space;
public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener, ValueChangeListener, SystemIDs
public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener<Event>, ValueChangeListener, SystemIDs
{
private WCreateFromWindow window;
@ -111,10 +109,6 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
protected WLocatorEditor locatorField = new WLocatorEditor();
protected Label upcLabel = new Label();
protected WStringEditor upcField = new WStringEditor();
/** Loaded Invoice */
private MInvoice m_invoice = null;
/** Loaded RMA */
private MRMA m_rma = null;
/**
* Dynamic Init
@ -270,7 +264,6 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
invoiceField.setSelectedIndex(-1);
rmaField.setSelectedIndex(-1);
loadOrder(C_Order_ID, false, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0);
m_invoice = null;
}
}
// Invoice
@ -554,4 +547,9 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
{
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -56,10 +56,8 @@ import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Hbox;
public class WCreateFromStatementUI extends CreateFromStatement implements EventListener, SystemIDs
public class WCreateFromStatementUI extends CreateFromStatement implements EventListener<Event>, SystemIDs
{
private static final long serialVersionUID = 1L;
private WCreateFromWindow window;
public WCreateFromStatementUI(GridTab tab)
@ -306,4 +304,9 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
{
window.dispose();
}
@Override
public Object getWindow() {
return window;
}
}

View File

@ -21,6 +21,7 @@ import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.WAppsAction;
import org.adempiere.webui.component.WListbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.WTableModelEvent;
import org.adempiere.webui.event.WTableModelListener;
import org.adempiere.webui.panel.StatusBarPanel;
@ -30,13 +31,14 @@ import org.compiere.util.Trx;
import org.compiere.util.TrxRunnable;
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.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Separator;
public class WCreateFromWindow extends Window implements EventListener, WTableModelListener
public class WCreateFromWindow extends Window implements EventListener<Event>, WTableModelListener, DialogEvents
{
private static final long serialVersionUID = 1L;
@ -47,6 +49,8 @@ public class WCreateFromWindow extends Window implements EventListener, WTableMo
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private StatusBarPanel statusBar = new StatusBarPanel();
private WListbox dataTable = ListboxFactory.newDataTable();
private boolean isCancel;
public static final String SELECT_ALL = "SelectAll";
@ -115,6 +119,7 @@ public class WCreateFromWindow extends Window implements EventListener, WTableMo
// OK - Save
if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
{
isCancel = false;
try
{
Trx.run(new TrxRunnable()
@ -132,11 +137,14 @@ public class WCreateFromWindow extends Window implements EventListener, WTableMo
{
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
@ -215,4 +223,9 @@ public class WCreateFromWindow extends Window implements EventListener, WTableMo
{
return confirmPanel;
}
public boolean isCancel()
{
return isCancel;
}
}

View File

@ -46,6 +46,7 @@ import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WButtonEditor;
import org.adempiere.webui.editor.WDateEditor;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridTab;
import org.compiere.model.MCash;
@ -71,6 +72,7 @@ import org.compiere.util.ValueNamePair;
import org.zkoss.zk.au.out.AuEcho;
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.util.Clients;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
@ -110,7 +112,7 @@ import org.zkoss.zul.Space;
* <li>BF [ 1789949 ] VPayment: is displaying just "CashNotCreated"
*/
public class WPayment extends Window
implements EventListener
implements EventListener<Event>, DialogEvents
{
/**
*
@ -129,7 +131,6 @@ public class WPayment extends Window
{
super();
this.setTitle(Msg.getMsg(Env.getCtx(), "Payment"));
this.setAttribute("mode", "modal");
m_WindowNo = WindowNo;
m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx"));
m_mTab = mTab;
@ -772,7 +773,7 @@ public class WPayment extends Window
* Load Bank Accounts
*/
SQL = MRole.getDefault().addAccessSQL(
"SELECT C_BankAccount_ID, Name || ' ' || AccountNo, IsDefault "
"SELECT C_BankAccount_ID, ba.Name || ' ' || AccountNo, IsDefault "
+ "FROM C_BankAccount ba"
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE b.IsActive='Y'",
@ -939,6 +940,13 @@ 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

@ -0,0 +1,28 @@
/******************************************************************************
* Copyright (C) 2012 Heng Sin Low *
* Copyright (C) 2012 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui.event;
/**
*
* @author hengsin
*
*/
public interface DialogEvents {
/**
* on modal close event, use this for highlight mode modal dialog to perform action after the modal dialog closed.
*/
public final static String ON_MODAL_CLOSE = "onModalClose";
}

View File

@ -38,6 +38,7 @@ import org.adempiere.webui.apps.BusyDialogTemplate;
import org.adempiere.webui.apps.ProcessModalDialog;
import org.adempiere.webui.apps.WReport;
import org.adempiere.webui.apps.form.WCreateFromFactory;
import org.adempiere.webui.apps.form.WCreateFromWindow;
import org.adempiere.webui.apps.form.WPayment;
import org.adempiere.webui.component.CWindowToolbar;
import org.adempiere.webui.component.IADTab;
@ -47,11 +48,13 @@ import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WButtonEditor;
import org.adempiere.webui.event.ActionEvent;
import org.adempiere.webui.event.ActionListener;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ToolbarListener;
import org.adempiere.webui.exception.ApplicationException;
import org.adempiere.webui.panel.action.ExportAction;
import org.adempiere.webui.part.AbstractUIPart;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.Callback;
import org.adempiere.webui.window.FDialog;
import org.adempiere.webui.window.FindWindow;
import org.adempiere.webui.window.WChat;
@ -172,6 +175,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
private boolean m_findCreateNew;
private boolean m_queryInitiating;
/**
* Constructor for non-embedded mode
* @param ctx
@ -519,6 +524,15 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
}
private void initQueryOnNew(MQuery result) {
if (curTab.isHighVolume() && m_findCreateNew)
onNew();
else if (result == null && curTab.getRowCount() == 0 && Env.isAutoNew(ctx, curWindowNo))
onNew();
else if (!curTab.isReadOnly() && curTab.isQueryNewRecord())
onNew();
}
/**
* @param query
* @param tabIndex
@ -526,26 +540,39 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
protected void initTab(MQuery query, int tabIndex) {
gridWindow.initTab(tabIndex);
GridTab gTab = gridWindow.getTab(tabIndex);
final GridTab gTab = gridWindow.getTab(tabIndex);
Env.setContext(ctx, curWindowNo, tabIndex, GridTab.CTX_TabLevel, Integer.toString(gTab.getTabLevel()));
// Query first tab
if (tabIndex == 0)
{
query = initialQuery(query, gTab);
if (gTab.isHighVolume() && m_findCancelled)
return;
if (query != null && query.getRecordCount() <= 1)
{
// goSingleRow = true;
}
// Set initial Query on first tab
if (query != null)
{
m_onlyCurrentRows = false;
gTab.setQuery(query);
}
m_queryInitiating = true;
initialQuery(query, gTab, new Callback<MQuery>() {
@Override
public void onCallback(MQuery result) {
m_queryInitiating = false;
if (m_findCancelled) {
SessionManager.getAppDesktop().closeWindow(curWindowNo);
return;
}
// Set initial Query on first tab
if (result != null)
{
m_onlyCurrentRows = false;
gTab.setQuery(result);
}
if (curTabpanel != null)
{
initFirstTabpanel();
initQueryOnNew(result);
}
}
});
curTab = gTab;
curTabIndex = tabIndex;
@ -565,8 +592,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (tabIndex == 0) {
curTabpanel = sortTab;
curTabpanel.createUI();
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords());
curTabpanel.activate(true);
if (!m_queryInitiating)
{
initFirstTabpanel();
}
}
gTab.addDataStatusListener(this);
}
@ -598,20 +627,23 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (tabIndex == 0) {
fTabPanel.createUI();
curTabpanel = fTabPanel;
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords());
curTabpanel.activate(true);
if (!m_queryInitiating)
{
initFirstTabpanel();
}
}
}
if (!m_queryInitiating && tabIndex == 0)
{
initQueryOnNew(query);
}
}
}
if (tabIndex == 0) {
if (curTab.isHighVolume() && m_findCreateNew)
onNew();
else if (query == null && curTab.getRowCount() == 0 && Env.isAutoNew(ctx, curWindowNo))
onNew();
else if (!curTab.isReadOnly() && curTab.isQueryNewRecord())
onNew();
}
private void initFirstTabpanel() {
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords());
curTabpanel.activate(true);
}
/**
@ -623,11 +655,15 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
* tab
* @return query or null
*/
private MQuery initialQuery(MQuery query, GridTab mTab)
private void initialQuery(final MQuery query, GridTab mTab, final Callback<MQuery> callback)
{
// We have a (Zoom) query
if (query != null && query.isActive() && query.getRecordCount() < 10)
return query;
{
callback.onCallback(query);
return;
}
//
StringBuffer where = new StringBuffer();
// Query automatically if high volume and no query
@ -665,26 +701,32 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
m_findCancelled = false;
m_findCreateNew = false;
GridField[] findFields = mTab.getFields();
FindWindow find = new FindWindow(curWindowNo,
GridField[] findFields = mTab.getFields();
final FindWindow find = new FindWindow(curWindowNo,
mTab.getName(), mTab.getAD_Table_ID(), mTab.getTableName(),
where.toString(), findFields, 10, mTab.getAD_Tab_ID()); // no query below 10
if (find.getTitle() != null && find.getTitle().length() > 0) {
// Title is not set when the number of rows is below the minRecords parameter (10)
if (!find.isCancel())
{
m_findCreateNew = find.isCreateNew();
if (!m_findCreateNew)
{
query = find.getQuery();
}
}
else
m_findCancelled = true;
find = null;
}
find.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!find.isCancel())
{
m_findCreateNew = find.isCreateNew();
MQuery result = m_findCreateNew ? query : find.getQuery();
callback.onCallback(result);
}
else
{
m_findCancelled = true;
callback.onCallback(null);
}
}
});
AEnv.showWindow(find);
}
else
{
callback.onCallback(query);
}
return query;
} // initialQuery
public String getTitle()
@ -819,12 +861,17 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (curTab.needSave(true, true) && !onSave(false))
return;
WOnlyCurrentDays ocd = new WOnlyCurrentDays();
m_onlyCurrentDays = ocd.getCurrentDays();
history(m_onlyCurrentDays);
}
focusToActivePanel();
final WOnlyCurrentDays ocd = new WOnlyCurrentDays();
ocd.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
m_onlyCurrentDays = ocd.getCurrentDays();
history(m_onlyCurrentDays);
focusToActivePanel();
}
});
AEnv.showWindow(ocd);
}
}
private void history(int onlyCurrentDays)
@ -898,10 +945,16 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
String description = infoName + ": " + infoDisplay;
new WChat(curWindowNo, curTab.getCM_ChatID(), curTab.getAD_Table_ID(), recordId, description, null);
curTab.loadChats();
toolbar.getButton("Chat").setPressed(curTab.hasChat());
focusToActivePanel();
WChat chat = new WChat(curWindowNo, curTab.getCM_ChatID(), curTab.getAD_Table_ID(), recordId, description, null);
chat.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
curTab.loadChats();
toolbar.getButton("Chat").setPressed(curTab.hasChat());
focusToActivePanel();
}
});
chat.showWindow();
}
/**
@ -1473,25 +1526,31 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
// Gets Fields from AD_Field_v
GridField[] findFields = GridField.createFields(ctx, curTab.getWindowNo(), 0,curTab.getAD_Tab_ID());
FindWindow find = new FindWindow (curTab.getWindowNo(), curTab.getName(),
final FindWindow find = new FindWindow (curTab.getWindowNo(), curTab.getName(),
curTab.getAD_Table_ID(), curTab.getTableName(),
curTab.getWhereExtended(), findFields, 1, curTab.getAD_Tab_ID());
if (!find.isCancel())
{
MQuery query = find.getQuery();
find.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!find.isCancel())
{
MQuery query = find.getQuery();
// Confirmed query
if (query != null)
{
m_onlyCurrentRows = false; // search history too
curTab.setQuery(query);
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); // autoSize
}
// Confirmed query
if (query != null)
{
m_onlyCurrentRows = false; // search history too
curTab.setQuery(query);
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); // autoSize
}
curTab.dataRefresh(false); // Elaine 2008/07/25
}
focusToActivePanel();
curTab.dataRefresh(false); // Elaine 2008/07/25
}
focusToActivePanel();
}
});
AEnv.showWindow(find);
}
/**
@ -1655,7 +1714,15 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
//show table with deletion rows -> value, name...
final Window messagePanel = new Window();
final Window messagePanel = new Window() {
private static final long serialVersionUID = 3954976581821972619L;
@Override
public void detach() {
super.detach();
focusToActivePanel();
}
};
messagePanel.setBorder("normal");
messagePanel.setWidth("600px");
messagePanel.setTitle(Msg.getMsg(Env.getCtx(), "Find").replaceAll("&", "") + ": " + title);
@ -1820,9 +1887,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
});
hbox.appendChild(btnCancel);
hbox.setPack("end");
hbox.setHflex("1");
AEnv.showWindow(messagePanel);
focusToActivePanel();
messagePanel.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(messagePanel);
}
//
@ -2012,7 +2081,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
* Start Button Process
* @param vButton button
*/
private void actionButton (WButtonEditor wButton)
private void actionButton (final WButtonEditor wButton)
{
if (curTab.hasChangedCurrentTabAndParents()) {
String msg = CLogger.retrieveErrorString("Please ReQuery Window");
@ -2043,7 +2112,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return;
}
int table_ID = curTab.getAD_Table_ID();
final int table_ID = curTab.getAD_Table_ID();
// Record_ID
@ -2074,32 +2143,32 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
boolean isProcessMandatory = false;
// Pop up Payment Rules
if (col.equals("PaymentRule"))
{
WPayment vp = new WPayment(curWindowNo, curTab, wButton);
final WPayment vp = new WPayment(curWindowNo, curTab, wButton);
if (vp.isInitOK()) // may not be allowed
{
vp.setVisible(true);
AEnv.showCenterScreen(vp);
}
//vp.dispose();
if (vp.needSave())
{
onSave(false);
onRefresh(false);
}
vp.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
vp.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (vp.needSave())
{
onSave(false);
onRefresh(false);
}
}
});
AEnv.showWindow(vp);
}
return;
} // PaymentRule
// Pop up Document Action (Workflow)
else if (col.equals("DocAction"))
{
isProcessMandatory = true;
WDocActionPanel win = new WDocActionPanel(curTab);
final WDocActionPanel win = new WDocActionPanel(curTab);
if (win.getNumberOfOptions() == 0)
{
logger.info("DocAction - No Options");
@ -2107,15 +2176,22 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
else
{
AEnv.showCenterScreen(win);
if (!win.isStartProcess())
return;
//batch = win.isBatch();
startWOasking = true;
//vda.dispose();
}
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>() {
public void onEvent(Event event) throws Exception {
if (!win.isStartProcess()) {
return;
}
boolean startWOasking = true;
boolean isProcessMandatory = true;
executeButtonProcess(wButton, startWOasking, table_ID, recordIdParam, isProcessMandatory);
}
});
AEnv.showWindow(win);
return;
}
} // DocAction
// Pop up Create From
@ -2128,8 +2204,17 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
if(cf.isInitOK())
{
cf.showWindow();
curTab.dataRefresh();
final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow();
window.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
window.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!window.isCancel()) {
curTab.dataRefresh();
}
}
});
cf.showWindow();
}
return;
}
@ -2196,6 +2281,13 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return;
} // Posted
executeButtonProcess(wButton, startWOasking, table_ID, record_ID,
isProcessMandatory);
} // actionButton
private void executeButtonProcess(final WButtonEditor wButton,
boolean startWOasking, int table_ID, int record_ID,
boolean isProcessMandatory) {
/**
* Start Process ----
*/
@ -2248,7 +2340,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
dialog.setVisible(true);
dialog.setPosition("center");
dialog.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
dialog.addEventListener(ProcessModalDialog.ON_MODAL_CLOSE, new EventListener<Event>() {
dialog.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
onRefresh(false);
@ -2261,7 +2353,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
onRefresh(false);
}
}
} // actionButton
}
/**
* @param event

View File

@ -27,6 +27,7 @@ import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridTab;
import org.compiere.model.MTable;
@ -48,7 +49,7 @@ import org.zkoss.zul.Space;
public class WDocActionPanel extends Window implements EventListener
public class WDocActionPanel extends Window implements EventListener<Event>, DialogEvents
{
/**
*
@ -299,12 +300,14 @@ public class WDocActionPanel extends Window implements EventListener
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

@ -19,9 +19,9 @@ package org.adempiere.webui.panel;
import java.util.logging.Level;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -39,7 +39,7 @@ import org.zkoss.zul.Separator;
* @date September 24, 2007
*/
public class WOnlyCurrentDays extends Window implements EventListener
public class WOnlyCurrentDays extends Window implements EventListener<Event>, DialogEvents
{
/**
*
@ -65,8 +65,7 @@ public class WOnlyCurrentDays extends Window implements EventListener
log.log(Level.SEVERE, "VOnlyCurrentDays", e);
}
this.setVisible(true);
AEnv.showWindow(this);
this.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
} // WOnlyCurrentDays
private Hbox mainPanel = new Hbox();
@ -116,7 +115,6 @@ public class WOnlyCurrentDays extends Window implements EventListener
this.setBorder("normal");
this.setTitle(Msg.getMsg(Env.getCtx(), "VOnlyCurrentDays"));
this.setClosable(true);
this.setAttribute("mode", "modal");
this.appendChild(new Separator());
this.appendChild(mainPanel);
@ -149,4 +147,9 @@ public class WOnlyCurrentDays extends Window implements EventListener
this.detach();
}
@Override
public void detach() {
super.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
}

View File

@ -51,7 +51,7 @@ import org.zkoss.zul.Vbox;
* @author hengsin
*
*/
public class ExportAction implements EventListener
public class ExportAction implements EventListener<Event>
{
private AbstractADWindowPanel panel;
@ -109,7 +109,7 @@ public class ExportAction implements EventListener
cboType.setSelectedIndex(0);
Vbox vb = new Vbox();
vb.setWidth("390px");
vb.setWidth("100%");
winExportFile.appendChild(vb);
Hbox hb = new Hbox();
@ -131,7 +131,8 @@ public class ExportAction implements EventListener
confirmPanel.addActionListener(this);
}
AEnv.showCenterScreen(winExportFile);
winExportFile.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(winExportFile);
}
@Override

View File

@ -0,0 +1,25 @@
/******************************************************************************
* Copyright (C) 2012 Heng Sin Low *
* Copyright (C) 2012 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui.util;
/**
*
* @author hengsin
*
* @param <T>
*/
public interface Callback<T> {
public void onCallback(T result);
}

View File

@ -34,7 +34,6 @@ import java.util.regex.Pattern;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns;
@ -57,6 +56,7 @@ import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.part.MultiTabPart;
@ -81,6 +81,7 @@ import org.compiere.util.SecureEngine;
import org.compiere.util.ValueNamePair;
import org.zkoss.zk.au.out.AuFocus;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -99,7 +100,7 @@ import org.zkoss.zul.Hbox;
* @author Sendy Yagambrum
* @date June 27, 2007
*/
public class FindWindow extends Window implements EventListener<Event>,ValueChangeListener, SystemIDs
public class FindWindow extends Window implements EventListener<Event>, ValueChangeListener, SystemIDs, DialogEvents
{
/**
*
@ -207,12 +208,10 @@ public class FindWindow extends Window implements EventListener<Event>,ValueChan
this.setWidth("750px");
this.setHeight("350px");
this.setTitle(Msg.getMsg(Env.getCtx(), "Find").replaceAll("&", "") + ": " + title);
this.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
this.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
this.setClosable(false);
this.setSizable(true);
this.setVisible(true);
AEnv.showWindow(this);
this.setSizable(true);
this.setMaximizable(true);
}
/**
* initialise lookup record tab
@ -360,6 +359,7 @@ public class FindWindow extends Window implements EventListener<Event>,ValueChan
Hbox confirmPanel = new Hbox();
confirmPanel.appendChild(pnlButtonRight);
confirmPanel.setWidth("100%");
confirmPanel.setPack("end");
advancedPanel = new Listbox();
advancedPanel.setSizedByContent(true);
@ -1141,6 +1141,8 @@ public class FindWindow extends Window implements EventListener<Event>,ValueChan
listcell.setLabel("");
listcell.getChildren().clear();
listcell.appendChild(component);
((HtmlBasedComponent)component).setHflex("1");
listcell.invalidate();
} // addComponent
/**
@ -1325,6 +1327,8 @@ public class FindWindow extends Window implements EventListener<Event>,ValueChan
m_targetFields = null;
//
super.dispose();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
} // dispose
/**

View File

@ -28,6 +28,7 @@ import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.compiere.model.MChat;
import org.compiere.model.MChatEntry;
import org.compiere.model.MUser;
@ -39,6 +40,7 @@ import org.compiere.util.Util;
import org.zkoss.zk.ui.Component;
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.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Div;
@ -56,7 +58,7 @@ import org.zkoss.zul.Treerow;
* @author Jorg Janke
* @version $Id: AChat.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $
*/
public class WChat extends Window implements EventListener
public class WChat extends Window implements EventListener<Event>, DialogEvents
{
/**
*
@ -104,15 +106,14 @@ public class WChat extends Window implements EventListener
m_chat = new MChat (Env.getCtx(), CM_Chat_ID, trxName);
loadChat();
//
try
{
newText.focus();
AEnv.showCenterScreen(this);
}
catch (Exception e)
{
}
} // Attachment
public void showWindow()
{
this.setAttribute(MODE_KEY, MODE_HIGHLIGHTED);
AEnv.showWindow(this);
newText.focus();
}
/** Window No */
@SuppressWarnings("unused")
@ -350,4 +351,9 @@ public class WChat extends Window implements EventListener
actionPerformed(event);
}
@Override
public void detach() {
super.detach();
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
}
} // AChat

View File

@ -132,7 +132,8 @@ public class WEMailDialog extends Window implements EventListener<Event>, ValueC
}
set(from, to, subject, message);
setAttachment(attachment);
AEnv.showCenterScreen(this);
setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(this);
} // commonInit

View File

@ -41,6 +41,7 @@ import org.adempiere.webui.component.Tabbox;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.DrillEvent;
import org.adempiere.webui.event.ZoomEvent;
import org.adempiere.webui.panel.ITabOnCloseHandler;
@ -786,19 +787,20 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
hb.appendChild(cboType);
cboType.setWidth("100%");
hb.setVflex("1");
hb.setStyle("margin-top: 10px");
Vbox vb = new Vbox();
vb.setVflex("1");
vb.setWidth("100%");
winExportFile.appendChild(vb);
vb.appendChild(hb);
vb.appendChild(confirmPanel);
vb.appendChild(confirmPanel);
confirmPanel.addActionListener(this);
confirmPanel.setVflex("0");
}
AEnv.showCenterScreen(winExportFile);
winExportFile.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
AEnv.showWindow(winExportFile);
} // cmd_export
private void exportFile()
@ -1023,18 +1025,23 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
bFind.setVisible(false);
else
{
FindWindow find = new FindWindow(m_WindowNo, title, AD_Table_ID, tableName,m_reportEngine.getWhereExtended(), findFields, 1, AD_Tab_ID);
if (!find.isCancel())
{
m_reportEngine.setQuery(find.getQuery());
try {
renderReport();
} catch (Exception e) {
throw new AdempiereException("Failed to render report", e);
}
revalidate();
}
find = null;
final FindWindow find = new FindWindow(m_WindowNo, title, AD_Table_ID, tableName,m_reportEngine.getWhereExtended(), findFields, 1, AD_Tab_ID);
find.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!find.isCancel())
{
m_reportEngine.setQuery(find.getQuery());
try {
renderReport();
} catch (Exception e) {
throw new AdempiereException("Failed to render report", e);
}
revalidate();
}
}
});
AEnv.showWindow(find);
}
} // cmd_find

View File

@ -53,7 +53,7 @@ import org.compiere.util.Msg;
* <li>BF [ 1896947 ] Generate invoice from Order error
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
*/
public class CreateFromInvoice extends CreateFrom
public abstract class CreateFromInvoice extends CreateFrom
{
/**
* Protected Constructor

View File

@ -35,7 +35,7 @@ import org.compiere.util.Msg;
* @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
*/
public class CreateFromRMA extends CreateFrom {
public abstract class CreateFromRMA extends CreateFrom {
public CreateFromRMA(GridTab mTab)
{

View File

@ -50,7 +50,7 @@ import org.compiere.util.Msg;
* <li>BF [ 1896947 ] Generate invoice from Order error
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
*/
public class CreateFromShipment extends CreateFrom
public abstract class CreateFromShipment extends CreateFrom
{
/** Loaded Invoice */
private MInvoice m_invoice = null;

View File

@ -42,7 +42,7 @@ import org.compiere.util.Msg;
* @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
*/
public class CreateFromStatement extends CreateFrom
public abstract class CreateFromStatement extends CreateFrom
{
public MBankAccount bankAccount;

View File

@ -20,4 +20,6 @@ public interface ICreateFrom
public void showWindow();
public void closeWindow();
public Object getWindow();
}