IDEMPIERE-5211 Restore field focus after opening of dialog or navigate to other tab (#1208)
This commit is contained in:
parent
72ee50fcf5
commit
2d70269daf
|
@ -1022,16 +1022,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
|
||||
if (record_ID == -1) // No Key
|
||||
{
|
||||
//aAttachment.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
EventListener<Event> listener = new EventListener<Event>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
toolbar.setPressed("Attachment",adTabbox.getSelectedGridTab().hasAttachment());
|
||||
focusToActivePanel();
|
||||
focusToLastFocusEditor();
|
||||
}
|
||||
};
|
||||
// Attachment va =
|
||||
|
@ -1084,7 +1082,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
public void onEvent(Event event) throws Exception {
|
||||
hideBusyMask();
|
||||
toolbar.setPressed("Chat",adTabbox.getSelectedGridTab().hasChat());
|
||||
focusToActivePanel();
|
||||
focusToLastFocusEditor();
|
||||
}
|
||||
});
|
||||
getComponent().getParent().appendChild(chat);
|
||||
|
@ -1125,7 +1123,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
public void onEvent(Event event) throws Exception {
|
||||
hideBusyMask();
|
||||
toolbar.setPressed("PostIt",adTabbox.getSelectedGridTab().hasPostIt());
|
||||
focusToActivePanel();
|
||||
focusToLastFocusEditor();
|
||||
}
|
||||
});
|
||||
getComponent().getParent().appendChild(postit);
|
||||
|
@ -1158,9 +1156,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
if (!b)
|
||||
{
|
||||
//restore focus
|
||||
if (lastFocusEditor != null && lastFocusEditor instanceof HtmlBasedComponent &&
|
||||
lastFocusEditor.getPage() != null && LayoutUtils.isReallyVisible(lastFocusEditor))
|
||||
((HtmlBasedComponent)lastFocusEditor).focus();
|
||||
focusToLastFocusEditor();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1171,6 +1167,15 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* restore focus to last known focus editor (if any)
|
||||
*/
|
||||
public void focusToLastFocusEditor() {
|
||||
if (lastFocusEditor != null && lastFocusEditor instanceof HtmlBasedComponent &&
|
||||
lastFocusEditor.getPage() != null && LayoutUtils.isReallyVisible(lastFocusEditor))
|
||||
((HtmlBasedComponent)lastFocusEditor).focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke when quick form is click
|
||||
*/
|
||||
|
@ -2303,12 +2308,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
}
|
||||
}
|
||||
toolbar.refreshUserQuery(adTabbox.getSelectedGridTab().getAD_Tab_ID(), getCurrentFindWindow().getAD_UserQuery_ID());
|
||||
focusToActivePanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
toolbar.setPressed("Find",adTabbox.getSelectedGridTab().isQueryActive());
|
||||
focusToLastFocusEditor();
|
||||
}
|
||||
focusToActivePanel();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3219,7 +3226,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
public void onEvent(Event event) throws Exception {
|
||||
hideBusyMask();
|
||||
if (!win.isStartProcess()) {
|
||||
focusToLastFocusEditor();
|
||||
if (!win.isStartProcess()) {
|
||||
return;
|
||||
}
|
||||
boolean startWOasking = true;
|
||||
|
@ -3252,7 +3260,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
hideBusyMask();
|
||||
if (!window.isCancel()) {
|
||||
onRefresh(true, false);
|
||||
}
|
||||
} else {
|
||||
focusToLastFocusEditor();
|
||||
}
|
||||
}
|
||||
});
|
||||
window.setZindex(1000);
|
||||
|
@ -3584,6 +3594,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
{
|
||||
statusBar.setStatusLine(error, true);
|
||||
}
|
||||
focusToLastFocusEditor();
|
||||
return;
|
||||
}
|
||||
actionButton((IProcessButton) event.getSource());
|
||||
|
@ -3755,7 +3766,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
*/
|
||||
public void onCustomize() {
|
||||
ADTabpanel tabPanel = (ADTabpanel) getADTab().getSelectedTabpanel();
|
||||
CustomizeGridViewDialog.onCustomize(tabPanel);
|
||||
CustomizeGridViewDialog.onCustomize(tabPanel, b -> {
|
||||
focusToLastFocusEditor();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3777,6 +3790,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
public void onSelect() {
|
||||
if (getCurrentFindWindow() != null && getCurrentFindWindow().getPage() != null && getCurrentFindWindow().isVisible() && m_queryInitiating) {
|
||||
LayoutUtils.openEmbeddedWindow(getComponent().getParent(), getCurrentFindWindow(), "overlap");
|
||||
} else {
|
||||
focusToLastFocusEditor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.zkoss.zk.ui.util.Clients;
|
|||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Hlayout;
|
||||
import org.zkoss.zul.Menuitem;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
|
@ -307,7 +308,12 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
return;
|
||||
|
||||
String title = Msg.getMsg(Env.getCtx(), "Who") + m_text;
|
||||
new WRecordInfo (title, m_dse, m_gridTab);
|
||||
WRecordInfo winfo = new WRecordInfo (title, m_dse, m_gridTab);
|
||||
winfo.addCallback(Window.AFTER_PAGE_DETACHED, t -> {
|
||||
ADWindow adwindow = ADWindow.findADWindow(BreadCrumb.this);
|
||||
if (adwindow != null)
|
||||
adwindow.getADWindowContent().focusToLastFocusEditor();
|
||||
});
|
||||
} else if (event.getTarget() == btnFirst) {
|
||||
if (toolbarListener != null)
|
||||
toolbarListener.onFirst();
|
||||
|
|
|
@ -560,7 +560,11 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
|||
protected void onCustomize(Event e) {
|
||||
if (getSelectedADTabpanel() instanceof ADTabpanel) {
|
||||
ADTabpanel tabPanel = (ADTabpanel) getSelectedADTabpanel();
|
||||
CustomizeGridViewDialog.onCustomize(tabPanel);
|
||||
CustomizeGridViewDialog.onCustomize(tabPanel, b -> {
|
||||
ADWindow adwindow = ADWindow.findADWindow(DetailPane.this);
|
||||
if (adwindow != null)
|
||||
adwindow.getADWindowContent().focusToLastFocusEditor();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,8 @@ public class WQuickForm extends Window implements IQuickForm
|
|||
// To maintain parent-child Quick Form
|
||||
prevQGV = adWinContent.getCurrQGV();
|
||||
adWinContent.setCurrQGV(quickGridView);
|
||||
|
||||
addCallback(AFTER_PAGE_DETACHED, t -> adWinContent.focusToLastFocusEditor());
|
||||
}
|
||||
|
||||
protected void initForm( )
|
||||
|
@ -264,7 +266,7 @@ public class WQuickForm extends Window implements IQuickForm
|
|||
ZKUpdateUtil.setWidth(quickGridView, getWidth());
|
||||
ZKUpdateUtil.setHeight(quickGridView, getHeight());
|
||||
|
||||
CustomizeGridViewDialog.showCustomize(0, gridTab.getAD_Tab_ID(), columnsWidth, gridFieldIds, null, quickGridView, true);
|
||||
CustomizeGridViewDialog.showCustomize(0, gridTab.getAD_Tab_ID(), columnsWidth, gridFieldIds, null, quickGridView, true, null);
|
||||
} // onCustomize
|
||||
|
||||
public void onIgnore( )
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package org.adempiere.webui.component;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.adempiere.webui.ISupportMask;
|
||||
import org.adempiere.webui.ShowMaskWrapper;
|
||||
import org.adempiere.webui.event.DialogEvents;
|
||||
|
@ -27,7 +25,6 @@ import org.zkoss.zk.ui.Executions;
|
|||
import org.zkoss.zk.ui.Page;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.Callback;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -79,7 +76,6 @@ public class Window extends org.zkoss.zul.Window implements ISupportMask
|
|||
/* (non-Javadoc)
|
||||
* @see org.zkoss.zul.Window#onPageDetached(org.zkoss.zk.ui.Page)
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void onPageDetached(Page page) {
|
||||
super.onPageDetached(page);
|
||||
|
@ -87,13 +83,7 @@ public class Window extends org.zkoss.zul.Window implements ISupportMask
|
|||
Executions.getCurrent().getDesktop().getExecution() != null) {
|
||||
Events.sendEvent(this, new Event(DialogEvents.ON_WINDOW_CLOSE, this, null));
|
||||
}
|
||||
//org.zkoss.zul.Window.onPageDetached doesn't call super.onPageDetached, bug ?
|
||||
Collection<Callback> callbacks = getCallback(AFTER_PAGE_DETACHED);
|
||||
for (Callback callback : callbacks) {
|
||||
callback.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the window mode attribute
|
||||
|
|
|
@ -240,6 +240,7 @@ public class CSVImportAction implements EventListener<Event>
|
|||
importFile();
|
||||
} else if (event.getName().equals(DialogEvents.ON_WINDOW_CLOSE)) {
|
||||
panel.hideBusyMask();
|
||||
panel.focusToLastFocusEditor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,8 +234,9 @@ public class ExportAction implements EventListener<Event>
|
|||
else if(event.getTarget().getId().equals(ConfirmPanel.A_OK))
|
||||
exportFile();
|
||||
else if (event.getName().equals(DialogEvents.ON_WINDOW_CLOSE)) {
|
||||
panel.hideBusyMask();
|
||||
}else if (event.getTarget().equals(cboType) && event.getName().equals(Events.ON_SELECT)) {
|
||||
panel.hideBusyMask();
|
||||
panel.focusToLastFocusEditor();
|
||||
} else if (event.getTarget().equals(cboType) && event.getName().equals(Events.ON_SELECT)) {
|
||||
displayExportTabSelection();
|
||||
}else if (event.getTarget() instanceof Checkbox) {
|
||||
// A child is not exportable without its parent
|
||||
|
|
|
@ -252,6 +252,7 @@ public class FileImportAction implements EventListener<Event>
|
|||
importFile();
|
||||
} else if (event.getName().equals(DialogEvents.ON_WINDOW_CLOSE)) {
|
||||
panel.hideBusyMask();
|
||||
panel.focusToLastFocusEditor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.adwindow.ADTabpanel;
|
||||
import org.adempiere.webui.adwindow.GridView;
|
||||
import org.adempiere.webui.adwindow.QuickGridView;
|
||||
|
@ -108,9 +109,20 @@ public class CustomizeGridViewDialog extends Window {
|
|||
/**
|
||||
* show grid view customization dialog for tabPanel
|
||||
* @param tabPanel
|
||||
* @return true if saved is ok
|
||||
* @return ignore the return value, it is not working correctly
|
||||
* @deprecated
|
||||
*/
|
||||
public static boolean onCustomize(ADTabpanel tabPanel) {
|
||||
onCustomize(tabPanel, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show grid view customization dialog for tabPanel
|
||||
* @param tabPanel
|
||||
* @param callback
|
||||
*/
|
||||
public static void onCustomize(ADTabpanel tabPanel, Callback<Boolean> callback) {
|
||||
Columns columns = tabPanel.getGridView().getListbox().getColumns();
|
||||
List<Component> columnList = columns.getChildren();
|
||||
GridField[] fields = tabPanel.getGridView().getFields();
|
||||
|
@ -130,7 +142,7 @@ public class CustomizeGridViewDialog extends Window {
|
|||
gridFieldIds.add(fields[i].getAD_Field_ID());
|
||||
|
||||
}
|
||||
return showCustomize(0, tabPanel.getGridTab().getAD_Tab_ID(), columnsWidth,gridFieldIds,tabPanel.getGridView(), null, false);
|
||||
showCustomize(0, tabPanel.getGridTab().getAD_Tab_ID(), columnsWidth,gridFieldIds,tabPanel.getGridView(), null, false, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,10 +153,30 @@ public class CustomizeGridViewDialog extends Window {
|
|||
* @param gridFieldIds list fieldId current display in gridview
|
||||
* @param gridPanel
|
||||
* @param isQuickForm
|
||||
* @param quickGridView
|
||||
* @param quickGridView
|
||||
* @return ignore the return value, it is not working correctly
|
||||
* @deprecated
|
||||
*/
|
||||
public static boolean showCustomize(int WindowNo, int AD_Tab_ID, Map <Integer, String> columnsWidth, ArrayList <Integer> gridFieldIds, GridView gridPanel,
|
||||
QuickGridView quickGridView, boolean isQuickForm)
|
||||
{
|
||||
showCustomize(WindowNo, AD_Tab_ID, columnsWidth, gridFieldIds, gridPanel, quickGridView, isQuickForm, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show User customize (modal)
|
||||
* @param WindowNo window no
|
||||
* @param AD_Tab_ID
|
||||
* @param columnsWidth
|
||||
* @param gridFieldIds list fieldId current display in gridview
|
||||
* @param gridPanel
|
||||
* @param quickGridView
|
||||
* @param isQuickForm
|
||||
* @param callback
|
||||
*/
|
||||
public static void showCustomize(int WindowNo, int AD_Tab_ID, Map <Integer, String> columnsWidth, ArrayList <Integer> gridFieldIds, GridView gridPanel,
|
||||
QuickGridView quickGridView, boolean isQuickForm, Callback<Boolean> callback)
|
||||
{
|
||||
CustomizeGridViewDialog customizeWindow = new CustomizeGridViewDialog(WindowNo, AD_Tab_ID, Env.getAD_User_ID(Env.getCtx()), columnsWidth, gridFieldIds,
|
||||
isQuickForm);
|
||||
|
@ -156,8 +188,11 @@ public class CustomizeGridViewDialog extends Window {
|
|||
{
|
||||
customizeWindow.setGridPanel(gridPanel);
|
||||
}
|
||||
customizeWindow.addCallback(Window.AFTER_PAGE_DETACHED, t -> {
|
||||
if (callback != null)
|
||||
callback.onCallback(customizeWindow.isSaved());
|
||||
});
|
||||
AEnv.showWindow(customizeWindow);
|
||||
return customizeWindow.isSaved();
|
||||
} // showCustomize
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue