1
/***************************************************************
2
* Name: ThreadSearchConfPanel
3
* Purpose: This class implements the configuration panel used
4
* in modal dialog called on "Options" button click
5
* and by C::B on "Environment" settings window.
6
* Author: Jerome ANTOINE
8
* Copyright: Jerome ANTOINE
10
**************************************************************/
12
#include <sdk.h> // Code::Blocks SDK
14
#include <wx/checkbox.h>
15
#include <wx/radiobox.h>
17
#include <wx/statbox.h>
18
#include <wx/stattext.h>
21
#include "ThreadSearch.h"
22
#include "SearchInPanel.h"
23
#include "DirectoryParamsPanel.h"
24
#include "ThreadSearchConfPanel.h"
25
#include "ThreadSearchControlIds.h"
26
#include "ThreadSearchViewManagerBase.h"
27
#include "ThreadSearchFindData.h"
28
#include "InsertIndexManager.h"
30
// begin wxGlade: ::extracode
35
ThreadSearchConfPanel::ThreadSearchConfPanel(ThreadSearch& threadSearchPlugin, wxWindow* parent,wxWindowID id)
36
:m_ThreadSearchPlugin(threadSearchPlugin)
38
Create(parent,id,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL);
40
// begin wxGlade: ThreadSearchConfPanel::ThreadSearchConfPanel
41
SizerOptions_staticbox = new wxStaticBox(this, -1, wxT("Options"));
42
SizerThreadSearchOptions_staticbox = new wxStaticBox(this, -1, wxT("Snippets search options"));
43
SizerThreadSearchLayoutGlobal_staticbox = new wxStaticBox(this, -1, wxT("Show/Hide"));
44
SizerListControlOptions_staticbox = new wxStaticBox(this, -1, wxT("List control options"));
45
SizerThreadSearchLayout_staticbox = new wxStaticBox(this, -1, wxT("Layout"));
46
SizerSearchIn_staticbox = new wxStaticBox(this, -1, wxT("Search in"));
47
m_pPnlSearchIn = new SearchInPanel(this, wxID_ANY);
48
m_pPnlDirParams = new DirectoryParamsPanel(this, wxID_ANY);
49
m_pChkWholeWord = new wxCheckBox(this, idChkWholeWord, wxT("Whole word"));
50
m_pChkStartWord = new wxCheckBox(this, idChkStartWord, wxT("Start word"));
51
m_pChkMatchCase = new wxCheckBox(this, idChkMatchCase, wxT("Match case"));
52
m_pChkRegExp = new wxCheckBox(this, idChkRegularExpression, wxT("Regular expression"));
53
m_pChkThreadSearchEnable = new wxCheckBox(this, idChkThreadSearchEnable, wxT("Enable 'Find occurrences' contextual menu item"));
54
m_pChkUseDefaultOptionsForThreadSearch = new wxCheckBox(this, idChkUseDefaultOptionsOnThreadSearch, wxT("Use default options when running 'Find occurrences' "));
55
//-moved-below-m_pChkShowThreadSearchToolBar = new wxCheckBox(this, idChkViewThreadSearchToolBar, wxT("Show ThreadSearch toolbar."));
56
m_pChkShowThreadSearchWidgets = new wxCheckBox(this, idChkShowThreadSearchWidgets, wxT("Show search widgets in ThreadSearch Messages panel."));
57
m_pChkShowCodePreview = new wxCheckBox(this, idChkShowCodePreview, wxT("Show code preview editor."));
58
m_pChkShowThreadSearchToolBar = new wxCheckBox(this, idChkViewThreadSearchToolBar, wxT("Show ThreadSearch toolbar."));
59
m_pChkDisplayLogHeaders = new wxCheckBox(this, idChkDisplayLogHeaders, wxT("Display header in log window."));
60
m_pChkDrawLogLines = new wxCheckBox(this, idChkDrawLogLines, wxT("Draw lines between log columns."));
62
const wxString m_pRadPanelManagement_choices[] = {
63
wxT("Messages notebook"),
66
m_pRadPanelManagement = new wxRadioBox(this, wxID_ANY, wxT("SnippetsSearch panel management by"), wxDefaultPosition, wxDefaultSize, 2, m_pRadPanelManagement_choices, 1, wxRA_SPECIFY_ROWS);
68
const wxString m_pRadLoggerType_choices[] = {
72
m_pRadLoggerType = new wxRadioBox(this, wxID_ANY, wxT("Logger type"), wxDefaultPosition, wxDefaultSize, 2, m_pRadLoggerType_choices, 1, wxRA_SPECIFY_ROWS);
74
const wxString m_pRadSplitterWndMode_choices[] = {
78
m_pRadSplitterWndMode = new wxRadioBox(this, wxID_ANY, wxT("Splitter window mode"), wxDefaultPosition, wxDefaultSize, 2, m_pRadSplitterWndMode_choices, 1, wxRA_SPECIFY_ROWS);
80
const wxString m_pRadSortBy_choices[] = {
84
m_pRadSortBy = new wxRadioBox(this, wxID_ANY, wxT("Sort results by"), wxDefaultPosition, wxDefaultSize, 2, m_pRadSortBy_choices, 1, wxRA_SPECIFY_ROWS);
90
// CodeSnippets does not show the SearchToolBar or use Layout options
91
m_pChkShowThreadSearchToolBar->Show(false); //(pecan 2008/5/22)
92
m_pRadPanelManagement->Show(false); //(pecan 2008/5/22)
94
//SizerThreadSearchOptions_staticbox->Show(false); //(pecan 2008/5/22)
95
m_pChkThreadSearchEnable->Show(false); //(pecan 2008/5/22)
96
m_pChkUseDefaultOptionsForThreadSearch->Show(false); //(pecan 2008/5/22)
100
BEGIN_EVENT_TABLE(ThreadSearchConfPanel, wxPanel)
101
// begin wxGlade: ThreadSearchConfPanel::event_table
102
EVT_CHECKBOX(idChkThreadSearchEnable, ThreadSearchConfPanel::OnThreadSearchEnable)
103
EVT_CHECKBOX(idChkViewThreadSearchToolBar, ThreadSearchConfPanel::OnChkShowThreadSearchToolBarClick)
104
EVT_CHECKBOX(idChkShowCodePreview, ThreadSearchConfPanel::OnChkCodePreview)
105
EVT_CHECKBOX(idChkShowThreadSearchWidgets, ThreadSearchConfPanel::OnChkShowThreadSearchWidgetsClick)
110
void ThreadSearchConfPanel::OnThreadSearchEnable(wxCommandEvent &event)
112
m_pChkUseDefaultOptionsForThreadSearch->Enable(event.IsChecked());
117
void ThreadSearchConfPanel::OnChkShowThreadSearchToolBarClick(wxCommandEvent &event)
119
if ( (event.IsChecked() == false) && (m_pChkShowThreadSearchWidgets->GetValue() == false) )
121
if ( wxID_YES != cbMessageBox(wxT("Do you really want to hide both ThreadSearch toolbar and widgets ?"),
122
wxT("Sure ?"), wxICON_QUESTION|wxYES_NO) )
124
m_pChkShowThreadSearchToolBar->SetValue(true);
131
void ThreadSearchConfPanel::OnChkCodePreview(wxCommandEvent &event)
133
m_pRadSplitterWndMode->Enable(event.IsChecked());
138
void ThreadSearchConfPanel::OnChkShowThreadSearchWidgetsClick(wxCommandEvent &event)
140
if ( (event.IsChecked() == false) && (m_pChkShowThreadSearchToolBar->GetValue() == false) )
142
if ( wxID_YES != cbMessageBox(wxT("Do you really want to hide both ThreadSearch toolbar and widgets ?"),
143
wxT("Sure ?"), wxICON_QUESTION|wxYES_NO) )
145
m_pChkShowThreadSearchWidgets->SetValue(true);
152
// wxGlade: add ThreadSearchConfPanel event handlers
155
void ThreadSearchConfPanel::set_properties()
157
// begin wxGlade: ThreadSearchConfPanel::set_properties
158
m_pChkWholeWord->SetToolTip(wxT("Search text matches only whole words"));
159
m_pChkWholeWord->SetValue(1);
160
m_pChkStartWord->SetToolTip(wxT("Matches only word starting with search expression"));
161
m_pChkMatchCase->SetToolTip(wxT("Case sensitive search."));
162
m_pChkMatchCase->SetValue(1);
163
m_pChkRegExp->SetToolTip(wxT("Search expression is a regular expression"));
164
m_pChkThreadSearchEnable->SetValue(1);
165
m_pChkUseDefaultOptionsForThreadSearch->SetValue(1);
166
m_pChkShowThreadSearchToolBar->SetValue(1);
167
m_pChkShowThreadSearchWidgets->SetValue(1);
168
m_pChkShowCodePreview->SetValue(1);
169
m_pChkDisplayLogHeaders->SetValue(1);
170
m_pRadPanelManagement->SetSelection(0);
171
m_pRadLoggerType->SetSelection(0);
172
m_pRadSplitterWndMode->SetSelection(0);
173
m_pRadSortBy->SetSelection(0);
176
ThreadSearchFindData findData;
177
m_ThreadSearchPlugin.GetFindData(findData);
179
m_pChkWholeWord->SetValue(findData.GetMatchWord());
180
m_pChkStartWord->SetValue(findData.GetStartWord());
181
m_pChkMatchCase->SetValue(findData.GetMatchCase());
182
m_pChkRegExp->SetValue(findData.GetRegEx());
183
m_pChkThreadSearchEnable->SetValue(m_ThreadSearchPlugin.GetCtxMenuIntegration());
184
m_pChkUseDefaultOptionsForThreadSearch->SetValue(m_ThreadSearchPlugin.GetUseDefValsForThreadSearch());
185
m_pChkUseDefaultOptionsForThreadSearch->Enable(m_ThreadSearchPlugin.GetCtxMenuIntegration());
186
m_pChkDisplayLogHeaders->SetValue(m_ThreadSearchPlugin.GetDisplayLogHeaders());
187
m_pChkDrawLogLines->SetValue(m_ThreadSearchPlugin.GetDrawLogLines());
188
m_pChkShowThreadSearchToolBar->SetValue(m_ThreadSearchPlugin.IsToolbarVisible());
189
m_pChkShowThreadSearchWidgets->SetValue(m_ThreadSearchPlugin.GetShowSearchControls());
190
m_pChkShowCodePreview->SetValue(m_ThreadSearchPlugin.GetShowCodePreview());
193
switch (m_ThreadSearchPlugin.GetManagerType())
195
case ThreadSearchViewManagerBase::TypeLayout :
201
// case ThreadSearchViewManagerBase::TypeMessagesNotebook :
207
m_pRadPanelManagement->SetSelection(radIndex);
210
switch (m_ThreadSearchPlugin.GetLoggerType())
212
case ThreadSearchLoggerBase::TypeTree:
218
// case ThreadSearchLoggerBase::TypeList :
224
m_pRadLoggerType->SetSelection(radIndex);
227
switch (m_ThreadSearchPlugin.GetSplitterMode())
229
case wxSPLIT_HORIZONTAL:
235
// case wxSPLIT_VERTICAL:
241
m_pRadSplitterWndMode->SetSelection(radIndex);
242
m_pRadSplitterWndMode->Enable(m_ThreadSearchPlugin.GetShowCodePreview());
245
switch (m_ThreadSearchPlugin.GetFileSorting())
247
case InsertIndexManager::SortByFileName:
253
// case ThreadSearch::SortByFilePath :
259
m_pRadSortBy->SetSelection(radIndex);
261
m_pPnlDirParams->SetSearchDirHidden(findData.GetHiddenSearch());
262
m_pPnlDirParams->SetSearchDirRecursively(findData.GetRecursiveSearch());
263
m_pPnlDirParams->SetSearchDirPath(findData.GetSearchPath());
264
m_pPnlDirParams->SetSearchMask(findData.GetSearchMask());
266
m_pPnlSearchIn->SetSearchInOpenFiles(findData.MustSearchInOpenFiles());
267
m_pPnlSearchIn->SetSearchInSnippetFiles(findData.MustSearchInProject());
268
m_pPnlSearchIn->SetSearchInSnippetFiles(findData.MustSearchInCodeSnippetsTree());
269
//-m_pPnlSearchIn->SetSearchInWorkspaceFiles(findData.MustSearchInWorkspace());
270
m_pPnlSearchIn->SetSearchInDirectory(findData.MustSearchInDirectory());
274
void ThreadSearchConfPanel::do_layout()
276
// begin wxGlade: ThreadSearchConfPanel::do_layout
277
wxBoxSizer* SizerTop = new wxBoxSizer(wxVERTICAL);
278
wxStaticBoxSizer* SizerThreadSearchLayout = new wxStaticBoxSizer(SizerThreadSearchLayout_staticbox, wxVERTICAL);
279
wxFlexGridSizer* SizerThreadSearchGridLayout = new wxFlexGridSizer(4, 2, 0, 0);
280
wxStaticBoxSizer* SizerListControlOptions = new wxStaticBoxSizer(SizerListControlOptions_staticbox, wxVERTICAL);
281
wxStaticBoxSizer* SizerThreadSearchLayoutGlobal = new wxStaticBoxSizer(SizerThreadSearchLayoutGlobal_staticbox, wxVERTICAL);
282
wxStaticBoxSizer* SizerThreadSearchOptions = new wxStaticBoxSizer(SizerThreadSearchOptions_staticbox, wxVERTICAL);
283
wxStaticBoxSizer* SizerOptions = new wxStaticBoxSizer(SizerOptions_staticbox, wxHORIZONTAL);
284
wxStaticBoxSizer* SizerSearchIn = new wxStaticBoxSizer(SizerSearchIn_staticbox, wxVERTICAL);
285
SizerSearchIn->Add(m_pPnlSearchIn, 0, wxALL|wxEXPAND, 2);
286
SizerSearchIn->Add(m_pPnlDirParams, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 2);
287
SizerTop->Add(SizerSearchIn, 0, wxALL|wxEXPAND, 4);
288
SizerOptions->Add(m_pChkWholeWord, 0, wxALL|wxADJUST_MINSIZE, 4);
289
SizerOptions->Add(m_pChkStartWord, 0, wxALL|wxADJUST_MINSIZE, 4);
290
SizerOptions->Add(m_pChkMatchCase, 0, wxALL|wxADJUST_MINSIZE, 4);
291
SizerOptions->Add(m_pChkRegExp, 0, wxALL|wxADJUST_MINSIZE, 4);
292
SizerTop->Add(SizerOptions, 0, wxALL|wxEXPAND, 4);
293
SizerThreadSearchOptions->Add(m_pChkThreadSearchEnable, 0, wxALL|wxADJUST_MINSIZE, 4);
294
SizerThreadSearchOptions->Add(m_pChkUseDefaultOptionsForThreadSearch, 0, wxALL|wxADJUST_MINSIZE, 4);
295
//(pecan 2008/5/22) not supported yet
296
//wxStaticText* m_pStaDefaultOptions = new wxStaticText(this, wxID_ANY, wxT(" ('Whole word' = true, 'Start word' = false, 'Match case' = true, 'Regular expression' = false)"));
297
wxStaticText* m_pStaDefaultOptions = new wxStaticText(this, wxID_ANY, wxT(" Place holder for yet to be supported context menu option."));
298
SizerThreadSearchOptions->Add(m_pStaDefaultOptions, 0, wxADJUST_MINSIZE, 0);
299
SizerTop->Add(SizerThreadSearchOptions, 0, wxALL|wxEXPAND, 4);
300
//--moved--belo--SizerThreadSearchLayoutGlobal->Add(m_pChkShowThreadSearchToolBar, 0, wxALL|wxADJUST_MINSIZE, 4);
301
SizerThreadSearchLayoutGlobal->Add(m_pChkShowThreadSearchWidgets, 0, wxALL|wxADJUST_MINSIZE, 4);
302
SizerThreadSearchLayoutGlobal->Add(m_pChkShowCodePreview, 0, wxALL|wxADJUST_MINSIZE, 4);
303
SizerThreadSearchLayoutGlobal->Add(m_pChkShowThreadSearchToolBar, 0, wxALL|wxADJUST_MINSIZE, 4);
304
SizerThreadSearchGridLayout->Add(SizerThreadSearchLayoutGlobal, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
305
SizerListControlOptions->Add(m_pChkDisplayLogHeaders, 0, wxALL|wxADJUST_MINSIZE, 4);
306
SizerListControlOptions->Add(m_pChkDrawLogLines, 0, wxALL|wxADJUST_MINSIZE, 4);
307
SizerThreadSearchGridLayout->Add(SizerListControlOptions, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
308
SizerThreadSearchGridLayout->Add(m_pRadPanelManagement, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
309
SizerThreadSearchGridLayout->Add(m_pRadLoggerType, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
310
SizerThreadSearchGridLayout->Add(m_pRadSplitterWndMode, 0, wxALL|wxEXPAND, 4);
311
SizerThreadSearchGridLayout->Add(m_pRadSortBy, 0, wxALL|wxEXPAND, 4);
312
SizerThreadSearchGridLayout->AddGrowableCol(0);
313
SizerThreadSearchGridLayout->AddGrowableCol(1);
314
SizerThreadSearchLayout->Add(SizerThreadSearchGridLayout, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 0);
315
SizerTop->Add(SizerThreadSearchLayout, 0, wxALL|wxEXPAND, 4);
319
SizerTop->SetSizeHints(this);
324
void ThreadSearchConfPanel::OnApply()
326
ThreadSearchFindData findData;
328
// Inits variable data from user values
329
findData.SetFindText (wxEmptyString);
330
findData.SetHiddenSearch (m_pPnlDirParams->GetSearchDirHidden());
331
findData.SetRecursiveSearch(m_pPnlDirParams->GetSearchDirRecursively());
332
findData.SetSearchPath (m_pPnlDirParams->GetSearchDirPath());
333
findData.SetSearchMask (m_pPnlDirParams->GetSearchMask());
334
findData.SetMatchWord (m_pChkWholeWord->IsChecked());
335
findData.SetStartWord (m_pChkStartWord->IsChecked());
336
findData.SetMatchCase (m_pChkMatchCase->IsChecked());
337
findData.SetRegEx (m_pChkRegExp->IsChecked());
339
findData.UpdateSearchScope(ScopeOpenFiles, m_pPnlSearchIn->GetSearchInOpenFiles());
340
findData.UpdateSearchScope(ScopeSnippetFiles, m_pPnlSearchIn->GetSearchInSnippetFiles());
341
//-findData.UpdateSearchScope(ScopeWorkspaceFiles, m_pPnlSearchIn->GetSearchInWorkspaceFiles());
342
findData.UpdateSearchScope(ScopeDirectoryFiles, m_pPnlSearchIn->GetSearchInDirectory());
344
// Updates plug-in with new datas
345
m_ThreadSearchPlugin.SetFindData(findData);
346
m_ThreadSearchPlugin.SetCtxMenuIntegration(m_pChkThreadSearchEnable->IsChecked());
347
m_ThreadSearchPlugin.SetUseDefValsForThreadSearch(m_pChkUseDefaultOptionsForThreadSearch->IsChecked());
348
m_ThreadSearchPlugin.SetShowSearchControls(m_pChkShowThreadSearchWidgets->IsChecked());
349
m_ThreadSearchPlugin.SetShowCodePreview(m_pChkShowCodePreview->IsChecked());
350
m_ThreadSearchPlugin.SetDisplayLogHeaders(m_pChkDisplayLogHeaders->IsChecked());
351
m_ThreadSearchPlugin.SetDrawLogLines(m_pChkDrawLogLines->IsChecked());
353
int radIndex = m_pRadPanelManagement->GetSelection();
354
ThreadSearchViewManagerBase::eManagerTypes mgrType;
359
mgrType = ThreadSearchViewManagerBase::TypeLayout;
365
mgrType = ThreadSearchViewManagerBase::TypeMessagesNotebook;
369
m_ThreadSearchPlugin.SetManagerType(mgrType);
371
radIndex = m_pRadLoggerType->GetSelection();
372
ThreadSearchLoggerBase::eLoggerTypes lgrType;
377
lgrType = ThreadSearchLoggerBase::TypeTree;
383
lgrType = ThreadSearchLoggerBase::TypeList;
387
m_ThreadSearchPlugin.SetLoggerType(lgrType);
389
radIndex = m_pRadSortBy->GetSelection();
390
InsertIndexManager::eFileSorting sortingType;
395
sortingType = InsertIndexManager::SortByFileName;
401
sortingType = InsertIndexManager::SortByFilePath;
405
m_ThreadSearchPlugin.SetFileSorting(sortingType);
407
radIndex = m_pRadSplitterWndMode->GetSelection();
408
wxSplitMode splitterMode;
413
splitterMode = wxSPLIT_VERTICAL;
419
splitterMode = wxSPLIT_HORIZONTAL;
423
m_ThreadSearchPlugin.SetSplitterMode(splitterMode);
425
// Updates toolbar visibility
426
m_ThreadSearchPlugin.ShowToolBar(m_pChkShowThreadSearchToolBar->IsChecked());
428
// Notifies plug-in observers (ThreadSearchView)
429
m_ThreadSearchPlugin.Notify();