Browse Source

Add ToolNotFoundProjectLoadException.

pull/403/head
Daniel Grunwald 12 years ago
parent
commit
086fc78876
  1. 4
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  2. 52
      src/Main/Base/Project/Project/ErrorProject.cs
  3. 67
      src/Main/Base/Project/Project/ProjectLoadException.cs
  4. 6
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  5. 4
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/NodeBuilder/DefaultDotNetNodeBuilder.cs
  6. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs
  7. 7
      src/Main/SharpDevelop/Project/ProjectService.cs
  8. 2
      src/Main/SharpDevelop/Project/SolutionLoader.cs

4
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -199,6 +199,7 @@ @@ -199,6 +199,7 @@
<Compile Include="Project\Configuration\IConfigurable.cs" />
<Compile Include="Project\Configuration\ConfigurationMapping.cs" />
<Compile Include="Project\Configuration\IConfigurationOrPlatformNameCollection.cs" />
<Compile Include="Project\ErrorProject.cs" />
<Compile Include="Project\IProjectBinding.cs" />
<Compile Include="Project\IProjectService.cs" />
<Compile Include="Project\ISolution.cs" />
@ -207,6 +208,7 @@ @@ -207,6 +208,7 @@
<Compile Include="Project\ProjectBindingDescriptor.cs" />
<Compile Include="Project\ProjectBindingDoozer.cs" />
<Compile Include="Project\ProjectInformation.cs" />
<Compile Include="Project\ProjectLoadException.cs" />
<Compile Include="Project\Project_TypeGuids.cs" />
<Compile Include="Project\SolutionEventArgs.cs" />
<Compile Include="Project\SolutionSection.cs" />
@ -568,7 +570,6 @@ @@ -568,7 +570,6 @@
<Compile Include="Src\Project\ProjectChangeWatcher.cs" />
<Compile Include="Src\Project\ProjectCustomToolOptions.cs" />
<Compile Include="Src\Project\ProjectStartException.cs" />
<Compile Include="Src\Project\ProjectLoadException.cs" />
<Compile Include="Src\Project\ProjectPropertyChangedEventArgs.cs" />
<Compile Include="Src\Project\ProjectUpgradeException.cs" />
<Compile Include="Refactoring\ContextAction.cs" />
@ -740,7 +741,6 @@ @@ -740,7 +741,6 @@
<Compile Include="Src\Gui\XmlForms\Lib\IObjectCreator.cs" />
<Compile Include="Src\Internal\Doozers\PadDescriptor.cs" />
<Compile Include="Src\Project\MissingProject.cs" />
<Compile Include="Src\Project\UnknownProject.cs" />
<Compile Include="Src\Gui\Pads\ErrorList\ErrorListPad.cs" />
<Compile Include="Src\Gui\Pads\ErrorList\ErrorListToolbarCommands.cs" />
<Compile Include="Src\Gui\Pads\CompilerMessageView\CompilerMessageViewToolbarCommands.cs" />

52
src/Main/Base/Project/Src/Project/UnknownProject.cs → src/Main/Base/Project/Project/ErrorProject.cs

