55 #include <wx/filedlg.h>
56 #include <wx/msgdlg.h>
57 #include <wx/filename.h>
69 m_SrvLocator(srv_locator)
83 unsaved.push_back(*it);
88 if (!path.empty() && !wxFileName::FileExists(path))
89 unsaved.push_back(*it);
107 if (!unsaved.empty()) {
110 for (
size_t i = 0;
i < unsaved.size();
i++)
111 selected.push_back(
i);
115 "There are new or modified projects. "
116 "If not saved the new projects will be lost and the modified "
117 "projects will loose all changes. Would you like to save the selected projects?",
118 false,
true, unsaved, selected);
129 else if (doc->IsLoaded()) {
131 if (doc->GetFilename().empty()) {
151 task_srv->AddTask(*task);
160 if (!ws)
return true;
163 copy(project_ids.begin(), project_ids.end(), back_inserter(toRemove));
169 if (!unsaved.empty()) {
172 for (
size_t i = 0;
i < unsaved.size();
i++)
173 selected.push_back(
i);
177 "These projects are new or modified, "
178 "all changes will be lost if these projects are not saved. Would you "
179 "like to save the selected projects?",
180 false,
true, unsaved, selected);
184 int res = wxMessageBox(
wxT(
"Remove selected projects?"),
wxT(
"Remove Project"),
185 wxYES_NO | wxICON_QUESTION);
190 if (
ok && !toRemove.empty()) {
214 if (!ws)
return true;
220 projects.push_back(doc->GetId());
244 else if (doc->IsLoaded()) {
245 auto id = doc->GetId();
246 loaded.push_back(
id);
248 for (
size_t j = 0; j < project_ids.size(); j++) {
249 if (project_ids[j] ==
id)
250 selected.push_back(loaded.size() - 1);
255 string title = save_as ?
"Save As" :
"Save";
290 wxT(
"Project \"%s\" is already opened."), filename.c_str());
291 wxMessageBox(
msg,
wxT(
"Open Project"), wxOK | wxICON_EXCLAMATION);
296 ids.push_back(doc->GetId());
308 task_srv->AddTask(*task);
316 wxString title = docTitle;
317 if (title.length() > 512) {
321 wxString fname = title +
wxT(
".gbp");
324 file_data.
m_Style = wxFD_SAVE | wxFD_OVERWRITE_PROMPT;
326 file_data.
m_Title =
wxT(
"Save Project \"") + title + (as ?
wxT(
"\" As") :
wxT(
"\""));
331 return wxEmptyString;
338 const string& description,
351 for(
size_t i = 0;
i < selected.size();
i++ ) {
361 int res = dlg.ShowModal();
381 if (filename.find(
wxT(
"http://")) == 0 || filename.find(
wxT(
"https://")) == 0 || filename.find(
wxT(
"ftp://")) == 0) {
382 wxString
msg =
wxT(
"The project\n") + filename;
383 msg +=
wxT(
"\nmust have a local file name in order to save it.");
389 if (filename.empty())
392 if (filename.empty()) {
407 catch (
const exception& e) {
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CAppTaskService - Application Task Service.
CAppTask - default implementation of IAppTask, use it as a base class for custom tasks.
virtual void SetRegistryPath(const string &path)
void SetFileName(const wxString &filename)
void Save(const wxString &abs_path)
void UnloadProject(bool reset_hist_async=true)
wxString GetFileName() const
CGBProjectHandle * GetProjectFromId(CGBProjectHandle::TId id)
static SWFileDlgData sm_ProjectDlgData
static data structures for File dialogs
CProjectService - a service providing API for operations with Workspaces and Projects.
void CreateNewWorkspace()
void RemoveProject(CGBDocument &doc)
CRef< objects::CGBWorkspace > GetGBWorkspace()
void AddProject(CGBDocument &doc)
void AddToProjectWorkspaceMRUList(const wxString &path)
CProjectTask(IServiceLocator *srv_locator, vector< wxString > &filenames)
static bool RemoveAllProjects(IServiceLocator *serviceLocator)
static void LoadProjects(IServiceLocator *serviceLocator, const TProjectIdVector &project_ids)
IServiceLocator * m_SrvLocator
void x_OpenProjects()
overriding CAppTask::x_Run()
vector< TProjectId > TProjectIdVector
static void Save(IServiceLocator *serviceLocator, const TProjectIdVector &project_ids, bool save_as)
static bool RemoveProjects(IServiceLocator *serviceLocator, const TProjectIdVector &project_ids, bool confirm=true)
static bool x_DoSaveUserSelected(CProjectService *service, objects::CGBWorkspace &ws, const string &title, const string &description, bool save_as, bool no_btn, const TProjectIdVector &project_ids, const TProjectIdVector &selected)
virtual ETaskState x_Run()
override this function in derived classes
static void UnLoadProjects(IServiceLocator *serviceLocator, const TProjectIdVector &project_ids)
vector< wxString > m_ProjectFilenames
CSaveDlg - a dialog for saving workspace and projects.
void SetParams(const SSaveProjectsDlgParams &value)
const SSaveProjectsDlgParams & GetParams() const
Template class for iteration on objects of class C (non-medifiable version)
Template class for iteration on objects of class C.
CGBProjectHandle * FindProjectByFilename(const string &filename)
finds a project in the folder and its sub folders
IServiceLocator - an abstract mechanism for locating services.
wxArrayInt m_ProjectsToSave
indices of the projects to save (checked items)
vector< objects::CGBProjectHandle::TId > m_ProjectIds
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
const string & GetMsg(void) const
Get message string.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
void Info(CExceptionArgs_Base &args)
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
ETaskState
List of task states defining the task management FSM.
@ eCompleted
successfully finished
void SetFilename(const wxString &filename)
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)
int NcbiFileBrowser(SFileDlgData &data, wxWindow *parent=NULL)
show wxFileDialog and returns
wxString GetFilename() const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
static wxString AskProjectSaveFilename(const wxString &docTitle, bool as=false)
static CProjectTask::TProjectIdVector s_GetUnsavedProjects(CGBWorkspace &ws, const CProjectTask::TProjectIdVector &projects)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
wxString ToWxString(const string &s)
string FnToStdString(const wxString &s)