IDEMPIERE-2125 Error in creating recent item avoids to save any record - refactor and apply same code from tbayen in two more places where is needed

This commit is contained in:
Carlos Ruiz 2014-08-08 19:02:55 +02:00
parent d76804a007
commit 9d6fbe06d2
1 changed files with 15 additions and 11 deletions

View File

@ -1517,14 +1517,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
Env.getAD_Role_ID(ctx), adTabbox.getSelectedGridTab().getAD_Window_ID(),
adTabbox.getSelectedGridTab().getAD_Tab_ID());
} else {
/* when a detail record is modified add header to recent items */
GridTab mainTab = adTabbox.getSelectedGridTab(); // find parent tab (IDEMPIERE-2125 - tbayen)
while (mainTab != null && mainTab.getTabLevel() > 0) {
GridTab parentTab = mainTab.getParentTab();
if (parentTab == mainTab)
break;
mainTab = parentTab;
}
GridTab mainTab = getMainTabAbove();
if (mainTab != null) {
MRecentItem.addModifiedField(ctx, mainTab.getAD_Table_ID(),
mainTab.getRecord_ID(), Env.getAD_User_ID(ctx),
@ -2176,8 +2169,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
Env.getAD_Role_ID(ctx), adTabbox.getSelectedGridTab().getAD_Window_ID(),
adTabbox.getSelectedGridTab().getAD_Tab_ID());
} else {
/* when a detail record is modified add header to recent items */
GridTab mainTab = gridWindow.getTab(0);
GridTab mainTab = getMainTabAbove();
if (mainTab != null) {
MRecentItem.addModifiedField(ctx, mainTab.getAD_Table_ID(),
mainTab.getRecord_ID(), Env.getAD_User_ID(ctx),
@ -2191,7 +2183,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
MRecentItem.touchUpdatedRecord(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(),
adTabbox.getSelectedGridTab().getRecord_ID(), Env.getAD_User_ID(ctx));
} else {
GridTab mainTab = gridWindow.getTab(0);
GridTab mainTab = getMainTabAbove();
if (mainTab != null) {
MRecentItem.touchUpdatedRecord(ctx, mainTab.getAD_Table_ID(),
mainTab.getRecord_ID(), Env.getAD_User_ID(ctx));
@ -2209,6 +2201,18 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
callback.onCallback(true);
}
private GridTab getMainTabAbove() {
/* when a detail record is modified add header to recent items */
GridTab mainTab = adTabbox.getSelectedGridTab(); // find parent tab (IDEMPIERE-2125 - tbayen)
while (mainTab != null && mainTab.getTabLevel() > 0) {
GridTab parentTab = mainTab.getParentTab();
if (parentTab == mainTab)
break;
mainTab = parentTab;
}
return mainTab;
}
private void showLastError() {
String msg = CLogger.retrieveErrorString(null);
if (msg != null)