File Browser (New name: Folder as Workspace) - in progress
Add "copy path", "add folder" and "remove all folders" 3 menu commands.
This commit is contained in:
parent
81deab0554
commit
7d0d874296
@ -150,8 +150,10 @@ static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pDa
|
||||
};
|
||||
|
||||
|
||||
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
|
||||
generic_string folderBrowser(HWND parent, const generic_string & title, int outputCtrlID, const TCHAR *defaultStr)
|
||||
{
|
||||
generic_string dirStr;
|
||||
|
||||
// This code was copied and slightly modifed from:
|
||||
// http://www.bcbdev.com/faqs/faq62.htm
|
||||
|
||||
@ -170,11 +172,13 @@ void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
|
||||
info.pidlRoot = NULL;
|
||||
TCHAR szDisplayName[MAX_PATH];
|
||||
info.pszDisplayName = szDisplayName;
|
||||
info.lpszTitle = TEXT("Select a folder to search from");
|
||||
info.lpszTitle = title.c_str();
|
||||
info.ulFlags = 0;
|
||||
info.lpfn = BrowseCallbackProc;
|
||||
|
||||
TCHAR directory[MAX_PATH];
|
||||
::GetDlgItemText(parent, outputCtrlID, directory, _countof(directory));
|
||||
if (outputCtrlID != 0)
|
||||
::GetDlgItemText(parent, outputCtrlID, directory, _countof(directory));
|
||||
directory[_countof(directory) - 1] = '\0';
|
||||
|
||||
if (!directory[0] && defaultStr)
|
||||
@ -193,12 +197,17 @@ void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
|
||||
// Return is true if success.
|
||||
TCHAR szDir[MAX_PATH];
|
||||
if (::SHGetPathFromIDList(pidl, szDir))
|
||||
{
|
||||
// Set edit control to the directory path.
|
||||
::SetDlgItemText(parent, outputCtrlID, szDir);
|
||||
if (outputCtrlID != 0)
|
||||
::SetDlgItemText(parent, outputCtrlID, szDir);
|
||||
dirStr = szDir;
|
||||
}
|
||||
pShellMalloc->Free(pidl);
|
||||
}
|
||||
pShellMalloc->Release();
|
||||
}
|
||||
return dirStr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ const bool dirDown = false;
|
||||
|
||||
typedef std::basic_string<TCHAR> generic_string;
|
||||
|
||||
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr = NULL);
|
||||
generic_string folderBrowser(HWND parent, const generic_string & title = TEXT(""), int outputCtrlID = 0, const TCHAR *defaultStr = NULL);
|
||||
generic_string getFolderName(HWND parent, const TCHAR *defaultDir = NULL);
|
||||
|
||||
void printInt(int int2print);
|
||||
|
@ -5383,7 +5383,7 @@ void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders)
|
||||
data.dlgID = IDM_VIEW_FILEBROWSER;
|
||||
|
||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
|
||||
generic_string title_temp = pNativeSpeaker->getAttrNameStr(FB_PROJECTPANELTITLE, "FileBrowser", "PanelTitle");
|
||||
generic_string title_temp = pNativeSpeaker->getAttrNameStr(FB_PANELTITLE, "FileBrowser", "PanelTitle");
|
||||
|
||||
static TCHAR title[32];
|
||||
if (title_temp.length() < 32)
|
||||
|
@ -504,7 +504,7 @@ BEGIN
|
||||
MENUITEM "Project Panel 2", IDM_VIEW_PROJECT_PANEL_2
|
||||
MENUITEM "Project Panel 3", IDM_VIEW_PROJECT_PANEL_3
|
||||
END
|
||||
|
||||
MENUITEM "Folder as Workspace", IDM_VIEW_FILEBROWSER
|
||||
MENUITEM "Document Map", IDM_VIEW_DOC_MAP
|
||||
MENUITEM "Function List", IDM_VIEW_FUNC_LIST
|
||||
MENUITEM SEPARATOR
|
||||
|
@ -1159,7 +1159,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
case IDD_FINDINFILES_BROWSE_BUTTON :
|
||||
{
|
||||
if (_currentStatus == FINDINFILES_DLG)
|
||||
folderBrowser(_hSelf, IDD_FINDINFILES_DIR_COMBO, _options._directory.c_str());
|
||||
folderBrowser(_hSelf, TEXT("Select a folder to search from"), IDD_FINDINFILES_DIR_COMBO, _options._directory.c_str());
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
|
@ -246,9 +246,9 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
|
||||
void FileBrowser::initPopupMenus()
|
||||
{
|
||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
|
||||
generic_string edit_removeFolderFromFileBrowser = pNativeSpeaker->getProjectPanelLangMenuStr("FileBrowserContextMenu", IDM_FILEBROWSER_REMOVEROOTFOLDER, PM_EDITREMOVE);
|
||||
/*
|
||||
//NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
|
||||
/*
|
||||
generic_string removeFolderFromFileBrowser = pNativeSpeaker->getProjectPanelLangMenuStr("FileBrowserContextMenu", IDM_FILEBROWSER_REMOVEROOTFOLDER, FB_REMOVEROOT);
|
||||
generic_string edit_rename = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_FILEBROWSER_RENAME, PM_EDITRENAME);
|
||||
generic_string edit_addfolder = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_FILEBROWSER_NEWFOLDER, PM_EDITNEWFOLDER);
|
||||
generic_string edit_addfiles = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_FILEBROWSER_ADDFILES, PM_EDITADDFILES);
|
||||
@ -260,18 +260,24 @@ void FileBrowser::initPopupMenus()
|
||||
edit_remove = pNativeSpeaker->getProjectPanelLangMenuStr("FolderMenu", IDM_FILEBROWSER_DELETEFOLDER, PM_EDITREMOVE);
|
||||
*/
|
||||
_hGlobalMenu = ::CreatePopupMenu();
|
||||
::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDROOT, TEXT("Add"));
|
||||
::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEALLROOTS, TEXT("Remove All"));
|
||||
|
||||
_hRootMenu = ::CreatePopupMenu();
|
||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEROOTFOLDER, edit_removeFolderFromFileBrowser.c_str());
|
||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEROOTFOLDER, TEXT("Remove"));
|
||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path"));
|
||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here"));
|
||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here"));
|
||||
|
||||
_hFolderMenu = ::CreatePopupMenu();
|
||||
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path"));
|
||||
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here"));
|
||||
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here"));
|
||||
//::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_NEWFOLDER, edit_addfolder.c_str());
|
||||
//::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDFILES, edit_addfiles.c_str());
|
||||
|
||||
_hFileMenu = ::CreatePopupMenu();
|
||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path"));
|
||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here"));
|
||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here"));
|
||||
//::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_RENAME, edit_rename.c_str());
|
||||
@ -692,8 +698,6 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
||||
{
|
||||
// get selected item handle
|
||||
HTREEITEM selectedNode = _treeView.getSelection();
|
||||
if (not selectedNode)
|
||||
return;
|
||||
|
||||
switch (cmdID)
|
||||
{
|
||||
@ -703,6 +707,8 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
||||
//
|
||||
case IDM_FILEBROWSER_REMOVEROOTFOLDER:
|
||||
{
|
||||
if (not selectedNode) return;
|
||||
|
||||
generic_string *rootPath = (generic_string *)_treeView.getItemParam(selectedNode);
|
||||
if (_treeView.getParent(selectedNode) != nullptr || rootPath == nullptr)
|
||||
return;
|
||||
@ -723,6 +729,8 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
||||
|
||||
case IDM_FILEBROWSER_EXPLORERHERE:
|
||||
{
|
||||
if (not selectedNode) return;
|
||||
|
||||
generic_string path = getNodePath(selectedNode);
|
||||
if (::PathFileExists(path.c_str()))
|
||||
{
|
||||
@ -736,6 +744,8 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
||||
|
||||
case IDM_FILEBROWSER_CMDHERE:
|
||||
{
|
||||
if (not selectedNode) return;
|
||||
|
||||
if (getNodeType(selectedNode) == browserNodeType_file)
|
||||
selectedNode = _treeView.getParent(selectedNode);
|
||||
|
||||
@ -750,18 +760,44 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_FILEBROWSER_COPYEPATH:
|
||||
{
|
||||
if (not selectedNode) return;
|
||||
generic_string path = getNodePath(selectedNode);
|
||||
str2Clipboard(path, _hParent);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_FILEBROWSER_REMOVEALLROOTS:
|
||||
{
|
||||
for (int i = _folderUpdaters.size() - 1; i >= 0; --i)
|
||||
{
|
||||
_folderUpdaters[i]->stopWatcher();
|
||||
|
||||
HTREEITEM root = getRootFromFullPath(_folderUpdaters[i]->_rootFolder._rootPath);
|
||||
if (root)
|
||||
_treeView.removeItem(root);
|
||||
|
||||
_folderUpdaters.erase(_folderUpdaters.begin() + i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_FILEBROWSER_ADDROOT:
|
||||
{
|
||||
generic_string folderPath = folderBrowser(_hParent, TEXT("Select a folder to add in Folder as Workspace panel"));
|
||||
if (not folderPath.empty())
|
||||
{
|
||||
addRootFolder(folderPath);
|
||||
}
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case IDM_FILEBROWSER_RENAME :
|
||||
TreeView_EditLabel(_treeView.getHSelf(), hTreeItem);
|
||||
break;
|
||||
|
||||
case IDM_FILEBROWSER_NEWFOLDER :
|
||||
{
|
||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
|
||||
generic_string newFolderLabel = pNativeSpeaker->getAttrNameStr(PM_NEWFOLDERNAME, "ProjectManager", "NewFolderName");
|
||||
createNewFolder(hTreeItem, newFolderLabel.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -37,7 +37,8 @@
|
||||
#include "TreeView.h"
|
||||
#include "fileBrowser_rc.h"
|
||||
|
||||
#define FB_PROJECTPANELTITLE TEXT("File Browser")
|
||||
#define FB_PANELTITLE TEXT("Folder as Workspace")
|
||||
/*
|
||||
#define PM_NEWFOLDERNAME TEXT("Folder Name")
|
||||
#define PM_NEWPROJECTNAME TEXT("Project Name")
|
||||
|
||||
@ -50,14 +51,16 @@
|
||||
#define PM_EDITNEWFOLDER TEXT("Add Folder")
|
||||
#define PM_EDITADDFILES TEXT("Add Files...")
|
||||
#define PM_EDITADDFILESRECUSIVELY TEXT("Add Files from Directory...")
|
||||
#define PM_EDITREMOVE TEXT("Remove\tDEL")
|
||||
#define PM_EDITMODIFYFILE TEXT("Modify File Path")
|
||||
*/
|
||||
#define FB_REMOVEROOT TEXT("Remove")
|
||||
|
||||
#define PM_WORKSPACEMENUENTRY TEXT("Workspace")
|
||||
#define PM_EDITMENUENTRY TEXT("Edit")
|
||||
//#define PM_EDITMODIFYFILE TEXT("Copy path")
|
||||
|
||||
#define PM_MOVEUPENTRY TEXT("Move Up\tCtrl+Up")
|
||||
#define PM_MOVEDOWNENTRY TEXT("Move Down\tCtrl+Down")
|
||||
//#define PM_WORKSPACEMENUENTRY TEXT("Workspace")
|
||||
//#define PM_EDITMENUENTRY TEXT("Edit")
|
||||
|
||||
//#define PM_MOVEUPENTRY TEXT("Move Up\tCtrl+Up")
|
||||
//#define PM_MOVEDOWNENTRY TEXT("Move Down\tCtrl+Down")
|
||||
|
||||
class TiXmlNode;
|
||||
|
||||
|
@ -34,16 +34,17 @@
|
||||
#define IDD_FILEBROWSER_MENU (IDD_FILEBROWSER + 10)
|
||||
|
||||
#define IDM_FILEBROWSER_REMOVEROOTFOLDER (IDD_FILEBROWSER_MENU + 1)
|
||||
#define IDM_FILEBROWSER_REMOVEALLROOTS (IDD_FILEBROWSER_MENU + 2)
|
||||
#define IDM_FILEBROWSER_ADDROOT (IDD_FILEBROWSER_MENU + 3)
|
||||
|
||||
/*
|
||||
#define IDM_FILEBROWSER_RENAME (IDD_FILEBROWSER_MENU + 1)
|
||||
#define IDM_FILEBROWSER_NEWFOLDER (IDD_FILEBROWSER_MENU + 2)
|
||||
#define IDM_FILEBROWSER_ADDFILES (IDD_FILEBROWSER_MENU + 3)
|
||||
|
||||
|
||||
#define IDM_FILEBROWSER_DELETEFILE (IDD_FILEBROWSER_MENU + 5)
|
||||
*/
|
||||
|
||||
//#define IDM_FILEBROWSER_MODIFYFILEPATH (IDD_FILEBROWSER_MENU + 6)
|
||||
#define IDM_FILEBROWSER_COPYEPATH (IDD_FILEBROWSER_MENU + 6)
|
||||
#define IDM_FILEBROWSER_EXPLORERHERE (IDD_FILEBROWSER_MENU + 8)
|
||||
#define IDM_FILEBROWSER_CMDHERE (IDD_FILEBROWSER_MENU + 9)
|
||||
|
||||
|
@ -1386,7 +1386,7 @@ INT_PTR CALLBACK DefaultDirectoryDlg::run_dlgProc(UINT Message, WPARAM wParam, L
|
||||
return TRUE;
|
||||
|
||||
case IDD_OPENSAVEDIR_ALWAYSON_BROWSE_BUTTON :
|
||||
folderBrowser(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT);
|
||||
folderBrowser(_hSelf, TEXT("Select a folder as default directory"), IDC_OPENSAVEDIR_ALWAYSON_EDIT);
|
||||
return TRUE;
|
||||
|
||||
case IDC_OPENSAVEDIR_CHECK_USENEWSTYLESAVEDIALOG:
|
||||
@ -2395,7 +2395,7 @@ INT_PTR CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
||||
}
|
||||
case IDD_BACKUPDIR_BROWSE_BUTTON :
|
||||
{
|
||||
folderBrowser(_hSelf, IDC_BACKUPDIR_EDIT);
|
||||
folderBrowser(_hSelf, TEXT("Select a folder as backup directory"), IDC_BACKUPDIR_EDIT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -2960,7 +2960,7 @@ INT_PTR CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LP
|
||||
|
||||
case IDD_CLOUDPATH_BROWSE_BUTTON:
|
||||
{
|
||||
folderBrowser(_hSelf, IDC_CLOUDPATH_EDIT);
|
||||
folderBrowser(_hSelf, TEXT("Select a folder from/to where Notepad++ reads/writes its settings"), IDC_CLOUDPATH_EDIT);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1060,6 +1060,44 @@ generic_string NativeLangSpeaker::getProjectPanelLangMenuStr(const char * nodeNa
|
||||
}
|
||||
return defaultStr;
|
||||
}
|
||||
/*
|
||||
generic_string NativeLangSpeaker::getFileBrowserLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const
|
||||
{
|
||||
if (!_nativeLangA) return defaultStr;
|
||||
|
||||
TiXmlNodeA *targetNode = _nativeLangA->FirstChild("FileBrowser");
|
||||
if (!targetNode) return defaultStr;
|
||||
|
||||
targetNode = targetNode->FirstChild("Menus");
|
||||
if (!targetNode) return defaultStr;
|
||||
|
||||
targetNode = targetNode->FirstChild(nodeName);
|
||||
if (!targetNode) return defaultStr;
|
||||
|
||||
const char *name = NULL;
|
||||
for (TiXmlNodeA *childNode = targetNode->FirstChildElement("Item");
|
||||
childNode;
|
||||
childNode = childNode->NextSibling("Item"))
|
||||
{
|
||||
TiXmlElementA *element = childNode->ToElement();
|
||||
int id;
|
||||
const char *idStr = element->Attribute("id", &id);
|
||||
|
||||
if (idStr && id == cmdID)
|
||||
{
|
||||
name = element->Attribute("name");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (name && name[0])
|
||||
{
|
||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||
return wmc->char2wchar(name, _nativeLangEncoding);
|
||||
}
|
||||
return defaultStr;
|
||||
}
|
||||
*/
|
||||
|
||||
generic_string NativeLangSpeaker::getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name) const
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
};
|
||||
bool getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message);
|
||||
generic_string getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const;
|
||||
//generic_string getFunctionListPanelLangStr(const char *nodeName, const TCHAR *defaultStr) const;
|
||||
//generic_string getFileBrowserLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const;
|
||||
generic_string getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name = NULL) const;
|
||||
int messageBox(const char *msgBoxTagName, HWND hWnd, const TCHAR *message, const TCHAR *title, int msgBoxType, int intInfo = 0, const TCHAR *strInfo = NULL);
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user