IDEMPIERE-2006 Process dialog: initial focus.

This commit is contained in:
Heng Sin Low 2014-06-19 17:28:21 +08:00
parent aa6b4a36f9
commit 330253aa89
3 changed files with 41 additions and 0 deletions

View File

@ -99,6 +99,8 @@ import com.lowagie.text.pdf.PdfWriter;
*/
public class ProcessDialog extends AbstractProcessDialog implements EventListener<Event>, 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);
}

View File

@ -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<Event> {
private IZoomableEditor searchEditor;

View File

@ -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;
}