new Listener<WindowEvent>() {
public void handleEvent(WindowEvent be) {
if (be.buttonClicked.getItemId()
.equalsIgnoreCase(Dialog.YES)) {
((ViewBrowserEditor) currentEditor).setUnDirty();
currentEditor.close(new CloseObserver() {
public void finishedClosed() {
((ViewBrowserEditor) currentEditor).setCloseAll(false);
callback.onSuccess(true);
}
});
return;
} else if (be.buttonClicked.getItemId().equalsIgnoreCase(Dialog.NO)) {
if (callback != null) {
callback.onSuccess(false);
}
return;
}
if (callback != null) {
callback.onSuccess(true);
}
}
});
} else {
if (callback != null) {
callback.onSuccess(true);
}
}
return;
}
if (currentEditor != null && currentEditor.isDirty() &&
(!currentEditor.equals(newEditor) || !(currentEditor instanceof ViewBrowserEditor))) {
String messageText = messages.saveEditorBeforeClosing(currentEditor.getTitle());
if (currentEditor.getTitle().equals(constants.views())) {
messageText = constants.closeModifiedViewHint();
}
MessageBoxUtils.yesNoCancel(constants.saveEditor(), messageText,
new Listener<WindowEvent>() {
public void handleEvent(WindowEvent be) {
if (be.buttonClicked.getItemId()
.equalsIgnoreCase(Dialog.YES)) {
currentEditor.doSave(callback);
return;
} else if (be.buttonClicked.getItemId().equalsIgnoreCase(Dialog.NO)) {
if (currentEditor instanceof ViewBrowserEditor) {
((ViewBrowserEditor) currentEditor).setUnDirty();
currentEditor.close(new CloseObserver() {
public void finishedClosed() {
((ViewBrowserEditor) currentEditor).setCloseAll(false);
callback.onSuccess(true);
}
});