IDEMPIERE-4380 Inconsistencies with selected filter query on tab navigation (#181)
* IDEMPIERE-4380 Inconcistencies with selected filter query on tab navigation * IDEMPIERE-4380 Heng Sin Peer review
This commit is contained in:
parent
a88d766078
commit
763876cca3
|
@ -1219,13 +1219,26 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
for (int i = 0; i < userQueries.length; i++) {
|
||||
Comboitem li = fQueryName.appendItem(userQueries[i].getName());
|
||||
li.setValue(userQueries[i].getAD_UserQuery_ID());
|
||||
if (AD_UserQuery_ID == userQueries[i].getAD_UserQuery_ID())
|
||||
if (AD_UserQuery_ID == userQueries[i].getAD_UserQuery_ID()) {
|
||||
fQueryName.setSelectedItem(li);
|
||||
if (AD_UserQuery_ID != getAD_UserQuery_ID())
|
||||
setSelectedUserQuery(AD_UserQuery_ID);
|
||||
}
|
||||
}
|
||||
if (AD_UserQuery_ID <= 0 || fQueryName.getItemCount() <= 1)
|
||||
fQueryName.setValue("");
|
||||
if (AD_UserQuery_ID <= 0 || fQueryName.getItemCount() <= 1
|
||||
|| fQueryName.getSelectedItem() == null)
|
||||
fQueryName.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
public void setSelectedUserQuery(int AD_UserQuery_ID) {
|
||||
for (MUserQuery userQuery : userQueries) {
|
||||
if (AD_UserQuery_ID == userQuery.getAD_UserQuery_ID()) {
|
||||
selectedUserQuery = userQuery;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedUserQuery(MUserQuery selectedUserQuery) {
|
||||
this.selectedUserQuery = selectedUserQuery;
|
||||
if (selectedUserQuery != null)
|
||||
|
|
|
@ -729,10 +729,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
m_findCancelled = false;
|
||||
m_findCreateNew = false;
|
||||
GridField[] findFields = mTab.getFields();
|
||||
findWindow = new FindWindow(curWindowNo,
|
||||
FindWindow findWindow = new FindWindow(curWindowNo,
|
||||
mTab.getName(), mTab.getAD_Table_ID(), mTab.getTableName(),
|
||||
where.toString(), findFields, 10, mTab.getAD_Tab_ID()); // no query below 10
|
||||
setupEmbeddedFindwindow();
|
||||
tabFindWindowHashMap.put(mTab, findWindow);
|
||||
setupEmbeddedFindwindow(findWindow);
|
||||
if (findWindow.initialize())
|
||||
{
|
||||
findWindow.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
|
@ -773,7 +774,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
}
|
||||
} // initialQuery
|
||||
|
||||
private void setupEmbeddedFindwindow() {
|
||||
private void setupEmbeddedFindwindow(FindWindow findWindow) {
|
||||
findWindow.setTitle(null);
|
||||
findWindow.setBorder("none");
|
||||
findWindow.setStyle("position: absolute;background-color: #fff;");
|
||||
|
@ -906,7 +907,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
private Menuitem m_lock = null;
|
||||
private Menuitem m_access = null;
|
||||
|
||||
private FindWindow findWindow;
|
||||
private HashMap<GridTab, FindWindow> tabFindWindowHashMap = new HashMap<GridTab, FindWindow>();
|
||||
private int masterRecord = -1;
|
||||
|
||||
private Div mask;
|
||||
|
||||
|
@ -1450,7 +1452,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
toolbar.setPressed("Find",adTabbox.getSelectedGridTab().isQueryActive() ||
|
||||
(!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0)));
|
||||
|
||||
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), findWindow != null ? findWindow.getAD_UserQuery_ID() : 0);
|
||||
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), getCurrentFindWindow() != null ? getCurrentFindWindow().getAD_UserQuery_ID() : 0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1823,6 +1825,13 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
{
|
||||
adTabbox.evaluate(e);
|
||||
}
|
||||
|
||||
int record_ID = adTabbox.getSelectedGridTab().getRecord_ID();
|
||||
|
||||
if (adTabbox.getSelectedGridTab().getTabLevel() == 0 && record_ID != masterRecord) {
|
||||
clenFindWindowHashMap();
|
||||
masterRecord = record_ID;
|
||||
}
|
||||
|
||||
boolean isNewRow = adTabbox.getSelectedGridTab().getRowCount() == 0 || adTabbox.getSelectedGridTab().isNew();
|
||||
toolbar.enableArchive(!isNewRow);
|
||||
|
@ -1831,7 +1840,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
toolbar.enableRequests(!isNewRow);
|
||||
toolbar.setPressed("Find", adTabbox.getSelectedGridTab().isQueryActive() ||
|
||||
(!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0)));
|
||||
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), findWindow != null ? findWindow.getAD_UserQuery_ID() : 0);
|
||||
/*if (adTabbox.getSelectedGridTab().isQueryActive() &&
|
||||
tabFindWindowHashMap.get(adTabbox.getSelectedGridTab()) != null)
|
||||
findWindow = tabFindWindowHashMap.get(adTabbox.getSelectedGridTab());*/
|
||||
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), getCurrentFindWindow() != null ? getCurrentFindWindow().getAD_UserQuery_ID() : 0);
|
||||
|
||||
toolbar.enablePrint(adTabbox.getSelectedGridTab().isPrinted() && !isNewRow);
|
||||
toolbar.enableReport(!isNewRow);
|
||||
|
@ -2137,30 +2149,21 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
private void doOnFind() {
|
||||
// Gets Fields from AD_Field_v
|
||||
GridField[] findFields = adTabbox.getSelectedGridTab().getFields();
|
||||
if (findWindow == null || !findWindow.validate(adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
||||
if (getCurrentFindWindow() == null || !getCurrentFindWindow().validate(adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
||||
adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
||||
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID())) {
|
||||
findWindow = new FindWindow (adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
||||
adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
||||
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID());
|
||||
|
||||
setupEmbeddedFindwindow();
|
||||
if (!findWindow.initialize()) {
|
||||
if (findWindow.getTotalRecords() == 0) {
|
||||
FDialog.info(curWindowNo, getComponent(), "NoRecordsFound");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!getFindWindow(findFields))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!findWindow.getEventListeners(DialogEvents.ON_WINDOW_CLOSE).iterator().hasNext()) {
|
||||
findWindow.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
if (!getCurrentFindWindow().getEventListeners(DialogEvents.ON_WINDOW_CLOSE).iterator().hasNext()) {
|
||||
getCurrentFindWindow().addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
hideBusyMask();
|
||||
if (!findWindow.isCancel())
|
||||
if (!getCurrentFindWindow().isCancel())
|
||||
{
|
||||
MQuery query = findWindow.getQuery();
|
||||
MQuery query = getCurrentFindWindow().getQuery();
|
||||
|
||||
// Confirmed query
|
||||
if (query != null)
|
||||
|
@ -2170,7 +2173,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, adTabbox.getSelectedGridTab().getMaxQueryRecords()); // autoSize
|
||||
}
|
||||
|
||||
if (findWindow.isCreateNew())
|
||||
if (getCurrentFindWindow().isCreateNew())
|
||||
onNew();
|
||||
else {
|
||||
adTabbox.getSelectedGridTab().dataRefresh(false); // Elaine 2008/07/25
|
||||
|
@ -2194,7 +2197,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
adTabbox.getSelectedTabpanel().switchRowPresentation();
|
||||
}
|
||||
}
|
||||
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), findWindow.getAD_UserQuery_ID());
|
||||
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), getCurrentFindWindow().getAD_UserQuery_ID());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2205,9 +2208,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
});
|
||||
}
|
||||
|
||||
getComponent().getParent().appendChild(findWindow);
|
||||
showBusyMask(findWindow);
|
||||
LayoutUtils.openEmbeddedWindow(toolbar, findWindow, "after_start");
|
||||
getComponent().getParent().appendChild(getCurrentFindWindow());
|
||||
showBusyMask(getCurrentFindWindow());
|
||||
LayoutUtils.openEmbeddedWindow(toolbar, getCurrentFindWindow(), "after_start");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2939,25 +2942,17 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
public void doOnQueryChange() {
|
||||
// Gets Fields from AD_Field_v
|
||||
GridField[] findFields = adTabbox.getSelectedGridTab().getFields();
|
||||
if (findWindow == null || !findWindow.validate(adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
||||
if (getCurrentFindWindow() == null || !getCurrentFindWindow().validate(adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
||||
adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
||||
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID())) {
|
||||
findWindow = new FindWindow (adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
||||
adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
||||
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID());
|
||||
|
||||
setupEmbeddedFindwindow();
|
||||
if (!findWindow.initialize()) {
|
||||
if (findWindow.getTotalRecords() == 0) {
|
||||
FDialog.info(curWindowNo, getComponent(), "NoRecordsFound");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!getFindWindow(findFields))
|
||||
return;
|
||||
}
|
||||
|
||||
findWindow.setAD_UserQuery_ID(toolbar.getAD_UserQuery_ID());
|
||||
findWindow.advancedOkClick();
|
||||
MQuery query = findWindow.getQuery();
|
||||
getCurrentFindWindow().setAD_UserQuery_ID(toolbar.getAD_UserQuery_ID());
|
||||
getCurrentFindWindow().advancedOkClick();
|
||||
MQuery query = getCurrentFindWindow().getQuery();
|
||||
|
||||
// Confirmed query
|
||||
if (query != null) {
|
||||
|
@ -2969,7 +2964,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
adTabbox.getSelectedGridTab().dataRefresh(false);
|
||||
|
||||
focusToActivePanel();
|
||||
findWindow.dispose();
|
||||
getCurrentFindWindow().dispose();
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -3622,8 +3617,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
|
||||
@Override
|
||||
public void onSelect() {
|
||||
if (findWindow != null && findWindow.getPage() != null && findWindow.isVisible() && m_queryInitiating) {
|
||||
LayoutUtils.openEmbeddedWindow(getComponent().getParent(), findWindow, "overlap");
|
||||
if (getCurrentFindWindow() != null && getCurrentFindWindow().getPage() != null && getCurrentFindWindow().isVisible() && m_queryInitiating) {
|
||||
LayoutUtils.openEmbeddedWindow(getComponent().getParent(), getCurrentFindWindow(), "overlap");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3639,6 +3634,40 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
return adwindow;
|
||||
}
|
||||
|
||||
public boolean getFindWindow(GridField[] findFields) {
|
||||
FindWindow findWindow;
|
||||
if (tabFindWindowHashMap.get(adTabbox.getSelectedGridTab()) != null) {
|
||||
findWindow = tabFindWindowHashMap.get(adTabbox.getSelectedGridTab());
|
||||
toolbar.setSelectedUserQuery(findWindow.getAD_UserQuery_ID());
|
||||
} else {
|
||||
findWindow = new FindWindow (adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
||||
adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
||||
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID());
|
||||
|
||||
setupEmbeddedFindwindow(findWindow);
|
||||
if (!findWindow.initialize()) {
|
||||
if (findWindow.getTotalRecords() == 0) {
|
||||
FDialog.info(curWindowNo, getComponent(), "NoRecordsFound");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
tabFindWindowHashMap.put(adTabbox.getSelectedGridTab(), findWindow);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public FindWindow getCurrentFindWindow() {
|
||||
return tabFindWindowHashMap.get(adTabbox.getSelectedGridTab());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean all the detail cached FindWindow objects
|
||||
* when the master record is changed
|
||||
*/
|
||||
private void clenFindWindowHashMap() {
|
||||
tabFindWindowHashMap.keySet().removeIf(tab -> tab.getTabLevel() != 0);
|
||||
}
|
||||
|
||||
private void clearTitleRelatedContext() {
|
||||
// IDEMPIERE-1328
|
||||
// clear the values for the tab header
|
||||
|
|
Loading…
Reference in New Issue