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::Widget
> m_xExperimentalImg
;
79 std::unique_ptr
<weld::CheckButton
> m_xMacroCB
;
80 std::unique_ptr
<weld::Widget
> m_xMacroImg
;
82 std::unique_ptr
<weld::Label
> m_xAddDialogText
;
84 std::unique_ptr
<weld::Widget
> m_xJavaFrame
;
86 DECL_LINK(EnableHdl_Impl
, weld::Toggleable
&, void);
87 DECL_LINK(CheckHdl_Impl
, const weld::TreeView::iter_col
&, void);
88 DECL_LINK(SelectHdl_Impl
, weld::TreeView
&, void);
89 DECL_LINK(AddHdl_Impl
, weld::Button
&, void);
90 DECL_LINK(ParameterHdl_Impl
, weld::Button
&, void);
91 DECL_LINK(ClassPathHdl_Impl
, weld::Button
&, void);
92 DECL_LINK(ResetHdl_Impl
, Timer
*, void);
94 DECL_LINK(StartFolderPickerHdl
, void *, void);
95 DECL_LINK(DialogClosedHdl
, css::ui::dialogs::DialogClosedEvent
*, void);
97 DECL_LINK(ExpertConfigHdl_Impl
, weld::Button
&, void);
101 void AddJRE( JavaInfo
const * _pInfo
);
102 void HandleCheckEntry(int nCheckedRow
);
103 void UpdateJavaPathText();
104 void AddFolder( const OUString
& _rFolder
);
105 void RequestRestart( svtools::RestartReason eReason
);
108 SvxJavaOptionsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
109 virtual ~SvxJavaOptionsPage() override
;
111 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rSet
);
113 virtual OUString
GetAllStrings() override
;
115 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
116 virtual void Reset( const SfxItemSet
* rSet
) override
;
117 virtual void FillUserData() override
;
120 // class SvxJavaParameterDlg ---------------------------------------------
122 class SvxJavaParameterDlg
: public weld::GenericDialogController
125 std::unique_ptr
<weld::Entry
> m_xParameterEdit
;
126 std::unique_ptr
<weld::Button
> m_xAssignBtn
;
127 std::unique_ptr
<weld::TreeView
> m_xAssignedList
;
128 std::unique_ptr
<weld::Button
> m_xRemoveBtn
;
129 std::unique_ptr
<weld::Button
> m_xEditBtn
;
131 DECL_LINK(ModifyHdl_Impl
, weld::Entry
&, void);
132 DECL_LINK(ActivateHdl_Impl
, weld::Entry
&, bool);
133 DECL_LINK(AssignHdl_Impl
, weld::Button
&, void);
134 DECL_LINK(SelectHdl_Impl
, weld::TreeView
&, void);
135 DECL_LINK(DblClickHdl_Impl
, weld::TreeView
&, bool);
136 DECL_LINK(RemoveHdl_Impl
, weld::Button
&, void);
137 DECL_LINK(EditHdl_Impl
, weld::Button
&, void);
139 void EnableRemoveButton()
141 m_xRemoveBtn
->set_sensitive(m_xAssignedList
->get_selected_index() != -1);
144 void EnableEditButton()
146 m_xEditBtn
->set_sensitive(m_xAssignedList
->get_selected_index() != -1);
149 void DisableAssignButton()
151 m_xAssignBtn
->set_sensitive(false);
154 void DisableRemoveButton()
156 m_xRemoveBtn
->set_sensitive(false);
159 void DisableEditButton()
161 m_xEditBtn
->set_sensitive(false);
165 explicit SvxJavaParameterDlg(weld::Window
* pParent
);
166 virtual ~SvxJavaParameterDlg() override
;
168 virtual short run() override
;
170 std::vector
< OUString
> GetParameters() const;
171 void SetParameters( std::vector
< OUString
> const & rParams
);
172 void DisableButtons();
173 void EditParameter();
176 // class SvxJavaClassPathDlg ---------------------------------------------
178 class SvxJavaClassPathDlg
: public weld::GenericDialogController
181 std::unique_ptr
<weld::TreeView
> m_xPathList
;
182 std::unique_ptr
<weld::Button
> m_xAddArchiveBtn
;
183 std::unique_ptr
<weld::Button
> m_xAddPathBtn
;
184 std::unique_ptr
<weld::Button
> m_xRemoveBtn
;
188 DECL_LINK(AddArchiveHdl_Impl
, weld::Button
&, void);
189 DECL_LINK(AddPathHdl_Impl
, weld::Button
&, void);
190 DECL_LINK(RemoveHdl_Impl
, weld::Button
&, void);
191 DECL_LINK(SelectHdl_Impl
, weld::TreeView
&, void);
193 bool IsPathDuplicate(std::u16string_view _rPath
);
194 void EnableRemoveButton()
196 m_xRemoveBtn
->set_sensitive(m_xPathList
->get_selected_index() != -1);
200 explicit SvxJavaClassPathDlg(weld::Window
* pParent
);
201 virtual ~SvxJavaClassPathDlg() override
;
203 const OUString
& GetOldPath() const { return m_sOldPath
; }
204 void SetFocus() { m_xPathList
->grab_focus(); }
206 OUString
GetClassPath() const;
207 #if HAVE_FEATURE_JAVA
208 void SetClassPath( const OUString
& _rPath
);
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */