new LastChanceSaveHandler() {
public void onLastChanceSave(LastChanceSaveEvent event)
{
// We're quitting. Save one last time.
final Token token = event.acquire();
boolean saving = doSave(null, null, null,
new ProgressIndicator()
{
public void onProgress(String message)
{
}
public void clearProgress()
{
// alternate way to signal completion. safe to quit
token.release();
}
public void onCompleted()
{
// We saved successfully. We're safe to quit now.
token.release();
}
public void onError(String message)
{
// The save didn't succeed. Oh well. Nothing we can
// do but quit.
token.release();
}
});
if (!saving)
{
// No save was performed (not needed). We're safe to quit
// now, no need to wait for server requests to complete.
token.release();
}
}
});
}