Author: mhutch
Date: 2007-06-08 08:42:59 -0400 (Fri, 08 Jun 2007)
New Revision: 78946

Modified:
   
trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs
   trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs
   trunk/monodevelop/Extras/AspNetEdit/ChangeLog
   trunk/monodevelop/Extras/AspNetEdit/Makefile.am
Log:
2007-06-08  Michael Hutchinson <[EMAIL PROTECTED]>

        * 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).



Modified: 
trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs
===================================================================
--- 
trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs
 2007-06-08 12:28:57 UTC (rev 78945)
+++ 
trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs
 2007-06-08 12:42:59 UTC (rev 78946)
@@ -58,6 +58,9 @@
                
                MonoDevelopProxy proxy;
                
+               bool activated = false;
+               bool suppressSerialisation = false;
+               
                internal AspNetEditViewContent (IViewContent viewContent)
                {
                        this.viewContent = viewContent;
@@ -67,9 +70,31 @@
                        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 @@
                        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 @@
                        
                        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 @@
                                } 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 ()

Modified: 
trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs
===================================================================
--- trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs 
2007-06-08 12:28:57 UTC (rev 78945)
+++ trunk/monodevelop/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs 
2007-06-08 12:42:59 UTC (rev 78946)
@@ -73,6 +73,23 @@
                        get { return host; }
                }
                
+               protected override void HandleError (Exception e)
+               {
+                       //remove the grid in case it was the source of the 
exception, as GTK# expose exceptions can fire repeatedly
+                       //also user should not be able to edit things when 
showing exceptions
+                       if (propertyGrid != null) {
+                               Gtk.Container parent = propertyGrid.Parent as 
Gtk.Container;
+                               if (parent != null)
+                                       parent.Remove (propertyGrid);
+                               
+                               propertyGrid.Destroy ();
+                               propertyGrid = null;
+                       }
+                       
+                       //show the error message
+                       base.HandleError (e);
+               }
+               
                void LoadGui (MonoDevelopProxy proxy, string document, string 
fileName)
                {
                        System.Diagnostics.Trace.WriteLine ("Creating 
AspNetEdit EditorHost");

Modified: trunk/monodevelop/Extras/AspNetEdit/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/AspNetEdit/ChangeLog       2007-06-08 12:28:57 UTC 
(rev 78945)
+++ trunk/monodevelop/Extras/AspNetEdit/ChangeLog       2007-06-08 12:42:59 UTC 
(rev 78946)
@@ -1,3 +1,10 @@
+2007-06-08  Michael Hutchinson <[EMAIL PROTECTED]>
+
+       * 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).
+
 2007-05-13  Michael Hutchinson <[EMAIL PROTECTED]> 
 
        * libs/jscall.dll, libs/JSCall.js: Having removed the unmanaged 

Modified: trunk/monodevelop/Extras/AspNetEdit/Makefile.am
===================================================================
--- trunk/monodevelop/Extras/AspNetEdit/Makefile.am     2007-06-08 12:28:57 UTC 
(rev 78945)
+++ trunk/monodevelop/Extras/AspNetEdit/Makefile.am     2007-06-08 12:42:59 UTC 
(rev 78946)
@@ -19,8 +19,8 @@
        -r:$(top_builddir)/build/AddIns/MonoDevelop.Projects.dll \
        -r:$(top_builddir)/build/AddIns/MonoDevelop.SourceEditor.dll \
        -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \
+       -r:$(top_srcdir)/build/AddIns/AspNetEdit/jscall.dll \
        -r:$(top_srcdir)/contrib/Mono.Addins.dll \
-       -r:$(top_srcdir)/build/AddIns/AspNetEdit/jscall.dll \
        -r:System \
        -r:System.Design \
        -r:System.Drawing \

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to