diff options
author | Michael Hutchinson <mhutchinson@novell.com> | 2007-06-08 16:42:59 +0400 |
---|---|---|
committer | Michael Hutchinson <mhutchinson@novell.com> | 2007-06-08 16:42:59 +0400 |
commit | 8cc144d3bdf621f2fd2bee6dc33761e9970eab2b (patch) | |
tree | a49859e5281c433b15fb38f7d03313c2e6b1eed5 /Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs | |
parent | b84f1c7432646af33c894c7323f6fe7817efe493 (diff) |
2007-06-08 Michael Hutchinson <m.j.hutchinson@gmail.com>
* AspNetEdit.Integration/EditorProcess.cs,
AspNetEdit.Integration/AspNetEditViewContent.cs: An attempt to
handle errors more gracefully, and some attempts to handle
document 'dirtiness' (not quite working).
svn path=/trunk/monodevelop/; revision=78946
Diffstat (limited to 'Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs')
-rw-r--r-- | Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs b/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs index 4a714a7b6c..7ec2709163 100644 --- a/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs +++ b/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs @@ -58,6 +58,9 @@ namespace AspNetEdit.Integration MonoDevelopProxy proxy; + bool activated = false; + bool suppressSerialisation = false; + internal AspNetEditViewContent (IViewContent viewContent) { this.viewContent = viewContent; @@ -67,9 +70,31 @@ namespace AspNetEdit.Integration designerFrame.Shadow = ShadowType.None; designerFrame.BorderWidth = 0; + viewContent.WorkbenchWindow.Closing += workbenchWindowClosingHandler; + viewContent.DirtyChanged += vcDirtyChanged; + viewContent.BeforeSave += vcBeforeSave; + designerFrame.Show (); } + void workbenchWindowClosingHandler (object sender, WorkbenchWindowEventArgs args) + { + if (activated) + suppressSerialisation = true; + } + + void vcDirtyChanged (object sender, System.EventArgs e) + { + if (activated && !viewContent.IsDirty) + viewContent.IsDirty = true; + } + + void vcBeforeSave (object sender, System.EventArgs e) + { + if (activated) + saveDocumentToTextView (); + } + public override Gtk.Widget Control { get { return designerFrame; } } @@ -78,10 +103,22 @@ namespace AspNetEdit.Integration get { return "Designer"; } } - public override void Dispose() + bool disposed = false; + + public override void Dispose () { + if (disposed) + return; + + disposed = true; + + base.WorkbenchWindow.Closing -= workbenchWindowClosingHandler; + viewContent.DirtyChanged -= vcDirtyChanged; + viewContent.BeforeSave -= vcBeforeSave; + DestroyEditorAndSockets (); designerFrame.Destroy (); + base.Dispose (); } public override void Selected () @@ -120,10 +157,26 @@ namespace AspNetEdit.Integration ITextBuffer textBuf = (ITextBuffer) viewContent.GetContent (typeof(ITextBuffer)); editorProcess.Initialise (proxy, textBuf.Text, viewContent.ContentName); + + activated = true; + + //FIXME: track 'dirtiness' properly + viewContent.IsDirty = true; } public override void Deselected () { + activated = false; + + //don't need to save if window is closing + if (!suppressSerialisation) + saveDocumentToTextView (); + + DestroyEditorAndSockets (); + } + + void saveDocumentToTextView () + { if (!editorProcess.ExceptionOccurred) { IEditableTextBuffer textBuf = (IEditableTextBuffer) viewContent.GetContent (typeof(IEditableTextBuffer)); @@ -133,12 +186,10 @@ namespace AspNetEdit.Integration } catch (Exception e) { IdeApp.Services.MessageService.ShowError (e, "The document could not be retrieved from the designer"); } - + if (doc != null) textBuf.Text = doc; } - - DestroyEditorAndSockets (); } void DestroyEditorAndSockets () |