NCBI C++ ToolKit
cleanup_panel.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: cleanup_panel.cpp 39666 2017-10-25 16:01:13Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
34 
35 #include <wx/sizer.h>
36 #include <wx/statbox.h>
37 #include <wx/radiobox.h>
38 #include <wx/msgdlg.h>
39 
40 ////@begin XPM images
41 ////@end XPM images
42 
43 
44 /*!
45  * CCleanupPanel type definition
46  */
47 
49 
50 IMPLEMENT_DYNAMIC_CLASS( CCleanupPanel, CAlgoToolManagerParamsPanel )
51 
52 
53 /*!
54  * CCleanupPanel event table definition
55  */
56 
57 BEGIN_EVENT_TABLE( CCleanupPanel, CAlgoToolManagerParamsPanel )
58 
59 ////@begin CCleanupPanel event table entries
60 ////@end CCleanupPanel event table entries
61 
63 
64 
65 /*!
66  * CCleanupPanel constructors
67  */
68 
69 CCleanupPanel::CCleanupPanel() : m_InputObjects()
70 {
71  Init();
72 }
73 
74 CCleanupPanel::CCleanupPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
75 : m_InputObjects()
76 {
77  Init();
78  Create(parent, id, pos, size, style);
79 }
80 
81 
82 /*!
83  * CCleanupPanel creator
84  */
85 
86 bool CCleanupPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
87 {
88 ////@begin CCleanupPanel creation
89  CAlgoToolManagerParamsPanel::Create( parent, id, pos, size, style );
90 
92  if (GetSizer())
93  {
94  GetSizer()->SetSizeHints(this);
95  }
96  Centre();
97 ////@end CCleanupPanel creation
98  return true;
99 }
100 
101 
102 /*!
103  * CCleanupPanel destructor
104  */
105 
107 {
108 ////@begin CCleanupPanel destruction
109 ////@end CCleanupPanel destruction
110 }
111 
112 
113 /*!
114  * Member initialisation
115  */
116 
118 {
119 ////@begin CCleanupPanel member initialisation
120  m_ObjectList = NULL;
121 ////@end CCleanupPanel member initialisation
122 }
123 
124 
125 /*!
126  * Control creation for CCleanupPanel
127  */
128 
130 {
131 ////@begin CCleanupPanel content construction
132  CCleanupPanel* itemCAlgoToolManagerParamsPanel1 = this;
133 
134  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
135  itemCAlgoToolManagerParamsPanel1->SetSizer(itemBoxSizer2);
136 
137  wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemCAlgoToolManagerParamsPanel1, wxID_ANY, _("Objects for Cleanup"));
138  wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
139  itemBoxSizer2->Add(itemStaticBoxSizer3, 1, wxGROW|wxALL, 5);
140 
141  m_ObjectList = new CObjectListWidget( itemCAlgoToolManagerParamsPanel1, ID_LISTCTRL1, wxDefaultPosition, itemCAlgoToolManagerParamsPanel1->ConvertDialogToPixels(wxSize(300, 150)), wxLC_REPORT );
142  itemStaticBoxSizer3->Add(m_ObjectList, 1, wxGROW|wxALL, 5);
143 
144  wxArrayString itemRadioBox5Strings;
145  itemRadioBox5Strings.Add(_("&Basic"));
146  itemRadioBox5Strings.Add(_("&Extended"));
147  wxRadioBox* itemRadioBox5 = new wxRadioBox( itemCAlgoToolManagerParamsPanel1, ID_RADIOBOX1, _("Cleanup Mode"), wxDefaultPosition, wxDefaultSize, itemRadioBox5Strings, 1, wxRA_SPECIFY_ROWS );
148  itemRadioBox5->SetSelection(0);
149  itemBoxSizer2->Add(itemRadioBox5, 0, wxALIGN_LEFT|wxALL, 5);
150 
151  // Set validators
152  itemRadioBox5->SetValidator( wxGenericValidator(& GetData().m_CleanupMode) );
153 ////@end CCleanupPanel content construction
154 }
155 
156 
157 /*!
158  * Should we show tooltips?
159  */
160 
162 {
163  return true;
164 }
165 
166 /*!
167  * Get bitmap resources
168  */
169 
170 wxBitmap CCleanupPanel::GetBitmapResource( const wxString& name )
171 {
172  // Bitmap retrieval
173 ////@begin CCleanupPanel bitmap retrieval
174  wxUnusedVar(name);
175  return wxNullBitmap;
176 ////@end CCleanupPanel bitmap retrieval
177 }
178 
179 /*!
180  * Get icon resources
181  */
182 
183 wxIcon CCleanupPanel::GetIconResource( const wxString& name )
184 {
185  // Icon retrieval
186 ////@begin CCleanupPanel icon retrieval
187  wxUnusedVar(name);
188  return wxNullIcon;
189 ////@end CCleanupPanel icon retrieval
190 }
191 
192 /*!
193  * Transfer data to the window
194  */
195 
197 {
198  if (m_InputObjects) {
201  }
202 
203  return wxPanel::TransferDataToWindow();
204 }
205 
206 /*!
207  * Transfer data from the window
208  */
209 
211 {
212  if (!wxPanel::TransferDataFromWindow())
213  return false;
214 
215  m_ObjectList->GetSelection(GetData().m_Objects);
216  if (GetData().m_Objects.empty()) {
217  wxMessageBox(wxT("Please select objects for cleanup."), wxT("Error"),
218  wxOK | wxICON_ERROR, this);
219  m_ObjectList->SetFocus();
220  return false;
221  }
222 
223  return true;
224 }
225 
226 static const char *kTableTag = "Table";
227 
229 {
230  if (!m_RegPath.empty()) {
232  string reg_path = CGuiRegistryUtil::MakeKey(m_RegPath, kTableTag);
233  CRegistryWriteView table_view = gui_reg.GetWriteView(reg_path);
234  m_ObjectList->SaveTableSettings(table_view);
235  }
236 }
237 
239 {
240  if (!m_RegPath.empty()) {
242  string reg_path;
243  CRegistryReadView table_view;
244 
246  table_view = gui_reg.GetReadView(reg_path);
247  m_ObjectList->LoadTableSettings(table_view);
248  }
249 }
250 
252 {
253  GetData().Init();
255 }
256 
CAlgoToolManagerParamsPanel.
string m_RegPath
registry path to the settings
static string MakeKey(const string &section, const string &key, const string &delim=CGuiRegistry::kDecimalDot)
create a key from a section and a subkey
Definition: registry.cpp:504
CRegistryWriteView GetWriteView(const string &section)
get a read-write view at a particular level.
Definition: registry.cpp:462
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
CRegistryReadView GetReadView(const string &section) const
get a read-only view at a particular level.
Definition: registry.cpp:428
CObjectListWidget - mediator widget.
void SetObjects(TConstScopedObjects &objects)
void GetSelection(TConstScopedObjects &objects)
ISelection-style API.
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
void LoadTableSettings(const CRegistryReadView &view, bool byName=false)
void SaveTableSettings(CRegistryWriteView &view, bool saveSorting=true) const
static const char * kTableTag
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
void Init()
Initialises member variables.
void CreateControls()
Creates the controls and sizers.
virtual void LoadSettings()
void RestoreDefaults()
override in derived classes
virtual bool TransferDataFromWindow()
Transfer data from the window.
void Init()
Initialises member variables.
virtual bool TransferDataToWindow()
Transfer data to the window.
static bool ShowToolTips()
Should we show tooltips?
CObjectListWidget * m_ObjectList
~CCleanupPanel()
Destructor.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
virtual void SaveSettings() const
override in derived classes
CCleanupParams & GetData()
Data access.
bool Create(wxWindow *parent, wxWindowID id=ID_CCLEANUPPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
TConstScopedObjects * m_InputObjects
CCleanupPanel()
Constructors.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
Modified on Sun Mar 03 03:16:50 2024 by modify_doxy.py rev. 669887