LibreOffice Module cui (master)  1
optjava.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <config_java.h>
23 
24 #include <memory>
25 #include <vector>
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>
33 
34 // forward ---------------------------------------------------------------
35 
36 #if HAVE_FEATURE_JAVA
37 struct JavaInfo;
38 #else
39 typedef void* JavaInfo;
40 #endif
41 
44 class SvxJavaListBox;
46 
47 // class SvxJavaOptionsPage ----------------------------------------------
48 
50 {
51 private:
52 #if HAVE_FEATURE_JAVA
53  std::vector<std::unique_ptr<JavaInfo>> m_parJavaInfo;
54  std::vector<OUString> m_parParameters;
55  OUString m_pClassPath;
56 #endif
57  OUString m_sInstallText;
58  OUString m_sAddDialogText;
60 
61  std::vector<std::unique_ptr<JavaInfo>> m_aAddedInfos;
62 
64  css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker;
65 
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;
73 
74  std::unique_ptr<SvxJavaParameterDlg> m_xParamDlg;
75  std::unique_ptr<SvxJavaClassPathDlg> m_xPathDlg;
76 
77  std::unique_ptr<weld::CheckButton> m_xExperimentalCB;
78  std::unique_ptr<weld::CheckButton> m_xMacroCB;
79 
80  std::unique_ptr<weld::Label> m_xAddDialogText;
81 
82  std::unique_ptr<weld::Widget> m_xJavaFrame;
83 
84  DECL_LINK(EnableHdl_Impl, weld::Button&, 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);
91 
92  DECL_LINK(StartFolderPickerHdl, void *, void);
93  DECL_LINK(DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
94 
95  DECL_LINK(ExpertConfigHdl_Impl, weld::Button&, void);
96 
97  void ClearJavaInfo();
98  void LoadJREs();
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 );
104 
105 public:
106  SvxJavaOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
107  virtual ~SvxJavaOptionsPage() override;
108 
109  static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
110 
111  virtual bool FillItemSet( SfxItemSet* rSet ) override;
112  virtual void Reset( const SfxItemSet* rSet ) override;
113  virtual void FillUserData() override;
114 };
115 
116 // class SvxJavaParameterDlg ---------------------------------------------
117 
119 {
120 private:
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;
126 
127  DECL_LINK(ModifyHdl_Impl, weld::Entry&, void);
128  DECL_LINK(AssignHdl_Impl, weld::Button&, void);
129  DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
130  DECL_LINK(DblClickHdl_Impl, weld::TreeView&, bool);
131  DECL_LINK(RemoveHdl_Impl, weld::Button&, void);
132  DECL_LINK(EditHdl_Impl, weld::Button&, void);
133 
135  {
136  m_xRemoveBtn->set_sensitive(m_xAssignedList->get_selected_index() != -1);
137  }
138 
140  {
141  m_xEditBtn->set_sensitive(m_xAssignedList->get_selected_index() != -1);
142  }
143 
145  {
146  m_xAssignBtn->set_sensitive(false);
147  }
148 
150  {
151  m_xRemoveBtn->set_sensitive(false);
152  }
153 
155  {
156  m_xEditBtn->set_sensitive(false);
157  }
158 
159 public:
160  explicit SvxJavaParameterDlg(weld::Window* pParent);
161  virtual ~SvxJavaParameterDlg() override;
162 
163  virtual short run() override;
164 
165  std::vector< OUString > GetParameters() const;
166  void SetParameters( std::vector< OUString > const & rParams );
167  void DisableButtons();
168  void EditParameter();
169 };
170 
171 // class SvxJavaClassPathDlg ---------------------------------------------
172 
174 {
175 private:
176  std::unique_ptr<weld::TreeView> m_xPathList;
177  std::unique_ptr<weld::Button> m_xAddArchiveBtn;
178  std::unique_ptr<weld::Button> m_xAddPathBtn;
179  std::unique_ptr<weld::Button> m_xRemoveBtn;
180 
181  OUString m_sOldPath;
182 
183  DECL_LINK(AddArchiveHdl_Impl, weld::Button&, void);
184  DECL_LINK(AddPathHdl_Impl, weld::Button&, void);
185  DECL_LINK(RemoveHdl_Impl, weld::Button&, void);
186  DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
187 
188  bool IsPathDuplicate(std::u16string_view _rPath);
190  {
191  m_xRemoveBtn->set_sensitive(m_xPathList->get_selected_index() != -1);
192  }
193 
194 public:
195  explicit SvxJavaClassPathDlg(weld::Window* pParent);
196  virtual ~SvxJavaClassPathDlg() override;
197 
198  const OUString& GetOldPath() const { return m_sOldPath; }
199  void SetFocus() { m_xPathList->grab_focus(); }
200 
201  OUString GetClassPath() const;
202  void SetClassPath( const OUString& _rPath );
203 };
204 
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void HandleCheckEntry(int nCheckedRow)
Definition: optjava.cxx:365
std::unique_ptr< weld::CheckButton > m_xMacroCB
Definition: optjava.hxx:78
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker
Definition: optjava.hxx:64
OUString m_sOldPath
Definition: optjava.hxx:181
std::unique_ptr< weld::CheckButton > m_xExperimentalCB
Definition: optjava.hxx:77
std::unique_ptr< weld::Button > m_xAssignBtn
Definition: optjava.hxx:122
OUString m_sInstallText
Definition: optjava.hxx:57
std::unique_ptr< weld::Button > m_xRemoveBtn
Definition: optjava.hxx:124
OUString GetClassPath() const
Definition: optjava.cxx:912
std::unique_ptr< weld::Button > m_xEditBtn
Definition: optjava.hxx:125
SvxJavaClassPathDlg(weld::Window *pParent)
Definition: optjava.cxx:756
void AddFolder(const OUString &_rFolder)
Definition: optjava.cxx:385
std::unique_ptr< weld::Button > m_xExpertConfigBtn
Definition: optjava.hxx:72
std::unique_ptr< SvxJavaParameterDlg > m_xParamDlg
Definition: optjava.hxx:74
void RequestRestart(svtools::RestartReason eReason)
Definition: optjava.cxx:456
std::pair< const TreeIter &, int > iter_col
SvxJavaOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optjava.cxx:68
std::unique_ptr< weld::TreeView > m_xPathList
Definition: optjava.hxx:176
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optjava.cxx:468
std::unique_ptr< weld::Widget > m_xJavaFrame
Definition: optjava.hxx:82
std::unique_ptr< weld::Button > m_xAddBtn
Definition: optjava.hxx:69
std::unique_ptr< weld::Button > m_xRemoveBtn
Definition: optjava.hxx:179
void EnableRemoveButton()
Definition: optjava.hxx:189
std::unique_ptr< weld::Button > m_xClassPathBtn
Definition: optjava.hxx:71
OUString m_sAddDialogText
Definition: optjava.hxx:58
void SetClassPath(const OUString &_rPath)
Definition: optjava.cxx:925
std::unique_ptr< weld::Button > m_xAddPathBtn
Definition: optjava.hxx:178
SvxJavaParameterDlg(weld::Window *pParent)
Definition: optjava.cxx:602
void EnableEditButton()
Definition: optjava.hxx:139
rtl::Reference< ::svt::DialogClosedListener > xDialogListener
Definition: optjava.hxx:63
std::unique_ptr< SvxJavaClassPathDlg > m_xPathDlg
Definition: optjava.hxx:75
virtual ~SvxJavaParameterDlg() override
Definition: optjava.cxx:625
void SetParameters(std::vector< OUString > const &rParams)
Definition: optjava.cxx:742
void UpdateJavaPathText()
Definition: optjava.cxx:375
std::unique_ptr< weld::Label > m_xAddDialogText
Definition: optjava.hxx:80
void EnableRemoveButton()
Definition: optjava.hxx:134
virtual ~SvxJavaOptionsPage() override
Definition: optjava.cxx:125
std::unique_ptr< weld::Button > m_xAddArchiveBtn
Definition: optjava.hxx:177
virtual void Reset(const SfxItemSet *rSet) override
Definition: optjava.cxx:560
virtual void FillUserData() override
Definition: optjava.cxx:595
std::unique_ptr< weld::CheckButton > m_xJavaEnableCB
Definition: optjava.hxx:66
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optjava.cxx:463
std::vector< OUString > GetParameters() const
Definition: optjava.cxx:725
void DisableRemoveButton()
Definition: optjava.hxx:149
const OUString & GetOldPath() const
Definition: optjava.hxx:198
DECL_LINK(EnableHdl_Impl, weld::Button &, void)
virtual ~SvxJavaClassPathDlg() override
Definition: optjava.cxx:774
std::unique_ptr< weld::TreeView > m_xJavaList
Definition: optjava.hxx:67
void DisableAssignButton()
Definition: optjava.hxx:144
virtual short run() override
Definition: optjava.cxx:718
std::vector< std::unique_ptr< JavaInfo > > m_aAddedInfos
Definition: optjava.hxx:61
DECL_LINK(ModifyHdl_Impl, weld::Entry &, void)
void AddJRE(JavaInfo const *_pInfo)
Definition: optjava.cxx:347
void ClearJavaInfo()
Definition: optjava.cxx:298
DECL_LINK(AddArchiveHdl_Impl, weld::Button &, void)
bool IsPathDuplicate(std::u16string_view _rPath)
Definition: optjava.cxx:896
void * JavaInfo
Definition: optjava.hxx:39
std::unique_ptr< weld::Entry > m_xParameterEdit
Definition: optjava.hxx:121
std::unique_ptr< weld::Label > m_xJavaPathText
Definition: optjava.hxx:68
void DisableEditButton()
Definition: optjava.hxx:154
std::unique_ptr< weld::Button > m_xParameterBtn
Definition: optjava.hxx:70
std::unique_ptr< weld::TreeView > m_xAssignedList
Definition: optjava.hxx:123