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 java.util.Properties;
|
||||||
|
|
||||||
|
import org.adempiere.util.Callback;
|
||||||
import org.adempiere.webui.LayoutUtils;
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.adempiere.webui.component.Tabpanel;
|
import org.adempiere.webui.component.Tabpanel;
|
||||||
import org.adempiere.webui.component.ToolBarButton;
|
import org.adempiere.webui.component.ToolBarButton;
|
||||||
|
@ -197,15 +198,45 @@ public class ADWindowContent extends AbstractADWindowContent
|
||||||
class TabOnCloseHanlder implements ITabOnCloseHandler {
|
class TabOnCloseHanlder implements ITabOnCloseHandler {
|
||||||
|
|
||||||
public void onClose(Tabpanel tabPanel) {
|
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()) {
|
if (ADWindowContent.this.onExit()) {
|
||||||
Tab tab = tabPanel.getLinkedTab();
|
closeTab (tabPanel);
|
||||||
tab.close();
|
|
||||||
if (getWindowNo() > 0)
|
|
||||||
SessionManager.getAppDesktop().unregisterWindow(getWindowNo());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
public static class ADWindowVlayout extends Vlayout implements IHelpContext {
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* 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
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean onExit()
|
public boolean onExit()
|
||||||
|
@ -979,10 +993,12 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
FDialog.info(this.curWindowNo, null, "SaveBeforeClose");
|
|
||||||
|
FDialog.ask(curWindowNo, null, "CloseUnSave?", getOnExitCallBack());
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue