Code::Blocks  SVN r11506
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
ProjectManager Class Reference

The entry point singleton for working with projects. More...

#include <projectmanager.h>

Inheritance diagram for ProjectManager:
Collaboration diagram for ProjectManager:

Public Member Functions

cbProjectManagerUIGetUI ()
 
void SetUI (cbProjectManagerUI *ui)
 
const FilesGroupsAndMasksGetFilesGroupsAndMasks () const
 
FilesGroupsAndMasksGetFilesGroupsAndMasks ()
 
wxString GetDefaultPath ()
 Retrieve the default path for new projects. More...
 
void SetDefaultPath (const wxString &path)
 Set the default path for new projects. More...
 
bool IsProjectStillOpen (cbProject *project)
 Is this a valid project? (i.e. More...
 
cbProjectGetActiveProject ()
 Retrieve the active project. More...
 
ProjectsArray * GetProjects ()
 Retrieve an array of all the opened projects. More...
 
cbProjectIsOpen (const wxString &filename)
 Check if a project is open based on the project's filename. More...
 
void SetProject (cbProject *project, bool refresh=true)
 Set the active project. More...
 
cbProjectLoadProject (const wxString &filename, bool activateIt=true)
 Load a project from disk. More...
 
void ReloadProject (cbProject *project)
 Reloads a project and tries to keep everything the same (project order, dependencies, active project) More...
 
bool SaveProject (cbProject *project)
 Save a project to disk. More...
 
bool SaveProjectAs (cbProject *project)
 Save a project to disk, asking for a filename. More...
 
bool SaveActiveProject ()
 Save the active project to disk. More...
 
bool SaveActiveProjectAs ()
 Save the active project to disk, asking for a filename. More...
 
bool SaveAllProjects ()
 Saves all projects to disk. More...
 
bool CloseProject (cbProject *project, bool dontsave=false, bool refresh=true)
 Close a project. More...
 
bool CloseActiveProject (bool dontsave=false)
 Close the active project. More...
 
bool CloseAllProjects (bool dontsave=false)
 Close all projects. More...
 
cbProjectNewProject (const wxString &filename=wxEmptyString)
 Create a new empty project. More...
 
int AddFileToProject (const wxString &filename, cbProject *project=nullptr, int target=-1)
 Add a file to a project. More...
 
int AddFileToProject (const wxString &filename, cbProject *project, wxArrayInt &targets)
 Add a file to a project. More...
 
int AddMultipleFilesToProject (const wxArrayString &filelist, cbProject *project, int target=-1)
 Add multiple files to a project. More...
 
int AddMultipleFilesToProject (const wxArrayString &filelist, cbProject *project, wxArrayInt &targets)
 Add multiple files to a project. More...
 
void RemoveFileFromProject (ProjectFile *pfile, cbProject *project)
 Remove a file from a project. More...
 
bool LoadWorkspace (const wxString &filename=DEFAULT_WORKSPACE)
 Load a workspace. More...
 
bool SaveWorkspace ()
 Save the open workspace. More...
 
bool SaveWorkspaceAs (const wxString &filename)
 Save the open workspace under a different filename. More...
 
bool CloseWorkspace ()
 Close the workspace. More...
 
bool IsLoadingProject ()
 Check if the project manager is loading a project. More...
 
bool IsLoadingWorkspace ()
 Check if the project manager is loading a workspace. More...
 
bool IsLoading ()
 Check if the project manager is loading a project/workspace. More...
 
bool IsClosingProject ()
 Check if the project manager is closing a project. More...
 
bool IsClosingWorkspace ()
 Check if the project manager is closing a workspace. More...
 
bool IsLoadingOrClosing ()
 Check if the project manager is loading/closing a project/workspace. More...
 
cbWorkspaceGetWorkspace ()
 Get the current workspace filename. More...
 
bool AddProjectDependency (cbProject *base, cbProject *dependsOn)
 Adds a project as a dependency of another project. More...
 
void RemoveProjectDependency (cbProject *base, cbProject *doesNotDependOn)
 Removes a project dependency. More...
 
void ClearProjectDependencies (cbProject *base)
 Removes all dependencies from project base. More...
 
void RemoveProjectFromAllDependencies (cbProject *base)
 Removes the project base from being a dependency of any other project. More...
 
const ProjectsArray * GetDependenciesForProject (cbProject *base)
 Get the array of projects base depends on. More...
 
bool CausesCircularDependency (cbProject *base, cbProject *dependsOn)
 Checks for circular dependencies between base and dependsOn. More...
 
void WorkspaceChanged ()
 Sends message to the plugins that the workspace has been changed. More...
 
bool BeginLoadingProject ()
 Begins the project loading process. More...
 
void EndLoadingProject (cbProject *project)
 Ends the project loading process. More...
 
bool BeginLoadingWorkspace ()
 Begins the workspace loading process. More...
 
void EndLoadingWorkspace ()
 Ends the workspace loading process. More...
 
ProjectManageroperator= (cb_unused const ProjectManager &rhs)
 
void SetIsRunning (cbPlugin *plugin)
 This method should be called when the applications is started by a plugin. More...
 
cbPluginGetIsRunning () const
 Return a pointer to the plugin which is running the application. More...
 
cbProjectFindProjectForFile (const wxString &file, ProjectFile **resultFile, bool isRelative, bool isUnixFilename)
 Return the project which has the file in it, also return the pointer to the ProjectFile object. More...
 

Static Public Member Functions

static bool CanShutdown ()
 Can the app shutdown? (actually: is ProjectManager busy at the moment?) More...
 
static bool IsBusy ()
 For use with plugins. More...
 
- Static Public Member Functions inherited from Mgr< ProjectManager >
static bool Valid ()
 
static ProjectManagerGet ()
 
static void Free ()
 

Private Member Functions

 ProjectManager (cb_unused const ProjectManager &rhs)
 
 ProjectManager ()
 
 ~ProjectManager () override
 
void OnAppDoneStartup (CodeBlocksEvent &event)
 
int DoAddFileToProject (const wxString &filename, cbProject *project, wxArrayInt &targets)
 

Private Attributes

cbProjectManagerUIm_ui
 
cbProjectm_pActiveProject
 
cbProjectm_pProjectToActivate
 
ProjectsArray * m_pProjects
 
DepsMap m_ProjectDeps
 
cbWorkspacem_pWorkspace
 
FilesGroupsAndMasksm_pFileGroups
 
bool m_IsLoadingProject
 
bool m_IsLoadingWorkspace
 
bool m_IsClosingProject
 
bool m_IsClosingWorkspace
 
wxString m_InitialDir
 
bool m_CanSendWorkspaceChanged
 
cbPluginm_RunningPlugin
 

Static Private Attributes

static bool s_CanShutdown = true
 

Friends

class Mgr< ProjectManager >
 
class Manager
 

Additional Inherited Members

- Protected Member Functions inherited from Mgr< ProjectManager >
 Mgr ()
 
virtual ~Mgr ()
 

Detailed Description

The entry point singleton for working with projects.

This is the project manager class. It handles all open projects and workspaces. It is through this class that you make requests about projects, like open a project, save it, set the active project (if more than one are opened), etc. To access a project, you must retrieve it from this class.

As all managers, this is a singleton class which you retrieve by asking the global Manager singleton. E.g. Manager::Get()->GetProjectManager()

Definition at line 142 of file projectmanager.h.

Constructor & Destructor Documentation

◆ ProjectManager() [1/2]

ProjectManager::ProjectManager ( cb_unused const ProjectManager rhs)
private

◆ ProjectManager() [2/2]

ProjectManager::ProjectManager ( )
private

◆ ~ProjectManager()

ProjectManager::~ProjectManager ( )
overrideprivate

Definition at line 104 of file projectmanager.cpp.

References m_pFileGroups, m_pProjects, m_pWorkspace, and m_ui.

Member Function Documentation

◆ AddFileToProject() [1/2]

int ProjectManager::AddFileToProject ( const wxString filename,
cbProject project = nullptr,
int  target = -1 
)

Add a file to a project.

This function comes in two versions. This version, expects a single build target index for the added file to belong to.

Parameters
filenameThe file to add to the project.
projectThe project to add this file to. If NULL, the active project is used.
targetThe index of the project's build target to add this file.
Returns
The build target's index that this file was added to.
Note
If the target index supplied is -1 then, if the project has exactly one build target, the file is added to this single build target. If the project has more than one build targets, a dialog appears so that the user can select which build target this file should belong to.

Definition at line 711 of file projectmanager.cpp.

References GetActiveProject().

Referenced by Wiz::CopyFiles(), MainFrame::OnFileNewWhat(), Wiz::RunProjectWizard(), and EditorManager::SwapActiveHeaderSource().

◆ AddFileToProject() [2/2]

int ProjectManager::AddFileToProject ( const wxString filename,
cbProject project,
wxArrayInt targets 
)

Add a file to a project.

This function comes in two versions. This version, expects an array of build target indices for the added file to belong to.

Parameters
filenameThe file to add to the project.
projectThe project to add this file to. If NULL, the active project is used.
targetsThe array of the project's build targets indices to add this file.
Returns
The number of build targets this file was added to.
Note
If the targets array is empty then, if the project has exactly one build target, the file is added to this single build target. If the project has more than one build targets, a dialog appears so that the user can select which build targets (multiple) this file should belong to.
Also note than when this function returns, the targets array will contain the user-selected build targets.

Definition at line 723 of file projectmanager.cpp.

References cbEVT_PROJECT_FILE_ADDED, DoAddFileToProject(), Manager::Get(), GetActiveProject(), Manager::GetPluginManager(), and PluginManager::NotifyPlugins().

◆ AddMultipleFilesToProject() [1/2]

int ProjectManager::AddMultipleFilesToProject ( const wxArrayString filelist,
cbProject project,
int  target = -1 
)

Add multiple files to a project.

This function comes in two versions. This version, expects a single build target index for the added files to belong to.

Parameters
filelistThe files to add to the project.
projectThe project to add these files to. If NULL, the active project is used.
targetThe index of the project's build target to add these files.
Returns
The build target's index that these files were added to.
Note
If the target index supplied is -1 then, if the project has exactly one build target, the files are added to this single build target. If the project has more than one build targets, a dialog appears so that the user can select which build target these files should belong to.

Definition at line 739 of file projectmanager.cpp.

References GetActiveProject().

Referenced by ProjectManagerUI::OnAddFilesToProjectRecursively(), and ProjectManagerUI::OnAddFileToProject().

◆ AddMultipleFilesToProject() [2/2]

int ProjectManager::AddMultipleFilesToProject ( const wxArrayString filelist,
cbProject project,
wxArrayInt targets 
)

Add multiple files to a project.

This function comes in two versions. This version, expects an array of build target indices for the added files to belong to.

Parameters
filelistThe files to add to the project.
projectThe project to add this file to. If NULL, the active project is used.
targetsThe array of the project's build targets indices to add this file.
Returns
The number of build targets these files were added to.
Note
If the targets array is empty then, if the project has exactly one build target, the files are added to this single build target. If the project has more than one build targets, a dialog appears so that the user can select which build targets (multiple) these files should belong to.
Also note than when this function returns, the targets array will contain the user-selected build targets.

Definition at line 751 of file projectmanager.cpp.

References _(), wxArrayString::Add(), cbProject::BeginAddFiles(), cbEVT_PROJECT_FILE_ADDED, DoAddFileToProject(), cbProject::EndAddFiles(), Manager::Get(), GetActiveProject(), Manager::GetAppFrame(), wxArrayString::GetCount(), Manager::GetPluginManager(), and PluginManager::NotifyPlugins().

◆ AddProjectDependency()

bool ProjectManager::AddProjectDependency ( cbProject base,
cbProject dependsOn 
)

Adds a project as a dependency of another project.

Projects inside workspaces allow you to set dependencies between them. When project A depends on project B, this means that before building project A, project B will be built because it obviously generates code that project A depends upon.

Parameters
baseThe project to set a dependency for.
dependsOnthe project that must be built before base project.

Definition at line 811 of file projectmanager.cpp.

References _T, CausesCircularDependency(), LogManager::DebugLog(), F(), Manager::Get(), Manager::GetLogManager(), CompileTargetBase::GetTitle(), m_ProjectDeps, m_pWorkspace, cbWorkspace::SetModified(), wxString::wx_str(), and wxNOT_FOUND.

Referenced by WorkspaceLoader::Open(), ScriptBindings::RegisterBindings(), and ReloadProject().

◆ BeginLoadingProject()

bool ProjectManager::BeginLoadingProject ( )

Begins the project loading process.

Only to be used by code that needs it (e.g. project importers).

Returns
True on success, false on failure.
Note
This call must be "closed" by a call to EndLoadingProject()!

Definition at line 983 of file projectmanager.cpp.

References _(), _T, cbMessageBox(), Manager::Get(), m_IsLoadingProject, and s_CanShutdown.

Referenced by LoadProject(), and NewProject().

◆ BeginLoadingWorkspace()

bool ProjectManager::BeginLoadingWorkspace ( )

Begins the workspace loading process.

Only to be used by code that needs it (e.g. workspace importers).

Returns
True on success, false on failure.
Note
This call must be "closed" by a call to EndLoadingWorkspace()!

Definition at line 1053 of file projectmanager.cpp.

References cbProjectManagerUI::BeginLoadingWorkspace(), CloseWorkspace(), m_IsLoadingWorkspace, and m_ui.

Referenced by LoadWorkspace().

◆ CanShutdown()

static bool ProjectManager::CanShutdown ( )
inlinestatic

Can the app shutdown? (actually: is ProjectManager busy at the moment?)

Definition at line 157 of file projectmanager.h.

Referenced by MainFrame::OnApplicationClose(), MainFrame::OnFileCloseProject(), and MainFrame::OnFileMenuUpdateUI().

◆ CausesCircularDependency()

bool ProjectManager::CausesCircularDependency ( cbProject base,
cbProject dependsOn 
)

Checks for circular dependencies between base and dependsOn.

Returns
True if circular dependency is detected, false if it isn't.

Definition at line 787 of file projectmanager.cpp.

References GetDependenciesForProject().

Referenced by AddProjectDependency().

◆ ClearProjectDependencies()

void ProjectManager::ClearProjectDependencies ( cbProject base)

Removes all dependencies from project base.

See also
AddProjectDependency()
Parameters
baseThe project to remove all dependencies from.

Definition at line 865 of file projectmanager.cpp.

References _T, LogManager::DebugLog(), Manager::Get(), Manager::GetLogManager(), CompileTargetBase::GetTitle(), m_ProjectDeps, m_pWorkspace, and cbWorkspace::SetModified().

Referenced by CloseProject(), ScriptBindings::RegisterBindings(), and ProjectDepsDlg::SaveList().

◆ CloseActiveProject()

bool ProjectManager::CloseActiveProject ( bool  dontsave = false)

Close the active project.

Same as CloseProject(GetActiveProject()).

Returns
True if project was closed, false if not.

Definition at line 472 of file projectmanager.cpp.

References CloseProject(), m_pActiveProject, m_pProjects, and SetProject().

Referenced by MainFrame::OnFileCloseProject(), and ScriptBindings::RegisterBindings().

◆ CloseAllProjects()

bool ProjectManager::CloseAllProjects ( bool  dontsave = false)

◆ CloseProject()

bool ProjectManager::CloseProject ( cbProject project,
bool  dontsave = false,
bool  refresh = true 
)

◆ CloseWorkspace()

bool ProjectManager::CloseWorkspace ( )

◆ DoAddFileToProject()

int ProjectManager::DoAddFileToProject ( const wxString filename,
cbProject project,
wxArrayInt targets 
)
private

◆ EndLoadingProject()

void ProjectManager::EndLoadingProject ( cbProject project)

◆ EndLoadingWorkspace()

void ProjectManager::EndLoadingWorkspace ( )

◆ FindProjectForFile()

cbProject * ProjectManager::FindProjectForFile ( const wxString file,
ProjectFile **  resultFile,
bool  isRelative,
bool  isUnixFilename 
)

Return the project which has the file in it, also return the pointer to the ProjectFile object.

Definition at line 1147 of file projectmanager.cpp.

References cbProject::GetFileByFilename(), and m_pProjects.

Referenced by DebuggerState::AddBreakpoint(), EditorManager::CheckForExternallyModifiedFiles(), EditorManager::Open(), EditorBase::SetTitle(), and cbAuiNotebook::UniqueIdFromTooltip().

◆ GetActiveProject()

cbProject* ProjectManager::GetActiveProject ( )
inline

Retrieve the active project.

Most of the times, this is the function you 'll be calling in ProjectManager.

Returns
A pointer to the active project.

Definition at line 177 of file projectmanager.h.

Referenced by AddFileToProject(), AddMultipleFilesToProject(), CompilerGCC::AskForActiveProject(), ProjectManagerUI::AskForBuildTargetIndex(), ProjectManagerUI::AskForMultiBuildTargetIndex(), CodeBlocksApp::BatchJob(), EditorManager::CollectDefines(), DebuggerGDB::Debug(), CompilerErrors::DoGotoError(), cbEditor::DoInitializations(), CodeCompletion::DoParseOpenedProjectAndActiveEditor(), MainFrame::DoUpdateAppTitle(), FilePathPanel::FilePathPanel(), FindReplaceDlg::FindReplaceDlg(), DebuggerManager::FindTargetsDebugger(), NativeParser::GetCurrentProject(), MainFrame::GetEditorDescription(), NativeParser::GetProjectByFilename(), FindReplaceDlg::GetTarget(), CompilerGCC::IsValidTarget(), ProjectManagerUI::OnAddFilesToProjectRecursively(), ProjectManagerUI::OnAddFileToProject(), EditorManager::OnAddFileToProject(), FilePathPanel::OnbtnBrowseClick(), ProjectManagerUI::OnCloseProject(), cbEditor::OnContextMenuEntry(), ProjectManagerUI::OnExecParameters(), MainFrame::OnFileMenuUpdateUI(), MainFrame::OnFileNewWhat(), MainFrame::OnFileSaveProject(), MainFrame::OnFileSaveProjectAs(), ProjectManagerUI::OnGotoFile(), ProjectManagerUI::OnKeyDown(), WizBuildTargetPanel::OnPageChanging(), NativeParser::OnParsingOneByOneTimer(), CompilerGCC::OnProjectActivated(), ProjectManagerUI::OnProjectFileActivated(), ProjectManagerUI::OnProperties(), ProjectManagerUI::OnRightClick(), DisassemblyDlg::OnSave(), FindReplaceDlg::OnSelectTarget(), ProjectManagerUI::OnSetActiveProject(), DebuggerMenuHandler::OnUpdateUI(), DebuggerToolbarHandler::OnUpdateUI(), ProjectManagerUI::OnUpdateUI(), CompilerGCC::OnUpdateUI(), CodeCompletion::OnWorkspaceChanged(), ProjectManagerUI::RebuildTree(), ScriptBindings::RegisterBindings(), MacrosManager::ReplaceMacros(), Wiz::RunTargetWizard(), WorkspaceLoader::SaveLayout(), FilePathPanel::SetAddToProject(), ProjectManagerUI::ShowMenu(), EditorManager::SwapActiveHeaderSource(), cbDebuggerPlugin::SyncEditor(), and cbDebuggerPlugin::ToolMenuEnabled().

◆ GetDefaultPath()

wxString ProjectManager::GetDefaultPath ( )

Retrieve the default path for new projects.

Returns
The default path for new projects. Contains trailing path separator.
Note
This might be empty if not configured before...

Definition at line 138 of file projectmanager.cpp.

References _T, wxString::Append(), Manager::Get(), Manager::GetConfigManager(), wxString::IsEmpty(), wxString::Last(), ConfigManager::Read(), and wxEmptyString.

Referenced by WizProjectPathPanel::OnPageChanged(), and ScriptBindings::RegisterBindings().

◆ GetDependenciesForProject()

const ProjectsArray * ProjectManager::GetDependenciesForProject ( cbProject base)

Get the array of projects base depends on.

Parameters
baseThe project to get its dependencies.
Returns
An array of project dependencies, or NULL if no dependencies are set for base.

Definition at line 922 of file projectmanager.cpp.

References m_ProjectDeps.

Referenced by CompilerGCC::CalculateProjectDependencies(), CausesCircularDependency(), ProjectDepsDlg::FillList(), ScriptBindings::RegisterBindings(), and WorkspaceLoader::Save().

◆ GetFilesGroupsAndMasks() [1/2]

const FilesGroupsAndMasks* ProjectManager::GetFilesGroupsAndMasks ( ) const
inline

◆ GetFilesGroupsAndMasks() [2/2]

FilesGroupsAndMasks* ProjectManager::GetFilesGroupsAndMasks ( )
inline

Definition at line 154 of file projectmanager.h.

◆ GetIsRunning()

cbPlugin * ProjectManager::GetIsRunning ( ) const

◆ GetProjects()

ProjectsArray* ProjectManager::GetProjects ( )
inline

◆ GetUI()

cbProjectManagerUI& ProjectManager::GetUI ( )
inline

◆ GetWorkspace()

cbWorkspace * ProjectManager::GetWorkspace ( )

◆ IsBusy()

bool ProjectManager::IsBusy ( )
static

For use with plugins.

Checks whether files in the project MAY be processed. This function has been made static for your convenience :)

