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

Go to the SVN repository for this file.

1 /* $Id: gb_flatfile_load_manager.cpp 46563 2021-07-13 17:50:23Z 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 
30 #include <ncbi_pch.hpp>
31 
33 
37 #include <wx/filename.h>
38 
39 
42 
44 {
45  return m_Manager.x_GetParamsPanel();
46 }
47 
49 {
50  CGBFlatFileParamsPanel* panel = m_Manager.x_GetParamsPanel();
51  if (panel) {
52  if (!panel->TransferDataFromWindow())
53  return false;
54  m_Manager.m_Params = panel->GetData();
55  }
56 
57  return true;
58 }
59 
60 ///////////////////////////////////////////////////////////////////////////////
61 /// CGBFlatFileLoadManager
63  : m_Descr("GenBank FlatFile files", ""), m_OptionsPage(*this)
64 {
65  m_Descr.SetLogEvent("loaders");
66 }
67 
68 //
69 // IFileLoadPanelClient implementation
70 //
71 
73 {
74  return m_Descr.GetLabel();
75 }
76 
78 {
81 }
82 
83 //
84 // IUILoadManager implementation
85 //
86 
88 {
89  m_SrvLocator = srv_locator;
90 }
91 
92 
94 {
95  m_ParentWindow = parent;
96 }
97 
98 
100 {
101  return m_Descr;
102 }
103 
104 
106 {
107  m_State = eParams;
108 }
109 
110 
112 {
113  m_State = eInvalid;
114  m_ParamsPanel = nullptr;
115 }
116 
118 {
119  return (m_State == eParams) ? x_GetParamsPanel() : nullptr;
120 }
121 
123 {
124  if (m_ParamsPanel == NULL) {
127  m_ParamsPanel->TransferDataToWindow();
128  }
129  return m_ParamsPanel;
130 }
131 
133 {
134  switch (m_State) {
135  case eParams:
136  return action == eNext;
137  case eCompleted:
138  return action == eBack;
139  default:
140  _ASSERT(false);
141  }
142  return false;
143 }
144 
145 
147 {
148  return m_State == eParams;
149 }
150 
151 
153 {
154  return m_State == eCompleted;
155 }
156 
157 
159 {
160  if (m_State == eParams && action == eNext) {
161  if (m_ParamsPanel->TransferDataFromWindow()) {
162  //TODO validate
165  return true;
166  }
167  return false;
168  }
169  else if (m_State == eCompleted && action == eBack) {
170  m_State = eParams;
171  return true;
172  }
173  _ASSERT(false);
174  return false;
175 }
176 
178 {
179  return nullptr;
180 }
181 
183 {
185 }
186 
188 {
191 }
192 
193 
194 bool CGBFlatFileLoadManager::ValidateFilenames(const vector<wxString>&)
195 {
196  // not implemented
197  return true;
198 }
199 
200 
201 void CGBFlatFileLoadManager::SetFilenames(const vector<wxString>& filenames)
202 {
204 }
205 
206 void CGBFlatFileLoadManager::GetFilenames(vector<wxString>& filenames) const
207 {
209 }
210 
212 {
213  return m_State == eParams;
214 }
215 
216 
217 bool CGBFlatFileLoadManager::RecognizeFormat(const wxString& filename)
218 {
219  wxString ext;
220  wxFileName::SplitPath(filename, 0, 0, &ext);
222 }
223 
225 {
226  return fmt == CFormatGuess::eFlatFileGenbank;
227 }
228 
230 {
231  static string sid("genbank_flatfile_load_manager");
232  return sid;
233 }
234 
236 {
237  static string slabel("GenBank FlatFile Format Load Manager");
238  return slabel;
239 }
240 
242 {
243  m_RegPath = path; // store for later use
244  m_Params.SetRegistryPath(m_RegPath + ".GBFlatFileParams");
245 }
246 
248 {
250 }
251 
253 {
255 }
256 
257 
static bool RecognizeExtension(EFileType fileType, const wxString &extension)
static wxString GetDialogFilter(EFileType fileType)
EFormat
The formats are checked in the same order as declared here.
virtual void SetRegistryPath(const string &path)
IRegSettings.
virtual void SaveSettings() const
const CGBFlatFileLoadParams & GetData() const
void SetData(const CGBFlatFileLoadParams &data)
IAppTask.
Definition: app_task.hpp:83
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
IUIObject - object that provides basic properties often required in a UI object.
Definition: ui_object.hpp:63
USING_SCOPE(objects)
#define NULL
Definition: ncbistd.hpp:225
virtual IAppTask * GetTask()
Once parameters are gathered and validated this function is called to produce the final Task object t...
virtual void SetParentWindow(wxWindow *parent)
virtual string GetLabel() const
virtual bool ValidateFilenames(const vector< wxString > &filenames)
checks given filenames and returns true if the manager can handle them, otherwise - shows an error me...
CGBFlatFileLoadManager()
CGBFlatFileLoadManager.
virtual void SetFilenames(const vector< wxString > &filenames)
initilize the manager with the given filenames
virtual void GetFilenames(vector< wxString > &filenames) const
get actual filenames that will be opened
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
virtual void CleanUI()
CleanUI() is called after the host finished using the manager.
virtual void InitUI()
Initializes the Manager before using it in UI.
virtual bool IsCompletedState()
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
virtual IExecuteUnit * GetExecuteUnit()
virtual bool RecognizeFormat(const wxString &filename)
return true if the given file format is supported by this manager
virtual void SetRegistryPath(const string &path)
virtual const IUIObject & GetDescriptor() const
Returns the object describing this tool (UI meta data).
CGBFlatFileParamsPanel * x_GetParamsPanel()
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
virtual bool CanDo(EAction action)
Indicates whether given transition is possible in the current state.
CGBFlatFileParamsPanel * m_ParamsPanel
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
virtual wxString GetFormatWildcard() const
return file wildcard for the format (example - "*.txt;*.tab" )
virtual bool IsInitialState()
return true if the current state of the loader UI is the first valid state (first step in a wizard-li...
virtual void SetLogEvent(const string &log_event)
Definition: ui_object.cpp:118
virtual const string & GetLabel() const
Definition: ui_object.cpp:124
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define wxT(x)
Definition: muParser.cpp:41
static int filenames
Definition: pcregrep.c:172
#define _ASSERT
Modified on Thu May 30 12:29:52 2024 by modify_doxy.py rev. 669887