From 8de7da2ea551dfc9f369a14af6471f3d9de63cc5 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 24 Sep 2012 16:31:22 -0500 Subject: [PATCH] IDEMPIERE-382 Prevent users to go to detail tabs if link fields are not filled / fix problem with zero ID tables --- .../src/org/compiere/grid/VTabbedPane.java | 6 ++++-- .../src/org/adempiere/webui/component/AbstractADTab.java | 8 ++++++-- .../WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java | 5 +++++ .../WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java | 8 ++++++++ .../src/org/adempiere/webui/panel/IADTabpanel.java | 5 +++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VTabbedPane.java b/org.adempiere.ui.swing/src/org/compiere/grid/VTabbedPane.java index 846f379e3b..8c4bddfa12 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VTabbedPane.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/VTabbedPane.java @@ -26,6 +26,7 @@ import org.compiere.apps.ADialog; import org.compiere.apps.APanel; import org.compiere.model.DataStatusEvent; import org.compiere.model.GridTab; +import org.compiere.model.MTable; import org.compiere.swing.CTabbedPane; import org.compiere.util.CLogger; import org.compiere.util.Env; @@ -272,14 +273,15 @@ public class VTabbedPane extends CTabbedPane if (oldC != null && oldC instanceof GridController) { GridController oldGC = (GridController)oldC; + int zeroValid = (MTable.isZeroIDTable(oldGC.getMTab().getTableName()) ? 1 : 0); if ((newGC.getTabLevel() > oldGC.getTabLevel()+1) - || (newGC.getTabLevel() > oldGC.getTabLevel() && oldGC.getMTab().getRecord_ID() <=0)) // TabLevel increase and parent ID <=0 IDEMPIERE 382 + || (newGC.getTabLevel() > oldGC.getTabLevel() && oldGC.getMTab().getRecord_ID()+zeroValid <=0)) // TabLevel increase and parent ID <=0 IDEMPIERE 382 { // validate // Search for right tab GridController rightGC = null; //boolean canJump = true; - boolean canJump = oldGC.getMTab().getRecord_ID() <=0 ? false : true; // IDEMPIERE 382 + boolean canJump = oldGC.getMTab().getRecord_ID()+zeroValid <=0 ? false : true; // IDEMPIERE 382 int currentLevel = newGC.getTabLevel(); for (int i = index-1; i >=0; i--) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AbstractADTab.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AbstractADTab.java index 522e606662..cb7a22bce6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AbstractADTab.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AbstractADTab.java @@ -29,6 +29,7 @@ import org.adempiere.webui.part.AbstractUIPart; import org.compiere.model.DataStatusEvent; import org.compiere.model.GridField; import org.compiere.model.GridTab; +import org.compiere.model.MTable; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Evaluator; @@ -242,8 +243,11 @@ public abstract class AbstractADTab extends AbstractUIPart implements IADTab currentLevel = tabPanel.getTabLevel(); } } - if (canJump && checkRecordID && oldTabpanel.getRecord_ID() <= 0) - canJump = false; + if (canJump && checkRecordID ) { + int zeroValid = (MTable.isZeroIDTable(oldTabpanel.getTableName()) ? 1 : 0); + if (oldTabpanel.getRecord_ID() + zeroValid <= 0) + canJump = false; + } } } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java index 433341c326..e1641dd27a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java @@ -870,6 +870,11 @@ public class ADSortTab extends Panel implements IADTabpanel return gridTab.getTabLevel(); } + public String getTableName() + { + return gridTab.getTableName(); + } + public int getRecord_ID() { return gridTab.getRecord_ID(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java index c982cee1c6..9510a7620c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java @@ -670,6 +670,14 @@ DataStatusListener, IADTabpanel return gridTab.getTabLevel(); } + /** + * @return The tablename of this Tabpanel + */ + public String getTableName() + { + return gridTab.getTableName(); + } + /** * @return The record ID of this Tabpanel */ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java index 76509b9bb4..93ae8da7b1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java @@ -33,6 +33,11 @@ public interface IADTabpanel extends Component, Evaluatee { */ public int getTabLevel(); + /** + * @return tablename + */ + public String getTableName(); + /** * @return record ID */