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

Go to the SVN repository for this file.

1 /* $Id: agp_loader.cpp 38477 2017-05-15 21:10:59Z evgeniev $
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 
32 #include "agp_loader.hpp"
34 
36 
38 #include <wx/filename.h>
39 
41 
43 {
44  return m_Manager.x_GetParamsPanel();
45 }
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 /// CAgpLoader
50  : m_Descr("AGP assembly files", "")
53  , m_State(eInvalid)
55  , m_OptionsPage(*this)
56 {
57  m_Descr.SetLogEvent("loaders");
58 }
59 
60 //
61 // IFileLoadPanelClient implementation
62 //
63 
64 string CAgpLoader::GetLabel() const
65 {
66  return m_Descr.GetLabel();
67 }
68 
70 {
73 }
74 
75 //
76 // IUILoadManager implementation
77 //
78 
80 {
81  m_SrvLocator = srv_locator;
82 }
83 
84 
85 void CAgpLoader::SetParentWindow(wxWindow* parent)
86 {
87  m_ParentWindow = parent;
88 }
89 
90 
92 {
93  return m_Descr;
94 }
95 
96 
98 {
99  m_State = eParams;
100 }
101 
102 
104 {
105  m_State = eInvalid;
106  m_ParamsPanel = NULL; // window is destroyed by the system
107 }
108 
109 
111 {
112  return (m_State == eParams) ? x_GetParamsPanel() : NULL;
113 }
114 
116 {
117  if(m_ParamsPanel == NULL) {
121  }
122  return m_ParamsPanel;
123 }
124 
126 {
127  switch(m_State) {
128  case eParams:
129  return action == eNext;
130  case eCompleted:
131  return action == eBack;
132  default:
133  _ASSERT(false);
134  return false;
135  }
136 }
137 
138 
140 {
141  return m_State == eParams;
142 }
143 
144 
146 {
147  return m_State == eCompleted; // does not matter
148 }
149 
150 
152 {
153  if(m_State == eParams && action == eNext) {
155  //TODO validate
158  return true;
159  }
160  return false;
161  } else if(m_State == eCompleted && action == eBack) {
162  m_State = eParams;
163  return true;
164  }
165  _ASSERT(false);
166  return false;
167 }
168 
169 
171 {
172  return nullptr;
173 }
174 
176 {
178 }
179 
181 {
184 }
185 
186 
187 bool CAgpLoader::ValidateFilenames(const vector<wxString>& /*filenames*/)
188 {
189  // not implemented
190  return true;
191 }
192 
193 
194 void CAgpLoader::SetFilenames(const vector<wxString>& filenames)
195 {
197 }
198 
199 void CAgpLoader::GetFilenames(vector<wxString>& filenames) const
200 {
202 }
203 
205 {
206  return m_State == eParams;
207 }
208 
209 bool CAgpLoader::RecognizeFormat(const wxString& filename)
210 {
211  wxString ext;
212  wxFileName::SplitPath(filename, 0, 0, &ext);
214 }
215 
217 {
218  return fmt == CFormatGuess::eAgp;
219 }
220 
222 {
223  static string sid("agp_format_load_manager");
224  return sid;
225 }
226 
227 
229 {
230  static string slabel("AGP Format Load Manager");
231  return slabel;
232 }
233 
234 void CAgpLoader::SetRegistryPath(const string& path)
235 {
236  m_RegPath = path; // store for later use
237  m_Params.SetRegistryPath(m_RegPath + ".Params");
238 }
239 
241 {
243 }
244 
245 
247 {
249 }
250 
virtual bool TransferDataFromWindow()
Transfer data from the window.
virtual bool TransferDataToWindow()
Transfer data to the window.
CAgpLoadParams & GetData()
Data access.
void SetData(const CAgpLoadParams &data)
virtual void SaveSettings() const
IRegSettings.
virtual void LoadSettings()
virtual void SetRegistryPath(const string &path)
IRegSettings.
C5ColObjectLoader.
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.
@ eAgp
AGP format assembly, AgpRead.
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
#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...
Definition: agp_loader.cpp:170
CAgpLoadParams m_Params
Definition: agp_loader.hpp:153
wxWindow * m_ParentWindow
Definition: agp_loader.hpp:147
virtual string GetLabel() const
Definition: agp_loader.cpp:64
CAgpLoader()
CAgpLoader.
Definition: agp_loader.cpp:49
virtual void CleanUI()
CleanUI() is called after the host finished using the manager.
Definition: agp_loader.cpp:103
virtual void InitUI()
Initializes the Manager before using it in UI.
Definition: agp_loader.cpp:97
CAgpLoadPage * m_ParamsPanel
Definition: agp_loader.hpp:152
virtual void SetFilenames(const vector< wxString > &filenames)
initilize the manager with the given filenames
Definition: agp_loader.cpp:194
virtual bool CanDo(EAction action)
Indicates whether given transition is possible in the current state.
Definition: agp_loader.cpp:125
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
Definition: agp_loader.cpp:110
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
Definition: agp_loader.cpp:151
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
Definition: agp_loader.cpp:139
virtual bool IsCompletedState()
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
Definition: agp_loader.cpp:145
virtual void SetRegistryPath(const string &path)
Definition: agp_loader.cpp:234
virtual bool ValidateFilenames(const vector< wxString > &filenames)
checks given filenames and returns true if the manager can handle them, otherwise - shows an error me...
Definition: agp_loader.cpp:187
EState m_State
Definition: agp_loader.hpp:148
virtual const IUIObject & GetDescriptor() const
Returns the object describing this tool (UI meta data).
Definition: agp_loader.cpp:91
string m_RegPath
Definition: agp_loader.hpp:150
CAgpLoadPage * x_GetParamsPanel()
Definition: agp_loader.cpp:115
virtual void LoadSettings()
Definition: agp_loader.cpp:246
vector< wxString > m_FileNames
Definition: agp_loader.hpp:154
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
Definition: agp_loader.cpp:221
virtual void GetFilenames(vector< wxString > &filenames) const
get actual filenames that will be opened
Definition: agp_loader.cpp:199
CUIObject m_Descr
Definition: agp_loader.hpp:144
CPage m_OptionsPage
Definition: agp_loader.hpp:156
IServiceLocator * m_SrvLocator
Definition: agp_loader.hpp:146
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
Definition: agp_loader.cpp:79
virtual wxPanel * GetPanel()
Definition: agp_loader.cpp:42
virtual bool RecognizeFormat(const wxString &filename)
return true if the given file format is supported by this manager
Definition: agp_loader.cpp:209
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
Definition: agp_loader.cpp:228
virtual bool IsInitialState()
return true if the current state of the loader UI is the first valid state (first step in a wizard-li...
Definition: agp_loader.cpp:204
virtual void SaveSettings() const
Definition: agp_loader.cpp:240
virtual IExecuteUnit * GetExecuteUnit()
Definition: agp_loader.cpp:175
virtual void SetParentWindow(wxWindow *parent)
Definition: agp_loader.cpp:85
virtual wxString GetFormatWildcard() const
return file wildcard for the format (example - "*.txt;*.tab" )
Definition: agp_loader.cpp:69
CAgpLoader & m_Manager
Definition: agp_loader.hpp:139
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: pcre2grep.c:247
#define _ASSERT
Modified on Fri Sep 20 14:57:32 2024 by modify_doxy.py rev. 669887