Returns
true if Loading,closing a project/workspace, or if the app is shutting down. False otherwise

Definition at line 627 of file projectmanager.cpp.

References Manager::Get(), Manager::GetProjectManager(), Manager::IsAppShuttingDown(), and IsLoadingOrClosing().

Referenced by CodeCompletion::OnEditorActivated(), CodeCompletion::OnEditorSave(), CodeCompletion::OnProjectActivated(), CodeCompletion::OnReparsingTimer(), cbEditor::OnScintillaEvent(), CodeCompletion::OnToolbarTimer(), and WorkspaceChanged().

◆ IsClosingProject()

bool ProjectManager::IsClosingProject ( )

Check if the project manager is closing a project.

Returns
True if it's closing a project, false otherwise

Definition at line 659 of file projectmanager.cpp.

References m_IsClosingProject.

◆ IsClosingWorkspace()

bool ProjectManager::IsClosingWorkspace ( )

Check if the project manager is closing a workspace.

Returns
True if it's closing a workspace, false otherwise

Definition at line 664 of file projectmanager.cpp.

References m_IsClosingWorkspace.

◆ IsLoading()

bool ProjectManager::IsLoading ( )

Check if the project manager is loading a project/workspace.

Returns
True if it's loading a project/workspace, false otherwise

Definition at line 654 of file projectmanager.cpp.

