27#include <config_java.h>
34#include <officecfg/Office/Common.hxx>
35#include <osl/file.hxx>
36#include <rtl/bootstrap.hxx>
51#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
52#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
53#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
55#include <jvmfwk/framework.hxx>
60#define CLASSPATH_DELIMITER SAL_PATHSEPARATOR
69 :
SfxTabPage(pPage, pController,
"cui/ui/optadvancedpage.ui",
"OptAdvancedPage", &
rSet)
70 , m_aResetIdle(
"cui options SvxJavaOptionsPage Reset")
71 , xDialogListener(new ::
svt::DialogClosedListener())
72 , m_xJavaEnableCB(m_xBuilder->weld_check_button(
"javaenabled"))
73 , m_xJavaList(m_xBuilder->weld_tree_view(
"javas"))
74 , m_xJavaPathText(m_xBuilder->weld_label(
"javapath"))
75 , m_xAddBtn(m_xBuilder->weld_button(
"add"))
76 , m_xParameterBtn(m_xBuilder->weld_button(
"parameters"))
77 , m_xClassPathBtn(m_xBuilder->weld_button(
"classpath"))
78 , m_xExpertConfigBtn(m_xBuilder->weld_button(
"expertconfig"))
79 , m_xExperimentalCB(m_xBuilder->weld_check_button(
"experimental"))
80 , m_xMacroCB(m_xBuilder->weld_check_button(
"macrorecording"))
81 , m_xAddDialogText(m_xBuilder->weld_label(
"selectruntime"))
82 , m_xJavaFrame(m_xBuilder->weld_widget(
"javaframe"))
94 std::vector<int> aWidths
97 o3tl::narrowing<int>(
m_xJavaList->get_pixel_size(
"Sun Microsystems Inc.").Width())
108 if (!officecfg::Office::Common::Security::EnableExpertConfiguration::get())
111 if (officecfg::Office::Common::Misc::MacroRecorderMode::isReadOnly())
114 if (officecfg::Office::Common::Misc::ExperimentalMode::isReadOnly())
139 bool bEnable = m_xJavaFrame->get_sensitive() && m_xJavaEnableCB->get_active();
140 m_xJavaList->set_sensitive(bEnable);
145 HandleCheckEntry(m_xJavaList->get_iter_index_in_parent(rRowCol.first));
150 UpdateJavaPathText();
157 Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
161 xFolderPicker->setDisplayDirectory( sWorkFolder );
162 xFolderPicker->setDescription( m_sAddDialogText );
164 Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
165 if ( xAsyncDlg.is() )
166 xAsyncDlg->startExecuteModal( xDialogListener );
167 else if ( xFolderPicker.is() && xFolderPicker->execute() == ExecutableDialogResults::OK )
168 AddFolder( xFolderPicker->getDirectory() );
179 std::vector< OUString > aParameterList;
184 if (
JFW_E_NONE == eErr && !m_parParameters.empty() )
186 aParameterList = m_parParameters;
187 m_xParamDlg->SetParameters( aParameterList );
192 aParameterList = m_xParamDlg->GetParameters();
193 m_xParamDlg->DisableButtons();
196 if (m_xParamDlg->run() ==
RET_OK)
198 if ( aParameterList != m_xParamDlg->GetParameters() )
200 aParameterList = m_xParamDlg->GetParameters();
208 m_xParamDlg->SetParameters( aParameterList );
226 sClassPath = m_pClassPath;
227 m_xPathDlg->SetClassPath( sClassPath );
231 sClassPath = m_xPathDlg->GetClassPath();
233 m_xPathDlg->SetFocus();
234 if (m_xPathDlg->run() ==
RET_OK)
237 if (m_xPathDlg->GetClassPath() != sClassPath)
239 sClassPath = m_xPathDlg->GetClassPath();
247 m_xPathDlg->SetClassPath( sClassPath );
264 Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY );
265 if ( xAsyncDlg.is() )
266 xAsyncDlg->startExecuteModal( xDialogListener );
267 else if ( xFolderPicker.is() && xFolderPicker->execute() == ExecutableDialogResults::OK )
268 AddFolder( xFolderPicker->getDirectory() );
278 if (
RET_OK == pEvt->DialogResult )
280 DBG_ASSERT( xFolderPicker.is(),
"SvxJavaOptionsPage::DialogClosedHdl(): no folder picker" );
282 AddFolder( xFolderPicker->getDirectory() );
291 aExpertConfigDlg.
Reset();
303 m_parJavaInfo.clear();
316 for (
auto const & pInfo: m_parJavaInfo)
327 std::unique_ptr<JavaInfo> pSelectedJava;
333 for (
auto const & pCmpInfo: m_parJavaInfo)
359 OUString sLocation = aLocObj.
getFSysPath(FSysStyle::Detect);
381 OUString sLocation =
m_xJavaList->get_selected_id();
390 bool bStartAgain =
true;
391 std::unique_ptr<JavaInfo> pInfo;
397 for (
auto const & pCmpInfo: m_parJavaInfo)
435 VclMessageType::Warning, VclButtonsType::Ok,
436 CuiResId(RID_CUISTR_JRE_NOT_RECOGNIZED)));
442 VclMessageType::Warning, VclButtonsType::Ok,
443 CuiResId(RID_CUISTR_JRE_FAILED_VERSION)));
467 return std::make_unique<SvxJavaOptionsPage>(pPage, pController, *rAttrSet);
472 bool bModified =
false;
476 std::shared_ptr< comphelper::ConfigurationChanges > xChanges(
478 officecfg::Office::Common::Misc::ExperimentalMode::set(
m_xExperimentalCB->get_active(), xChanges );
484 if (
m_xMacroCB->get_state_changed_from_saved() )
486 std::shared_ptr< comphelper::ConfigurationChanges > xChanges(
488 officecfg::Office::Common::Misc::MacroRecorderMode::set(
m_xMacroCB->get_active(), xChanges );
498 SAL_WARN_IF(
JFW_E_NONE != eErr,
"cui.options",
"SvxJavaOptionsPage::FillItemSet(): error in jfw_setVMParameters");
508 SAL_WARN_IF(
JFW_E_NONE != eErr,
"cui.options",
"SvxJavaOptionsPage::FillItemSet(): error in jfw_setUserClassPath");
519 if (
i < m_parJavaInfo.size() )
520 pInfo = m_parJavaInfo[
i].get();
524 std::unique_ptr<JavaInfo> pSelectedJava;
537 SAL_WARN_IF(
JFW_E_NONE != eErr,
"cui.options",
"SvxJavaOptionsPage::FillItemSet(): error in jfw_setSelectedJRE");
545 bool bEnabled =
false;
548 "SvxJavaOptionsPage::FillItemSet(): error in jfw_getEnabled" );
553 "SvxJavaOptionsPage::FillItemSet(): error in jfw_setEnabled" );
568 bool bEnabled =
false;
575 std::unique_ptr<JavaInfo> pSelectedJava;
588 m_xExperimentalCB->set_active( officecfg::Office::Common::Misc::ExperimentalMode::get() );
590 m_xMacroCB->set_active( officecfg::Office::Common::Misc::MacroRecorderMode::get() );
605 : GenericDialogController(pParent,
"cui/ui/javastartparametersdialog.ui",
606 "JavaStartParameters")
607 , m_xParameterEdit(m_xBuilder->weld_entry(
"parameterfield"))
608 , m_xAssignBtn(m_xBuilder->weld_button(
"assignbtn"))
609 , m_xAssignedList(m_xBuilder->weld_tree_view(
"assignlist"))
610 , m_xRemoveBtn(m_xBuilder->weld_button(
"removebtn"))
611 , m_xEditBtn(m_xBuilder->weld_button(
"editbtn"))
635 m_xAssignBtn->set_sensitive(!sParam.isEmpty());
641 if (sParam.isEmpty())
644 int nPos = m_xAssignedList->find_text(sParam);
647 m_xAssignedList->append_text(sParam);
648 m_xAssignedList->select(m_xAssignedList->n_children() - 1);
651 m_xAssignedList->select(
nPos);
652 m_xParameterEdit->set_text(OUString());
653 ModifyHdl_Impl(*m_xParameterEdit);
655 EnableRemoveButton();
660 if (m_xAssignBtn->get_sensitive())
662 AssignHdl_Impl(*m_xAssignBtn);
676 EnableRemoveButton();
687 int nPos = m_xAssignedList->get_selected_index();
690 m_xAssignedList->remove(
nPos);
691 int nCount = m_xAssignedList->n_children();
696 m_xAssignedList->select(
nPos);
703 EnableRemoveButton();
719 if (!aParamEditDlg.run())
723 if ( !editedClassPath.isEmpty() && editableClassPath != editedClassPath )
735 return GenericDialogController::run();
741 std::vector< OUString > aParamList;
742 aParamList.reserve(
nCount);
758 for (
auto const & sParam: rParams)
770 : GenericDialogController(pParent,
"cui/ui/javaclasspathdialog.ui",
"JavaClassPath")
771 , m_xPathList(m_xBuilder->weld_tree_view(
"paths"))
772 , m_xAddArchiveBtn(m_xBuilder->weld_button(
"archive"))
773 , m_xAddPathBtn(m_xBuilder->weld_button(
"folder"))
774 , m_xRemoveBtn(m_xBuilder->weld_button(
"remove"))
798 if (m_xPathList->count_selected_rows() > 0)
800 osl::FileBase::getFileURLFromSystemPath(m_xPathList->get_selected_text(), sFolder);
803 if (!sFolder.isEmpty())
807 OUString sURL = aDlg.
GetPath();
809 if (osl::FileBase::getSystemPathFromFileURL(sURL, sFile) == osl::FileBase::E_None)
812 if ( !IsPathDuplicate( sFile ) )
815 m_xPathList->select(m_xPathList->n_children() - 1);
819 OUString sMsg(
CuiResId( RID_CUISTR_MULTIFILE_DBL_ERR ) );
820 sMsg = sMsg.replaceFirst(
"%1", sFile );
822 VclMessageType::Warning, VclButtonsType::Ok, sMsg));
828 OUString sMsg(
CuiResId( RID_CUISTR_CANNOTCONVERTURL_ERR ) );
829 sMsg = sMsg.replaceFirst(
"%1", sURL );
831 VclMessageType::Warning, VclButtonsType::Ok, sMsg));
835 EnableRemoveButton();
840 Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
844 if (m_xPathList->count_selected_rows() > 0)
846 osl::FileBase::getFileURLFromSystemPath(m_xPathList->get_selected_text(), sOldFolder);
849 if (sOldFolder.isEmpty())
851 xFolderPicker->setDisplayDirectory( sOldFolder );
852 if ( xFolderPicker->execute() == ExecutableDialogResults::OK )
854 OUString sFolderURL( xFolderPicker->getDirectory() );
857 if (osl::FileBase::getSystemPathFromFileURL(sFolderURL, sNewFolder)
858 == osl::FileBase::E_None)
860 if ( !IsPathDuplicate( sNewFolder ) )
863 m_xPathList->select(m_xPathList->n_children() - 1);
867 OUString sMsg(
CuiResId( RID_CUISTR_MULTIFILE_DBL_ERR ) );
868 sMsg = sMsg.replaceFirst(
"%1", sNewFolder );
870 VclMessageType::Warning, VclButtonsType::Ok, sMsg));
876 OUString sMsg(
CuiResId( RID_CUISTR_CANNOTCONVERTURL_ERR ) );
877 sMsg = sMsg.replaceFirst(
"%1", sFolderURL );
879 VclMessageType::Warning, VclButtonsType::Ok, sMsg));
883 EnableRemoveButton();
888 int nPos = m_xPathList->get_selected_index();
891 m_xPathList->remove(
nPos);
892 int nCount = m_xPathList->n_children();
897 m_xPathList->select(
nPos );
901 EnableRemoveButton();
906 EnableRemoveButton();
927 OUStringBuffer sPath;
931 if (!sPath.isEmpty())
935 return sPath.makeStringAndClear();
939void SvxJavaClassPathDlg::SetClassPath(
const OUString& _rPath )
944 if (!_rPath.isEmpty())
947 for (
auto const& path : paths)
950 if (path.startsWith(
"$"))
953 rtl::Bootstrap::expandMacros(sURL);
957 osl::FileBase::getFileURLFromSystemPath(path, sURL);
Reference< XExecutableDialog > m_xDialog
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
virtual void Start(bool bStartTimer=true) override
void SetNeedsRestart(svtools::RestartReason eReason)
SfxOkDialogController * GetDialogController() const
void SetUserData(const OUString &rString)
weld::Window * GetFrameWeld() const
const OUString & GetWorkPath() const
SvxJavaClassPathDlg(weld::Window *pParent)
std::unique_ptr< weld::Button > m_xAddArchiveBtn
std::unique_ptr< weld::TreeView > m_xPathList
bool IsPathDuplicate(std::u16string_view _rPath)
OUString GetClassPath() const
std::unique_ptr< weld::Button > m_xRemoveBtn
virtual ~SvxJavaClassPathDlg() override
std::unique_ptr< weld::Button > m_xAddPathBtn
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::CheckButton > m_xMacroCB
std::unique_ptr< weld::CheckButton > m_xJavaEnableCB
OUString m_sAddDialogText
std::unique_ptr< weld::Button > m_xExpertConfigBtn
void HandleCheckEntry(int nCheckedRow)
void RequestRestart(svtools::RestartReason eReason)
void UpdateJavaPathText()
std::unique_ptr< SvxJavaClassPathDlg > m_xPathDlg
std::unique_ptr< weld::TreeView > m_xJavaList
std::unique_ptr< weld::Button > m_xAddBtn
void AddFolder(const OUString &_rFolder)
std::unique_ptr< SvxJavaParameterDlg > m_xParamDlg
rtl::Reference< ::svt::DialogClosedListener > xDialogListener
std::unique_ptr< weld::Label > m_xJavaPathText
virtual void FillUserData() override
std::unique_ptr< weld::Widget > m_xJavaFrame
std::unique_ptr< weld::CheckButton > m_xExperimentalCB
virtual ~SvxJavaOptionsPage() override
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker
std::unique_ptr< weld::Button > m_xParameterBtn
void AddJRE(JavaInfo const *_pInfo)
std::unique_ptr< weld::Label > m_xAddDialogText
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
virtual void Reset(const SfxItemSet *rSet) override
SvxJavaOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
std::unique_ptr< weld::Button > m_xClassPathBtn
std::vector< std::unique_ptr< JavaInfo > > m_aAddedInfos
void EnableRemoveButton()
void SetParameters(std::vector< OUString > const &rParams)
void DisableRemoveButton()
std::vector< OUString > GetParameters() const
SvxJavaParameterDlg(weld::Window *pParent)
std::unique_ptr< weld::Button > m_xAssignBtn
void DisableAssignButton()
virtual ~SvxJavaParameterDlg() override
std::unique_ptr< weld::Button > m_xEditBtn
virtual short run() override
std::unique_ptr< weld::Button > m_xRemoveBtn
std::unique_ptr< weld::Entry > m_xParameterEdit
std::unique_ptr< weld::TreeView > m_xAssignedList
void SetInvokeHandler(const Link< Timer *, void > &rLink)
static std::shared_ptr< ConfigurationChanges > create()
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
void SetDisplayDirectory(const OUString &rPath)
void SetTitle(const OUString &rNewTitle)
void SetContext(Context _eNewContext)
std::shared_ptr< weld::Dialog > m_xDialog
std::pair< const TreeIter &, int > iter_col
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
javaFrameworkError jfw_setSelectedJRE(JavaInfo const *pInfo)
javaFrameworkError jfw_getJavaInfoByPath(OUString const &pPath, std::unique_ptr< JavaInfo > *ppInfo)
javaFrameworkError jfw_setVMParameters(std::vector< OUString > const &arOptions)
javaFrameworkError jfw_addJRELocation(OUString const &sLocation)
javaFrameworkError jfw_setUserClassPath(OUString const &pCp)
javaFrameworkError jfw_getSelectedJRE(std::unique_ptr< JavaInfo > *ppInfo)
javaFrameworkError jfw_getVMParameters(std::vector< OUString > *parOptions)
bool jfw_areEqualJavaInfo(JavaInfo const *pInfoA, JavaInfo const *pInfoB)
javaFrameworkError jfw_getUserClassPath(OUString *ppCP)
javaFrameworkError jfw_setEnabled(bool bEnabled)
javaFrameworkError jfw_findAllJREs(std::vector< std::unique_ptr< JavaInfo > > *pparInfo)
javaFrameworkError jfw_getEnabled(bool *pbEnabled)
std::vector< OUString > jfw_convertUserPathList(OUString const &sUserPath)
#define JFW_REQUIRE_NEEDRESTART
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
OString strip(const OString &rIn, char c)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
#define CLASSPATH_DELIMITER
IMPL_LINK(SvxJavaOptionsPage, CheckHdl_Impl, const weld::TreeView::iter_col &, rRowCol, void)
IMPL_LINK_NOARG(SvxJavaOptionsPage, EnableHdl_Impl, weld::Toggleable &, void)