From 8707986f80f6ffeb79fb5bdb7c3824f321c1161d Mon Sep 17 00:00:00 2001 From: Konstantin Krivopustov Date: Tue, 31 May 2016 11:45:23 +0400 Subject: [PATCH] PL-7289 Implementing Committable in a browser controller does not affect showing message about unsaved changes --- .../cuba/desktop/gui/components/DesktopWindow.java | 9 ++------- .../cuba/gui/components/EditorWindowDelegate.java | 4 +--- .../com/haulmont/cuba/gui/components/WindowDelegate.java | 7 +++++++ modules/web/src/com/haulmont/cuba/web/gui/WebWindow.java | 9 ++------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopWindow.java b/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopWindow.java index 958470c605..637808146b 100644 --- a/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopWindow.java +++ b/modules/desktop/src/com/haulmont/cuba/desktop/gui/components/DesktopWindow.java @@ -396,8 +396,8 @@ public class DesktopWindow implements Window, Component.Disposable, return res; } - protected boolean isModified() { - return getDsContext() != null && getDsContext().isModified(); + public boolean isModified() { + return delegate.isModified(); } private void stopTimers() { @@ -1498,11 +1498,6 @@ public class DesktopWindow implements Window, Component.Disposable, return delegate.getDatasource(); } - @Override - public boolean isModified() { - return ((EditorWindowDelegate) delegate).isModified(); - } - @Override public boolean commit() { return commit(true); diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/EditorWindowDelegate.java b/modules/gui/src/com/haulmont/cuba/gui/components/EditorWindowDelegate.java index f7f1a0da1a..3d0634fc4c 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/EditorWindowDelegate.java +++ b/modules/gui/src/com/haulmont/cuba/gui/components/EditorWindowDelegate.java @@ -241,10 +241,8 @@ public class EditorWindowDelegate extends WindowDelegate { public boolean isModified() { if (readOnly) return false; - else if (wrapper instanceof Window.Committable) - return ((Window.Committable) wrapper).isModified(); else - return window.getDsContext() != null && window.getDsContext().isModified(); + return super.isModified(); } public boolean commit(boolean close) { diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/WindowDelegate.java b/modules/gui/src/com/haulmont/cuba/gui/components/WindowDelegate.java index 35e365b92b..7cdbd7f4f0 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/WindowDelegate.java +++ b/modules/gui/src/com/haulmont/cuba/gui/components/WindowDelegate.java @@ -213,6 +213,13 @@ public class WindowDelegate { return true; } + public boolean isModified() { + if (wrapper instanceof Window.Committable) + return ((Window.Committable) wrapper).isModified(); + else + return window.getDsContext() != null && window.getDsContext().isModified(); + } + public Window openWindow(String windowAlias, WindowManager.OpenType openType, Map params) { WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias); return window.getWindowManager().openWindow(windowInfo, openType, params); diff --git a/modules/web/src/com/haulmont/cuba/web/gui/WebWindow.java b/modules/web/src/com/haulmont/cuba/web/gui/WebWindow.java index 6793a40267..ed81eeb419 100644 --- a/modules/web/src/com/haulmont/cuba/web/gui/WebWindow.java +++ b/modules/web/src/com/haulmont/cuba/web/gui/WebWindow.java @@ -1121,8 +1121,8 @@ public class WebWindow implements Window, Component.Wrapper, return false; } - protected boolean isModified() { - return getDsContext() != null && getDsContext().isModified(); + public boolean isModified() { + return delegate.isModified(); } @Override @@ -1416,11 +1416,6 @@ public class WebWindow implements Window, Component.Wrapper, } } - @Override - public boolean isModified() { - return ((EditorWindowDelegate) delegate).isModified(); - } - @Override public boolean commit() { return commit(true);