IDEMPIERE-4864 Fix shortcut handling for combobox and ad window (#784)

Fix focus issue after closing of Process Info Dialog.
This commit is contained in:
hengsin 2021-07-20 17:17:54 +08:00 committed by GitHub
parent e27e11cfce
commit c72d4609b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 4 deletions

View File

@ -16,7 +16,9 @@ package org.adempiere.webui;
import org.adempiere.webui.component.Mask; import org.adempiere.webui.component.Mask;
import org.adempiere.webui.part.UIPart; import org.adempiere.webui.part.UIPart;
import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.Clients;
/** /**
* Helper class for any component want implement {@link ISupportMask} * Helper class for any component want implement {@link ISupportMask}
@ -73,7 +75,14 @@ public class ShowMaskWrapper implements ISupportMask {
if (maskObj != null || maskObj.getParent() != null){ if (maskObj != null || maskObj.getParent() != null){
// in same request, not yet call to show mask // in same request, not yet call to show mask
if (!ShowMaskWrapper.hasFlagShowMask(comp)){ if (!ShowMaskWrapper.hasFlagShowMask(comp)){
Component p = maskObj.getParent();
maskObj.detach(); maskObj.detach();
if (p == comp) {
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
script.append(p.getUuid()).append("');");
script.append("w.busy=null;");
Clients.response(new AuScript(script.toString()));
}
} }
} }
} }

View File

@ -3486,7 +3486,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
showBusyMask(dialog); showBusyMask(dialog);
LayoutUtils.openOverlappedWindow(getComponent(), dialog, "middle_center"); LayoutUtils.openOverlappedWindow(getComponent(), dialog, "middle_center");
} }
dialog.focus(); Executions.schedule(getComponent().getDesktop(), e -> dialog.focus(), new Event("onPostShowProcessModalDialog"));
} }
if (adTabbox.getSelectedGridTab().isQuickForm()) { if (adTabbox.getSelectedGridTab().isQuickForm()) {
adTabbox.getSelectedGridTab().dataRefreshAll(false, false); adTabbox.getSelectedGridTab().dataRefreshAll(false, false);
@ -3653,7 +3653,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (m_logs != null && m_logs.length > 0) { if (m_logs != null && m_logs.length > 0) {
ProcessInfoDialog.showProcessInfo(pi, curWindowNo, getComponent(), false); ProcessInfoDialog dialog = ProcessInfoDialog.showProcessInfo(pi, curWindowNo, getComponent(), false);
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, e -> focusToActivePanel());
} }
} }

View File

@ -1356,4 +1356,15 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
} }
}); });
} }
@Override
public void focus() {
super.focus();
if (getParameterPanel() != null) {
if (getParameterPanel().focusToFirstEditor())
return;
}
if (bOK != null)
bOK.focus();
}
} }

View File

@ -215,7 +215,7 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
* @param needFillLogFromDb if ProcessInfoUtil.setLogFromDB(pi) is called by outer function, * @param needFillLogFromDb if ProcessInfoUtil.setLogFromDB(pi) is called by outer function,
* just pass false, other pass true to avoid duplicate message * just pass false, other pass true to avoid duplicate message
*/ */
public static void showProcessInfo (ProcessInfo pi, int windowNo, final Component comp, boolean needFillLogFromDb) { public static ProcessInfoDialog showProcessInfo (ProcessInfo pi, int windowNo, final Component comp, boolean needFillLogFromDb) {
ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(Env.getCtx(), windowNo),AEnv.getDialogHeader(Env.getCtx(), windowNo), pi, needFillLogFromDb); ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(Env.getCtx(), windowNo),AEnv.getDialogHeader(Env.getCtx(), windowNo), pi, needFillLogFromDb);
final ISupportMask supportMask = LayoutUtils.showWindowWithMask(dialog, comp, LayoutUtils.OVERLAP_PARENT); final ISupportMask supportMask = LayoutUtils.showWindowWithMask(dialog, comp, LayoutUtils.OVERLAP_PARENT);
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() { dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@ -225,5 +225,6 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
} }
}); });
Executions.schedule(comp.getDesktop(), e -> dialog.btnOk.focus(), new Event("onPostShowProcessInfoDialog")); Executions.schedule(comp.getDesktop(), e -> dialog.btnOk.focus(), new Event("onPostShowProcessInfoDialog"));
return dialog;
} }
} }