1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <config_java.h>
26 #include <vcl/timer.hxx>
27 #include <vcl/idle.hxx>
28 #include <vcl/weld.hxx>
29 #include <sfx2/tabdlg.hxx>
30 #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
31 #include <svtools/dialogclosedlistener.hxx>
32 #include <svtools/restartdialog.hxx>
34 // forward ---------------------------------------------------------------
39 typedef void* JavaInfo
;
42 class SvxJavaParameterDlg
;
43 class SvxJavaClassPathDlg
;
45 class OfaTreeOptionsDialog
;
47 // class SvxJavaOptionsPage ----------------------------------------------
49 class SvxJavaOptionsPage
: public SfxTabPage
53 std::vector
<std::unique_ptr
<JavaInfo
>> m_parJavaInfo
;
54 std::vector
<OUString
> m_parParameters
;
55 OUString m_pClassPath
;
57 OUString m_sInstallText
;
58 OUString m_sAddDialogText
;
61 std::vector
<std::unique_ptr
<JavaInfo
>> m_aAddedInfos
;
63 rtl::Reference
< ::svt::DialogClosedListener
> xDialogListener
;
64 css::uno::Reference
< css::ui::dialogs::XFolderPicker2
> xFolderPicker
;
66 std::unique_ptr
<weld::CheckButton
> m_xJavaEnableCB
;
67 std::unique_ptr
<weld::TreeView
> m_xJavaList
;
68 std::unique_ptr
<weld::Label
> m_xJavaPathText
;
69 std::unique_ptr
<weld::Button
> m_xAddBtn
;
70 std::unique_ptr
<weld::Button
> m_xParameterBtn
;
71 std::unique_ptr
<weld::Button
> m_xClassPathBtn
;
72 std::unique_ptr
<weld::Button
> m_xExpertConfigBtn
;
74 std::unique_ptr
<SvxJavaParameterDlg
> m_xParamDlg
;
75 std::unique_ptr
<SvxJavaClassPathDlg
> m_xPathDlg
;
77 std::unique_ptr
<weld::CheckButton
> m_xExperimentalCB
;
78 std::unique_ptr
<weld::CheckButton
> m_xMacroCB
;
80 std::unique_ptr
<weld::Label
> m_xAddDialogText
;
82 std::unique_ptr
<weld::Widget
> m_xJavaFrame
;
84 DECL_LINK(EnableHdl_Impl
, weld::Toggleable
&, void);
85 DECL_LINK(CheckHdl_Impl
, const weld::TreeView::iter_col
&, void);
86 DECL_LINK(SelectHdl_Impl
, weld::TreeView
&, void);
87 DECL_LINK(AddHdl_Impl
, weld::Button
&, void);
88 DECL_LINK(ParameterHdl_Impl
, weld::Button
&, void);
89 DECL_LINK(ClassPathHdl_Impl
, weld::Button
&, void);
90 DECL_LINK(ResetHdl_Impl
, Timer
*, void);
92 DECL_LINK(StartFolderPickerHdl
, void *, void);
93 DECL_LINK(DialogClosedHdl
, css::ui::dialogs::DialogClosedEvent
*, void);
95 DECL_LINK(ExpertConfigHdl_Impl
, weld::Button
&, void);
99 void AddJRE( JavaInfo
const * _pInfo
);
100 void HandleCheckEntry(int nCheckedRow
);
101 void UpdateJavaPathText();
102 void AddFolder( const OUString
& _rFolder
);
103 void RequestRestart( svtools::RestartReason eReason
);
106 SvxJavaOptionsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
107 virtual ~SvxJavaOptionsPage() override
;
109 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rSet
);
111 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
112 virtual void Reset( const SfxItemSet
* rSet
) override
;
113 virtual void FillUserData() override
;
116 // class SvxJavaParameterDlg ---------------------------------------------
118 class SvxJavaParameterDlg
: public weld::GenericDialogController
121 std::unique_ptr
<weld::Entry
> m_xParameterEdit
;
122 std::unique_ptr
<weld::Button
> m_xAssignBtn
;
123 std::unique_ptr
<weld::TreeView
> m_xAssignedList
;
124 std::unique_ptr
<weld::Button
> m_xRemoveBtn
;
125 std::unique_ptr
<weld::Button
> m_xEditBtn
;
127 DECL_LINK(ModifyHdl_Impl
, weld::Entry
&, void);
128 DECL_LINK(ActivateHdl_Impl
, weld::Entry
&, bool);
129 DECL_LINK(AssignHdl_Impl
, weld::Button
&, void);
130 DECL_LINK(SelectHdl_Impl
, weld::TreeView
&, void);
131 DECL_LINK(DblClickHdl_Impl
, weld::TreeView
&, bool);
132 DECL_LINK(RemoveHdl_Impl
, weld::Button
&, void);
133 DECL_LINK(EditHdl_Impl
, weld::Button
&, void);
135 void EnableRemoveButton()
137 m_xRemoveBtn
->set_sensitive(m_xAssignedList
->get_selected_index() != -1);
140 void EnableEditButton()
142 m_xEditBtn
->set_sensitive(m_xAssignedList
->get_selected_index() != -1);
145 void DisableAssignButton()
147 m_xAssignBtn
->set_sensitive(false);
150 void DisableRemoveButton()
152 m_xRemoveBtn
->set_sensitive(false);
155 void DisableEditButton()
157 m_xEditBtn
->set_sensitive(false);
161 explicit SvxJavaParameterDlg(weld::Window
* pParent
);
162 virtual ~SvxJavaParameterDlg() override
;
164 virtual short run() override
;
166 std::vector
< OUString
> GetParameters() const;
167 void SetParameters( std::vector
< OUString
> const & rParams
);
168 void DisableButtons();
169 void EditParameter();
172 // class SvxJavaClassPathDlg ---------------------------------------------
174 class SvxJavaClassPathDlg
: public weld::GenericDialogController
177 std::unique_ptr
<weld::TreeView
> m_xPathList
;
178 std::unique_ptr
<weld::Button
> m_xAddArchiveBtn
;
179 std::unique_ptr
<weld::Button
> m_xAddPathBtn
;
180 std::unique_ptr
<weld::Button
> m_xRemoveBtn
;
184 DECL_LINK(AddArchiveHdl_Impl
, weld::Button
&, void);
185 DECL_LINK(AddPathHdl_Impl
, weld::Button
&, void);
186 DECL_LINK(RemoveHdl_Impl
, weld::Button
&, void);
187 DECL_LINK(SelectHdl_Impl
, weld::TreeView
&, void);
189 bool IsPathDuplicate(std::u16string_view _rPath
);
190 void EnableRemoveButton()
192 m_xRemoveBtn
->set_sensitive(m_xPathList
->get_selected_index() != -1);
196 explicit SvxJavaClassPathDlg(weld::Window
* pParent
);
197 virtual ~SvxJavaClassPathDlg() override
;
199 const OUString
& GetOldPath() const { return m_sOldPath
; }
200 void SetFocus() { m_xPathList
->grab_focus(); }
202 OUString
GetClassPath() const;
203 #if HAVE_FEATURE_JAVA
204 void SetClassPath( const OUString
& _rPath
);
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */