IDEMPIERE-1149 Implements SetFocus on field - handle the default focus in edit mode for grid view

This commit is contained in:
Elaine Tan 2013-08-05 17:05:02 +08:00
parent 4277e7395e
commit beaaf3e8e3
1 changed files with 23 additions and 7 deletions

View File

@ -27,6 +27,7 @@ import org.adempiere.webui.component.Urlbox;
import org.adempiere.webui.editor.WButtonEditor;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WEditorPopupMenu;
import org.adempiere.webui.editor.WImageEditor;
import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.ActionEvent;
import org.adempiere.webui.event.ActionListener;
@ -90,6 +91,9 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
private AbstractADWindowContent m_windowPanel;
private ActionListener buttonListener;
/** DefaultFocusField */
private WEditor defaultFocusField = null;
/**
*
* @param gridTab
@ -384,6 +388,10 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
editor.getComponent().setWidgetOverride("fieldHelp", HelpController.escapeJavascriptContent(gridPanelFields[i].getHelp()));
editor.getComponent().setWidgetListener("onFocus", "zWatch.fire('onFieldTooltip', this, null, this.fieldHeader(), this.fieldDescription(), this.fieldHelp());");
editor.getComponent().setWidgetListener("onBlur", "zWatch.fire('onFieldTooltip', this);");
// Default Focus
if (defaultFocusField == null && gridPanelFields[i].isDefaultFocus())
defaultFocusField = editor;
}
if (!gridPanelFields[i].isDisplayedGrid() || gridPanelFields[i].isToolbarButton()) {
@ -585,6 +593,13 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
if (currentRow != null && currentRow.getParent() != null) {
WEditor toFocus = null;
WEditor firstEditor = null;
if (defaultFocusField != null
&& defaultFocusField.isVisible() && defaultFocusField.isReadWrite() && defaultFocusField.getComponent().getParent() != null
&& !(defaultFocusField instanceof WImageEditor)) {
toFocus = defaultFocusField;
}
else
{
for (WEditor editor : getEditors()) {
if (editor.isVisible() && editor.getComponent().getParent() != null) {
if (editor.isReadWrite()) {
@ -595,6 +610,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
firstEditor = editor;
}
}
}
if (toFocus != null) {
focusToEditor(toFocus);
} else if (firstEditor != null) {