References m_IsLoadingProject, and m_IsLoadingWorkspace.

Referenced by EditorManager::Open(), and UserVariableManager::Replace().

◆ IsLoadingOrClosing()

bool ProjectManager::IsLoadingOrClosing ( )

Check if the project manager is loading/closing a project/workspace.

Returns
True if it is loading/closing something, false otherwise

Definition at line 639 of file projectmanager.cpp.

References m_IsClosingProject, m_IsClosingWorkspace, m_IsLoadingProject, and m_IsLoadingWorkspace.

Referenced by IsBusy().

◆ IsLoadingProject()

bool ProjectManager::IsLoadingProject ( )

Check if the project manager is loading a project.

Returns
True if it's loading a project, false otherwise

Definition at line 644 of file projectmanager.cpp.

References m_IsLoadingProject.

Referenced by ProjectManagerUI::OnCloseProject(), and ProjectManagerUI::OnSaveProject().

◆ IsLoadingWorkspace()

bool ProjectManager::IsLoadingWorkspace ( )

Check if the project manager is loading a workspace.

Returns
True if it's loading a workspace, false otherwise

Definition at line 649 of file projectmanager.cpp.

References m_IsLoadingWorkspace.

◆ IsOpen()

cbProject * ProjectManager::IsOpen ( const wxString filename)

