IDEMPIERE-1149 Implements SetFocus on field. Shouldn't set initial focus to detail tab.

This commit is contained in:
Heng Sin Low 2013-11-15 16:24:22 +08:00
parent 72180bb630
commit 6ab722f237
2 changed files with 27 additions and 3 deletions

View File

@ -1410,7 +1410,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
@Override
public void focus() {
if (formContainer.isVisible())
if (form.isVisible())
this.focusToFirstEditor(true);
else
listPanel.focus();

View File

@ -730,7 +730,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
setFocusToField(columnOnClick);
columnOnClick = null;
} else {
renderer.focusToFirstEditor();
focusToFirstEditorIfNotDetailTab();
}
} else {
focusToRow(row);
@ -761,6 +761,30 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
}
}
private void focusToFirstEditorIfNotDetailTab() {
ADTabpanel adtabpanel = null;
boolean setFocus = true;
Component parent = listbox.getParent();
while (parent != null) {
if (parent instanceof ADTabpanel) {
adtabpanel = (ADTabpanel) parent;
break;
}
parent = parent.getParent();
}
if (adtabpanel != null)
{
ADWindow adwindow = ADWindow.findADWindow(adtabpanel);
if (adwindow != null) {
IADTabpanel selectedADTabpanel = adwindow.getADWindowContent().getADTab().getSelectedTabpanel();
if (selectedADTabpanel != adtabpanel)
setFocus = false;
}
}
if (setFocus)
renderer.focusToFirstEditor();
}
/**
* scroll grid to the current focus row
*/
@ -774,7 +798,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
setFocusToField(columnOnClick);
columnOnClick = null;
} else {
renderer.focusToFirstEditor();
focusToFirstEditorIfNotDetailTab();
}
} else {
Component cmp = null;