diff --git a/client/src/org/compiere/apps/APanel.java b/client/src/org/compiere/apps/APanel.java index a43c6b9afe..5cf87fbdd6 100644 --- a/client/src/org/compiere/apps/APanel.java +++ b/client/src/org/compiere/apps/APanel.java @@ -516,6 +516,7 @@ public final class APanel extends CPanel boolean included = false; // MTab GridTab gTab = m_mWorkbench.getMWindow(wb).getTab(tab); + Env.setContext(m_ctx, m_curWindowNo, tab, "TabLevel", Integer.toString(gTab.getTabLevel())); // Query first tab if (tab == 0) { @@ -1127,8 +1128,29 @@ public final class APanel extends CPanel int index = m_curWinTab.getSelectedIndex(); if (index == m_curWinTab.getTabCount()-1) return; - m_curGC.getTable().removeEditor(); - m_curWinTab.setSelectedIndex(index+1); + //hengsin, bug [ 1637763 ] + if (m_curWinTab instanceof VTabbedPane) + { + VTabbedPane tabPane = (VTabbedPane)m_curWinTab; + index++; + while ( index < tabPane.getTabCount() ) + { + if (tabPane.isEnabledAt(index)) + { + m_curGC.getTable().removeEditor(); + tabPane.setSelectedIndex(index); + break; + } + else + index++; + } + } + else + { + m_curGC.getTable().removeEditor(); + m_curWinTab.setSelectedIndex(index+1); + } + } // navigateDetail /** @@ -1139,8 +1161,28 @@ public final class APanel extends CPanel int index = m_curWinTab.getSelectedIndex(); if (index == 0) return; - m_curGC.getTable().removeEditor(); - m_curWinTab.setSelectedIndex(index-1); + //hengsin, bug [ 1637763 ] + if (m_curWinTab instanceof VTabbedPane) + { + VTabbedPane tabPane = (VTabbedPane)m_curWinTab; + index--; + while ( index >= 0 ) + { + if (tabPane.isEnabledAt(index)) + { + m_curGC.getTable().removeEditor(); + tabPane.setSelectedIndex(index); + break; + } + else + index--; + } + } + else + { + m_curGC.getTable().removeEditor(); + m_curWinTab.setSelectedIndex(index-1); + } } // navigateParent diff --git a/client/src/org/compiere/grid/GridController.java b/client/src/org/compiere/grid/GridController.java index 6155405db0..57a8509055 100644 --- a/client/src/org/compiere/grid/GridController.java +++ b/client/src/org/compiere/grid/GridController.java @@ -1098,5 +1098,12 @@ public class GridController extends CPanel return Env.getContext(Env.getCtx(), m_WindowNo, variableName); } // get_ValueAsString - + /** + * Is controller data not stale + * @return boolean + */ + public boolean isCurrent() + { + return m_mTab != null ? m_mTab.isCurrent() : false; + } } // GridController diff --git a/client/src/org/compiere/grid/VTabbedPane.java b/client/src/org/compiere/grid/VTabbedPane.java index 8f4abf5543..e186c12e4a 100644 --- a/client/src/org/compiere/grid/VTabbedPane.java +++ b/client/src/org/compiere/grid/VTabbedPane.java @@ -146,6 +146,38 @@ public class VTabbedPane extends CTabbedPane removeAll(); } // dispose + @Override + //hengsin, bug [ 1637763 ] + public boolean isEnabledAt(int index) { + boolean enabled = super.isEnabledAt(index); + if (!enabled) return enabled; + Component comp = getComponentAt(index); + GridController gc = null; + if (comp instanceof GridController) + gc = (GridController)comp; + // Display + if (gc != null) + { + enabled = isDisplay(gc); + } + return enabled; + } + + //hengsin, bug [ 1637763 ] + private boolean isDisplay(GridController gc) + { + String logic = gc.getDisplayLogic(); + if (logic != null && logic.length() > 0) + { + boolean display = Evaluator.evaluateLogic(gc, logic); + if (!display) + { + log.info("Not displayed - " + logic); + return false; + } + } + return true; + } /** * Set Selected Index. @@ -161,16 +193,9 @@ public class VTabbedPane extends CTabbedPane // Display if (newGC != null) { - String logic = newGC.getDisplayLogic(); - if (logic != null && logic.length() > 0) - { - boolean display = Evaluator.evaluateLogic(newGC, logic); - if (!display) - { - log.info("Not displayed - " + logic); - return; - } - } + //hengsin, bug [ 1637763 ] + if(isDisplay(newGC) == false) + return; } // @@ -183,23 +208,38 @@ public class VTabbedPane extends CTabbedPane GridController oldGC = (GridController)oldC; if (newGC.getTabLevel() > oldGC.getTabLevel()+1) { + // validate // Search for right tab + GridController rightGC = null; + boolean canJump = true; + int currentLevel = newGC.getTabLevel(); for (int i = index-1; i >=0; i--) { Component rightC = getComponentAt(i); - GridController rightGC = null; if (rightC instanceof GridController) { - rightGC = (GridController)rightC; - if (rightGC.getTabLevel() == oldGC.getTabLevel()+1) + GridController gc = (GridController)rightC; + //can only skip level if all parent data are not stale + if (gc.getTabLevel() < currentLevel) { - ADialog.warn(0, this, "TabSwitchJumpGo", rightGC.getTitle()); - return; + if (gc.getTabLevel() == oldGC.getTabLevel()+1) + { + rightGC = gc; + } + if (!gc.isCurrent()) + canJump = false; + currentLevel = gc.getTabLevel(); } } } - ADialog.warn(0, this, "TabSwitchJump"); - return; + if (canJump == false) + { + if (rightGC != null ) + ADialog.warn(0, this, "TabSwitchJumpGo", rightGC.getTitle()); + else + ADialog.warn(0, this, "TabSwitchJump"); + return; + } } oldGC.setMnemonics(false); }