Check if a project is open based on the project's filename.

Parameters
filenameThe project's filename. Must be an absolute path.
Returns
A pointer to the project if it is open, or NULL if it is not.

Definition at line 187 of file projectmanager.cpp.

References CompileTargetBase::GetFilename(), wxString::IsEmpty(), wxString::Lower(), m_pProjects, wxString::Matches(), and realpath().

Referenced by WorkspaceLoader::LoadLayout(), LoadProject(), NewProject(), WorkspaceLoader::Open(), MainFrame::OpenGeneric(), and ScriptBindings::RegisterBindings().

◆ IsProjectStillOpen()

bool ProjectManager::IsProjectStillOpen ( cbProject project)

Is this a valid project? (i.e.

is it still open?)

Parameters
projectThe project to check its validity.
Returns
True if the project is valid (i.e. still open), false if not.

Definition at line 151 of file projectmanager.cpp.

References m_pProjects.

◆ LoadProject()

cbProject * ProjectManager::LoadProject ( const wxString filename,
bool  activateIt = true 
)

Load a project from disk.

This function, internally, uses IsOpen() so that the same project can't be loaded twice.

Parameters
filenameThe project file's filename.
activateItActive the project after loading.
Returns
If the function succeeds, a pointer to the newly opened project is returned. Else the return value is NULL.

