/**
* Loads the projects saved in the Projects File.
*/
public static void loadProjects()
{
ProjectsHandler projectsHandler = Activator.getDefault().getProjectsHandler();
File projectsFile = getProjectsFile();
boolean loadFailed = false;
Project[] projects = null;
// We try to load the projects file
if ( projectsFile.exists() )
{
try
{
projects = ProjectsImporter.getProjects( new FileInputStream( projectsFile ), projectsFile
.getAbsolutePath() );
}
catch ( ProjectsImportException e )
{
loadFailed = true;
}
catch ( FileNotFoundException e )
{
loadFailed = true;
}
if ( !loadFailed )
{
// If everything went fine, we add the projects
for ( Project project : projects )
{
projectsHandler.addProject( project );
}
}
else
{
// If something went wrong, we try to load the temp projects file
File tempProjectsFile = getTempProjectsFile();
if ( tempProjectsFile.exists() )
{
try
{
projects = ProjectsImporter.getProjects( new FileInputStream( tempProjectsFile ), projectsFile
.getAbsolutePath() );
loadFailed = false;
}
catch ( ProjectsImportException e )
{
reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), e, Messages
.getString( "PluginUtils.ProjectsLoadingError" ), Messages
.getString( "PluginUtils.ErrorLoadingProject" ) );
return;
}
catch ( FileNotFoundException e )
{
reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), e, Messages
.getString( "PluginUtils.ProjectsLoadingError" ), Messages
.getString( "PluginUtils.ErrorLoadingProject" ) );
return;
}
// We add the projects
for ( Project project : projects )
{
projectsHandler.addProject( project );
}
}
else
{
reportError( Messages.getString( "PluginUtils.ErrorLoadingProject" ), null, Messages