[Libreoffice-commits] .: cui/source svtools/inc svtools/Library_svt.mk svtools/Package_inc.mk svtools/source svtools/uiconfig svtools/UI_svt.mk
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 27 03:52:10 PST 2012
cui/source/inc/cuires.hrc | 2
cui/source/options/optjava.cxx | 6 -
cui/source/options/optjava.src | 7 -
svtools/Library_svt.mk | 1
svtools/Package_inc.mk | 1
svtools/UI_svt.mk | 1
svtools/inc/svtools/restartdialog.hxx | 40 +++++++++
svtools/inc/svtools/svtools.hrc | 6 -
svtools/source/dialogs/restartdialog.cxx | 78 +++++++++++++++++++
svtools/source/java/javaerror.src | 13 ---
svtools/source/java/javainteractionhandler.cxx | 13 +--
svtools/uiconfig/ui/restartdialog.ui | 102 +++++++++++++++++++++++++
12 files changed, 237 insertions(+), 33 deletions(-)
New commits:
commit 872d76228fc440d22924b69a391f027dbdc8e693
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Nov 27 12:40:15 2012 +0100
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
diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc
index c497fda..1e14f82 100644
--- a/cui/source/inc/cuires.hrc
+++ b/cui/source/inc/cuires.hrc
@@ -24,7 +24,7 @@
// Resource-Id's ------------------------------------------------------------
-#define RID_SVX_MSGBOX_JAVA_RESTART (RID_SVX_START + 0)
+// RID_SVX_START + 0 unused
#define RID_SVX_MSGBOX_OPTIONS_RESTART (RID_SVX_START + 1)
#define RID_SVX_MSGBOX_LANGUAGE_RESTART (RID_SVX_START + 2)
#define RID_CUI_DIALOG_COLORPICKER (RID_SVX_START + 3)
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 32d9441..821bb92 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -32,6 +32,7 @@
#include <vcl/waitobj.hxx>
#include <unotools/pathoptions.hxx>
#include <svtools/imagemgr.hxx>
+#include "svtools/restartdialog.hxx"
#include "svtools/treelistentry.hxx"
#include <sfx2/filedlghelper.hxx>
#include <comphelper/processfactory.hxx>
@@ -662,8 +663,9 @@ sal_Bool SvxJavaOptionsPage::FillItemSet( SfxItemSet& /*rCoreSet*/ )
if ( bRunning ||
( ( pInfo->nRequirements & JFW_REQUIRE_NEEDRESTART ) == JFW_REQUIRE_NEEDRESTART ) )
{
- WarningBox aWarnBox( this, CUI_RES( RID_SVX_MSGBOX_JAVA_RESTART ) );
- aWarnBox.Execute();
+ svtools::executeRestartDialog(
+ comphelper::getProcessComponentContext(), this,
+ svtools::RESTART_REASON_JAVA);
}
eErr = jfw_setSelectedJRE( pInfo );
diff --git a/cui/source/options/optjava.src b/cui/source/options/optjava.src
index 77cd195..4ee2751 100644
--- a/cui/source/options/optjava.src
+++ b/cui/source/options/optjava.src
@@ -290,13 +290,6 @@ ErrorBox RID_SVXERR_JRE_FAILED_VERSION
Message [ en-US ] = "The Java runtime environment you selected is not the required version.\nPlease select a different folder." ;
};
-WarningBox RID_SVX_MSGBOX_JAVA_RESTART
-{
- BUTTONS = WB_OK ;
- DEFBUTTON = WB_DEF_OK ;
- Message [ en-US ] = "For the selected Java runtime environment to work properly, %PRODUCTNAME must be restarted.\nPlease restart %PRODUCTNAME now." ;
-};
-
WarningBox RID_SVX_MSGBOX_OPTIONS_RESTART
{
BUTTONS = WB_OK ;
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index fd81beb..7ed5a70 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 551d66f..054bd29 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 250bd5f..4afe25e 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 0000000..85afd7d
--- /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 c855cab..01ee8a8 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 0000000..1004a2d
--- /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 09b904c..0949b68 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 e38fa9a..d142ded 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 0000000..dd041b4
--- /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>
More information about the Libreoffice-commits
mailing list