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

A workspace class. More...

#include <cbworkspace.h>

Collaboration diagram for cbWorkspace:

Public Member Functions

 cbWorkspace (const wxString &filename=DEFAULT_WORKSPACE)
 Constructor. More...
 
virtual ~cbWorkspace ()
 Destructor. More...
 
virtual bool Save (bool force=false)
 Save the workspace. More...
 
virtual bool SaveAs (const wxString &filename)
 Save the workspace under a different filename. More...
 
virtual wxString GetFilename () const
 Get the workspace file's name. More...
 
virtual wxString GetTitle () const
 Get the workspace's title. More...
 
virtual void SetTitle (const wxString &title)
 Set the workspace's title. More...
 
virtual bool IsOK () const
 Was this workspace loaded successfully? More...
 
virtual bool IsDefault () const
 Is this workspace the Code::Blocks default? More...
 
virtual bool GetModified () const
 Is this workspace modified? More...
 
virtual void SetModified (bool modified)
 Mark the workspace as modified or not. More...
 
void SetPreferredTarget (const wxString &target)
 Set the preferred target for this workspace. More...
 
wxString GetPreferredTarget () const
 Get the preferred target for this workspace. More...
 
void ActiveProjectChanged ()
 
bool SaveLayout ()
 

Private Member Functions

void Load ()
 
bool LoadLayout ()
 

Private Attributes

bool m_IsOK
 
bool m_IsDefault
 
bool m_Modified
 
wxFileName m_Filename
 
wxString m_Title
 
wxString m_PreferredTargetName
 

Detailed Description

A workspace class.

Workspaces are just collections of projects. By loading a workspace, all the projects it contains are loaded.
There is always a workspace open. The default one does not contain any projects.
Currently, no inter-project dependencies are supported but at some point they will be ;)

Note
The way WorkspaceLoader works now, requires that you save and delete the loaded workspace before creating a new one...

Definition at line 26 of file cbworkspace.h.

Constructor & Destructor Documentation

◆ cbWorkspace()

cbWorkspace::cbWorkspace ( const wxString filename = DEFAULT_WORKSPACE)

Constructor.

Parameters
filenameThe file from which to load the workspace. If this parameter is empty, the default workspace is loaded.

Definition at line 26 of file cbworkspace.cpp.

References DEFAULT_WORKSPACE, ConfigManager::GetConfigFolder(), wxString::IsEmpty(), Load(), m_Filename, m_IsDefault, wxString::Matches(), wxDirExists(), and wxMkdir().

◆ ~cbWorkspace()

cbWorkspace::~cbWorkspace ( )
virtual

Destructor.

Definition at line 58 of file cbworkspace.cpp.

Member Function Documentation

◆ ActiveProjectChanged()

void cbWorkspace::ActiveProjectChanged ( )

Definition at line 170 of file cbworkspace.cpp.

References SaveLayout().

Referenced by ProjectManager::SetProject().

◆ GetFilename()

virtual wxString cbWorkspace::GetFilename ( ) const
inlinevirtual

Get the workspace file's name.

Returns
The name of the file this workspace was loaded from.

Definition at line 60 of file cbworkspace.h.

Referenced by MacrosManager::ClearProjectKeys(), CompilerGCC::InitBuildLog(), MainFrame::OnFileSaveAll(), MainFrame::OnFileSaveWorkspace(), MainFrame::OnFileSaveWorkspaceAs(), and ProjectManagerUI::RebuildTree().

◆ GetModified()

virtual bool cbWorkspace::GetModified ( ) const
inlinevirtual

Is this workspace modified?

Returns
True if the workspace is modified, false if not.
Note
A workspace is considered modified when projects are added-to/removed-from it, when the project's order is changed or when the active project is changed.

Definition at line 102 of file cbworkspace.h.

Referenced by MainFrame::OnFileMenuUpdateUI(), MainFrame::OnFileSaveAll(), ProjectManagerUI::QueryCloseWorkspace(), and ProjectManager::ReloadProject().

◆ GetPreferredTarget()

wxString cbWorkspace::GetPreferredTarget ( ) const

Get the preferred target for this workspace.

Definition at line 165 of file cbworkspace.cpp.

References m_PreferredTargetName.

◆ GetTitle()

virtual wxString cbWorkspace::GetTitle ( ) const
inlinevirtual

◆ IsDefault()

virtual bool cbWorkspace::IsDefault ( ) const
inlinevirtual

Is this workspace the Code::Blocks default?

Returns
True if the workspace is the default, false if not.

