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

Go to the SVN repository for this file.

1 /* $Id: orginfo_panel.cpp 47139 2022-09-12 19:11:59Z asztalos $
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: Andrea Asztalos
27  */
28 
29 #include <ncbi_pch.hpp>
32 #include <gui/utils/command.hpp>
40 
41 
42 
43 #include <wx/sizer.h>
44 #include <wx/listbook.h>
45 #include <wx/button.h>
46 #include <wx/cshelp.h>
47 #include <wx/icon.h>
48 
50 
51 /*
52  * COrganismInfoPanel type definition
53  */
54 
55 IMPLEMENT_DYNAMIC_CLASS( COrganismInfoPanel, wxPanel )
56 
57 
58 /*
59  * COrganismInfoPanel event table definition
60  */
61 
62 BEGIN_EVENT_TABLE( COrganismInfoPanel, wxPanel )
63  EVT_LISTBOOK_PAGE_CHANGED(ID_ORGINFONTBK, COrganismInfoPanel::OnPageChanged)
64  EVT_LISTBOOK_PAGE_CHANGING(ID_ORGINFONTBK, COrganismInfoPanel::OnPageChanging)
65  EVT_BUTTON(ID_ORGINFOBTN, COrganismInfoPanel::OnImportSrcTable)
67 
68 
69 /*
70  * COrganismInfoPanel constructors
71  */
72 
74 {
75  Init();
76 }
77 
78 COrganismInfoPanel::COrganismInfoPanel( wxWindow* parent, IWorkbench* wb, ICommandProccessor* cmdproc, objects::CSeq_entry_Handle seh, const wxString& dir, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
79  : m_Workbench(wb), m_Seh(seh), m_CmdProcessor(cmdproc), m_WorkDir(dir)
80 {
81  Init();
82  Create(parent, id, pos, size, style);
83 }
84 
85 
86 /*
87  * COrganismInfoPanel creator
88  */
89 
90 bool COrganismInfoPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
91 {
92 ////@begin COrganismInfoPanel creation
93  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
94  wxPanel::Create( parent, id, pos, size, style );
95 
97  if (GetSizer())
98  {
99  GetSizer()->SetSizeHints(this);
100  }
101  Centre();
102 ////@end COrganismInfoPanel creation
103  return true;
104 }
105 
106 
107 /*
108  * COrganismInfoPanel destructor
109  */
110 
112 {
113 ////@begin COrganismInfoPanel destruction
114 ////@end COrganismInfoPanel destruction
115 }
116 
117 
118 /*
119  * Member initialisation
120  */
121 
123 {
124 ////@begin COrganismInfoPanel member initialisation
125  m_Listbook = NULL;
128 ////@end COrganismInfoPanel member initialisation
129 }
130 
131 
132 /*
133  * Control creation for COrganismInfoPanel
134  */
135 
137 {
138 ////@begin COrganismInfoPanel content construction
139  COrganismInfoPanel* itemPanel1 = this;
140 
141  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
142  itemPanel1->SetSizer(itemBoxSizer2);
143 
144  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
145  itemBoxSizer2->Add(itemBoxSizer1, 0, wxALIGN_LEFT|wxALL, 5);
146 
147  wxButton* itemButton2 = new wxButton( itemPanel1, ID_ORGINFOBTN, _("Import tab-delimited table"), wxDefaultPosition, wxDefaultSize, 0 );
148  itemBoxSizer1->Add(itemButton2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
149 
150  m_Listbook = new wxListbook( itemPanel1, ID_ORGINFONTBK, wxDefaultPosition, wxDefaultSize, wxBK_TOP|wxNO_BORDER );
151  itemBoxSizer2->Add(m_Listbook, 1, wxGROW | wxALL, 5);
152 
154  m_Listbook->AddPage(m_GeneralPanel, _("General"));
155 
157  m_Listbook->AddPage(m_AdvancedPanel, _("Additional qualifiers"));
158 
159 ////@end COrganismInfoPanel content construction
160 }
161 
163 {
164  return x_DoStepForward(m_Listbook);
165 }
166 
168 {
170 }
171 
172 
174 {
175  wxWindow *win = m_Listbook->GetCurrentPage();
176  if (!win)
177  return false;
178  return win->TransferDataFromWindow();
179 }
180 
181 
182 void COrganismInfoPanel::OnPageChanging(wxBookCtrlEvent& event)
183 {
184  ApplyCommand();
185 }
186 
187 void COrganismInfoPanel::OnPageChanged(wxBookCtrlEvent& event)
188 {
189  GetParentWizard(this)->UpdateOnPageChange(this);
190 }
191 
192 
193 void COrganismInfoPanel::OnImportSrcTable(wxCommandEvent& event)
194 {
195  if (!m_Seh) return;
196 
197  CQualTableLoadManager* qual_mgr = NULL;
198  CRef<CFileLoadWizard> fileManager(new CFileLoadWizard());
199  vector<string> format_ids;
200  format_ids.push_back("file_loader_qual_table");
201  fileManager->LoadFormats(format_ids);
202  fileManager->SetWorkDir(m_WorkDir);
203 
204  for( size_t i = 0; i < fileManager->GetFormatManagers().size(); ++i ) {
205  const IFileLoadPanelClient* mgr = fileManager->GetFormatManagers()[0].GetPointerOrNull();
206 
207  if ("file_loader_qual_table" == mgr->GetFileLoaderId()) {
208  const CQualTableLoadManager* const_qual_mgr = dynamic_cast<const CQualTableLoadManager*>(mgr);
209  if (const_qual_mgr) {
210  qual_mgr = const_cast<CQualTableLoadManager*>(const_qual_mgr);
211  qual_mgr->SetTopLevelEntry(m_Seh);
212  qual_mgr->SetServiceLocator(m_Workbench);
213  }
214  }
215  }
216 
217  vector<CIRef<IOpenObjectsPanelClient> > loadManagers;
218  loadManagers.push_back(CIRef<IOpenObjectsPanelClient>(fileManager.GetPointer()));
219 
220  COpenObjectsDlg dlg(this);
221  dlg.SetSize(760, 940);
222  dlg.Centre(wxBOTH|wxCENTRE_ON_SCREEN);
223  dlg.SetMinSize(wxSize(760, 940));
224  dlg.SetRegistryPath("Dialogs.Edit.OpenTables");
225  dlg.SetManagers(loadManagers);
226 
227  if (dlg.ShowModal() == wxID_OK) {
228  //CIRef<IObjectLoader> object_loader(dlg.GetObjectLoader());
229  //qual_mgr->x_GetColumnIdPanel()->x_TableReaderCommon(object_loader, wxT("Reading file(s)..."));
230  qual_mgr->x_GetColumnIdPanel()->x_TableReaderMacro();
231  }
232 }
233 
234 
235 /*
236  * Should we show tooltips?
237  */
238 
240 {
241  return true;
242 }
243 
244 /*
245  * Get bitmap resources
246  */
247 
248 wxBitmap COrganismInfoPanel::GetBitmapResource( const wxString& name )
249 {
250  // Bitmap retrieval
251 ////@begin COrganismInfoPanel bitmap retrieval
252  wxUnusedVar(name);
253  return wxNullBitmap;
254 ////@end COrganismInfoPanel bitmap retrieval
255 }
256 
257 /*
258  * Get icon resources
259  */
260 
261 wxIcon COrganismInfoPanel::GetIconResource( const wxString& name )
262 {
263  // Icon retrieval
264 ////@begin COrganismInfoPanel icon retrieval
265  wxUnusedVar(name);
266  return wxNullIcon;
267 ////@end COrganismInfoPanel icon retrieval
268 }
269 
270 
271 void COrganismInfoPanel::ApplyDescriptor(objects::CSeqdesc& desc)
272 {
273  if (desc.IsSource()) {
274  m_GeneralPanel->ApplyBioSource(desc.SetSource());
275  m_AdvancedPanel->ApplyBioSource(desc.SetSource());
276  }
277 }
278 
280 {
281  for (size_t i = 0; i < m_Listbook->GetPageCount(); ++i) {
282  m_Listbook->GetPage(i)->TransferDataToWindow();
283  }
284  return wxPanel::TransferDataToWindow();
285 }
286 
288 {
289  auto page = x_GetCurrentPage();
290  if (page) {
291  page->ApplyCommand();
292  }
293 }
294 
296 {
297  ISubmissionPage* page = nullptr;
298  if (m_Listbook) {
299  wxWindow *win = m_Listbook->GetCurrentPage();
300  if (win) {
301  page = dynamic_cast<ISubmissionPage*>(win);
302  }
303  }
304  return page;
305 }
306 
307 void COrganismInfoPanel::SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
308 {
309  m_Seh = seh;
312 }
313 
315 {
316  for (size_t i = 0; i < m_Listbook->GetPageCount(); ++i)
317  {
318  wxWindow* win = m_Listbook->GetPage(i);
319  ISubmissionPage* page = dynamic_cast<ISubmissionPage*>(win);
320  page->ReportMissingFields(text);
321  }
322 }
323 
325 {
326  auto page = x_GetCurrentPage();
327  if (page) {
328  return page->GetAnchor();
329  }
330  return wxEmptyString;
331 }
332 
334 {
335  auto page = x_GetCurrentPage();
336  if (page) {
337  return page->GetName();
338  }
339  return wxEmptyString;
340 }
341 
virtual void SetRegistryPath(const string &path)
Definition: dialog.cpp:59
void SetManagers(vector< CIRef< IOpenObjectsPanelClient > > &managers)
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
void ApplyBioSource(objects::CBioSource &src)
void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
void ApplyBioSource(objects::CBioSource &src)
COrgGeneralPanel * m_GeneralPanel
virtual wxString GetName() const
bool Create(wxWindow *parent, wxWindowID id=ID_CORGANISMINFOPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void OnPageChanging(wxBookCtrlEvent &event)
~COrganismInfoPanel()
Destructor.
IWorkbench * m_Workbench
ICommandProccessor * m_CmdProcessor
virtual void ReportMissingFields(string &text)
virtual bool StepForward()
objects::CSeq_entry_Handle m_Seh
virtual void ApplyDescriptor(objects::CSeqdesc &desc)
virtual wxString GetAnchor()
void OnPageChanged(wxBookCtrlEvent &event)
COrgAdvancedPanel * m_AdvancedPanel
virtual void ApplyCommand()
static bool ShowToolTips()
Should we show tooltips?
void Init()
Initialises member variables.
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
wxListbook * m_Listbook
virtual bool TransferDataFromWindow()
COrganismInfoPanel()
Constructors.
virtual bool TransferDataToWindow()
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void CreateControls()
Creates the controls and sizers.
void OnImportSrcTable(wxCommandEvent &event)
virtual bool StepBackward()
ISubmissionPage * x_GetCurrentPage() const
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CTableFileLoadManager.
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
CAttribTableColumnIdPanel * x_GetColumnIdPanel()
void SetTopLevelEntry(CSeq_entry_Handle seq_entry)
CRef –.
Definition: ncbiobj.hpp:618
virtual void UpdateOnPageChange(wxWindow *current_page)=0
Undo/Redo interface for editing operations.
virtual string GetFileLoaderId() const =0
bool x_DoStepForward(wxListbook *book)
virtual void ReportMissingFields(string &text)
bool x_DoStepBackward(wxListbook *book)
CSubmissionPageChangeListener * GetParentWizard(wxWindow *wnd) const
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
GUI command routing and handling framework.
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:986
#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()
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
const struct ncbi::grid::netcache::search::fields::SIZE size
Modified on Fri Jul 19 17:09:56 2024 by modify_doxy.py rev. 669887