diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java index 6ee470f186..9f727b8ead 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java @@ -446,7 +446,7 @@ public class WQuickEntry extends Window implements EventListener<Event>, ValueCh public int getRecord_ID() { - if (quickPOs.get(0) == null) + if (quickPOs.isEmpty() || quickPOs.get(0) == null) return 0; return quickPOs.get(0).get_ID(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java index 9bc59abc26..08711ece84 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java @@ -43,8 +43,10 @@ import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.editor.WTableDirEditor; 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.grid.WQuickEntry; import org.adempiere.webui.panel.InfoPanel; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; @@ -71,12 +73,14 @@ import org.compiere.util.KeyNamePair; import org.compiere.util.Msg; import org.compiere.util.Util; import org.compiere.util.ValueNamePair; +import org.zkoss.zk.au.out.AuEcho; import org.zkoss.zk.ui.Component; 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.SwipeEvent; +import org.zkoss.zk.ui.util.Clients; import org.zkoss.zul.Center; import org.zkoss.zul.Checkbox; import org.zkoss.zul.Comboitem; @@ -2005,5 +2009,41 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL return true; } + + @Override + protected boolean hasNew() { + return getADWindowID () > 0; + } + + /** + * Get id of window link with main table of this info window + * @param tableName + * @return + */ + protected int getADWindowID() { + String isSOTrx = Env.getContext(Env.getCtx(), p_WindowNo, "IsSOTrx"); + if (!isLookup() && Util.isEmpty(isSOTrx)) { + isSOTrx = "Y"; + } + + return super.getAD_Window_ID(MTable.getTableName(Env.getCtx(), infoWindow.getAD_Table_ID()), isSOTrx.equalsIgnoreCase("Y")); + } + + @Override + protected void newRecordAction() { + final WQuickEntry vqe = new WQuickEntry (0, getADWindowID()); + + vqe.loadRecord (0); + + vqe.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { + @Override + public void onEvent(Event event) throws Exception { + Clients.response(new AuEcho(InfoWindow.this, "onQueryCallback", null)); + } + }); + + vqe.setVisible(true); + AEnv.showWindow(vqe); + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 3439767c04..769a56e04d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -123,10 +123,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>, protected final static String ON_RUN_PROCESS = "onRunProcess"; // attribute key of info process protected final static String ATT_INFO_PROCESS_KEY = "INFO_PROCESS"; - protected int pageSize; protected MInfoRelated[] relatedInfoList; - public static InfoPanel create (int WindowNo, String tableName, String keyColumn, String value, boolean multiSelection, String whereClause) @@ -246,6 +244,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>, } confirmPanel = new ConfirmPanel(true, true, true, true, true, true); // Elaine 2008/12/16 + confirmPanel.addComponentsLeft(confirmPanel.createButton(ConfirmPanel.A_NEW)); confirmPanel.addActionListener(Events.ON_CLICK, this); confirmPanel.setHflex("1"); @@ -253,6 +252,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>, confirmPanel.getButton(ConfirmPanel.A_CUSTOMIZE).setVisible(hasCustomize()); confirmPanel.getButton(ConfirmPanel.A_HISTORY).setVisible(hasHistory()); confirmPanel.getButton(ConfirmPanel.A_ZOOM).setVisible(hasZoom()); + confirmPanel.getButton(ConfirmPanel.A_NEW).setVisible(hasNew()); // if (!isLookup()) { @@ -1189,7 +1189,6 @@ public abstract class InfoPanel extends Window implements EventListener<Event>, confirmPanel.getButton(ConfirmPanel.A_ZOOM).setEnabled(!enable?enable : (contentPanel.getSelectedCount() == 1) ); //red1 only zoom for single record if (hasProcess()) confirmPanel.getButton(ConfirmPanel.A_PROCESS).setEnabled(enable); - // IDEMPIERE-1334 start for (Button btProcess : btProcessList){ btProcess.setEnabled(enable); @@ -1262,6 +1261,12 @@ public abstract class InfoPanel extends Window implements EventListener<Event>, * @return true if it has zoom (default false) */ protected boolean hasZoom() {return false;} + /** + * Has new function for create new record (false) + * To be overwritten by concrete classes + * @return + */ + protected boolean hasNew() {return false;} /** * Save Selection Details * To be overwritten by concrete classes @@ -1378,6 +1383,9 @@ public abstract class InfoPanel extends Window implements EventListener<Event>, if (isLookup()) this.detach(); } + }else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_NEW))) + { + newRecordAction (); } // IDEMPIERE-1334 handle event click into process button start else if (ON_RUN_PROCESS.equals(event.getName())){ @@ -1706,6 +1714,11 @@ public abstract class InfoPanel extends Window implements EventListener<Event>, } } + /** + * process action when user click to new button + */ + protected void newRecordAction (){} + public void addValueChangeListener(ValueChangeListener listener) { if (listener == null)