[ 2656716 ] Focus management enhancement
- Regression : button with pull down menu not working. - Grid sometime render twice. - javadoc - unuse import
This commit is contained in:
parent
66e7a7d0ff
commit
4b8d6dca2c
|
@ -16,20 +16,13 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MRMA;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
|
|
@ -27,14 +27,12 @@ import java.util.logging.Level;
|
|||
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.event.ToolbarListener;
|
||||
import org.adempiere.webui.panel.IADTabpanel;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.HtmlBasedComponent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
@ -90,13 +88,11 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
|
||||
// Elaine 2008/12/04
|
||||
/** Show Personal Lock */
|
||||
public boolean isPersonalLock = MRole.getDefault().isPersonalLock();
|
||||
public boolean isPersonalLock = MRole.getDefault().isPersonalLock();
|
||||
private boolean isAllowProductInfo = MRole.getDefault().isAllow_Info_Product();
|
||||
|
||||
private int windowNo = 0;
|
||||
|
||||
private IADTab adTab = null;
|
||||
|
||||
/** Last Modifier of Action Event */
|
||||
// public int lastModifiers;
|
||||
//
|
||||
|
@ -145,7 +141,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
addSeparator();
|
||||
btnLock = createButton("Lock", "Lock", "Lock"); // Elaine 2008/12/04
|
||||
btnLock.setVisible(isPersonalLock);
|
||||
btnZoomAcross = createButton("ZoomAcross", "ZoomAcross", "ZoomAcross");
|
||||
btnZoomAcross = createButton("ZoomAcross", "ZoomAcross", "ZoomAcross");
|
||||
btnActiveWorkflows = createButton("ActiveWorkflows", "WorkFlow", "WorkFlow");
|
||||
btnRequests = createButton("Requests", "Request", "Request");
|
||||
btnProductInfo = createButton("ProductInfo", "Product", "InfoProduct");
|
||||
|
@ -291,7 +287,6 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
public void onEvent(Event event)
|
||||
{
|
||||
String eventName = event.getName();
|
||||
Component eventComp = event.getTarget();
|
||||
|
||||
if(eventName.equals(Events.ON_CLICK))
|
||||
{
|
||||
|
@ -342,12 +337,6 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
}
|
||||
}
|
||||
this.event = null;
|
||||
if (adTab != null) {
|
||||
IADTabpanel adTabPanel = adTab.getSelectedTabpanel();
|
||||
if (adTabPanel != null && adTabPanel instanceof HtmlBasedComponent) {
|
||||
((HtmlBasedComponent)adTabPanel).focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableHistoryRecords(boolean enabled)
|
||||
|
@ -558,13 +547,4 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
public void setWindowNo(int windowNo) {
|
||||
this.windowNo = windowNo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param adTab
|
||||
*/
|
||||
public void setADTab(IADTab adTab) {
|
||||
this.adTab = adTab;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,6 +75,10 @@ public class GridPanel extends Borderlayout implements EventListener
|
|||
|
||||
public static final String PAGE_SIZE_KEY = "ZK_PAGING_SIZE";
|
||||
|
||||
//copy from org.zkoss.zul.Grid
|
||||
private static final String ATTR_ON_INIT_RENDER_POSTED =
|
||||
"org.zkoss.zul.Grid.onInitLaterPosted";
|
||||
|
||||
public GridPanel()
|
||||
{
|
||||
this(0);
|
||||
|
@ -175,18 +179,24 @@ public class GridPanel extends Borderlayout implements EventListener
|
|||
renderer.stopEditing(false);
|
||||
if (rowIndex >= 0 && pgIndex >= 0) {
|
||||
listModel.updateComponent(pgIndex);
|
||||
//this is needed to make focus and auto scroll work
|
||||
org.zkoss.zul.Row row = (org.zkoss.zul.Row)listbox.getRows().getChildren().get(pgIndex);
|
||||
listbox.renderRow(row);
|
||||
//don't have to call renderRow if render event have been posted
|
||||
if (listbox.getAttribute(ATTR_ON_INIT_RENDER_POSTED) == null) {
|
||||
//this is needed to make focus and auto scroll work
|
||||
org.zkoss.zul.Row row = (org.zkoss.zul.Row)listbox.getRows().getChildren().get(pgIndex);
|
||||
listbox.renderRow(row);
|
||||
}
|
||||
Events.echoEvent("onPostRenderSelectedRow", this, null);
|
||||
}
|
||||
} else {
|
||||
renderer.stopEditing(false);
|
||||
if (rowIndex >= 0) {
|
||||
listModel.updateComponent(rowIndex);
|
||||
//this is needed to make focus and auto scroll work
|
||||
org.zkoss.zul.Row row = (org.zkoss.zul.Row)listbox.getRows().getChildren().get(rowIndex);
|
||||
listbox.renderRow(row);
|
||||
//don't have to call renderRow if render event have been posted
|
||||
if (listbox.getAttribute(ATTR_ON_INIT_RENDER_POSTED) == null) {
|
||||
//this is needed to make focus and auto scroll work
|
||||
org.zkoss.zul.Row row = (org.zkoss.zul.Row)listbox.getRows().getChildren().get(rowIndex);
|
||||
listbox.renderRow(row);
|
||||
}
|
||||
Events.echoEvent("onPostRenderSelectedRow", this, null);
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +209,8 @@ public class GridPanel extends Borderlayout implements EventListener
|
|||
renderer.setFocusToField();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* set paging size
|
||||
* @param pageSize
|
||||
|
|
|
@ -177,6 +177,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @return Component
|
||||
*/
|
||||
public Component createPart(Object parent)
|
||||
{
|
||||
if (parent instanceof Component)
|
||||
|
@ -185,16 +189,20 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
adTab = createADTab();
|
||||
adTab.addSelectionEventListener(this);
|
||||
|
||||
toolbar.setADTab(adTab);
|
||||
|
||||
return super.createPart(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StatusBarPanel
|
||||
*/
|
||||
public StatusBarPanel getStatusBar()
|
||||
{
|
||||
return statusBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isEmbedded() {
|
||||
return embeddedTabindex >= 0;
|
||||
}
|
||||
|
@ -208,8 +216,23 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
statusBar = new StatusBarPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IADTab
|
||||
*/
|
||||
protected abstract IADTab createADTab();
|
||||
|
||||
private void focusToActivePanel() {
|
||||
IADTabpanel adTabPanel = adTab.getSelectedTabpanel();
|
||||
if (adTabPanel != null && adTabPanel instanceof HtmlBasedComponent) {
|
||||
((HtmlBasedComponent)adTabPanel).focus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param adWindowId
|
||||
* @param query
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean initPanel(int adWindowId, MQuery query)
|
||||
{
|
||||
// Set AutoCommit for this Window
|
||||
|
@ -300,6 +323,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query
|
||||
* @param tabIndex
|
||||
*/
|
||||
protected void initTab(MQuery query, int tabIndex) {
|
||||
gridWindow.initTab(tabIndex);
|
||||
|
||||
|
@ -465,9 +492,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
setActiveTab(curInd + 1);
|
||||
}
|
||||
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @see ToolbarListener#onParentRecord()
|
||||
*/
|
||||
public void onParentRecord()
|
||||
|
@ -477,6 +506,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
setActiveTab(curInd - 1);
|
||||
}
|
||||
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -485,6 +516,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public void onFirst()
|
||||
{
|
||||
curTab.navigate(0);
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -493,6 +525,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public void onLast()
|
||||
{
|
||||
curTab.navigate(curTab.getRowCount() - 1);
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -501,6 +534,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public void onNext()
|
||||
{
|
||||
curTab.navigateRelative(+1);
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,6 +543,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public void onPrevious()
|
||||
{
|
||||
curTab.navigateRelative(-1);
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
// Elaine 2008/12/04
|
||||
|
@ -579,6 +614,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
|
||||
history(m_onlyCurrentDays);
|
||||
}
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
private void history(int onlyCurrentDays)
|
||||
|
@ -623,7 +659,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
|
||||
curTab.loadAttachments(); // reload
|
||||
toolbar.getButton("Attachment").setPressed(curTab.hasAttachment());
|
||||
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -632,8 +668,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public void onToggle()
|
||||
{
|
||||
curTabpanel.switchRowPresentation();
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean onExit()
|
||||
{
|
||||
String message = "Please save changes before closing";
|
||||
|
@ -648,6 +688,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
* @see EventListener#onEvent(Event)
|
||||
*/
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
if (!Events.ON_SELECT.equals(event.getName()))
|
||||
|
@ -801,6 +845,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e
|
||||
* @see DataStatusListener#dataStatusChanged(DataStatusEvent)
|
||||
*/
|
||||
public void dataStatusChanged(DataStatusEvent e)
|
||||
{
|
||||
//ignore non-ui thread event for now.
|
||||
|
@ -943,6 +991,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
toolbar.enableReport(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isFirstTab()
|
||||
{
|
||||
int selTabIndex = adTab.getSelectedIndex();
|
||||
|
@ -956,6 +1007,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
curTab.dataRefreshAll();
|
||||
curTabpanel.dynamicDisplay(0);
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -995,6 +1047,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
logger.severe("Could not create new record");
|
||||
}
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
// Elaine 2008/11/19
|
||||
|
@ -1026,6 +1079,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
logger.severe("Could not create new record");
|
||||
}
|
||||
focusToActivePanel();
|
||||
}
|
||||
//
|
||||
|
||||
|
@ -1059,6 +1113,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
|
||||
curTab.dataRefresh(); // Elaine 2008/07/25
|
||||
}
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1078,6 +1133,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
curTabpanel.dynamicDisplay(0);
|
||||
toolbar.enableIgnore(false);
|
||||
}
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1086,6 +1142,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public void onSave()
|
||||
{
|
||||
onSave(true);
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1139,6 +1196,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
}
|
||||
}
|
||||
curTabpanel.dynamicDisplay(0);
|
||||
focusToActivePanel();
|
||||
}
|
||||
|
||||
// Elaine 2008/12/01
|
||||
|
@ -1306,6 +1364,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
hbox.appendChild(btnCancel);
|
||||
|
||||
AEnv.showWindow(messagePanel);
|
||||
focusToActivePanel();
|
||||
}
|
||||
//
|
||||
|
||||
|
@ -1669,36 +1728,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
if (curTab.needSave(true, false))
|
||||
this.onSave();
|
||||
|
||||
// hengsin - [ 1639242 ] Inconsistent appearance of Process/Report Dialog
|
||||
// globalqss - Add support for Don't ShowHelp option in Process
|
||||
// this code must be changed if integrated the parameters and help in only one window
|
||||
/*
|
||||
MProcess pr = new MProcess(m_ctx, vButton.getProcess_ID(), null);
|
||||
if (pr.getShowHelp() != null && pr.getShowHelp().equals("N")) {
|
||||
startWOasking = true;
|
||||
}
|
||||
// end globalqss
|
||||
|
||||
// Ask user to start process, if Description and Help is not empty
|
||||
|
||||
if (!startWOasking && !(vButton.getDescription().equals("") && vButton.getHelp().equals("")))
|
||||
if (!ADialog.ask(m_curWindowNo, this, "StartProcess?",
|
||||
// "<b><i>" + vButton.getText() + "</i></b><br>" +
|
||||
vButton.getDescription() + "\n" + vButton.getHelp()))
|
||||
return;
|
||||
//
|
||||
String title = vButton.getDescription();
|
||||
if (title == null || title.length() == 0)
|
||||
title = vButton.getName();
|
||||
ProcessInfo pi = new ProcessInfo (title, vButton.getProcess_ID(), table_ID, record_ID);
|
||||
pi.setAD_User_ID (Env.getAD_User_ID(m_ctx));
|
||||
pi.setAD_Client_ID (Env.getAD_Client_ID(m_ctx));
|
||||
pi.setIsBatch(batch);
|
||||
|
||||
// Trx trx = Trx.get(Trx.createTrxName("AppsPanel"), true);
|
||||
ProcessCtl.process(this, m_curWindowNo, pi, null); // calls lockUI, unlockUI
|
||||
*/
|
||||
|
||||
if (!getComponent().getDesktop().isServerPushEnabled())
|
||||
getComponent().getDesktop().enableServerPush(true);
|
||||
|
||||
|
@ -1713,10 +1742,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
dialog.setPosition("center");
|
||||
AEnv.showWindow(dialog);
|
||||
}
|
||||
// curTab.dataRefresh();
|
||||
// curTabpanel.dynamicDisplay(0);
|
||||
} // actionButton
|
||||
|
||||
/**
|
||||
* @param event
|
||||
* @see ActionListener#actionPerformed(ActionEvent)
|
||||
*/
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
if (event.getSource() instanceof WButtonEditor)
|
||||
|
|
|
@ -41,6 +41,12 @@ public class SessionContextListener implements ExecutionInit,
|
|||
{
|
||||
public static final String SESSION_CTX = "WebUISessionContext";
|
||||
|
||||
/**
|
||||
* @param exec
|
||||
* @param parent
|
||||
*
|
||||
* @see ExecutionInit#init(Execution, Execution)
|
||||
*/
|
||||
public void init(Execution exec, Execution parent)
|
||||
{
|
||||
if (parent == null)
|
||||
|
@ -62,6 +68,12 @@ public class SessionContextListener implements ExecutionInit,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exec
|
||||
* @param parent
|
||||
* @param errs
|
||||
* @see ExecutionCleanup#cleanup(Execution, Execution, List)
|
||||
*/
|
||||
public void cleanup(Execution exec, Execution parent, List errs)
|
||||
{
|
||||
if (parent == null)
|
||||
|
@ -71,10 +83,20 @@ public class SessionContextListener implements ExecutionInit,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comp
|
||||
* @param evt
|
||||
* @see EventThreadInit#prepare(Component, Event)
|
||||
*/
|
||||
public void prepare(Component comp, Event evt)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comp
|
||||
* @param evt
|
||||
* @see EventThreadInit#init(Component, Event)
|
||||
*/
|
||||
public boolean init(Component comp, Event evt)
|
||||
{
|
||||
ServerContext ctx = (ServerContext) Executions.getCurrent().getAttribute(
|
||||
|
@ -87,10 +109,20 @@ public class SessionContextListener implements ExecutionInit,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comp
|
||||
* @param evt
|
||||
* @see EventThreadResume#beforeResume(Component, Event)
|
||||
*/
|
||||
public void beforeResume(Component comp, Event evt)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comp
|
||||
* @param evt
|
||||
* @see EventThreadResume#afterResume(Component, Event)
|
||||
*/
|
||||
public void afterResume(Component comp, Event evt)
|
||||
{
|
||||
ServerContext ctx = (ServerContext) Executions.getCurrent().getAttribute(
|
||||
|
@ -98,6 +130,11 @@ public class SessionContextListener implements ExecutionInit,
|
|||
ServerContext.setCurrentInstance(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comp
|
||||
* @param evt
|
||||
* @see EventThreadResume#abortResume(Component, Event)
|
||||
*/
|
||||
public void abortResume(Component comp, Event evt)
|
||||
{
|
||||
// do nothing
|
||||
|
|
Loading…
Reference in New Issue