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++) {
|
for (int i = 0; i < userQueries.length; i++) {
|
||||||
Comboitem li = fQueryName.appendItem(userQueries[i].getName());
|
Comboitem li = fQueryName.appendItem(userQueries[i].getName());
|
||||||
li.setValue(userQueries[i].getAD_UserQuery_ID());
|
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);
|
fQueryName.setSelectedItem(li);
|
||||||
|
if (AD_UserQuery_ID != getAD_UserQuery_ID())
|
||||||
|
setSelectedUserQuery(AD_UserQuery_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (AD_UserQuery_ID <= 0 || fQueryName.getItemCount() <= 1)
|
if (AD_UserQuery_ID <= 0 || fQueryName.getItemCount() <= 1
|
||||||
fQueryName.setValue("");
|
|| 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) {
|
public void setSelectedUserQuery(MUserQuery selectedUserQuery) {
|
||||||
this.selectedUserQuery = selectedUserQuery;
|
this.selectedUserQuery = selectedUserQuery;
|
||||||
if (selectedUserQuery != null)
|
if (selectedUserQuery != null)
|
||||||
|
|
|
@ -729,10 +729,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
m_findCancelled = false;
|
m_findCancelled = false;
|
||||||
m_findCreateNew = false;
|
m_findCreateNew = false;
|
||||||
GridField[] findFields = mTab.getFields();
|
GridField[] findFields = mTab.getFields();
|
||||||
findWindow = new FindWindow(curWindowNo,
|
FindWindow findWindow = new FindWindow(curWindowNo,
|
||||||
mTab.getName(), mTab.getAD_Table_ID(), mTab.getTableName(),
|
mTab.getName(), mTab.getAD_Table_ID(), mTab.getTableName(),
|
||||||
where.toString(), findFields, 10, mTab.getAD_Tab_ID()); // no query below 10
|
where.toString(), findFields, 10, mTab.getAD_Tab_ID()); // no query below 10
|
||||||
setupEmbeddedFindwindow();
|
tabFindWindowHashMap.put(mTab, findWindow);
|
||||||
|
setupEmbeddedFindwindow(findWindow);
|
||||||
if (findWindow.initialize())
|
if (findWindow.initialize())
|
||||||
{
|
{
|
||||||
findWindow.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
findWindow.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||||
|
@ -773,7 +774,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
}
|
}
|
||||||
} // initialQuery
|
} // initialQuery
|
||||||
|
|
||||||
private void setupEmbeddedFindwindow() {
|
private void setupEmbeddedFindwindow(FindWindow findWindow) {
|
||||||
findWindow.setTitle(null);
|
findWindow.setTitle(null);
|
||||||
findWindow.setBorder("none");
|
findWindow.setBorder("none");
|
||||||
findWindow.setStyle("position: absolute;background-color: #fff;");
|
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_lock = null;
|
||||||
private Menuitem m_access = 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;
|
private Div mask;
|
||||||
|
|
||||||
|
@ -1450,7 +1452,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
toolbar.setPressed("Find",adTabbox.getSelectedGridTab().isQueryActive() ||
|
toolbar.setPressed("Find",adTabbox.getSelectedGridTab().isQueryActive() ||
|
||||||
(!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0)));
|
(!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);
|
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();
|
boolean isNewRow = adTabbox.getSelectedGridTab().getRowCount() == 0 || adTabbox.getSelectedGridTab().isNew();
|
||||||
toolbar.enableArchive(!isNewRow);
|
toolbar.enableArchive(!isNewRow);
|
||||||
|
@ -1831,7 +1840,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
toolbar.enableRequests(!isNewRow);
|
toolbar.enableRequests(!isNewRow);
|
||||||
toolbar.setPressed("Find", adTabbox.getSelectedGridTab().isQueryActive() ||
|
toolbar.setPressed("Find", adTabbox.getSelectedGridTab().isQueryActive() ||
|
||||||
(!isNewRow && (m_onlyCurrentRows || m_onlyCurrentDays > 0)));
|
(!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.enablePrint(adTabbox.getSelectedGridTab().isPrinted() && !isNewRow);
|
||||||
toolbar.enableReport(!isNewRow);
|
toolbar.enableReport(!isNewRow);
|
||||||
|
@ -2137,30 +2149,21 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
private void doOnFind() {
|
private void doOnFind() {
|
||||||
// Gets Fields from AD_Field_v
|
// Gets Fields from AD_Field_v
|
||||||
GridField[] findFields = adTabbox.getSelectedGridTab().getFields();
|
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().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
||||||
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID())) {
|
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID())) {
|
||||||
findWindow = new FindWindow (adTabbox.getSelectedGridTab().getWindowNo(), adTabbox.getSelectedGridTab().getName(),
|
if (!getFindWindow(findFields))
|
||||||
adTabbox.getSelectedGridTab().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
return;
|
||||||
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 (!findWindow.getEventListeners(DialogEvents.ON_WINDOW_CLOSE).iterator().hasNext()) {
|
if (!getCurrentFindWindow().getEventListeners(DialogEvents.ON_WINDOW_CLOSE).iterator().hasNext()) {
|
||||||
findWindow.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
getCurrentFindWindow().addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
hideBusyMask();
|
hideBusyMask();
|
||||||
if (!findWindow.isCancel())
|
if (!getCurrentFindWindow().isCancel())
|
||||||
{
|
{
|
||||||
MQuery query = findWindow.getQuery();
|
MQuery query = getCurrentFindWindow().getQuery();
|
||||||
|
|
||||||
// Confirmed query
|
// Confirmed query
|
||||||
if (query != null)
|
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
|
adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, adTabbox.getSelectedGridTab().getMaxQueryRecords()); // autoSize
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findWindow.isCreateNew())
|
if (getCurrentFindWindow().isCreateNew())
|
||||||
onNew();
|
onNew();
|
||||||
else {
|
else {
|
||||||
adTabbox.getSelectedGridTab().dataRefresh(false); // Elaine 2008/07/25
|
adTabbox.getSelectedGridTab().dataRefresh(false); // Elaine 2008/07/25
|
||||||
|
@ -2194,7 +2197,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
adTabbox.getSelectedTabpanel().switchRowPresentation();
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -2205,9 +2208,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getComponent().getParent().appendChild(findWindow);
|
getComponent().getParent().appendChild(getCurrentFindWindow());
|
||||||
showBusyMask(findWindow);
|
showBusyMask(getCurrentFindWindow());
|
||||||
LayoutUtils.openEmbeddedWindow(toolbar, findWindow, "after_start");
|
LayoutUtils.openEmbeddedWindow(toolbar, getCurrentFindWindow(), "after_start");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2939,25 +2942,17 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
public void doOnQueryChange() {
|
public void doOnQueryChange() {
|
||||||
// Gets Fields from AD_Field_v
|
// Gets Fields from AD_Field_v
|
||||||
GridField[] findFields = adTabbox.getSelectedGridTab().getFields();
|
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().getAD_Table_ID(), adTabbox.getSelectedGridTab().getTableName(),
|
||||||
adTabbox.getSelectedGridTab().getWhereExtended(), findFields, 1, adTabbox.getSelectedGridTab().getAD_Tab_ID())) {
|
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 (!getFindWindow(findFields))
|
||||||
if (!findWindow.initialize()) {
|
return;
|
||||||
if (findWindow.getTotalRecords() == 0) {
|
|
||||||
FDialog.info(curWindowNo, getComponent(), "NoRecordsFound");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
findWindow.setAD_UserQuery_ID(toolbar.getAD_UserQuery_ID());
|
getCurrentFindWindow().setAD_UserQuery_ID(toolbar.getAD_UserQuery_ID());
|
||||||
findWindow.advancedOkClick();
|
getCurrentFindWindow().advancedOkClick();
|
||||||
MQuery query = findWindow.getQuery();
|
MQuery query = getCurrentFindWindow().getQuery();
|
||||||
|
|
||||||
// Confirmed query
|
// Confirmed query
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
|
@ -2969,7 +2964,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
adTabbox.getSelectedGridTab().dataRefresh(false);
|
adTabbox.getSelectedGridTab().dataRefresh(false);
|
||||||
|
|
||||||
focusToActivePanel();
|
focusToActivePanel();
|
||||||
findWindow.dispose();
|
getCurrentFindWindow().dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -3622,8 +3617,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelect() {
|
public void onSelect() {
|
||||||
if (findWindow != null && findWindow.getPage() != null && findWindow.isVisible() && m_queryInitiating) {
|
if (getCurrentFindWindow() != null && getCurrentFindWindow().getPage() != null && getCurrentFindWindow().isVisible() && m_queryInitiating) {
|
||||||
LayoutUtils.openEmbeddedWindow(getComponent().getParent(), findWindow, "overlap");
|
LayoutUtils.openEmbeddedWindow(getComponent().getParent(), getCurrentFindWindow(), "overlap");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3639,6 +3634,40 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
return adwindow;
|
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() {
|
private void clearTitleRelatedContext() {
|
||||||
// IDEMPIERE-1328
|
// IDEMPIERE-1328
|
||||||
// clear the values for the tab header
|
// clear the values for the tab header
|
||||||
|
|
Loading…
Reference in New Issue