Definition at line 213 of file projectmanager.cpp.

References BeginLoadingProject(), EndLoadingProject(), FileTypeOf(), ftCodeBlocksProject, Manager::Get(), PluginManager::GetMIMEHandlerForFile(), Manager::GetPluginManager(), cbProject::IsLoaded(), IsOpen(), m_IsLoadingWorkspace, m_pProjectToActivate, cbMimePlugin::OpenFile(), SetProject(), and wxFileExists().

Referenced by MainFrame::DoOpenProject(), TemplateManager::NewProjectFromUserTemplate(), WorkspaceLoader::Open(), ScriptBindings::RegisterBindings(), and ReloadProject().

◆ LoadWorkspace()

bool ProjectManager::LoadWorkspace ( const wxString filename = DEFAULT_WORKSPACE)

◆ NewProject()

cbProject * ProjectManager::NewProject ( const wxString filename = wxEmptyString)

Create a new empty project.

Parameters
filenamethe project's filename
Returns
A pointer to the new project if succesful, or NULL if not.
Note
When the new project is created, if no filename parameter was supplied, it asks the user where to save it. If the user cancels the Save dialog, then NULL is returned from this function.

Definition at line 357 of file projectmanager.cpp.

References _(), BeginLoadingProject(), cbMessageBox(), EndLoadingProject(), wxString::IsEmpty(), IsOpen(), m_IsLoadingWorkspace, SetProject(), wxFileExists(), wxICON_QUESTION, wxICON_WARNING, wxID_YES, wxRemoveFile(), and wxYES_NO.