@ -21,36 +21,44 @@ using ICSharpCode.Core; @@ -21,36 +21,44 @@ using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Project
{
public class UnknownProject : AbstractProject
public class ErrorProject : AbstractProject
{
string warningText = "${res:ICSharpCode.SharpDevelop.Commands.ProjectBrowser.NoBackendForProjectType}";
bool warningDisplayedToUser;
public string WarningText {
get { return warningText; }
set { warningText = value; }
readonly Exception exception;
/// <summary>
/// The exception associated that prevented loading this project.
/// This should be a <c>ProjectLoadException</c> or <c>IOException</c>.
/// </summary>
public Exception Exception {
get {
return exception;
}
}
//string warningText = "${res:ICSharpCode.SharpDevelop.Commands.ProjectBrowser.NoBackendForProjectType}";
public bool WarningDisplayedToUser {
get { return warningDisplayedToUser; }
set { warningDisplayedToUser = value; }
}
// public void ShowWarningMessageBox()
// {
// warningDisplayedToUser = true;
// MessageService.ShowError("Error loading " + this.FileName + ":\n" + warningText);
// }
public void ShowWarningMessageBox()
{
warningDisplayedToUser = true;
MessageService.ShowError("Error loading " + this.FileName + ":\n" + warningText);
}
public UnknownProject(ProjectLoadInformation information, string warningText)
: this(information)
public ErrorProject(ProjectLoadInformation information, Exception exception)
: base(information)
{
this.warningText = warningText;
if (exception == null)
throw new ArgumentNullException("exception");
this.exception = exception;
}
public UnknownProject(ProjectLoadInformation information)
: base(information)
public override void ProjectLoaded()
{
base.ProjectLoaded();
var error = exception as ProjectLoadException;
if (error != null) {
SD.OutputPad.BuildCategory.Activate();
error.WriteToOutputPad(SD.OutputPad.BuildCategory);
}
}
protected override ProjectBehavior GetOrCreateBehavior()

67
src/Main/Base/Project/Src/Project/ProjectLoadException.cs → src/Main/Base/Project/Project/ProjectLoadException.cs

@ -18,6 +18,8 @@ @@ -18,6 +18,8 @@
using System;
using System.Runtime.Serialization;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop.Project
{
@ -42,5 +44,70 @@ namespace ICSharpCode.SharpDevelop.Project @@ -42,5 +44,70 @@ namespace ICSharpCode.SharpDevelop.Project
protected ProjectLoadException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
public virtual void WriteToOutputPad(IOutputCategory category)
{
category.AppendLine(this.Message);
}
/// <summary>
/// Gets whether the exception supports showing a dialog that has additional information
/// not contained in the error message.
/// </summary>
public virtual bool CanShowDialog {
get {
return false;
}
}
public virtual void ShowDialog()
{
}
}
[Serializable()]
public class ToolNotFoundProjectLoadException : ProjectLoadException
{
/// <summary>
/// The description text
/// </summary>
public string Description { get; set; }
/// <summary>
/// The link target (with leading http://)
/// </summary>
public string LinkTarget { get; set; }
/// <summary>
/// 32x32 icon to display next to the description. May be null.
/// </summary>
public IImage Icon { get; set; }
public ToolNotFoundProjectLoadException() : base()
{
}
public ToolNotFoundProjectLoadException(string message) : base(message)
{
}
public ToolNotFoundProjectLoadException(string message, Exception innerException) : base(message, innerException)
{
}
protected ToolNotFoundProjectLoadException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
public override bool CanShowDialog {
get { return true; }
}
public override void ShowDialog()
{
using (var dlg = new ToolNotFoundDialog(this.Description, this.LinkTarget, this.Icon)) {
dlg.ShowDialog();
}
}
}
}

6
src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs

@ -285,7 +285,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -285,7 +285,11 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
CreateProject();
} catch (ProjectLoadException ex) {
LoggingService.Error("Unable to create new project.", ex);
MessageService.ShowError(ex.Message);
if (ex.CanShowDialog) {
ex.ShowDialog();
} else {
MessageService.ShowError(ex.Message);
}
} catch (IOException ex) {
LoggingService.Error("Unable to create new project.", ex);
MessageService.ShowError(ex.Message);

4
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/NodeBuilder/DefaultDotNetNodeBuilder.cs

@ -41,10 +41,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -41,10 +41,10 @@ namespace ICSharpCode.SharpDevelop.Project
missingNode.SetIcon("Icons.16x16.Warning");
missingNode.Text = ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.ProjectBrowser.ProjectFileNotFound");
missingNode.AddTo(projectNode);
} else if (project is UnknownProject) {
} else if (project is ErrorProject) {
CustomNode unknownNode = new CustomNode();
unknownNode.SetIcon("Icons.16x16.Warning");
unknownNode.Text = StringParser.Parse(((UnknownProject)project).WarningText);
unknownNode.Text = ((ErrorProject)project).Exception.Message;
unknownNode.AddTo(projectNode);
} else if (project is MSBuildFileProject) {
projectNode.OpenedImage = projectNode.ClosedImage = "Icons.16x16.XMLFileIcon";

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (project is MissingProject) {
OpenedImage = ClosedImage = "ProjectBrowser.MissingProject";
this.ContextmenuAddinTreePath = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/MissingProjectNode";
} else if (project is UnknownProject) {
} else if (project is ErrorProject) {
OpenedImage = ClosedImage = "ProjectBrowser.ProjectWarning";
this.ContextmenuAddinTreePath = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/UnknownProjectNode";
} else {

7
src/Main/SharpDevelop/Project/ProjectService.cs

@ -196,6 +196,13 @@ namespace ICSharpCode.SharpDevelop.Project @@ -196,6 +196,13 @@ namespace ICSharpCode.SharpDevelop.Project
project.ProjectLoaded();
SD.FileService.RecentOpen.AddRecentProject(solution.FileName);
Project.Converter.UpgradeViewContent.ShowIfRequired(solution);
foreach (var project in solution.Projects.OfType<ErrorProject>()) {
var error = project.Exception as ProjectLoadException;
if (error != null && error.CanShowDialog) {
error.ShowDialog();
break; // show at most 1 dialog
}
}
}
/*

2
src/Main/SharpDevelop/Project/SolutionLoader.cs

@ -206,7 +206,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -206,7 +206,7 @@ namespace ICSharpCode.SharpDevelop.Project
exception = ex;
}
LoggingService.Warn("Project load error", exception);
return new UnknownProject(projectInfo, exception.Message);
return new ErrorProject(projectInfo, exception);
}
#endregion

Loading…
Cancel
Save