1003416 IDEMPIERE-1478 Usability improvement - closing without saving. Peer Review.

This commit is contained in:
Heng Sin Low 2013-10-31 12:26:29 +08:00
parent 374d7ac576
commit 216c61b9d9
2 changed files with 12 additions and 43 deletions

View File

@ -195,34 +195,18 @@ public class ADWindowContent extends AbstractADWindowContent
}
}
class TabOnCloseHanlder implements ITabOnCloseHandler {
class TabOnCloseHanlder implements ITabOnCloseHandler, Callback<Boolean> {
private 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()) {
closeTab (tabPanel);
}
}
}
class OnCloseCallback implements Callback<Boolean>{
Tabpanel tabPanel;
public Tabpanel getTabPanel() {
return tabPanel;
}
public void setTabPanel(Tabpanel tabPanel) {
this.tabPanel = tabPanel;
ADWindowContent.this.onExit(this);
}
@Override
public void onCallback(Boolean result) {
if (result){
closeTab (tabPanel);
}
this.tabPanel = null;
}
}

View File

@ -970,33 +970,18 @@ 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
* @param callback
*/
public boolean onExit()
public void onExit(Callback<Boolean> callback)
{
if (!boolChanges)
{
return true;
callback.onCallback(Boolean.TRUE);
}
else{
FDialog.ask(curWindowNo, null, "CloseUnSave?", getOnExitCallBack());
return false;
else
{
FDialog.ask(curWindowNo, null, "CloseUnSave?", callback);
}
}