Referenced by ScriptBindings::RegisterBindings(), and Wiz::RunProjectWizard().

◆ OnAppDoneStartup()

void ProjectManager::OnAppDoneStartup ( CodeBlocksEvent event)
private

Definition at line 932 of file projectmanager.cpp.

References m_CanSendWorkspaceChanged.

Referenced by ProjectManager().

◆ operator=()

ProjectManager& ProjectManager::operator= ( cb_unused const ProjectManager rhs)
inline

Definition at line 432 of file projectmanager.h.

References _T, and cbThrow.

◆ ReloadProject()

void ProjectManager::ReloadProject ( cbProject project)

Reloads a project and tries to keep everything the same (project order, dependencies, active project)

Parameters
projectthe project that will be reloaded, the pointer will be invalid after the call.

Definition at line 284 of file projectmanager.cpp.

References AddProjectDependency(), CloseProject(), cbProjectManagerUI::FreezeTree(), CompileTargetBase::GetFilename(), cbWorkspace::GetModified(), LoadProject(), m_pActiveProject, m_pProjects, m_ProjectDeps, m_pWorkspace, m_ui, cbProjectManagerUI::RebuildTree(), cbWorkspace::SetModified(), cbProjectManagerUI::UnfreezeTree(), wxEmptyString, and wxNOT_FOUND.

