~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/projectsimporter/projectsimporter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
 
 * http://www.gnu.org/licenses/gpl-3.0.html
4
 
 *
5
 
 * $Revision$
6
 
 * $Id$
7
 
 * $HeadURL$
8
 
 */
9
 
 
10
 
#include "sdk.h"
11
 
 
12
 
#ifndef CB_PRECOMP
13
 
    #include <wx/filename.h>
14
 
    #include <wx/intl.h>
15
 
    #include <wx/utils.h>
16
 
    #include <wx/filename.h>
17
 
    #include <wx/fs_zip.h>
18
 
    #include <wx/menu.h>
19
 
    #include <wx/xrc/xmlres.h>
20
 
 
21
 
    #include "globals.h"
22
 
    #include "manager.h"
23
 
    #include "logmanager.h"
24
 
    #include "projectmanager.h"
25
 
    #include "logmanager.h"
26
 
    #include "compilerfactory.h"
27
 
    #include "cbproject.h"
28
 
    #include "cbworkspace.h"
29
 
#endif
30
 
 
31
 
#include "projectsimporter.h"
32
 
#include "devcpploader.h"
33
 
#include "msvc7loader.h"
34
 
#include "msvc7workspaceloader.h"
35
 
#include "msvcloader.h"
36
 
#include "msvcworkspaceloader.h"
37
 
#include "importers_globals.h"
38
 
#include "filefilters.h"
39
 
 
40
 
// this auto-registers the plugin
41
 
namespace
42
 
{
43
 
PluginRegistrant<ProjectsImporter> reg(_T("ProjectsImporter"));
44
 
}
45
 
 
46
 
ProjectsImporter::ProjectsImporter()
47
 
{
48
 
    //ctor
49
 
    if (!Manager::LoadResource(_T("projectsimporter.zip")))
50
 
    {
51
 
        NotifyMissingFile(_T("projectsimporter.zip"));
52
 
    }
53
 
}
54
 
 
55
 
ProjectsImporter::~ProjectsImporter()
56
 
{
57
 
    //dtor
58
 
}
59
 
 
60
 
void ProjectsImporter::OnAttach()
61
 
{
62
 
}
63
 
 
64
 
 
65
 
void ProjectsImporter::OnRelease(bool appShutDown)
66
 
{
67
 
}
68
 
 
69
 
int ProjectsImporter::Configure()
70
 
{
71
 
    return 0;
72
 
}
73
 
 
74
 
cbConfigurationPanel* ProjectsImporter::GetConfigurationPanel(wxWindow* parent)
75
 
{
76
 
    return 0;
77
 
}
78
 
 
79
 
void ProjectsImporter::BuildMenu(wxMenuBar* menuBar)
80
 
{
81
 
    if (!IsAttached() || !menuBar)
82
 
    {
83
 
        return;
84
 
    }
85
 
 
86
 
    m_Menu = Manager::Get()->LoadMenu(_T("project_import_menu"), false);
87
 
 
88
 
    if (!m_Menu)
89
 
    {
90
 
        return;
91
 
    }
92
 
 
93
 
    wxMenu* fileMenu = menuBar->GetMenu(0);
94
 
    if (fileMenu)
95
 
    {
96
 
        // The position is hard-coded. Please adjust it if necessary
97
 
        fileMenu->Insert(7, wxNewId(), _T("&Import project"), m_Menu);
98
 
        fileMenu->InsertSeparator(8);
99
 
    }
100
 
}
101
 
 
102
 
bool ProjectsImporter::CanHandleFile(const wxString& filename) const
103
 
{
104
 
    FileType ft = FileTypeOf(filename);
105
 
    return ft == ftDevCppProject ||
106
 
           ft == ftMSVC6Project ||
107
 
           ft == ftMSVC6Workspace ||
108
 
           ft == ftMSVC7Project ||
109
 
           ft == ftMSVC7Workspace;
110
 
}
111
 
 
112
 
int ProjectsImporter::OpenFile(const wxString& filename)
113
 
