summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-11-27 12:40:15 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-11-27 12:51:39 +0100
commit872d76228fc440d22924b69a391f027dbdc8e693 (patch)
tree8c62817deff6b6636bb04d353af8be2ff7cc5052 /svtools
parent602b746330d21ae1b9c0fc60eb0980ed92cd5680 (diff)
Introduce a Restart dialog that allows to automatically restart LO
...instead of just telling the user to restart manually. The one existing dialog (duplicated into svtools and cui) that got replaced by this is the dialog asking to restart when the choice of JVM changed. There are more similar dialogs that would benefit from replacing them, like RID_SVX_MSGBOX_OPTIONS_RESTART (cui/source/options/optjava.src), but that one is called when closing a dialog nested within the Options dialog, and calling OfficeRestartManger.requestRestart in such a nested situation still leads to a crash. The design idea is that when more similar dialogs are replaced, restartdialog.ui contains a list of hidden GtkLables with the appropriate prose why a restart is required in the given case, and restartdialog.hxx's RestartReason enum contains corresponding values that will show exactly one of those GtkLables. The new svtools/uiconfig/ui/restartdialog.ui is probably still pretty rough and could benefit from some UX love. Change-Id: Id939188ee22f24301a8a3598b83afb31339bded5
Diffstat (limited to 'svtools')
-rw-r--r--svtools/Library_svt.mk1
-rw-r--r--svtools/Package_inc.mk1
-rw-r--r--svtools/UI_svt.mk1
-rw-r--r--svtools/inc/svtools/restartdialog.hxx40
-rw-r--r--svtools/inc/svtools/svtools.hrc6
-rw-r--r--svtools/source/dialogs/restartdialog.cxx78
-rw-r--r--svtools/source/java/javaerror.src13
-rw-r--r--svtools/source/java/javainteractionhandler.cxx13
-rw-r--r--svtools/uiconfig/ui/restartdialog.ui102
9 files changed, 232 insertions, 23 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index fd81beb9dbc3..7ed5a70e201d 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -130,6 +130,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/dialogs/mcvmath \
svtools/source/dialogs/PlaceEditDialog \
svtools/source/dialogs/prnsetup \
+ svtools/source/dialogs/restartdialog \
svtools/source/dialogs/roadmapwizard \
svtools/source/dialogs/ServerDetailsControls \
svtools/source/dialogs/wizardmachine \
diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk
index 551d66f1e921..054bd29c76dc 100644
--- a/svtools/Package_inc.mk
+++ b/svtools/Package_inc.mk
@@ -108,6 +108,7 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/popupmenucontrollerbas
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/popupwindowcontroller.hxx,svtools/popupwindowcontroller.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/printoptions.hxx,svtools/printoptions.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/prnsetup.hxx,svtools/prnsetup.hxx))
+$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/restartdialog.hxx,svtools/restartdialog.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/roadmap.hxx,svtools/roadmap.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/roadmapwizard.hxx,svtools/roadmapwizard.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/rtfkeywd.hxx,svtools/rtfkeywd.hxx))
diff --git a/svtools/UI_svt.mk b/svtools/UI_svt.mk
index 250bd5f57c9a..4afe25e7b17d 100644
--- a/svtools/UI_svt.mk
+++ b/svtools/UI_svt.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_UI_UI,svt))
$(eval $(call gb_UI_add_uifiles,svt,\
svtools/uiconfig/ui/graphicexport \
svtools/uiconfig/ui/placeedit \
+ svtools/uiconfig/ui/restartdialog \
))
# vim: set noet sw=4 ts=4:
diff --git a/svtools/inc/svtools/restartdialog.hxx b/svtools/inc/svtools/restartdialog.hxx
new file mode 100644
index 000000000000..85afd7d89f3c
--- /dev/null
+++ b/svtools/inc/svtools/restartdialog.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SVTOOLS_RESTARTDIALOG_HXX
+#define INCLUDED_SVTOOLS_RESTARTDIALOG_HXX
+
+#include "sal/config.h"
+
+#include "com/sun/star/uno/Reference.hxx"
+#include "svtools/svtdllapi.h"
+
+class Window;
+namespace com { namespace sun { namespace star { namespace uno {
+ class XComponentContext;
+} } } }
+
+namespace svtools {
+
+enum RestartReason {
+ RESTART_REASON_JAVA
+ // "For the selected Java runtime environment to work properly,
+ // %PRODUCTNAME must be restarted."
+};
+
+SVT_DLLPUBLIC void executeRestartDialog(
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ const & context,
+ Window * parent, RestartReason reason);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/inc/svtools/svtools.hrc b/svtools/inc/svtools/svtools.hrc
index c855cabcc851..01ee8a88e430 100644
--- a/svtools/inc/svtools/svtools.hrc
+++ b/svtools/inc/svtools/svtools.hrc
@@ -205,8 +205,8 @@
#define STR_ERROR_JVMCREATIONFAILED (STR_SVT_JAVAERROR_START+1)
#define STR_WARNING_JAVANOTFOUND (STR_SVT_JAVAERROR_START+2)
#define STR_WARNING_INVALIDJAVASETTINGS (STR_SVT_JAVAERROR_START+3)
-#define STR_ERROR_RESTARTREQUIRED (STR_SVT_JAVAERROR_START+4)
-#define STR_SVT_JAVAERROR_END (STR_ERROR_RESTARTREQUIRED)
+// STR_SVT_JAVAERROR_START + 4 unused
+#define STR_SVT_JAVAERROR_END (STR_SVT_JAVAERROR_START+4)
// String array to match UI language names to LanguageType values and vice versa
#define STR_ARR_SVT_LANGUAGE_TABLE_START (STR_SVT_JAVAERROR_END + 1)
@@ -244,7 +244,7 @@
#define ERRORBOX_JVMCREATIONFAILED (RID_SVTOOLS_START+21)
#define WARNINGBOX_JAVANOTFOUND (RID_SVTOOLS_START+22)
#define WARNINGBOX_INVALIDJAVASETTINGS (RID_SVTOOLS_START+23)
-#define ERRORBOX_RESTARTREQUIRED (RID_SVTOOLS_START+24)
+// RID_SVTOOLS_START + 24 unused
#define WARNINGBOX_INVALIDJAVASETTINGS_MAC (RID_SVTOOLS_START+25)
#define ERRORBOX_JVMCREATIONFAILED_MAC (RID_SVTOOLS_START+26)
diff --git a/svtools/source/dialogs/restartdialog.cxx b/svtools/source/dialogs/restartdialog.cxx
new file mode 100644
index 000000000000..1004a2d6d394
--- /dev/null
+++ b/svtools/source/dialogs/restartdialog.cxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "sal/config.h"
+
+#include <cassert>
+
+#include "com/sun/star/task/OfficeRestartManager.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "svtools/restartdialog.hxx"
+#include "tools/link.hxx"
+#include "vcl/button.hxx"
+#include "vcl/dialog.hxx"
+#include "vcl/window.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+class RestartDialog: public ModalDialog {
+public:
+ RestartDialog(Window * parent, svtools::RestartReason reason):
+ ModalDialog(parent, "RestartDialog", "svt/ui/restartdialog.ui")
+ {
+ get(reasonJava_, "reason_java");
+ get(btnYes_, "yes");
+ get(btnNo_, "no");
+ switch (reason) {
+ case svtools::RESTART_REASON_JAVA:
+ reasonJava_->Show();
+ break;
+ default:
+ assert(false); // this cannot happen
+ }
+ btnYes_->SetClickHdl(LINK(this, RestartDialog, hdlYes));
+ btnNo_->SetClickHdl(LINK(this, RestartDialog, hdlNo));
+ }
+
+private:
+ DECL_LINK(hdlYes, void *);
+ DECL_LINK(hdlNo, void *);
+
+ Window * reasonJava_;
+ PushButton * btnYes_;
+ PushButton * btnNo_;
+};
+
+IMPL_LINK_NOARG(RestartDialog, hdlYes) {
+ EndDialog(true);
+ return 0;
+}
+
+IMPL_LINK_NOARG(RestartDialog, hdlNo) {
+ EndDialog(false);
+ return 0;
+}
+
+}
+
+void svtools::executeRestartDialog(
+ css::uno::Reference< css::uno::XComponentContext > const & context,
+ Window * parent, RestartReason reason)
+{
+ if (RestartDialog(parent, reason).Execute()) {
+ css::task::OfficeRestartManager::get(context)->requestRestart(
+ css::uno::Reference< css::task::XInteractionHandler >());
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/java/javaerror.src b/svtools/source/java/javaerror.src
index 09b904c4d935..0949b68f2648 100644
--- a/svtools/source/java/javaerror.src
+++ b/svtools/source/java/javaerror.src
@@ -60,14 +60,6 @@ ErrorBox ERRORBOX_JVMCREATIONFAILED
Message[ en-US ] = "%PRODUCTNAME requires a Java runtime environment (JRE) to perform this task. The selected JRE is defective. Please select another version or install a new JRE and select it under Tools - Options - %PRODUCTNAME - Java.";
};
-ErrorBox ERRORBOX_RESTARTREQUIRED
-{
- Buttons = WB_OK;
- DefButton = WB_DEF_OK ;
- Message[ en-US ] = "For the selected Java runtime environment to work properly, %PRODUCTNAME must be restarted. Please restart %PRODUCTNAME now.";
-};
-
-
String STR_WARNING_JAVANOTFOUND
{
@@ -79,11 +71,6 @@ String STR_WARNING_INVALIDJAVASETTINGS
Text[ en-US ] = "Select JRE";
};
-String STR_ERROR_RESTARTREQUIRED
-{
- Text[ en-US ] = "Restart Required";
-};
-
String STR_QUESTION_JAVADISABLED
{
Text[ en-US ] = "Enable JRE" ;
diff --git a/svtools/source/java/javainteractionhandler.cxx b/svtools/source/java/javainteractionhandler.cxx
index e38fa9a98d32..d142dedd564d 100644
--- a/svtools/source/java/javainteractionhandler.cxx
+++ b/svtools/source/java/javainteractionhandler.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/java/JavaDisabledException.hpp>
#include <com/sun/star/java/JavaVMCreationFailureException.hpp>
#include <com/sun/star/java/RestartRequiredException.hpp>
+#include <comphelper/processfactory.hxx>
#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>
#include <osl/mutex.hxx>
@@ -34,6 +35,7 @@
#include <tools/rcid.h>
#include <jvmfwk/framework.h>
+#include <svtools/restartdialog.hxx>
#include <svtools/svtresid.hxx>
#include <svtools/javainteractionhandler.hxx>
#include <svtools/javacontext.hxx>
@@ -201,14 +203,11 @@ void SAL_CALL JavaInteractionHandler::handle( const Reference< XInteractionReque
//before it can be used.
SolarMutexGuard aSolarGuard;
m_bRestartRequired_Handled = true;
- ErrorBox aErrorBox(NULL, SvtResId( ERRORBOX_RESTARTREQUIRED ) );
- aErrorBox.SetText(SvtResId( STR_ERROR_RESTARTREQUIRED ).toString());
- nResult = aErrorBox.Execute();
- }
- else
- {
- nResult = RET_OK;
+ svtools::executeRestartDialog(
+ comphelper::getProcessComponentContext(), 0,
+ svtools::RESTART_REASON_JAVA);
}
+ nResult = RET_OK;
}
if ( nResult == RET_CANCEL || nResult == RET_NO)
diff --git a/svtools/uiconfig/ui/restartdialog.ui b/svtools/uiconfig/ui/restartdialog.ui
new file mode 100644
index 000000000000..dd041b4ec52b
--- /dev/null
+++ b/svtools/uiconfig/ui/restartdialog.ui
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="RestartDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <property name="layout_style">center</property>
+ <child>
+ <object class="GtkButton" id="yes">
+ <property name="label" translatable="yes">Restart now</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="no">
+ <property name="label" translatable="yes">Restart later</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="reason_java">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">For the selected Java runtime environment to work properly, %PRODUCTNAME must be restarted.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Do you want to restart %PRODUCTNAME now?</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">yes</action-widget>
+ <action-widget response="0">no</action-widget>
+ </action-widgets>
+ </object>
+</interface>