Referenced by ProjectManagerUI::CheckForExternallyModifiedProjects().

◆ RemoveFileFromProject()

void ProjectManager::RemoveFileFromProject ( ProjectFile pfile,
cbProject project 
)

◆ RemoveProjectDependency()

void ProjectManager::RemoveProjectDependency ( cbProject base,
cbProject doesNotDependOn 
)

Removes a project dependency.

See also
AddProjectDependency()
Parameters
baseThe project to remove a dependency from.
doesNotDependOnThe project that is to stop being a dependency of project base.

Definition at line 842 of file projectmanager.cpp.

References _T, LogManager::DebugLog(), F(), Manager::Get(), Manager::GetLogManager(), CompileTargetBase::GetTitle(), m_ProjectDeps, m_pWorkspace, cbWorkspace::SetModified(), and wxString::wx_str().

Referenced by ScriptBindings::RegisterBindings().

◆ RemoveProjectFromAllDependencies()

void ProjectManager::RemoveProjectFromAllDependencies ( cbProject base)

Removes the project base from being a dependency of any other project.

See also
AddProjectDependency()
Parameters
baseThe project to remove from all dependencies.

Definition at line 881 of file projectmanager.cpp.

References _T, LogManager::DebugLog(), F(), Manager::Get(), Manager::GetLogManager(), CompileTargetBase::GetTitle(), m_ProjectDeps, m_pWorkspace, cbWorkspace::SetModified(), wxString::wx_str(), and wxNOT_FOUND.

Referenced by CloseProject(), and ScriptBindings::RegisterBindings().

◆ SaveActiveProject()

bool ProjectManager::SaveActiveProject ( )

Save the active project to disk.

Same as SaveProject(GetActiveProject()).

Returns
True if saving was succesful, false if not.

Definition at line 506 of file projectmanager.cpp.

References m_pActiveProject, and SaveProject().

Referenced by MainFrame::OnFileSaveProject(), and ScriptBindings::RegisterBindings().

◆ SaveActiveProjectAs()

bool ProjectManager::SaveActiveProjectAs ( )

Save the active project to disk, asking for a filename.

Same as SaveProjectAs(GetActiveProject()).

Returns
True if saving was succesful, false if not.
Note
A false return value doesn't necessarily mean failure. The user might have cancelled the SaveAs dialog...

Definition at line 511 of file projectmanager.cpp.

References m_pActiveProject, and SaveProjectAs().

Referenced by MainFrame::OnFileSaveProjectAs(), and ScriptBindings::RegisterBindings().

◆ SaveAllProjects()

bool ProjectManager::SaveAllProjects ( )

Saves all projects to disk.

Returns
True if all projects were saved, false if even one save operation failed.

Definition at line 516 of file projectmanager.cpp.

References cbProjectManagerUI::FreezeTree(), cbProject::GetModified(), m_pProjects, m_ui, SaveProject(), and cbProjectManagerUI::UnfreezeTree().

Referenced by MainFrame::OnFileSaveAll(), and ScriptBindings::RegisterBindings().

◆ SaveProject()

bool ProjectManager::SaveProject ( cbProject project)

Save a project to disk.

Parameters
projectA pointer to the project to save.
Returns
True if saving was succesful, false if not.

Definition at line 481 of file projectmanager.cpp.

References m_ui, cbProjectManagerUI::RebuildTree(), and cbProject::Save().

Referenced by ProjectManagerUI::OnSaveProject(), ScriptBindings::RegisterBindings(), SaveActiveProject(), and SaveAllProjects().

◆ SaveProjectAs()

bool ProjectManager::SaveProjectAs ( cbProject project)

Save a project to disk, asking for a filename.

Parameters
projectA pointer to the project to save.
Returns
True if saving was succesful, false if not.
Note
A false return value doesn't necessarily mean failure. The user might have cancelled the SaveAs dialog...

Definition at line 493 of file projectmanager.cpp.

References m_ui, cbProjectManagerUI::RebuildTree(), and cbProject::SaveAs().

Referenced by ScriptBindings::RegisterBindings(), and SaveActiveProjectAs().

◆ SaveWorkspace()

bool ProjectManager::SaveWorkspace ( )

Save the open workspace.

Returns
True if the workspace is saved succefully, false if not.

Definition at line 577 of file projectmanager.cpp.

References GetWorkspace(), and cbWorkspace::Save().

Referenced by MainFrame::OnFileSaveAll(), MainFrame::OnFileSaveWorkspace(), ProjectManagerUI::OnSaveWorkspace(), ProjectManagerUI::QueryCloseWorkspace(), and ScriptBindings::RegisterBindings().

