39 template<>
ProjectManager* Mgr<ProjectManager>::instance =
nullptr;
78 m_IsLoadingProject(false),
79 m_IsLoadingWorkspace(false),
80 m_IsClosingProject(false),
81 m_IsClosingWorkspace(false),
83 m_CanSendWorkspaceChanged(false),
114 for (
int i = 0; i < count; ++i)
142 path.
Append(wxFILE_SEP_PATH);
154 for (
int i = 0; i < count; ++i)
164 bool activeProjectChanged =
false;
169 activeProjectChanged =
true;
179 if (activeProjectChanged)
193 for (
int i = 0; i < count; ++i)
291 ProjectsArray projectDependencies;
292 ProjectsArray projectsDependingOnReloaded;
299 if (it->first == project)
300 projectDependencies = *(it->second);
304 projectsDependingOnReloaded.push_back(it->first);
309 int originalPosition =
m_pProjects->Index(project);
316 if (!projectDependencies.empty())
318 for (ProjectsArray::iterator it = projectDependencies.begin(); it != projectDependencies.end(); ++it)
321 if (!projectsDependingOnReloaded.empty())
323 for (ProjectsArray::iterator it = projectsDependingOnReloaded.begin();
324 it != projectsDependingOnReloaded.end(); ++it)
330 int loadedPosition = -1;
335 if (*it == loadedProject)
336 loadedPosition = index;
338 if ((*it)->GetFilename() == activeProjectName)
339 projectToActivate = *it;
343 m_pProjects->Insert(loadedProject, originalPosition);
345 if (projectToActivate)
361 if (
cbMessageBox(
_(
"Project file already exists.\nAre you really sure you want to OVERWRITE it?"),
366 cbMessageBox(
_(
"Couldn't remove the old project file to create the new one.\nThe file might be read-only?!"),
456 event.SetProject(project);
521 for (
int i = 0; i < prjCount; ++i)
532 return count == prjCount;
676 if (targets.GetCount() == 0)
685 if (targets.GetCount() == 0)
701 for (
size_t i = 0; i < targets.GetCount(); ++i)
708 return targets.GetCount();
732 event.SetProject(project);
733 event.SetString(filename);
763 for (
unsigned int i = 0; i < filelist.
GetCount(); ++i)
766 addedFiles.
Add(filelist[i]);
772 for (
unsigned int i = 0; i < addedFiles.
GetCount(); ++i)
775 event.SetProject(project);
776 event.SetString(addedFiles[i]);
784 return targets.GetCount();
789 if (!base || !dependsOn)
793 if (base == dependsOn)
800 for (
size_t i = 0; i < arr->GetCount(); ++i)
813 if (!base || !dependsOn)
820 ProjectsArray* arr =
nullptr;
825 arr =
new ProjectsArray;
844 if (!base || !doesNotDependOn)
851 ProjectsArray* arr = it->second;
852 arr->Remove(doesNotDependOn);
856 if (!arr->GetCount())
888 if (it->first == base)
894 ProjectsArray* arr = it->second;
902 int index = arr->Index(base);
904 arr->RemoveAt(index);
910 if (!arr->GetCount())
912 DepsMap::iterator it2 = it++;
965 cbMessageBox(
_(
"Can't remove file because it is auto-generated..."),
_(
"Error"));
977 evt.SetString(filename);
988 if (!
Manager::Get()->GetPluginManager()->FindPluginByName(
_T(
"Compiler")))
990 cbMessageBox(
_(
"Deactivating the compiler plugin is most unwise.\n\nIf you intend to open a project, you have to re-activate the compiler plugin first."),
_(
"Error"));
1010 bool newAddition =
m_pProjects->Index(project) == -1;
1032 event.SetProject(project);
1096 for (
size_t i = 0; i <
m_pProjects->GetCount(); ++i)
1104 event.SetProject(project);
1115 if (numNotes == 1 ||
1117 "Do you want to display them now, one after the other?"),
1119 _(
"Display project notes?"),
1122 for (
size_t i = 0; i <
m_pProjects->GetCount(); ++i)
1148 bool isRelative,
bool isUnixFilename)
1150 for (
size_t i = 0; i <
m_pProjects->GetCount(); ++i)
1162 *resultFile =
nullptr;
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
wxString F(const wxChar *msg,...)
sprintf-like function
void SetDefaultPath(const wxString &path)
Set the default path for new projects.
bool IsLoadingProject()
Check if the project manager is loading a project.
EVTIMPORT const wxEventType cbEVT_PROJECT_FILE_ADDED
bool IsClosingProject()
Check if the project manager is closing a project.
void RemoveProject(cbProject *WXUNUSED(project)) override
EVTIMPORT const wxEventType cbEVT_WORKSPACE_CLOSING_COMPLETE
bool Matches(const wxString &mask) const
static wxString GetCwd(const wxString &volume=wxEmptyString)
bool IsProjectStillOpen(cbProject *project)
Is this a valid project? (i.e.
PluginManager * GetPluginManager() const
bool wxRemoveFile(const wxString &file)
void FreezeTree() override
Stop the tree control from updating.
virtual bool IsOK() const
Was this workspace loaded successfully?
bool SaveActiveProject()
Save the active project to disk.
void SetIsRunning(cbPlugin *plugin)
This method should be called when the applications is started by a plugin.
cbProject * IsOpen(const wxString &filename)
Check if a project is open based on the project's filename.
void ReloadProject(cbProject *project)
Reloads a project and tries to keep everything the same (project order, dependencies, active project)
void RebuildTree() override
Rebuild the project manager's tree.
ConfigManager * GetConfigManager(const wxString &name_space) const
UserVariableManager * GetUserVariableManager() const
virtual void RebuildTree()=0
Rebuild the project manager's tree.
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
bool SaveWorkspaceAs(const wxString &filename)
Save the open workspace under a different filename.
void RemoveProjectFromAllDependencies(cbProject *base)
Removes the project base from being a dependency of any other project.
virtual bool GetModified() const
Is this workspace modified?
static bool IsAppShuttingDown()
EVTIMPORT const wxEventType cbEVT_WORKSPACE_CLOSING_BEGIN
int DoAddFileToProject(const wxString &filename, cbProject *project, wxArrayInt &targets)
bool wxFileExists(const wxString &filename)
bool QueryCloseProject(cbProject *WXUNUSED(proj), bool dontsavefiles=false) override
wxFileName file
The full filename of this file.
void RemoveFileFromProject(ProjectFile *pfile, cbProject *project)
Remove a file from a project.
virtual void SetTitle(const wxString &title)
Set the workspace's title.
wxTreeItemId GetTreeSelection() override
Get the selection of the project manager's tree (GUI).
cbTreeCtrl * GetTree() override
Retrieve a pointer to the project manager's tree (GUI).
virtual bool QueryCloseAllProjects()=0
Checks whether all projects are saved.
virtual bool Save(bool force=false)
Save the workspace.
wxString GetDefaultPath()
Retrieve the default path for new projects.
EVTIMPORT const wxEventType cbEVT_PROJECT_ACTIVATE
void UnfreezeTree(bool force=false) override
Le the tree control be updated again.
cbPlugin * m_RunningPlugin
virtual void SetModified(bool modified)
Mark the workspace as modified or not.
virtual void UnfreezeTree(bool force=false)=0
Le the tree control be updated again.
void EndAddFiles()
Notify that file(s) addition finished.
bool SaveAs()
Save the project under a different name.
bool IsLoading()
Check if the project manager is loading a project/workspace.
DLLIMPORT FileType FileTypeOf(const wxString &filename)
int AddMultipleFilesToProject(const wxArrayString &filelist, cbProject *project, int target=-1)
Add multiple files to a project.
bool m_CanSendWorkspaceChanged
Base class for mime plugins.
int AskForBuildTargetIndex(cbProject *project=nullptr) override
Utility function.
Represents a file in a Code::Blocks project.
ProjectBuildTarget * GetCurrentlyCompilingTarget()
Get a pointer to the currently compiling target.
A generic Code::Blocks event.
ProjectsArray * m_pProjects
bool RemoveFile(ProjectFile *pf)
Remove a file from the project.
void BeginAddFiles()
Notify that file(s) will be added shortly.
wxWindow * GetAppWindow() const
~ProjectManager() override
cbMimePlugin * GetMIMEHandlerForFile(const wxString &filename)
EditorManager * GetEditorManager() const
bool CloseAllFiles(bool dontsave=false)
Close all project files.
bool CausesCircularDependency(cbProject *base, cbProject *dependsOn)
Checks for circular dependencies between base and dependsOn.
void BeginLoadingWorkspace() override
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
bool CloseActiveProject(bool dontsave=false)
Close the active project.
bool MakeRelativeTo(const wxString &pathBase=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
bool BeginLoadingProject()
Begins the project loading process.
void Write(const wxString &name, const wxString &value, bool ignoreEmpty=false)
Represents a Code::Blocks project.
cbProject * NewProject(const wxString &filename=wxEmptyString)
Create a new empty project.
EVTIMPORT const wxEventType cbEVT_WORKSPACE_LOADING_COMPLETE
virtual const wxString & GetFilename() const
bool SaveActiveProjectAs()
Save the active project to disk, asking for a filename.
cbWorkspace * m_pWorkspace
cbPlugin * GetIsRunning() const
Return a pointer to the plugin which is running the application.
cbProject * LoadProject(const wxString &filename, bool activateIt=true)
Load a project from disk.
virtual const wxString & GetTitle() const
Read the target's title.
bool IsLoadingOrClosing()
Check if the project manager is loading/closing a project/workspace.
wxFrame * GetAppFrame() const
bool CloseProject(cbProject *project, bool dontsave=false, bool refresh=true)
Close a project.
void ShowNotes(bool nonEmptyOnly, bool editable=false)
Show project notes now.
static bool IsBatchBuild()
void OnAppDoneStartup(CodeBlocksEvent &event)
LogManager * GetLogManager() const
void EndLoadingWorkspace()
Ends the workspace loading process.
cbProject * GetActiveProject()
Retrieve the active project.
wxString Read(const wxString &key, const wxString &defaultVal=wxEmptyString)
void RemoveProjectDependency(cbProject *base, cbProject *doesNotDependOn)
Removes a project dependency.
virtual wxString GetBasePath() const
Read the target's base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
virtual bool QueryCloseProject(cbProject *proj, bool dontsavefiles=false)=0
Checks whether project is saved.
virtual void RemoveProject(cbProject *project)=0
bool BeginLoadingWorkspace()
Begins the workspace loading process.
const wxStringCharType * wx_str() const
bool m_IsLoadingWorkspace
bool AddProjectDependency(cbProject *base, cbProject *dependsOn)
Adds a project as a dependency of another project.
virtual void FinishLoadingProject(cbProject *project, bool newAddition, FilesGroupsAndMasks *fileGroups)=0
FilesGroupsAndMasks * m_pFileGroups
void NotifyPlugins(CodeBlocksEvent &event)
virtual void BeginLoadingWorkspace()=0
const wxString & GetNotes() const
Get notes on the project.
ProjectFile * AddFile(const wxString &targetName, const wxString &filename, bool compile=true, bool link=true, unsigned short int weight=50)
Add a file to the project.
bool SaveProjectAs(cbProject *project)
Save a project to disk, asking for a filename.
bool SaveProject(cbProject *project)
Save a project to disk.
const wxString & _(const wxString &string)
virtual bool SaveAs(const wxString &filename)
Save the workspace under a different filename.
int GetBuildTargetsCount()
virtual void UpdateActiveProject(cbProject *oldProject, cbProject *newProject, bool refresh)=0
cbProject * m_pProjectToActivate
wxArray< int > wxArrayInt
bool IsClosingWorkspace()
Check if the project manager is closing a workspace.
EVTIMPORT const wxEventType cbEVT_APP_STARTUP_DONE
static bool IsBusy()
For use with plugins.
ProjectBuildTarget * GetBuildTarget(int index)
Access a build target.
cbWorkspace * GetWorkspace()
Get the current workspace filename.
void EndLoadingProject(cbProject *project)
Ends the project loading process.
void WorkspaceChanged()
Sends message to the plugins that the workspace has been changed.
wxString & Append(const char *psz)
void SetProject(cbProject *project, bool refresh=true)
Set the active project.
cbAuiNotebook * GetNotebook() override
virtual void CloseWorkspace()=0
The entry point singleton for working with projects.
void SetProject(cbProject *project)
void CloseWorkspace() override
bool CloseAllProjects(bool dontsave=false)
Close all projects.
cbAuiNotebook * GetNotebook()
bool GetShowNotesOnLoad() const
Get show project notes on load automatically.
bool LoadLayout()
Load the project's layout.
A notebook class This class is derived from wxAuiNotebook, to enhance its abilities.
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
bool CloseWorkspace()
Close the workspace.
bool ProcessEvent(CodeBlocksEvent &event)
bool GetModified() const override
EVTIMPORT const wxEventType cbEVT_WORKSPACE_CHANGED
EVTIMPORT const wxEventType cbEVT_PROJECT_OPEN
void RegisterEventSink(wxEventType eventType, IEventFunctorBase< CodeBlocksEvent > *functor)
virtual void FinishLoadingWorkspace(cbProject *activeProject, const wxString &workspaceTitle)=0
void SwitchToProjectsPage() override
Switches the management's notebook to the Projects tab.
size_t Add(const wxString &str, size_t copies=1)
cbProject * 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...
cbProject * GetParentProject()
virtual bool QueryCloseWorkspace()=0
Asks user to save the workspace, projects and files (Yes/No/cancel).
Represents a Code::Blocks project build target.
bool Normalize(int flags=wxPATH_NORM_ALL, const wxString &cwd=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
bool QueryCloseAllProjects() override
Checks whether all projects are saved.
EVTIMPORT const wxEventType cbEVT_PROJECT_CLOSE
cbProjectManagerUI * m_ui
void SetUI(cbProjectManagerUI *ui)
ProjectFile * AutoGeneratedBy() const
If this is an auto-generated file, which file is generating it?
bool QueryCloseWorkspace() override
Asks user to save the workspace, projects and files (Yes/No/cancel).
bool IsLoadingWorkspace()
Check if the project manager is loading a workspace.
bool SaveAllProjects()
Saves all projects to disk.
void ShowFileInTree(ProjectFile &WXUNUSED(projectFile)) override
EVTIMPORT const wxEventType cbEVT_PROJECT_FILE_REMOVED
bool LoadWorkspace(const wxString &filename=DEFAULT_WORKSPACE)
Load a workspace.
bool m_IsClosingWorkspace
void AddBuildTarget(const wxString &targetName)
Make this file belong to an additional build target.
bool UpdateProjectFiles(cbProject *project)
void ActiveProjectChanged()
virtual void FreezeTree()=0
Stop the tree control from updating.
void MinimizeFreeSpace()
Minmize free horizontal page.
bool Save()
Save the project.
void UpdateActiveProject(cbProject *WXUNUSED(oldProject), cbProject *WXUNUSED(newProject), bool WXUNUSED(refresh)) override
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
virtual int OpenFile(const wxString &filename)=0
Open the file.
int AddFileToProject(const wxString &filename, cbProject *project=nullptr, int target=-1)
Add a file to a project.
virtual wxString GetTitle() const
Get the workspace's title.
cbProject * m_pActiveProject
static wxString Format(const wxString &format,...)
void FinishLoadingProject(cbProject *WXUNUSED(project), bool WXUNUSED(newAddition), FilesGroupsAndMasks *WXUNUSED(fileGroups)) override
bool SaveWorkspace()
Save the open workspace.
void FinishLoadingWorkspace(cbProject *WXUNUSED(activeProject), const wxString &WXUNUSED(workspaceTitle)) override
const ProjectsArray * GetDependenciesForProject(cbProject *base)
Get the array of projects base depends on.
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
bool SaveLayout()
Save the project's layout.
DLLIMPORT wxString realpath(const wxString &path)
static bool s_CanShutdown
void ClearProjectDependencies(cbProject *base)
Removes all dependencies from project base.