From 013487eecbd8e0c6340b63432deb1108245b3466 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 19 Mar 2013 17:20:36 +0800 Subject: [PATCH] IDEMPIERE-761 New record on role is showing role 0 info on detail. --- .../adempiere/webui/adwindow/ADSortTab.java | 19 ++++++++++++++ .../adempiere/webui/adwindow/ADTabpanel.java | 26 +++++++++++++++++++ .../webui/adwindow/CompositeADTabbox.java | 8 ++++-- .../adempiere/webui/adwindow/IADTabpanel.java | 5 ++++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java index 99a082eb2d..0076c7c5f3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java @@ -989,5 +989,24 @@ public class ADSortTab extends Panel implements IADTabpanel public DetailPane getDetailPane() { return null; } + + @Override + public void resetDetailForNewParentRecord() { + yesModel.removeAllElements(); + noModel.removeAllElements(); + + setIsChanged(false); + bAdd.setEnabled(false); + bRemove.setEnabled(false); + bUp.setEnabled(false); + bDown.setEnabled(false); + yesList.setEnabled(false); + noList.setEnabled(false); + + yesList.setItemRenderer(yesModel); + yesList.setModel(yesModel); + noList.setItemRenderer(noModel); + noList.setModel(noModel); + } } //ADSortTab diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java index f112f6f80a..c582e9ebed 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java @@ -233,6 +233,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer listPanel.getListbox().addEventListener(Events.ON_DOUBLE_CLICK, this); } + @Override public void setDetailPane(DetailPane component) { detailPane = component; @@ -272,6 +273,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer south.setSclass("adwindow-gridview-detail"); } + @Override public DetailPane getDetailPane() { return detailPane; } @@ -389,6 +391,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * Create UI components if not already created */ + @Override public void createUI() { if (uiCreated) return; @@ -649,6 +652,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer * Validate display properties of fields of current row * @param col */ + @Override public void dynamicDisplay (int col) { if (!gridTab.isOpen()) @@ -796,6 +800,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * @return String */ + @Override public String getDisplayLogic() { return gridTab.getDisplayLogic(); @@ -804,6 +809,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * @return String */ + @Override public String getTitle() { return gridTab.getName(); @@ -812,6 +818,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * @param variableName */ + @Override public String get_ValueAsString(String variableName) { return Env.getContext(Env.getCtx(), windowNo, variableName); @@ -820,6 +827,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * @return The tab level of this Tabpanel */ + @Override public int getTabLevel() { return gridTab.getTabLevel(); @@ -828,6 +836,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * @return The tablename of this Tabpanel */ + @Override public String getTableName() { return gridTab.getTableName(); @@ -836,6 +845,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * @return The record ID of this Tabpanel */ + @Override public int getRecord_ID() { return gridTab.getRecord_ID(); @@ -845,6 +855,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer * Is panel need refresh * @return boolean */ + @Override public boolean isCurrent() { return gridTab != null ? gridTab.isCurrent() : false; @@ -862,6 +873,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer /** * Retrieve from db */ + @Override public void query() { boolean open = gridTab.isOpen(); @@ -876,6 +888,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer * @param onlyCurrentDays * @param maxRows */ + @Override public void query (boolean onlyCurrentRows, int onlyCurrentDays, int maxRows) { boolean open = gridTab.isOpen(); @@ -884,6 +897,19 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer gridTab.getTableModel().fireTableDataChanged(); } + /** + * clear data grid for new parent record that's not saved yet + */ + @Override + public void resetDetailForNewParentRecord () + { + boolean open = gridTab.isOpen(); + if (open) + { + gridTab.clearForNewParentRecord(); + } + } + /** * @return GridTab */ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java index d103b72663..e8a283b252 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java @@ -728,8 +728,12 @@ public class CompositeADTabbox extends AbstractADTabbox } private void onActivateDetail(IADTabpanel tabPanel) { - tabPanel.createUI(); - tabPanel.query(false, 0, 0); + tabPanel.createUI(); + if (headerTab.getGridTab().isNew()) { + tabPanel.resetDetailForNewParentRecord(); + } else { + tabPanel.query(false, 0, 0); + } if (!tabPanel.isVisible()) tabPanel.setVisible(true); if (!tabPanel.isGridView()) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java index aa1efe2c12..f417de2c47 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java @@ -180,4 +180,9 @@ public interface IADTabpanel extends Component, Evaluatee { * @return detailpane */ public DetailPane getDetailPane(); + + /** + * reset detail data grid when parent tab current record is new and not saved yet + */ + public abstract void resetDetailForNewParentRecord(); }