56 #include <wx/msgdlg.h>
57 #include <wx/filename.h>
66 "File Format Loader Manager");
71 : m_Descriptor(
"File Import",
""),
78 m_AltToolManager(
NULL),
80 m_ProjectSelPanel(
NULL),
98 vector< CIRef<IFileFormatLoaderManager> > managers;
101 for(
size_t i = 0;
i < managers.size(); ++
i ) {
130 return manager->GetDescriptor();
203 return manager->GetCurrentPanel();
243 return action ==
eNext;
248 if(manager->IsInitialState()) {
251 return manager->CanDo(action);
278 static const wxFormatString
kFORMAT_CONFLICT_MSG =
"Detected data format '%s' doesn't appear to match the format you selected.\n"
279 "Are you sure you want to load your data as '%s'?\nClick 'Yes' to proceed or click 'No' to process the data as '%s'.";
285 if (manager->CanGuessFormat() ==
false)
291 if (detected_manager != 0 && detected_manager != manager) {
293 wxString detected_frm = format_name ?
ToWxString(format_name ) :
wxT(
"No name");
294 wxString selected_frm;
302 manager.
Reset(detected_manager);
330 wxMessageBox(
wxT(
"Wrong file name or file doesn't exist:\n") + *it,
331 wxT(
"File Open Error"),wxICON_ERROR | wxOK);
346 if (!manager->ValidateFilenames(
filenames))
349 string id = manager->GetFileLoaderId();
350 if (
id ==
"file_loader_auto") {
360 if (
id ==
"file_loader_gbench_project") {
365 else if(manager->IsCompletedState()) {
376 if(action ==
eBack && manager->IsInitialState()) {
382 manager->DoTransition(action);
384 if(action ==
eNext && manager->IsCompletedState()) {
391 if(action ==
eBack) {
393 if(manager->IsInitialState()) {
399 manager->DoTransition(action);
402 }
else if(action ==
eNext) {
418 if (!service->HasWorkspace())
419 service->CreateNewWorkspace();
427 service->AddProject(*doc);
439 string id = manager->GetFileLoaderId();
453 IAppTask* task = manager->GetTask();
480 execute_unit = manager->GetExecuteUnit();
503 if (
nullptr == auto_loader)
551 if (! manager->ValidateFilenames(
filenames)) {
552 NcbiErrorBox(
"The file(s) cannot be opened with this file format manager!");
558 string id = manager->GetFileLoaderId();
593 vector<CFileLoadOptionPanel::CFormatDescriptor> formats;
604 bool hidden = (
id ==
"file_loader_gbench_project");
644 string mgr_path =
m_RegPath +
"." + manager->GetFileLoaderId();
666 string mgr_label = manager->GetDescriptor().GetLabel();
672 vector<string> values;
679 CTime time(it->first);
683 string manager_label =
FnToStdString(it->second.GetFileLoaderLabel());
684 string manager_id = it->second.GetFileLoaderId();
685 values.push_back(s_time);
686 values.push_back(filename);
687 values.push_back(manager_label);
688 values.push_back(manager_id);
717 vector<string> values;
722 for(
size_t i = 0;
i + 2 < values.size() ; ) {
724 string s_time = values[
i++];
727 string manager_id = values[
i++];
746 string mgr_label = manager->GetDescriptor().GetLabel();
747 if(mgr_label == sel_fmt_label) {
static bool FileExists(const wxString &fileName)
CDataLoadingAppTask - a task that executes CDataLoadingAppJob.
void SetOptions(const CSelectProjectOptions &options)
CExtensionPointDeclaration - static declaration helper.
void ResentCurrentManager()
IFileFormatLoaderManager * GetCurrentManager()
CFormatGuess::EFormat SetFormatManager(const vector< wxString > &filenames)
CFileLoadManager & m_Manager
virtual wxPanel * GetPanel()
virtual IWizardPage * GetFirstPage()
Returns first options page (if any) of the tool to be shown in wizard dialog.
CProjectSelectorPanel * m_ProjectSelPanel
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
IUIToolManager * m_AltToolManager
If a file type is better handled by a different tool manager, set it here.
wxWindow * m_ParentWindow
CFileLoadManager()
CFileLoadManager.
TProjectId x_CreateNewProject(const string &new_prj_name)
virtual void InitUI()
Initializes the Manager before using it in UI.
virtual void ResetState()
objects::CGBProjectHandle::TId TProjectId
virtual const IUIObject & GetDescriptor() const
Returns the object describing this tool (UI meta data).
virtual void SetRegistryPath(const string &path)
virtual void OnFormatChanged()
called by File Format panel when a user selects a format
virtual void AddFileFormat(IFileFormatLoaderManager *manager)
void x_UpdateWizardPages()
virtual IExecuteUnit * GetExecuteUnit()
bool x_CheckFormatConflict(const vector< wxString > &filenames, TFormatMgrRef &manager)
virtual void SetPrevPage(IWizardPage *prevPage)
Sets a wizard page which should show before the first page of the tool.
TFormatMgrRef m_AutodetectFormat
virtual bool CanDo(EAction action)
Indicates whether given transition is possible in the current state.
void SetDialog(COpenDlg *dlg)
virtual void SaveSettings() const
vector< TFormatMgrRef > m_FormatManagers
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
SProjectSelectorParams m_ProjectParams
vector< wxString > m_Filenames
CFileLoadOptionPanel * x_GetOptionsPanel()
IWizardPage * m_OpenObjectsPage
IServiceLocator * m_SrvLocator
CIRef< IFileFormatLoaderManager > TFormatMgrRef
CFileLoadOptionPanel * m_OptionPanel
virtual void SetFilenames(vector< wxString > &filenames)
TMRUPathList m_FileMRUList
void LoadRegisteredManagers()
virtual void SetParentWindow(wxWindow *parent)
virtual IAppTask * GetTask()
Once parameters are gathered and validated this function is called to produce the final Task object t...
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
virtual bool IsCompletedState()
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
bool x_CanLeavePage(bool forward)
virtual void LoadSettings()
virtual void CleanUI()
CleanUI() is called after the host finished using the manager.
void SetFilenames(const vector< wxString > &filenames)
void SetMRU(const TFileMRU &file_mru)
void SetManager(CFileLoadManager *manager)
void SelectFormat(int format)
void GetFilenames(vector< wxString > &filenames) const
void SetCheckFormat(bool value=true)
void SetFormats(const vector< CFormatDescriptor > &formats)
CRegistryWriteView GetWriteView(const string §ion)
get a read-write view at a particular level.
static CGuiRegistry & GetInstance()
access the application-wide singleton
CRegistryReadView GetReadView(const string §ion) const
get a read-only view at a particular level.
CProjectSelectorPanel - a panel that allows the user to specify how the project items created by a pl...
virtual bool TransferDataFromWindow()
void SetProjectService(CProjectService *service)
void GetParams(SProjectSelectorParams ¶ms) const
virtual bool TransferDataToWindow()
void SetParams(const SProjectSelectorParams ¶ms)
CProjectService - a service providing API for operations with Workspaces and Projects.
class CRegistryReadView provides a nested hierarchical view at a particular key.
bool GetBool(const string &key, bool default_val=false) const
string GetString(const string &key, const string &default_val=kEmptyStr) const
void GetStringVec(const string &key, vector< string > &val) const
void Set(const string &key, int val)
access a named key at this level, with no recursion
CProjectSelectOptions - describes how new Project Items shall be added to a workspace.
static CGBDocument * CreateProject(CProjectService *service, const string &prjName, const string &prjDesc)
void Set_AddToExistingProject(TProjectId &project_id, const string &folder=kEmptyStr)
static void InitProjectnameGenerator(objects::CGBWorkspace &ws, CUniqueLabelGenerator &projectNames)
const TTimeToTMap & GetMap() const
void Add(T elem, time_t time=0)
CUniqueLabelGenerator Modifies the given label so that it becomes unique in the given set of labels b...
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
virtual void SaveSettings() const =0
virtual void LoadSettings()=0
virtual void SetRegistryPath(const string &path)=0
IServiceLocator - an abstract mechanism for locating services.
IUIObject - object that provides basic properties often required in a UI object.
virtual void SetOptionsPage(IWizardPage *)=0
virtual void SetNextPage(IWizardPage *)=0
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
void GetExtensionAsInterface(const string &ext_point_id, vector< CIRef< I > > &interfaces)
GetExtensionAsInterface() is a helper function that extracts all extensions implementing the specifie...
string MakeUniqueLabel(const string &label) const
after considering all existing labels produces a modified unique version of the original label
void NcbiErrorBox(const string &message, const string &title="Error")
specialized Message Box function for reporting critical errors
EDialogReturnValue NcbiMessageBoxW(const wxString &message, TDialogType type=eDialog_Ok, EDialogIcon icon=eIcon_Exclamation, const wxString &title=wxT("Error"), EDialogTextMode text_mode=eRaw)
virtual const string & GetLabel() const =0
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CTime & ToLocalTime(void)
Convert the time into local time.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
time_t GetTimeT(void) const
Get time in time_t format.
static CTimeFormat GetPredefined(EPredefined fmt, TFlags flags=fDefault)
Get predefined format.
@ eISO8601_DateTimeSec
Y-M-DTh:m:s (eg 1997-07-16T19:20:30)
static const char label[]
unsigned int
A callback function used to compare two keys in a database.
wxEVT_COMMAND_MENU_SELECTED
void ToLoadingOptions(CSelectProjectOptions &options)
static const char * kSelectedFormatTag
static const char * kCheckFormatTag
static CExtensionPointDeclaration sDSTypeExtPoint("file_format_loader_manager", "File Format Loader Manager")
EXTENSION_POINT__UI_DATA_SOURCE_TYPE Extension point declaration.
static const wxFormatString kFORMAT_CONFLICT_MSG
static const char * kMRUTag
wxString ToWxString(const string &s)
wxString FnToWxString(const string &s)
string FnToStdString(const wxString &s)