IDEMPIERE-1149 Implements SetFocus on field - handle the default focus in edit mode for grid view
This commit is contained in:
parent
4277e7395e
commit
beaaf3e8e3
|
@ -27,6 +27,7 @@ import org.adempiere.webui.component.Urlbox;
|
||||||
import org.adempiere.webui.editor.WButtonEditor;
|
import org.adempiere.webui.editor.WButtonEditor;
|
||||||
import org.adempiere.webui.editor.WEditor;
|
import org.adempiere.webui.editor.WEditor;
|
||||||
import org.adempiere.webui.editor.WEditorPopupMenu;
|
import org.adempiere.webui.editor.WEditorPopupMenu;
|
||||||
|
import org.adempiere.webui.editor.WImageEditor;
|
||||||
import org.adempiere.webui.editor.WebEditorFactory;
|
import org.adempiere.webui.editor.WebEditorFactory;
|
||||||
import org.adempiere.webui.event.ActionEvent;
|
import org.adempiere.webui.event.ActionEvent;
|
||||||
import org.adempiere.webui.event.ActionListener;
|
import org.adempiere.webui.event.ActionListener;
|
||||||
|
@ -90,6 +91,9 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
||||||
private AbstractADWindowContent m_windowPanel;
|
private AbstractADWindowContent m_windowPanel;
|
||||||
private ActionListener buttonListener;
|
private ActionListener buttonListener;
|
||||||
|
|
||||||
|
/** DefaultFocusField */
|
||||||
|
private WEditor defaultFocusField = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridTab
|
* @param gridTab
|
||||||
|
@ -384,6 +388,10 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
||||||
editor.getComponent().setWidgetOverride("fieldHelp", HelpController.escapeJavascriptContent(gridPanelFields[i].getHelp()));
|
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("onFocus", "zWatch.fire('onFieldTooltip', this, null, this.fieldHeader(), this.fieldDescription(), this.fieldHelp());");
|
||||||
editor.getComponent().setWidgetListener("onBlur", "zWatch.fire('onFieldTooltip', this);");
|
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()) {
|
if (!gridPanelFields[i].isDisplayedGrid() || gridPanelFields[i].isToolbarButton()) {
|
||||||
|
@ -585,6 +593,13 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
||||||
if (currentRow != null && currentRow.getParent() != null) {
|
if (currentRow != null && currentRow.getParent() != null) {
|
||||||
WEditor toFocus = null;
|
WEditor toFocus = null;
|
||||||
WEditor firstEditor = 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()) {
|
for (WEditor editor : getEditors()) {
|
||||||
if (editor.isVisible() && editor.getComponent().getParent() != null) {
|
if (editor.isVisible() && editor.getComponent().getParent() != null) {
|
||||||
if (editor.isReadWrite()) {
|
if (editor.isReadWrite()) {
|
||||||
|
@ -595,6 +610,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
||||||
firstEditor = editor;
|
firstEditor = editor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (toFocus != null) {
|
if (toFocus != null) {
|
||||||
focusToEditor(toFocus);
|
focusToEditor(toFocus);
|
||||||
} else if (firstEditor != null) {
|
} else if (firstEditor != null) {
|
||||||
|
|
Loading…
Reference in New Issue