diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index 3f25b8b06a..29917b534a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -99,6 +99,8 @@ import com.lowagie.text.pdf.PdfWriter; */ public class ProcessDialog extends AbstractProcessDialog implements EventListener, IHelpContext { + public static final String ON_INITIAL_FOCUS_EVENT = "onInitialFocus"; + /** * generate serial version ID */ @@ -154,6 +156,7 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene init(Env.getCtx(), WindowNo, AD_Process_ID, null, "70%", false, false); querySaved(); addEventListener(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT, this); + addEventListener(ON_INITIAL_FOCUS_EVENT, this); } catch(Exception ex) { @@ -360,6 +363,14 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene bSave.setEnabled(enabled && !lastRun); bDelete.setEnabled(enabled && fSavedName.getSelectedIndex() > -1 && !lastRun); + } else if (event.getName().equals(ON_INITIAL_FOCUS_EVENT)) { + if (!isUILocked()) + { + if (!getParameterPanel().focusToFirstEditor()) + { + bOK.focus(); + } + } } else { super.onEvent(event); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java index 7f0bba4168..81d8560fb4 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java @@ -25,11 +25,14 @@ import java.util.logging.Level; import org.adempiere.webui.component.Column; import org.adempiere.webui.component.Columns; +import org.adempiere.webui.component.EditorBox; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.GridFactory; +import org.adempiere.webui.component.NumberBox; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; +import org.adempiere.webui.component.Urlbox; import org.adempiere.webui.editor.IZoomableEditor; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditorPopupMenu; @@ -51,6 +54,8 @@ import org.compiere.util.CLogger; import org.compiere.util.DB; 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; @@ -815,7 +820,31 @@ public class ProcessParameterPanel extends Panel implements public void setProcessInfo(ProcessInfo processInfo) { m_processInfo = processInfo; } + + public boolean focusToFirstEditor() { + if (m_wEditors.isEmpty()) + return false; + for(WEditor editor : m_wEditors) { + if (editor.isVisible()) { + focusToEditor(editor); + return true; + } + } + return false; + } + private void focusToEditor(WEditor toFocus) { + Component c = toFocus.getComponent(); + if (c instanceof EditorBox) { + c = ((EditorBox)c).getTextbox(); + } else if (c instanceof NumberBox) { + c = ((NumberBox)c).getDecimalbox(); + } else if (c instanceof Urlbox) { + c = ((Urlbox)c).getTextbox(); + } + ((HtmlBasedComponent)c).focus(); + } + static class ZoomListener implements EventListener { private IZoomableEditor searchEditor; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java index edc8453f1c..bfa5a2ab08 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/TabbedDesktop.java @@ -76,6 +76,7 @@ public abstract class TabbedDesktop extends AbstractDesktop { pd.setTitle(null); preOpenNewTab(); windowContainer.addWindow(tabPanel, title, true); + Events.postEvent(ProcessDialog.ON_INITIAL_FOCUS_EVENT, pd, null); } return pd; }