Enhancement for saving workspace file

closes #3029, closes #3234
pull/3254/head
SinghRajenM 8 years ago committed by Don HO
parent ca3c2a6016
commit 3661527fca

@ -917,7 +917,7 @@ void ProjectPanel::popupMenuCmd(int cmdID)
} }
FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL)); FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL));
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); setFileExtFilter(fDlg);
if (TCHAR *fn = fDlg.doOpenSingleFileDlg()) if (TCHAR *fn = fDlg.doOpenSingleFileDlg())
{ {
if (!openWorkSpace(fn)) if (!openWorkSpace(fn))
@ -1043,7 +1043,8 @@ void ProjectPanel::popupMenuCmd(int cmdID)
bool ProjectPanel::saveWorkSpaceAs(bool saveCopyAs) bool ProjectPanel::saveWorkSpaceAs(bool saveCopyAs)
{ {
FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL)); FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL));
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); setFileExtFilter(fDlg);
fDlg.setExtIndex(0); // 0 index for "custom extention" type if any else for "All types *.*"
if (TCHAR *fn = fDlg.doSaveDlg()) if (TCHAR *fn = fDlg.doSaveDlg())
{ {
@ -1058,6 +1059,20 @@ bool ProjectPanel::saveWorkSpaceAs(bool saveCopyAs)
return false; return false;
} }
void ProjectPanel::setFileExtFilter(FileDialog & fDlg)
{
const TCHAR *ext = NppParameters::getInstance()->getNppGUI()._definedWorkspaceExt.c_str();
generic_string workspaceExt = TEXT("");
if (*ext != '\0')
{
if (*ext != '.')
workspaceExt += TEXT(".");
workspaceExt += ext;
fDlg.setExtFilter(TEXT("Workspace file"), workspaceExt.c_str(), NULL);
}
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
}
void ProjectPanel::addFiles(HTREEITEM hTreeItem) void ProjectPanel::addFiles(HTREEITEM hTreeItem)
{ {
FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL)); FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL));

@ -26,14 +26,9 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef PROJECTPANEL_H #pragma once
#define PROJECTPANEL_H
//#include <windows.h>
#ifndef DOCKINGDLGINTERFACE_H
#include "DockingDlgInterface.h" #include "DockingDlgInterface.h"
#endif //DOCKINGDLGINTERFACE_H
#include "TreeView.h" #include "TreeView.h"
#include "ProjectPanel_rc.h" #include "ProjectPanel_rc.h"
@ -68,6 +63,7 @@ enum NodeType {
}; };
class TiXmlNode; class TiXmlNode;
class FileDialog;
class ProjectPanel : public DockingDlgInterface { class ProjectPanel : public DockingDlgInterface {
public: public:
@ -141,6 +137,7 @@ protected:
void showContextMenu(int x, int y); void showContextMenu(int x, int y);
generic_string getAbsoluteFilePath(const TCHAR * relativePath); generic_string getAbsoluteFilePath(const TCHAR * relativePath);
void openSelectFile(); void openSelectFile();
void setFileExtFilter(FileDialog & fDlg);
}; };
class FileRelocalizerDlg : public StaticDialog class FileRelocalizerDlg : public StaticDialog
@ -167,5 +164,3 @@ private :
generic_string _fullFilePath; generic_string _fullFilePath;
}; };
#endif // PROJECTPANEL_H

Loading…
Cancel
Save