@ -23,6 +23,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# include "resource.h"
# include "tinyxml.h"
# include "FileDialog.h"
# include "localization.h"
# include "Parameters.h"
# define CX_BITMAP 16
# define CY_BITMAP 16
@ -52,19 +54,21 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
0 , 0 , 0 , 0 , _hSelf , ( HMENU ) 0 , _hInst , NULL ) ;
TBBUTTON tbButtons [ 2 ] ;
static TCHAR * projectMenuStr = TEXT ( " Workspace " ) ;
NativeLangSpeaker * pNativeSpeaker = ( NppParameters : : getInstance ( ) ) - > getNativeLangSpeaker ( ) ;
generic_string workspace_entry = pNativeSpeaker - > getProjectPanelLangMenuStr ( " Entries " , 0 , PM_WORKSPACEMENUENTRY ) ;
generic_string edit_entry = pNativeSpeaker - > getProjectPanelLangMenuStr ( " Entries " , 1 , PM_EDITMENUENTRY ) ;
tbButtons [ 0 ] . idCommand = IDB_PROJECT_BTN ;
tbButtons [ 0 ] . iBitmap = I_IMAGENONE ;
tbButtons [ 0 ] . fsState = TBSTATE_ENABLED ;
tbButtons [ 0 ] . fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE ;
tbButtons [ 0 ] . iString = ( INT_PTR ) projectMenuStr ;
tbButtons [ 0 ] . iString = ( INT_PTR ) workspace_entry . c_str ( ) ;
static TCHAR * editMenuStr = TEXT ( " Edit " ) ;
tbButtons [ 1 ] . idCommand = IDB_EDIT_BTN ;
tbButtons [ 1 ] . iBitmap = I_IMAGENONE ;
tbButtons [ 1 ] . fsState = TBSTATE_ENABLED ;
tbButtons [ 1 ] . fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE ;
tbButtons [ 1 ] . iString = ( INT_PTR ) editMenuStr ;
tbButtons [ 1 ] . iString = ( INT_PTR ) edit_entry . c_str ( ) ;
SendMessage ( _hToolbarMenu , TB_BUTTONSTRUCTSIZE , ( WPARAM ) sizeof ( TBBUTTON ) , 0 ) ;
SendMessage ( _hToolbarMenu , TB_ADDBUTTONS , ( WPARAM ) sizeof ( tbButtons ) / sizeof ( TBBUTTON ) , ( LPARAM ) & tbButtons ) ;
@ -77,6 +81,7 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
_treeView . display ( ) ;
if ( ! openWorkSpace ( _workSpaceFilePath . c_str ( ) ) )
newWorkSpace ( ) ;
return TRUE ;
}
@ -144,31 +149,56 @@ void ProjectPanel::checkIfNeedSave(const TCHAR *title)
void ProjectPanel : : initMenus ( )
{
_hWorkSpaceMenu = : : CreatePopupMenu ( ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWWS , TEXT ( " New Workspace " ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_OPENWS , TEXT ( " Open Workspace " ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RELOADWS , TEXT ( " Reload Workspace " ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_SAVEWS , TEXT ( " Save " ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_SAVEASWS , TEXT ( " Save As... " ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_SAVEACOPYASWS , TEXT ( " Save a Copy As... " ) ) ;
NativeLangSpeaker * pNativeSpeaker = ( NppParameters : : getInstance ( ) ) - > getNativeLangSpeaker ( ) ;
generic_string new_workspace = pNativeSpeaker - > getProjectPanelLangMenuStr ( " WorkspaceMenu " , IDM_PROJECT_NEWWS , PM_NEWWORKSPACE ) ;
generic_string open_workspace = pNativeSpeaker - > getProjectPanelLangMenuStr ( " WorkspaceMenu " , IDM_PROJECT_OPENWS , PM_OPENWORKSPACE ) ;
generic_string reload_workspace = pNativeSpeaker - > getProjectPanelLangMenuStr ( " WorkspaceMenu " , IDM_PROJECT_RELOADWS , PM_RELOADWORKSPACE ) ;
generic_string save_workspace = pNativeSpeaker - > getProjectPanelLangMenuStr ( " WorkspaceMenu " , IDM_PROJECT_SAVEWS , PM_SAVEWORKSPACE ) ;
generic_string saveas_workspace = pNativeSpeaker - > getProjectPanelLangMenuStr ( " WorkspaceMenu " , IDM_PROJECT_SAVEASWS , PM_SAVEASWORKSPACE ) ;
generic_string saveacopyas_workspace = pNativeSpeaker - > getProjectPanelLangMenuStr ( " WorkspaceMenu " , IDM_PROJECT_SAVEACOPYASWS , PM_SAVEACOPYASWORKSPACE ) ;
generic_string newproject_workspace = pNativeSpeaker - > getProjectPanelLangMenuStr ( " WorkspaceMenu " , IDM_PROJECT_NEWPROJECT , PM_NEWPROJECTWORKSPACE ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWWS , new_workspace . c_str ( ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_OPENWS , open_workspace . c_str ( ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RELOADWS , reload_workspace . c_str ( ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_SAVEWS , save_workspace . c_str ( ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_SAVEASWS , saveas_workspace . c_str ( ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_SAVEACOPYASWS , saveacopyas_workspace . c_str ( ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , ( UINT ) - 1 , 0 ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWPROJECT , TEXT ( " Add New Project " ) ) ;
: : InsertMenu ( _hWorkSpaceMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWPROJECT , newproject_workspace . c_str ( ) ) ;
generic_string edit_rename = pNativeSpeaker - > getProjectPanelLangMenuStr ( " ProjectMenu " , IDM_PROJECT_RENAME , PM_EDITRENAME ) ;
generic_string edit_addfolder = pNativeSpeaker - > getProjectPanelLangMenuStr ( " ProjectMenu " , IDM_PROJECT_NEWFOLDER , PM_EDITNEWFOLDER ) ;
generic_string edit_addfiles = pNativeSpeaker - > getProjectPanelLangMenuStr ( " ProjectMenu " , IDM_PROJECT_ADDFILES , PM_EDITADDFILES ) ;
generic_string edit_remove = pNativeSpeaker - > getProjectPanelLangMenuStr ( " ProjectMenu " , IDM_PROJECT_DELETEFOLDER , PM_EDITREMOVE ) ;
_hProjectMenu = : : CreatePopupMenu ( ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RENAME , TEXT ( " Rename " ) ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWFOLDER , TEXT ( " Add Folder " ) ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_ADDFILES , TEXT ( " Add Files... " ) ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_DELETEFOLDER , TEXT ( " Remove " ) ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RENAME , edit_rename . c_str ( ) ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWFOLDER , edit_addfolder . c_str ( ) ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_ADDFILES , edit_addfiles . c_str ( ) ) ;
: : InsertMenu ( _hProjectMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_DELETEFOLDER , edit_remove . c_str ( ) ) ;
edit_rename = pNativeSpeaker - > getProjectPanelLangMenuStr ( " FolderMenu " , IDM_PROJECT_RENAME , PM_EDITRENAME ) ;
edit_addfolder = pNativeSpeaker - > getProjectPanelLangMenuStr ( " FolderMenu " , IDM_PROJECT_NEWFOLDER , PM_EDITNEWFOLDER ) ;
edit_addfiles = pNativeSpeaker - > getProjectPanelLangMenuStr ( " FolderMenu " , IDM_PROJECT_ADDFILES , PM_EDITADDFILES ) ;
edit_remove = pNativeSpeaker - > getProjectPanelLangMenuStr ( " FolderMenu " , IDM_PROJECT_DELETEFOLDER , PM_EDITREMOVE ) ;
_hFolderMenu = : : CreatePopupMenu ( ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RENAME , TEXT ( " Rename " ) ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWFOLDER , TEXT ( " Add Folder " ) ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_ADDFILES , TEXT ( " Add Files... " ) ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_DELETEFOLDER , TEXT ( " Remove " ) ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RENAME , edit_rename . c_str ( ) ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_NEWFOLDER , edit_addfolder . c_str ( ) ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_ADDFILES , edit_addfiles . c_str ( ) ) ;
: : InsertMenu ( _hFolderMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_DELETEFOLDER , edit_remove . c_str ( ) ) ;
edit_rename = pNativeSpeaker - > getProjectPanelLangMenuStr ( " FileMenu " , IDM_PROJECT_RENAME , PM_EDITRENAME ) ;
edit_remove = pNativeSpeaker - > getProjectPanelLangMenuStr ( " FileMenu " , IDM_PROJECT_DELETEFILE , PM_EDITREMOVE ) ;
generic_string edit_modifyfile = pNativeSpeaker - > getProjectPanelLangMenuStr ( " FileMenu " , IDM_PROJECT_MODIFYFILEPATH , PM_EDITMODIFYFILE ) ;
_hFileMenu = : : CreatePopupMenu ( ) ;
: : InsertMenu ( _hFileMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RENAME , TEXT ( " Rename " ) ) ;
: : InsertMenu ( _hFileMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_DELETEFILE , TEXT ( " Remove " ) ) ;
: : InsertMenu ( _hFileMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_MODIFYFILEPATH , TEXT ( " Modify File Path " ) ) ;
: : InsertMenu ( _hFileMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_RENAME , edit_rename . c_str ( ) ) ;
: : InsertMenu ( _hFileMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_DELETEFILE , edit_remove . c_str ( ) ) ;
: : InsertMenu ( _hFileMenu , 0 , MF_BYCOMMAND , IDM_PROJECT_MODIFYFILEPATH , edit_modifyfile . c_str ( ) ) ;
}
@ -265,9 +295,9 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName)
_workSpaceFilePath = projectFileName ;
_treeView . removeAllItems ( ) ;
HTREEITEM rootItem = _treeView . addItem ( TEXT ( " Workspace " ) , TVI_ROOT , INDEX_CLEAN_ROOT ) ;
NativeLangSpeaker * pNativeSpeaker = ( NppParameters : : getInstance ( ) ) - > getNativeLangSpeaker ( ) ;
generic_string workspace = pNativeSpeaker - > getProjectPanelLangStr ( " WorkspaceRootName " , PM_WORKSPACEROOTNAME ) ;
HTREEITEM rootItem = _treeView . addItem ( workspace . c_str ( ) , TVI_ROOT , INDEX_CLEAN_ROOT ) ;
for ( ; childNode ; childNode = childNode - > NextSibling ( TEXT ( " Project " ) ) )
{
@ -283,7 +313,9 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName)
void ProjectPanel : : newWorkSpace ( )
{
_treeView . addItem ( TEXT ( " Workspace " ) , TVI_ROOT , INDEX_CLEAN_ROOT ) ;
NativeLangSpeaker * pNativeSpeaker = ( NppParameters : : getInstance ( ) ) - > getNativeLangSpeaker ( ) ;
generic_string workspace = pNativeSpeaker - > getProjectPanelLangStr ( " WorkspaceRootName " , PM_WORKSPACEROOTNAME ) ;
_treeView . addItem ( workspace . c_str ( ) , TVI_ROOT , INDEX_CLEAN_ROOT ) ;
setWorkSpaceDirty ( false ) ;
_workSpaceFilePath = TEXT ( " " ) ;
}