~ubuntu-branches/ubuntu/karmic/codelite/karmic

« back to all changes in this revision

Viewing changes to Plugin/workspace.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-08-15 17:42:43 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090815174243-nlb9ikgigbiybz12
Tags: 1.0.2893+dfsg-0ubuntu1
* debian/rules:
  + Tidy up get-orig-source rule
* debian/control:
  + Bump Standards-Version
  + Change Maintainer email address to @ubuntu.com
  + Drop cdbs build-dependency
* debian/copyright:
  + Update to DEP-5 format
* debian/patches/00_add-fPIC.patch:
  + Dropped, fix upstream
* Closes LP: #413992

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <wx/tokenzr.h>
32
32
#include "macros.h"
33
33
#include "wx/regex.h"
 
34
#include "globals.h"
34
35
 
35
36
Workspace::Workspace()
36
37
{
39
40
Workspace::~Workspace()
40
41
{
41
42
        if ( m_doc.IsOk() ) {
42
 
                m_doc.Save(m_fileName.GetFullPath());
 
43
                SaveXmlFile();
43
44
        }
44
45
}
45
46
 
59
60
void Workspace::CloseWorkspace()
60
61
{
61
62
        if (m_doc.IsOk()) {
62
 
                m_doc.Save(m_fileName.GetFullPath());
 
63
                SaveXmlFile();
63
64
                m_doc = wxXmlDocument();
64
65
        }
65
66
 
87
88
                return false;
88
89
        }
89
90
 
 
91
        SetWorkspaceLastModifiedTime(GetFileLastModifiedTime());
 
92
 
90
93
        // This function sets the working directory to the workspace directory!
91
94
        ::wxSetWorkingDirectory(m_fileName.GetPath());
92
95
 
138
141
                delete oldMapping;
139
142
        }
140
143
        parent->AddChild(mapping->ToXml());
141
 
        m_doc.Save(m_fileName.GetFullPath());
142
 
        
 
144
        SaveXmlFile();
 
145
 
143
146
    // force regeneration of makefiles for all projects
144
147
        for (std::map<wxString, ProjectPtr>::iterator iter = m_projects.begin(); iter != m_projects.end(); iter++) {
145
148
        iter->second->SetModified(true);
150
153
{
151
154
        // If we have an open workspace, close it
152
155
        if ( m_doc.IsOk() ) {
153
 
                if ( !m_doc.Save(m_fileName.GetFullPath()) ) {
 
156
                if ( !SaveXmlFile() ) {
154
157
                        errMsg = wxT("Failed to save current workspace");
155
158
                        return false;
156
159
                }
176
179
        m_doc.GetRoot()->AddProperty(wxT("Name"), name);
177
180
        m_doc.GetRoot()->AddProperty(wxT("Database"), dbFileName.GetFullPath());
178
181
 
179
 
        m_doc.Save(m_fileName.GetFullPath());
 
182
        SaveXmlFile();
180
183
        //create an empty build matrix
181
184
        SetBuildMatrix(new BuildMatrix(NULL));
182
185
        return true;
263
266
{
264
267
        BuildMatrixPtr matrix = GetBuildMatrix();
265
268
        wxString selConfName = matrix->GetSelectedConfigurationName();
266
 
        
 
269
 
267
270
        std::list<WorkspaceConfigurationPtr> wspList = matrix->GetConfigurations();
268
271
        std::list<WorkspaceConfigurationPtr>::iterator iter = wspList.begin();
269
272
        for (; iter !=  wspList.end(); iter++) {
280
283
                (*iter)->SetConfigMappingList(prjList);
281
284
                matrix->SetConfiguration((*iter));
282
285
        }
283
 
        
 
286
 
284
287
        // and set the configuration name
285
288
        matrix->SetSelectedConfigurationName(selConfName);
286
289
        SetBuildMatrix(matrix);
312
315
                SetActiveProject(name, true);
313
316
        }
314
317
 
315
 
        m_doc.Save(m_fileName.GetFullPath());
 
318
        SaveXmlFile();
316
319
        if (addToBuildMatrix) {
317
320
                AddProjectToBuildMatrix(proj);
318
321
        }
375
378
                node->AddProperty(wxT("Path"), fn.GetFullPath());
376
379
                node->AddProperty(wxT("Active"), m_projects.size() == 1 ? wxT("Yes") : wxT("No"));
377
380
                m_doc.GetRoot()->AddChild(node);
378
 
                if (!m_doc.Save(m_fileName.GetFullPath())) {
 
381
                if (!SaveXmlFile()) {
379
382
                        wxMessageBox(_("Failed to save workspace file to disk. Please check that you have permission to write to disk"),
380
383
                                     wxT("CodeLite"), wxICON_ERROR | wxOK);
381
384
                        return false;
472
475
                        }
473
476
                }
474
477
        }
475
 
        return m_doc.Save( m_fileName.GetFullPath() );
 
478
        return SaveXmlFile();
476
479
}
477
480
 
478
481
wxString Workspace::GetActiveProjectName()
507
510
                }
508
511
                child = child->GetNext();
509
512
        }
510
 
        m_doc.Save( m_fileName.GetFullPath() );
 
513
        SaveXmlFile();
511
514
}
512
515
 
513
516
bool Workspace::CreateVirtualDirectory(const wxString &vdFullPath, wxString &errMsg)
548
551
        return proj->DeleteVirtualDir(fixedPath);
549
552
}
550
553
 
 
554
bool Workspace::SaveXmlFile()
 
555
{
 
556
        bool ok = m_doc.Save(m_fileName.GetFullPath());
 
557
        SetWorkspaceLastModifiedTime(GetFileLastModifiedTime());
 
558
 
 
559
        return ok;
 
560
}
 
561
 
551
562
void Workspace::Save()
552
563
{
553
564
        if ( m_doc.IsOk() ) {
555
566
                for (; iter != m_projects.end(); iter ++) {
556
567
                        iter->second->Save();
557
568
                }
558
 
                m_doc.Save(m_fileName.GetFullPath());
 
569
                SaveXmlFile();
559
570
        }
560
571
}
561
572
 
632
643
        return NULL;
633
644
}
634
645
 
635
 
bool Workspace::ReloadProject(const wxString& file)
636
 
{
637
 
        // first search for the project file
638
 
        ProjectPtr proj(new Project());
639
 
        if (!proj->Load(file)) {
640
 
                wxLogMessage(wxT("Failed to load project file: '") + file + wxT("'"));
641
 
                return false;
642
 
        }
643
 
        m_projects[proj->GetName()] = proj;
644
 
        return true;
645
 
}
646
 
 
647
646
void Workspace::ReloadWorkspace()
648
647
{
649
648
        m_doc = wxXmlDocument();
659
658
                wxLogMessage(wxT("Reload workspace: ")+ err_msg);
660
659
        }
661
660
}
 
661
 
 
662
time_t Workspace::GetFileLastModifiedTime() const
 
663
{
 
664
        return GetFileModificationTime(GetWorkspaceFileName());
 
665
}