Definition at line 93 of file cbworkspace.h.

Referenced by MainFrame::OnFileOpenDefWorkspace(), MainFrame::OnFileSaveAll(), and ProjectManagerUI::QueryCloseWorkspace().

◆ IsOK()

virtual bool cbWorkspace::IsOK ( ) const
inlinevirtual

Was this workspace loaded successfully?

Returns
True if the workspace was loaded successfully, false if not.
Note
Because the only way to load a workspace is through its constructor, and because we don't use exceptions, this is the only way to know if loading succeeded.

Definition at line 87 of file cbworkspace.h.

Referenced by ProjectManager::EndLoadingWorkspace(), and ProjectManager::LoadWorkspace().

◆ Load()

void cbWorkspace::Load ( )
private

◆ LoadLayout()

bool cbWorkspace::LoadLayout ( )
private

◆ Save()

bool cbWorkspace::Save ( bool  force = false)
virtual

Save the workspace.

Parameters
forceIf false (the default), the workspace will not be written to disk, if it is not marked as modified.
Returns
True if saving succeeded, false if not.

Definition at line 102 of file cbworkspace.cpp.

References _(), _T, cbMessageBox(), LogManager::DebugLog(), F(), Manager::Get(), wxFileName::GetFullPath(), Manager::GetLogManager(), wxString::IsEmpty(), m_Filename, m_Modified, m_Title, WorkspaceLoader::Save(), SaveAs(), SaveLayout(), SetModified(), wxString::wx_str(), and wxICON_WARNING.

Referenced by SaveAs(), and ProjectManager::SaveWorkspace().

◆ SaveAs()

bool cbWorkspace::SaveAs ( const wxString filename)
virtual

Save the workspace under a different filename.

Parameters
filenameThe name of the file to save.
Returns
True if saving succeeded, false if not.
Note
If the filename parameter is empty, a file dialog to choose the filename to save will be displayed.

Definition at line 123 of file cbworkspace.cpp.

References _(), _T, DEFAULT_WORKSPACE, Manager::Get(), wxFileName::GetExt(), FileFilters::GetFilterString(), wxFileName::GetFullName(), wxFileName::GetPath(), m_Filename, m_IsDefault, wxString::Matches(), PlaceWindow(), Save(), wxFileName::SetExt(), FileFilters::WORKSPACE_EXT, wxEmptyString, wxFD_OVERWRITE_PROMPT, wxFD_SAVE, and wxID_OK.

Referenced by Save(), and ProjectManager::SaveWorkspaceAs().

◆ SaveLayout()

bool cbWorkspace::SaveLayout ( )

◆ SetModified()

void cbWorkspace::SetModified ( bool  modified)
virtual

◆ SetPreferredTarget()

void cbWorkspace::SetPreferredTarget ( const wxString target)

Set the preferred target for this workspace.

Definition at line 159 of file cbworkspace.cpp.

References wxString::IsEmpty(), and m_PreferredTargetName.

Referenced by WorkspaceLoader::LoadLayout(), and CompilerGCC::OnSelectTarget().

◆ SetTitle()

void cbWorkspace::SetTitle ( const wxString title)
virtual

Set the workspace's title.

Parameters
titleThe new title.

Definition at line 147 of file cbworkspace.cpp.

References m_Title, and SetModified().

Referenced by ProjectManager::GetWorkspace(), and ProjectManagerUI::OnRenameWorkspace().

Member Data Documentation

◆ m_Filename

wxFileName cbWorkspace::m_Filename
private

Definition at line 126 of file cbworkspace.h.

Referenced by cbWorkspace(), Load(), LoadLayout(), Save(), SaveAs(), and SaveLayout().

◆ m_IsDefault

bool cbWorkspace::m_IsDefault
private

Definition at line 124 of file cbworkspace.h.

Referenced by cbWorkspace(), Load(), and SaveAs().

◆ m_IsOK

bool cbWorkspace::m_IsOK
private

Definition at line 123 of file cbworkspace.h.

Referenced by Load().

◆ m_Modified

bool cbWorkspace::m_Modified
private

Definition at line 125 of file cbworkspace.h.

Referenced by Save(), and SetModified().

◆ m_PreferredTargetName

wxString cbWorkspace::m_PreferredTargetName
private

Definition at line 128 of file cbworkspace.h.

Referenced by GetPreferredTarget(), and SetPreferredTarget().

◆ m_Title

wxString cbWorkspace::m_Title
private

Definition at line 127 of file cbworkspace.h.

Referenced by Load(), Save(), and SetTitle().


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