IDEMPIERE-1478 Usability improvement - closing without saving

This commit is contained in:
hieplq 2013-10-29 16:46:36 +07:00
parent 6f0b259c97
commit ac5c4fdde8
2 changed files with 55 additions and 8 deletions

View File

@ -25,6 +25,7 @@ package org.adempiere.webui.adwindow;
import java.util.Properties;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton;
@ -197,14 +198,44 @@ public class ADWindowContent extends AbstractADWindowContent
class TabOnCloseHanlder implements ITabOnCloseHandler {
public void onClose(Tabpanel tabPanel) {
if (ADWindowContent.this.getOnExitCallBack() == null){
OnCloseCallback onCloseCallback = new OnCloseCallback();
ADWindowContent.this.setOnExitCallBack(onCloseCallback);
onCloseCallback.setTabPanel(tabPanel);
}
if (ADWindowContent.this.onExit()) {
closeTab (tabPanel);
}
}
}
class OnCloseCallback implements Callback<Boolean>{
Tabpanel tabPanel;
public Tabpanel getTabPanel() {
return tabPanel;
}
public void setTabPanel(Tabpanel tabPanel) {
this.tabPanel = tabPanel;
}
@Override
public void onCallback(Boolean result) {
if (result){
closeTab (tabPanel);
}
}
}
/**
* close tab contain this window
* @param tabPanel
*/
protected void closeTab (Tabpanel tabPanel) {
Tab tab = tabPanel.getLinkedTab();
tab.close();
if (getWindowNo() > 0)
SessionManager.getAppDesktop().unregisterWindow(getWindowNo());
}
}
}
public static class ADWindowVlayout extends Vlayout implements IHelpContext {
/**

View File

@ -970,6 +970,20 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
focusToActivePanel();
}
/**
* handle respond of user with close un save message.
* must set before call onExit
*/
private Callback<Boolean> onExitCallBack;
public Callback<Boolean> getOnExitCallBack() {
return onExitCallBack;
}
public void setOnExitCallBack(Callback<Boolean> onExitCallBack) {
this.onExitCallBack = onExitCallBack;
}
/**
* @return boolean
*/
@ -979,12 +993,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
{
return true;
}
else
FDialog.info(this.curWindowNo, null, "SaveBeforeClose");
else{
FDialog.ask(curWindowNo, null, "CloseUnSave?", getOnExitCallBack());
return false;
}
}
/**
* @param event
* @see EventListener#onEvent(Event)