◆ SaveWorkspaceAs()

bool ProjectManager::SaveWorkspaceAs ( const wxString filename)

Save the open workspace under a different filename.

Parameters
filenameThe workspace to save.
Returns
True if the workspace is saved succefully, false if not.

Definition at line 582 of file projectmanager.cpp.

References GetWorkspace(), and cbWorkspace::SaveAs().

Referenced by MainFrame::OnFileSaveWorkspaceAs(), ProjectManagerUI::OnSaveAsWorkspace(), and ScriptBindings::RegisterBindings().

◆ SetDefaultPath()

void ProjectManager::SetDefaultPath ( const wxString path)

Set the default path for new projects.

Note
ProjectManager doesn't use this by itself. It's only doing the book-keeping. Usually this is set/queried from project wizards...

Definition at line 146 of file projectmanager.cpp.

References _T, Manager::Get(), Manager::GetConfigManager(), and ConfigManager::Write().

Referenced by WizProjectPathPanel::OnPageChanging(), and ScriptBindings::RegisterBindings().

◆ SetIsRunning()

void ProjectManager::SetIsRunning ( cbPlugin plugin)

This method should be called when the applications is started by a plugin.

There is only one plugin which could be running the application. Running means that plugin has started the executable and it is waiting for it to finish.

Definition at line 1137 of file projectmanager.cpp.

References m_RunningPlugin.

Referenced by CompilerGCC::KillProcess(), cbDebuggerPlugin::MarkAsStopped(), CompilerGCC::NotifyJobDone(), cbDebuggerPlugin::OnCompilerFinished(), DebuggerMenuHandler::OnRunToCursor(), DebuggerMenuHandler::OnStart(), DebuggerMenuHandler::OnStep(), and CompilerGCC::Run().

◆ SetProject()

void ProjectManager::SetProject ( cbProject project,
bool  refresh = true 
)

◆ SetUI()

void ProjectManager::SetUI ( cbProjectManagerUI ui)

Definition at line 132 of file projectmanager.cpp.

References m_ui.

◆ WorkspaceChanged()

void ProjectManager::WorkspaceChanged ( )

Friends And Related Function Documentation

◆ Manager

friend class Manager
friend

Definition at line 147 of file projectmanager.h.

◆ Mgr< ProjectManager >

friend class Mgr< ProjectManager >
friend

Definition at line 146 of file projectmanager.h.

Member Data Documentation

◆ m_CanSendWorkspaceChanged

bool ProjectManager::m_CanSendWorkspaceChanged
private

Definition at line 470 of file projectmanager.h.

Referenced by OnAppDoneStartup(), and WorkspaceChanged().

◆ m_InitialDir

wxString ProjectManager::m_InitialDir
private

Definition at line 469 of file projectmanager.h.

Referenced by CloseAllProjects(), CloseProject(), and ProjectManager().

◆ m_IsClosingProject

bool ProjectManager::m_IsClosingProject
private

◆ m_IsClosingWorkspace

bool ProjectManager::m_IsClosingWorkspace
private

Definition at line 468 of file projectmanager.h.

Referenced by CloseWorkspace(), IsClosingWorkspace(), and IsLoadingOrClosing().

◆ m_IsLoadingProject

bool ProjectManager::m_IsLoadingProject
private

◆ m_IsLoadingWorkspace

bool ProjectManager::m_IsLoadingWorkspace
private

◆ m_pActiveProject

cbProject* ProjectManager::m_pActiveProject
private

◆ m_pFileGroups

FilesGroupsAndMasks* ProjectManager::m_pFileGroups
private

Definition at line 464 of file projectmanager.h.

Referenced by EndLoadingProject(), ProjectManager(), and ~ProjectManager().

◆ m_pProjects

ProjectsArray* ProjectManager::m_pProjects
private

◆ m_pProjectToActivate

cbProject* ProjectManager::m_pProjectToActivate
private

Definition at line 460 of file projectmanager.h.

Referenced by EndLoadingWorkspace(), LoadProject(), and ProjectManager().

◆ m_ProjectDeps

DepsMap ProjectManager::m_ProjectDeps
private

◆ m_pWorkspace

cbWorkspace* ProjectManager::m_pWorkspace
private

◆ m_RunningPlugin

cbPlugin* ProjectManager::m_RunningPlugin
private

Definition at line 471 of file projectmanager.h.

Referenced by GetIsRunning(), and SetIsRunning().

◆ m_ui

cbProjectManagerUI* ProjectManager::m_ui
private

◆ s_CanShutdown

bool ProjectManager::s_CanShutdown = true
staticprivate

Definition at line 144 of file projectmanager.h.

Referenced by BeginLoadingProject(), and EndLoadingProject().


The documentation for this class was generated from the following files: