IDEMPIERE-5772 - Info Window Ctx - Paging Issue (#1952)
* IDEMPIERE-5772 - Info Window Ctx - Paging Issue * IDEMPIERE-5772 - Info Window Ctx - Paging Issue * IDEMPIERE-5772 - update javadoc * Fix trying to access nonexistent field error * IDEMPIERE-5772 - Fix bug in maintaining user selection order
This commit is contained in:
parent
9678c01664
commit
fa7a8d46bf
|
@ -628,9 +628,9 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx()));
|
private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx()));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the indexes of selected row, maintains the selection order
|
* Contains the keys of the selected rows in the order of selection
|
||||||
*/
|
*/
|
||||||
protected ArrayList<Integer> m_rowSelectionOrder = new ArrayList<Integer>();
|
protected ArrayList<Object> m_rowSelectionOrder = new ArrayList<Object>();
|
||||||
/**
|
/**
|
||||||
* Number of selected rows
|
* Number of selected rows
|
||||||
*/
|
*/
|
||||||
|
@ -3410,25 +3410,37 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
* Update row selection order
|
* Update row selection order
|
||||||
*/
|
*/
|
||||||
protected void updateRowSelectionOrder() {
|
protected void updateRowSelectionOrder() {
|
||||||
if(m_selectedCount == m_count) {
|
// check if any rows are found
|
||||||
for(int rowIdx = 0; rowIdx < m_count; rowIdx++) {
|
if(contentPanel.getModel().size() <= 0) {
|
||||||
if(!m_rowSelectionOrder.contains(rowIdx))
|
|
||||||
m_rowSelectionOrder.add((Integer)rowIdx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(m_selectedCount == 0) {
|
|
||||||
m_rowSelectionOrder.clear();
|
m_rowSelectionOrder.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// update selection
|
||||||
|
if(!p_multipleSelection && m_lastSelectedIndex >= 0) {
|
||||||
|
m_rowSelectionOrder.clear();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Object> lastSelectedRecord = (List<Object>)contentPanel.getModel().get(m_lastSelectedIndex);
|
||||||
|
Object key = lastSelectedRecord.get(0);
|
||||||
|
if(key instanceof IDColumn)
|
||||||
|
key = ((IDColumn)key).getRecord_ID();
|
||||||
|
m_rowSelectionOrder.add(key);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!p_multipleSelection) {
|
// add selected rows
|
||||||
m_rowSelectionOrder.clear();
|
for(Map.Entry<Object, List<Object>> entry : getSelectedRowInfo().entrySet()) {
|
||||||
m_rowSelectionOrder.add(m_lastSelectedIndex);
|
List<Object> candidateRecord = entry.getValue();
|
||||||
|
// get row key
|
||||||
|
Object key = candidateRecord.get(0);
|
||||||
|
if(key instanceof IDColumn)
|
||||||
|
key = ((IDColumn)key).getRecord_ID();
|
||||||
|
//
|
||||||
|
if(!m_rowSelectionOrder.contains(key))
|
||||||
|
m_rowSelectionOrder.add(key);
|
||||||
}
|
}
|
||||||
else {
|
// remove unselected rows
|
||||||
if(m_rowSelectionOrder.contains(m_lastSelectedIndex))
|
for(Iterator<Object> it = m_rowSelectionOrder.iterator(); it.hasNext();) {
|
||||||
m_rowSelectionOrder.remove((Integer)m_lastSelectedIndex);
|
if(!getSelectedRowInfo().containsKey(it.next()))
|
||||||
else
|
it.remove();
|
||||||
m_rowSelectionOrder.add(m_lastSelectedIndex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // updateRowSelectionOrder
|
} // updateRowSelectionOrder
|
||||||
|
@ -3437,8 +3449,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
* Put values from the selected row into the context
|
* Put values from the selected row into the context
|
||||||
*/
|
*/
|
||||||
protected void updateContext(boolean checkQueryCriteria) {
|
protected void updateContext(boolean checkQueryCriteria) {
|
||||||
Map<Object, List<Object>> rowInfo = getSelectedRowInfo();
|
List<Object> lastSelectedRow = getLastSelectedRow();
|
||||||
List<Object> lastSelectedRow = m_rowSelectionOrder.size() > 0 ? rowInfo.get(getRowKeyAt(m_rowSelectionOrder.get(m_rowSelectionOrder.size() - 1))) : null;
|
|
||||||
|
|
||||||
if(checkQueryCriteria) {
|
if(checkQueryCriteria) {
|
||||||
// put parameter values into the context
|
// put parameter values into the context
|
||||||
|
@ -3494,8 +3505,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
protected String getSelectedIDsForCtx() {
|
protected String getSelectedIDsForCtx() {
|
||||||
String returnVal = null;
|
String returnVal = null;
|
||||||
|
|
||||||
for(int idx : m_rowSelectionOrder) {
|
for(Object key : m_rowSelectionOrder) {
|
||||||
String selectedID = Objects.toString(getRowKeyAt(idx));
|
String selectedID = Objects.toString(key);
|
||||||
if(returnVal == null)
|
if(returnVal == null)
|
||||||
returnVal = selectedID;
|
returnVal = selectedID;
|
||||||
else
|
else
|
||||||
|
@ -3504,4 +3515,14 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get last selected row
|
||||||
|
* @return List
|
||||||
|
*/
|
||||||
|
protected List<Object> getLastSelectedRow() {
|
||||||
|
int index = m_rowSelectionOrder.size() - 1;
|
||||||
|
|
||||||
|
List<Object> lastSelectedRow = m_rowSelectionOrder.size() > 0 ? getSelectedRowInfo().get(m_rowSelectionOrder.get(index)) : null;
|
||||||
|
return lastSelectedRow;
|
||||||
|
}
|
||||||
} // Info
|
} // Info
|
||||||
|
|
Loading…
Reference in New Issue