{
114
 
    FileType ft = FileTypeOf(filename);
115
 
    switch (ft)
116
 
    {
117
 
        case ftDevCppProject: // fallthrough
118
 
        case ftMSVC6Project:  // fallthrough
119
 
        case ftMSVC7Project:  // fallthrough
120
 
        case ftXcode1Project: // fallthrough
121
 
        case ftXcode2Project: // fallthrough
122
 
            return LoadProject(filename);
123
 
            break;
124
 
 
125
 
        case ftMSVC6Workspace: // fallthrough
126
 
        case ftMSVC7Workspace: // fallthrough
127
 
            return LoadWorkspace(filename);
128
 
            break;
129
 
 
130
 
        default:
131
 
            cbMessageBox(_("Failed to import file: unsupported"), _("Error"), wxICON_ERROR);
132
 
            return -1;
133
 
    }
134
 
    return -1;
135
 
}
136
 
 
137
 
int ProjectsImporter::LoadProject(const wxString& filename)
138
 
{
139
 
    wxFileName the_file(filename);
140
 
    if (!the_file.FileExists())
141
 
        return -1;
142
 
    the_file.SetExt(FileFilters::CODEBLOCKS_EXT);
143
 
 
144
 
    cbProject* prj = Manager::Get()->GetProjectManager()->NewProject(the_file.GetFullPath());
145
 
    if (!prj)
146
 
        return -1;
147
 
 
148
 
    // Make a check whether the project exists in current workspace
149
 
    if (Manager::Get()->GetProjectManager()->BeginLoadingProject())
150
 
    {
151
 
        wxBusyCursor wait;
152
 
 
 
1
/*
 
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 
3
 * http://www.gnu.org/licenses/gpl-3.0.html
 
4
 *
 
5
 * $Revision$
 
6
 * $Id$
 
7
 * $HeadURL$
 
8
 */
 
9
 
 
10
#include "sdk.h"
 
11
 
 
12
#ifndef CB_PRECOMP
 
13
    #include <wx/filename.h>
 
14
    #include <wx/intl.h>
 
15
    #include <wx/utils.h>
 
16
    #include <wx/filename.h>
 
17
    #include <wx/fs_zip.h>
 
18
    #include <wx/menu.h>
 
19
    #include <wx/xrc/xmlres.h>
 
20
 
 
21
    #include "globals.h"
 
22
    #include "manager.h"
 
23
    #include "logmanager.h"
 
24
    #include "projectmanager.h"
 
25
    #include "logmanager.h"
 
26
    #include "compilerfactory.h"
 
27
    #include "cbproject.h"
 
28
    #include "cbworkspace.h"
 
29
#endif
 
30
 
 
31
#include "projectsimporter.h"
 
32
#include "devcpploader.h"
 
33
#include "msvc7loader.h"
 
34
#include "msvc7workspaceloader.h"
 
35
#include "msvcloader.h"
 
36
#include "msvcworkspaceloader.h"
 
37
#include "importers_globals.h"
 
38
#include "filefilters.h"
 
39
 
 
40
// this auto-registers the plugin
 
41
namespace
 
42
{
 
43
PluginRegistrant<ProjectsImporter> reg(_T("ProjectsImporter"));
 
44
}
 
45
 
 
46
ProjectsImporter::ProjectsImporter()
 
47
{
 
48
    //ctor
 
49
    if (!Manager::LoadResource(_T("projectsimporter.zip")))
 
50
    {
 
51
        NotifyMissingFile(_T("projectsimporter.zip"));
 
52
    }
 
53
}
 
54
 
 
55
ProjectsImporter::~ProjectsImporter()
 
56
{
 
57
    //dtor
 
58
}
 
59
 
 
60
void ProjectsImporter::OnAttach()
 
61
{
 
62
}
 
63
 
 
64
 
 
65
void ProjectsImporter::OnRelease(bool appShutDown)
 
66
{
 
67
}
 
68
 
 
69
int ProjectsImporter::Configure()
 
70
{
 
71
    return 0;
 
72
}
 
73
 
 
74
cbConfigurationPanel* ProjectsImporter::GetConfigurationPanel(wxWindow* parent)
 
75
{
 
76
    return 0;
 
77
}
 
78
 
 
79
void ProjectsImporter::BuildMenu(wxMenuBar* menuBar)
 
80
{
 
81
    if (!IsAttached() || !menuBar)
 
82
    {
 
83
        return;
 
84
    }
 
85
 
 
86
    m_Menu = Manager::Get()->LoadMenu(_T("project_import_menu"), false);
 
87
 
 
88
    if (!m_Menu)
 
89
    {
 
90
        return;
 
91
    }
 
92
 
 
93
    wxMenu* fileMenu = menuBar->GetMenu(0);
 
94
    if (fileMenu)
 
95
    {
 
96
        int menuId = 0, id = 0;
 
97
        wxMenuItemList menuItems = fileMenu->GetMenuItems();
 
98
        menuId = fileMenu->FindItem(_T("R&ecent files"));
 
99
        wxMenuItem* recentFileItem = fileMenu->FindItem(menuId);
 
100
        id = menuItems.IndexOf(recentFileItem);
 
101
        if (id == wxNOT_FOUND)
 
102
        {
 
103
            id = 7;
 
104
        }
 
105
        else
 
106
        {
 
107
            ++id;
 
108
        }
 
109
        // The position is hard-coded to "Recent Files" menu. Please adjust it if necessary
 
110
        fileMenu->Insert(++id, wxNewId(), _("&Import project"), m_Menu);
 
111
        fileMenu->InsertSeparator(++id);
 
112
    }
 
113
}
 
114
 
 
115
bool ProjectsImporter::CanHandleFile(const wxString& filename) const
 
116
{
 
117
    const FileType ft = FileTypeOf(filename);
 
118
    return ft == ftDevCppProject ||
 
119
           ft == ftMSVC6Project ||
 
120
           ft == ftMSVC6Workspace ||
 
121
           ft == ftMSVC7Project ||
 
122
           ft == ftMSVC7Workspace;
 
123
}
 
124
 
 
125
int ProjectsImporter::OpenFile(const wxString& filename)
 
126
{
 
127
    const FileType ft = FileTypeOf(filename);
 
128
    switch (ft)
 
129
    {
 
130
        case ftDevCppProject: // fallthrough
 
131
        case ftMSVC6Project:  // fallthrough
 
132
        case ftMSVC7Project:  // fallthrough
 
133
        case ftXcode1Project: // fallthrough
 
134
        case ftXcode2Project: // fallthrough
 
135
            return LoadProject(filename);
 
136
            break;
 
137
 
 
138
        case ftMSVC6Workspace: // fallthrough
 
139
        case ftMSVC7Workspace: // fallthrough
 
140
            return LoadWorkspace(filename);
 
141
            break;
 
142
 
 
143
        default:
 
144
            cbMessageBox(_("Failed to import file: unsupported"), _("Error"), wxICON_ERROR);
 
145
            return -1;
 
146
    }
 
147
    return -1;
 
148
}
 
149
 
 
150
int ProjectsImporter::LoadProject(const wxString& filename)
 
151
{
 
152
    wxFileName the_file(filename);
 
153
    if (!the_file.FileExists())
 
154
        return -1;
 
155
    the_file.SetExt(FileFilters::CODEBLOCKS_EXT);
 
156
 
 
157
    cbProject* prj = Manager::Get()->GetProjectManager()->NewProject(the_file.GetFullPath());
 
158
    if (!prj)
 
159
        return -1;
 
160
 
 
161
    // Make a check whether the project exists in current workspace
 
162
    if (Manager::Get()->GetProjectManager()->BeginLoadingProject())
 
163
    {
 
164
        wxBusyCursor wait;
 
165
 
 
166
        #if wxCHECK_VERSION(2, 9, 0)
 
167
        Manager::Get()->GetLogManager()->Log(F(_("Importing %s: "), filename.wx_str()));
 
168
        #else
153
169
        Manager::Get()->GetLogManager()->Log(F(_("Importing %s: "), filename.c_str()));
154
 
        IBaseLoader* loader = 0L;
155
 
        FileType ft = FileTypeOf(filename);
156
 
        switch (ft)
157
 
        {
158
 
            case ftDevCppProject:
159
 
                loader = new DevCppLoader(prj); break;
160
 
            case ftMSVC6Project:
161
 
                loader = new MSVCLoader(prj); break;
162
 
            case ftMSVC7Project:
163
 
                loader = new MSVC7Loader(prj); break;
164
 
            case ftXcode1Project: /* placeholder, fallthrough (for now) */
165
 
            case ftXcode2Project: /* placeholder, fallthrough (for now) */
166
 
            default:
167
 
                Manager::Get()->GetProjectManager()->EndLoadingProject(0);
168
 
                cbMessageBox(_("Failed to import file: File type not supported."), _("Error"), wxICON_ERROR);
169
 
                return -1;
170
 
        }
171
 
 
172
 
        wxString compilerID;
173
 
        if (ImportersGlobals::UseDefaultCompiler)
174
 
            compilerID = CompilerFactory::GetDefaultCompilerID();
175
 
        else
176
 
        {
177
 
            // select compiler for the imported project
178
 
            // need to do it before actual import, because the importer might need
179
 
            // project's compiler information (like the object files extension etc).
180
 
            Compiler* compiler = CompilerFactory::SelectCompilerUI(_("Select compiler for ") + wxFileName(filename).GetFullName());
181
 
            if (!compiler) // User hit Cancel.
182
 
            {
183
 
                if (loader) delete loader;
184
 
                Manager::Get()->GetProjectManager()->EndLoadingProject(0);
185
 
                Manager::Get()->GetProjectManager()->CloseProject(prj, true, false);
186
 
                Manager::Get()->GetProjectManager()->RebuildTree();
187
 
                cbMessageBox(_("Import canceled."), _("Information"), wxICON_INFORMATION);
188
 
                return -1;
189
 
            }
190
 
 
191
 
            compilerID = compiler->GetID();
192
 
            if (compilerID.IsEmpty())
193
 
                compilerID = CompilerFactory::GetDefaultCompilerID();
194
 
        }
195
 
 
196
 
        prj->SetCompilerID(compilerID);
197
 
 
198
 
        // actually import project file
199
 
        if (loader->Open(filename))
200
 
        {
201
 
            prj->CalculateCommonTopLevelPath();
202
 
            prj->Save(); // Save it now to avoid project file opening error
203
 
//            prj->SetModified(true);
204
 
 
205
 
            Manager::Get()->GetProjectManager()->EndLoadingProject(prj);
206
 
            if (!Manager::Get()->GetProjectManager()->IsLoadingWorkspace())
207
 
                Manager::Get()->GetProjectManager()->SetProject(prj);
208
 
        }
209
 
        else
210
 
        {
211
 
            if (loader) delete loader;
212
 
            Manager::Get()->GetProjectManager()->EndLoadingProject(0);
213
 
            Manager::Get()->GetProjectManager()->CloseProject(prj, true, false);
214
 
            Manager::Get()->GetProjectManager()->RebuildTree();
215
 
            cbMessageBox(_("Failed to import file: Wrong file format."), _("Error"), wxICON_ERROR);
216
 
            return -1;
217
 
        }
218
 
 
219
 
        if (loader) delete loader;
220
 
        Manager::Get()->GetProjectManager()->EndLoadingProject(prj);
221
 
        return prj ? 0 : -1;
222
 
    }
223
 
 
224
 
    cbMessageBox(_("Failed to import file (internal error)."), _("Error"), wxICON_ERROR);
225
 
    Manager::Get()->GetProjectManager()->EndLoadingProject(0);
226
 
    Manager::Get()->GetProjectManager()->CloseProject(prj, true, false);
227
 
    Manager::Get()->GetProjectManager()->RebuildTree();
228
 
    return -1;
229
 
}
230
 
 
231
 
int ProjectsImporter::LoadWorkspace(const wxString& filename)
232
 
{
233
 
    wxFileName the_file(filename);
234
 
    if (!the_file.FileExists())
235
 
        return -1;
236
 
 
237
 
    wxBusyCursor wait;
238
 
 
239
 
    if (!Manager::Get()->GetProjectManager()->BeginLoadingWorkspace())
240
 
        return -1;
241
 
 
242
 
    cbWorkspace* wksp = Manager::Get()->GetProjectManager()->GetWorkspace();
243
 
    if (!wksp)
244
 
    {
245
 
        Manager::Get()->GetProjectManager()->EndLoadingWorkspace();
246
 
        return -1;
247
 
    }
248
 
 
 
170
        #endif
 
171
        IBaseLoader* loader = 0L;
 
172
        FileType ft = FileTypeOf(filename);
 
173
        switch (ft)
 
174
        {
 
175
            case ftDevCppProject:
 
176
                loader = new DevCppLoader(prj); break;
 
177
            case ftMSVC6Project:
 
178
                loader = new MSVCLoader(prj); break;
 
179
            case ftMSVC7Project:
 
180
                loader = new MSVC7Loader(prj); break;
 
181
            case ftXcode1Project: /* placeholder, fallthrough (for now) */
 
182
            case ftXcode2Project: /* placeholder, fallthrough (for now) */
 
183
            default:
 
184
                Manager::Get()->GetProjectManager()->EndLoadingProject(0);
 
185
                cbMessageBox(_("Failed to import file: File type not supported."), _("Error"), wxICON_ERROR);
 
186
                return -1;
 
187
        }
 
188
 
 
189
        wxString compilerID;
 
190
        if (ImportersGlobals::UseDefaultCompiler)
 
191
            compilerID = CompilerFactory::GetDefaultCompilerID();
 
192
        else
 
193
        {
 
194
            // select compiler for the imported project
 
195
            // need to do it before actual import, because the importer might need
 
196
            // project's compiler information (like the object files extension etc).
 
197
            Compiler* compiler = CompilerFactory::SelectCompilerUI(_("Select compiler for ") + wxFileName(filename).GetFullName());
 
198
            if (!compiler) // User hit Cancel.
 
199
            {
 
200
                if (loader) delete loader;
 
201
                Manager::Get()->GetProjectManager()->EndLoadingProject(0);
 
202
                Manager::Get()->GetProjectManager()->CloseProject(prj, true, false);
 
203
                Manager::Get()->GetProjectManager()->RebuildTree();
 
204
                cbMessageBox(_("Import canceled."), _("Information"), wxICON_INFORMATION);
 
205
                return -1;
 
206
            }
 
207
 
 
208
            compilerID = compiler->GetID();
 
209
            if (compilerID.IsEmpty())
 
210
                compilerID = CompilerFactory::GetDefaultCompilerID();
 
211
        }
 
212
 
 
213
        prj->SetCompilerID(compilerID);
 
214
 
 
215
        // actually import project file
 
216
        if (loader->Open(filename))
 
217
        {
 
218
            prj->CalculateCommonTopLevelPath();
 
219
            prj->Save(); // Save it now to avoid project file opening error
 
220
//            prj->SetModified(true);
 
221
 
 
222
            Manager::Get()->GetProjectManager()->EndLoadingProject(prj);
 
223
            if (!Manager::Get()->GetProjectManager()->IsLoadingWorkspace())
 
224
                Manager::Get()->GetProjectManager()->SetProject(prj);
 
225
        }
 
226
        else
 
227
        {
 
228
            if (loader) delete loader;
 
229
            Manager::Get()->GetProjectManager()->EndLoadingProject(0);
 
230
            Manager::Get()->GetProjectManager()->CloseProject(prj, true, false);
 
231
            Manager::Get()->GetProjectManager()->RebuildTree();
 
232
            cbMessageBox(_("Failed to import file: Wrong file format."), _("Error"), wxICON_ERROR);
 
233
            return -1;
 
234
        }
 
235
 
 
236
        if (loader) delete loader;
 
237
        Manager::Get()->GetProjectManager()->EndLoadingProject(prj);
 
238
        return prj ? 0 : -1;
 
239
    }
 
240
 
 
241
    cbMessageBox(_("Failed to import file (internal error)."), _("Error"), wxICON_ERROR);
 
242
    Manager::Get()->GetProjectManager()->EndLoadingProject(0);
 
243
    Manager::Get()->GetProjectManager()->CloseProject(prj, true, false);
 
244
    Manager::Get()->GetProjectManager()->RebuildTree();
 
245
    return -1;
 
246
}
 
247
 
 
248
int ProjectsImporter::LoadWorkspace(const wxString& filename)
 
249
{
 
250
    wxFileName the_file(filename);
 
251
    if (!the_file.FileExists())
 
252
        return -1;
 
253
 
 
254
    wxBusyCursor wait;
 
255
 
 
256
    if (!Manager::Get()->GetProjectManager()->BeginLoadingWorkspace())
 
257
        return -1;
 
258
 
 
259
    cbWorkspace* wksp = Manager::Get()->GetProjectManager()->GetWorkspace();
 
260
    if (!wksp)
 
261
    {
 
262
        Manager::Get()->GetProjectManager()->EndLoadingWorkspace();
 
263
        return -1;
 
264
    }
 
265
 
 
266
    #if wxCHECK_VERSION(2, 9, 0)
 
267
    Manager::Get()->GetLogManager()->Log(F(_("Importing %s: "), filename.wx_str()));
 
268
    #else
249
269
    Manager::Get()->GetLogManager()->Log(F(_("Importing %s: "), filename.c_str()));
250
 
    FileType ft = FileTypeOf(filename);
251
 
    IBaseWorkspaceLoader* pWsp = 0;
252
 
    switch (ft)
253
 
    {
254
 
        case ftMSVC6Workspace:
255
 
            pWsp = new MSVCWorkspaceLoader; break;
256
 
        case ftMSVC7Workspace:
257
 
            pWsp = new MSVC7WorkspaceLoader; break;
258
 
        default:
259
 
            break;
260
 
    }
261
 
 
262
 
    if (!pWsp)
263
 
    {
264
 
        cbMessageBox(_("Failed to import file: unsupported"), _("Error"), wxICON_ERROR);
265
 
        Manager::Get()->GetProjectManager()->EndLoadingWorkspace();
266
 
        return -1;
267
 
    }
268
 
 
269
 
    wxString Title;
270
 
    if (pWsp->Open(filename, Title))
271
 
    {
272
 
        if (!Title.IsEmpty())
273
 
        {
274
 
            wksp->SetTitle(Title);
275
 
        }
276
 
    }
277
 
    wksp->SetModified(true);
278
 
    delete pWsp;
279
 
 
280
 
    Manager::Get()->GetProjectManager()->EndLoadingWorkspace();
281
 
    return 0;
282
 
}
 
270
    #endif
 
271
    FileType ft = FileTypeOf(filename);
 
272
    IBaseWorkspaceLoader* pWsp = 0;
 
273
    switch (ft)
 
274
    {
 
275
        case ftMSVC6Workspace:
 
276
            pWsp = new MSVCWorkspaceLoader; break;
 
277
        case ftMSVC7Workspace:
 
278
            pWsp = new MSVC7WorkspaceLoader; break;
 
279
        default:
 
280
            break;
 
281
    }
 
282
 
 
283
    if (!pWsp)
 
284
    {
 
285
        cbMessageBox(_("Failed to import file: unsupported"), _("Error"), wxICON_ERROR);
 
286
        Manager::Get()->GetProjectManager()->EndLoadingWorkspace();
 
287
        return -1;
 
288
    }
 
289
 
 
290
    wxString Title;
 
291
    if (pWsp->Open(filename, Title))
 
292
    {
 
293
        if (!Title.IsEmpty())
 
294
        {
 
295
            wksp->SetTitle(Title);
 
296
        }
 
297
        wksp->SetModified(true);
 
298
    }
 
299
    else
 
300
        cbMessageBox(_("Failed to import *any* projects from workspace file."), _("Error"), wxICON_ERROR);
 
301
 
 
302
    delete pWsp;
 
303
    Manager::Get()->GetProjectManager()->EndLoadingWorkspace();
 
304
 
 
305
    return 0;
 
306
}