IDEMPIERE-1478 Usability improvement - closing without saving
This commit is contained in:
parent
6f0b259c97
commit
ac5c4fdde8
|
@ -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,15 +198,45 @@ 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()) {
|
||||
Tab tab = tabPanel.getLinkedTab();
|
||||
tab.close();
|
||||
if (getWindowNo() > 0)
|
||||
SessionManager.getAppDesktop().unregisterWindow(getWindowNo());
|
||||
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 {
|
||||
/**
|
||||
* generated serial id
|
||||
|
|
|
@ -971,6 +971,20 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public boolean onExit()
|
||||
|
@ -979,10 +993,12 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
FDialog.info(this.curWindowNo, null, "SaveBeforeClose");
|
||||
|
||||
return false;
|
||||
else{
|
||||
|
||||
FDialog.ask(curWindowNo, null, "CloseUnSave?", getOnExitCallBack());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue