IDEMPIERE-5851 - Set Focus Automatically to the 1st Row of the Info Window Result Set (#2001)
* IDEMPIERE-5851 - Set Focus Automatically to the 1st Row of the Info Window Result Set * IDEMPIERE-5851 - pr2001 patch by Heng Sin * IDEMPIERE-5851 - remove unintended change
This commit is contained in:
parent
7f2f0f2591
commit
72c00ff0d6
|
@ -25,6 +25,7 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -104,6 +105,7 @@ import org.compiere.util.ValueNamePair;
|
||||||
import org.zkoss.zk.au.out.AuEcho;
|
import org.zkoss.zk.au.out.AuEcho;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
|
import org.zkoss.zk.ui.HtmlBasedComponent;
|
||||||
import org.zkoss.zk.ui.Page;
|
import org.zkoss.zk.ui.Page;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
@ -1018,6 +1020,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
restoreSelectedInPage();
|
restoreSelectedInPage();
|
||||||
updateStatusBar (m_count);
|
updateStatusBar (m_count);
|
||||||
setStatusSelected ();
|
setStatusSelected ();
|
||||||
|
setFocusToContentPanel();
|
||||||
addDoubleClickListener();
|
addDoubleClickListener();
|
||||||
|
|
||||||
if (paging != null && paging.getParent() == null)
|
if (paging != null && paging.getParent() == null)
|
||||||
|
@ -1844,7 +1847,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Object> candidateRecord = (List<Object>)contentPanel.getModel().get(rowIndex);
|
List<Object> candidateRecord = (List<Object>)contentPanel.getModel().get(rowIndex);
|
||||||
|
|
||||||
if (contentPanel.getModel().isSelected(candidateRecord)){
|
int ri = rowIndex;
|
||||||
|
if (contentPanel.getModel().isSelected(candidateRecord) || Arrays.stream(contentPanel.getSelectedIndices()).anyMatch(si -> si==ri)){
|
||||||
recordSelectedData.put(keyCandidate, candidateRecord);// add or update selected record info
|
recordSelectedData.put(keyCandidate, candidateRecord);// add or update selected record info
|
||||||
}else{
|
}else{
|
||||||
if (recordSelectedData.containsKey(keyCandidate)){// unselected record
|
if (recordSelectedData.containsKey(keyCandidate)){// unselected record
|
||||||
|
@ -2268,6 +2272,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
}else if (event.getTarget() == contentPanel && event.getName().equals("onAfterRender")){
|
}else if (event.getTarget() == contentPanel && event.getName().equals("onAfterRender")){
|
||||||
//IDEMPIERE-1334 at this event selected item from listBox and model is sync
|
//IDEMPIERE-1334 at this event selected item from listBox and model is sync
|
||||||
enableButtons();
|
enableButtons();
|
||||||
|
setFocusToContentPanel();
|
||||||
}
|
}
|
||||||
else if (event.getTarget() == contentPanel && event.getName().equals(Events.ON_DOUBLE_CLICK))
|
else if (event.getTarget() == contentPanel && event.getName().equals(Events.ON_DOUBLE_CLICK))
|
||||||
{
|
{
|
||||||
|
@ -3525,4 +3530,28 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
List<Object> lastSelectedRow = m_rowSelectionOrder.size() > 0 ? getSelectedRowInfo().get(m_rowSelectionOrder.get(index)) : null;
|
List<Object> lastSelectedRow = m_rowSelectionOrder.size() > 0 ? getSelectedRowInfo().get(m_rowSelectionOrder.get(index)) : null;
|
||||||
return lastSelectedRow;
|
return lastSelectedRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set focus to {@link #contentPanel}:<br/>
|
||||||
|
* - Single selection: auto select first item and set focus to it.<br/>
|
||||||
|
* - Multiple selection: set focus to first item.
|
||||||
|
*/
|
||||||
|
private void setFocusToContentPanel() {
|
||||||
|
if(contentPanel.getRowCount() > 0) {
|
||||||
|
if(p_multipleSelection) {
|
||||||
|
|
||||||
|
((HtmlBasedComponent)contentPanel.getItems().get(0)).focus();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(contentPanel.getSelectedItem() == null)
|
||||||
|
contentPanel.setSelectedIndex(0);
|
||||||
|
|
||||||
|
((HtmlBasedComponent)contentPanel.getSelectedItem()).focus();
|
||||||
|
contentPanel.getSelectedItem().setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatusSelected ();
|
||||||
|
m_lastSelectedIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // Info
|
} // Info
|
||||||
|
|
Loading…
Reference in New Issue