diff options
author | Wade Berrier <wade@mono-cvs.ximian.com> | 2007-03-08 01:14:19 +0300 |
---|---|---|
committer | Wade Berrier <wade@mono-cvs.ximian.com> | 2007-03-08 01:14:19 +0300 |
commit | a158155808d5dd2eb1a902496728dfd2dc2456aa (patch) | |
tree | f808bbdb220cc0202af984e605ee927583311dc9 | |
parent | aca6a41a900f040c062c675ecea5af04fe063a0d (diff) |
Merged the following revisions from trunk:
asp.net editor fixes:
73390
73398
73403
73405
Other fixes:
73393
73394
73395
svn path=/branches/monodevelop/0.13/; revision=73916
25 files changed, 318 insertions, 148 deletions
diff --git a/Core/src/MonoDevelop.Core.Gui/ChangeLog b/Core/src/MonoDevelop.Core.Gui/ChangeLog index df4be81cca..41aae7e1ca 100644 --- a/Core/src/MonoDevelop.Core.Gui/ChangeLog +++ b/Core/src/MonoDevelop.Core.Gui/ChangeLog @@ -1,3 +1,7 @@ +2007-02-24 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Core.Gui.addin.xml: Fix compatible version number. + 2007-02-16 Lluis Sanchez Gual <lluis@novell.com> * MonoDevelop.Core.Gui.addin.xml: Change add-in versions to 0.13. diff --git a/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.addin.xml b/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.addin.xml index 45299604a3..4fb079a1f3 100644 --- a/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.addin.xml +++ b/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.addin.xml @@ -6,7 +6,7 @@ description = "Provides basic GUI services" category = "MonoDevelop Core" version = "0.13.0" - compatVersion = "0.10.0"> + compatVersion = "0.13.0"> <Runtime> <Import assembly="MonoDevelop.Components.dll"/> diff --git a/Core/src/MonoDevelop.Documentation/ChangeLog b/Core/src/MonoDevelop.Documentation/ChangeLog index 3586d11a22..4a259e241d 100644 --- a/Core/src/MonoDevelop.Documentation/ChangeLog +++ b/Core/src/MonoDevelop.Documentation/ChangeLog @@ -1,3 +1,7 @@ +2007-02-24 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Documentation.addin.xml: Fix compatible version number. + 2007-02-16 Lluis Sanchez Gual <lluis@novell.com> * MonoDevelop.Documentation.addin.xml: Change add-in versions to 0.13. diff --git a/Core/src/MonoDevelop.Documentation/MonoDevelop.Documentation.addin.xml b/Core/src/MonoDevelop.Documentation/MonoDevelop.Documentation.addin.xml index d65ea04192..848aaee257 100644 --- a/Core/src/MonoDevelop.Documentation/MonoDevelop.Documentation.addin.xml +++ b/Core/src/MonoDevelop.Documentation/MonoDevelop.Documentation.addin.xml @@ -6,7 +6,7 @@ description = "Integrates the Mono documentation browser (Monodoc) into the MonoDevelop IDE" category = "IDE extensions" version = "0.13.0" - compatVersion = "0.10.0"> + compatVersion = "0.13.0"> <Runtime> <Import assembly="MonoDevelop.Documentation.dll"/> diff --git a/Core/src/MonoDevelop.Ide/ChangeLog b/Core/src/MonoDevelop.Ide/ChangeLog index 648137c9bd..4048fc03b6 100644 --- a/Core/src/MonoDevelop.Ide/ChangeLog +++ b/Core/src/MonoDevelop.Ide/ChangeLog @@ -1,3 +1,7 @@ +2007-02-24 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Ide.addin.xml: Fix compatible version number. + 2007-02-21 Ankit Jain <jankit@novell.com> * MonoDevelop.Ide.Gui/ProjectOperations.cs (AddReferenceToProject): Ensure diff --git a/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml b/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml index 9014f420e7..17c3c2572d 100644 --- a/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml +++ b/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml @@ -6,7 +6,7 @@ description = "The MonoDevelop IDE application." category = "Applications" version = "0.13.0" - compatVersion = "0.10.0"> + compatVersion = "0.13.0"> <Runtime> diff --git a/Core/src/MonoDevelop.Projects/ChangeLog b/Core/src/MonoDevelop.Projects/ChangeLog index c022ac3d79..7ea388aad0 100644 --- a/Core/src/MonoDevelop.Projects/ChangeLog +++ b/Core/src/MonoDevelop.Projects/ChangeLog @@ -1,3 +1,11 @@ +2006-02-25 Michael Hutchinson <m.j.hutchinson@gmail.com> + + * Core/src/MonoDevelop.Projects/MonoDevelop.Projects/Project.cs: + Remove OnPreBuild as it's no longer used or called. I was overriding + it and relying on it being called! + Make GetReferenceDeployFiles public so I don't have to duplicate it + for AspNetAddProject's GetDeployFiles. + 2007-02-21 Lluis Sanchez Gual <lluis@novell.com> * MonoDevelop.Projects/DotNetProjectConfiguration.cs: If the output diff --git a/Core/src/MonoDevelop.Projects/MonoDevelop.Projects/Project.cs b/Core/src/MonoDevelop.Projects/MonoDevelop.Projects/Project.cs index ae1b89c0e3..d68566d78d 100644 --- a/Core/src/MonoDevelop.Projects/MonoDevelop.Projects/Project.cs +++ b/Core/src/MonoDevelop.Projects/MonoDevelop.Projects/Project.cs @@ -228,7 +228,7 @@ namespace MonoDevelop.Projects } } - DeployFileCollection GetReferenceDeployFiles (bool force) + public DeployFileCollection GetReferenceDeployFiles (bool force) { DeployFileCollection deployFiles = new DeployFileCollection (); @@ -462,22 +462,6 @@ namespace MonoDevelop.Projects } } - protected virtual void DoPreBuild (IProgressMonitor monitor) - { - AbstractProjectConfiguration conf = ActiveConfiguration as AbstractProjectConfiguration; - - // create output directory, if not exists - string outputDir = conf.OutputDirectory; - try { - DirectoryInfo directoryInfo = new DirectoryInfo(outputDir); - if (!directoryInfo.Exists) { - directoryInfo.Create(); - } - } catch (Exception e) { - throw new ApplicationException("Can't create project output directory " + outputDir + " original exception:\n" + e.ToString()); - } - } - protected virtual ICompilerResult DoBuild (IProgressMonitor monitor) { return new DefaultCompilerResult (new CompilerResults (null), ""); diff --git a/Extras/AspNetAddIn/ChangeLog b/Extras/AspNetAddIn/ChangeLog index 3258f1682b..e4b4946caa 100644 --- a/Extras/AspNetAddIn/ChangeLog +++ b/Extras/AspNetAddIn/ChangeLog @@ -1,3 +1,11 @@ +2007-02-25 Michael Hutchinson <m.j.hutchinson@gmail.com> + + * Project/AspNetAppProject.cs: + Remove DoPreBuild override as it's a deprecated build extension point. + Now set AspNetAppProjectConfiguration.SourceDirectory via a FileName + override, which is more robust. + Implement GetDeployFiles to handle ASP.NET bin folder. + 2007-02-21 Ankit Jain <jankit@novell.com> * Project/VerifyCodeBehindBuildStep.cs: Warn the user if diff --git a/Extras/AspNetAddIn/Project/AspNetAppProject.cs b/Extras/AspNetAddIn/Project/AspNetAppProject.cs index c089d52160..a84b6132ee 100644 --- a/Extras/AspNetAddIn/Project/AspNetAppProject.cs +++ b/Extras/AspNetAddIn/Project/AspNetAppProject.cs @@ -39,6 +39,7 @@ using MonoDevelop.Core.ProgressMonitoring; using MonoDevelop.Projects; using MonoDevelop.Projects.Parser; using MonoDevelop.Projects.Serialization; +using MonoDevelop.Projects.Deployment; using AspNetAddIn.Parser.Tree; using AspNetAddIn.Parser; @@ -88,30 +89,80 @@ namespace AspNetAddIn public AspNetAppProject () { + commonInit (); } public AspNetAppProject (string languageName) : base (languageName) { + commonInit (); } public AspNetAppProject (string languageName, ProjectCreateInformation info, XmlElement projectOptions) : base (languageName, info, projectOptions) { + commonInit (); } + + private void commonInit () + { + //AspNetAppProjectConfiguration needs SourceDirectory set so it can append "bin" to determine the output path + Configurations.ConfigurationAdded += delegate (object ob, ConfigurationEventArgs args) { + AspNetAppProjectConfiguration conf = (AspNetAppProjectConfiguration) args.Configuration; + conf.SourceDirectory = BaseDirectory; + }; + } + + //AspNetAppProjectConfiguration needs SourceDirectory set so it can append "bin" to determine the output path + public override string FileName { + get { + return base.FileName; + } + set { + base.FileName = value; + foreach (AspNetAppProjectConfiguration conf in Configurations) + conf.SourceDirectory = BaseDirectory; + } + } + public override IConfiguration CreateConfiguration (string name) { AspNetAppProjectConfiguration conf = new AspNetAppProjectConfiguration (); conf.Name = name; conf.CompilationParameters = LanguageBinding.CreateCompilationParameters (null); + conf.SourceDirectory = BaseDirectory; return conf; } #endregion + //custom version of GetDeployFiles which puts libraries in the bin directory + public override DeployFileCollection GetDeployFiles () + { + DeployFileCollection files = new DeployFileCollection (); + + //add files that are marked to 'deploy' + foreach (ProjectFile pf in ProjectFiles) + if (pf.BuildAction == BuildAction.FileCopy) + files.Add (new DeployFile (pf.FilePath, pf.RelativePath)); + + //add referenced libraries + DeployFileCollection dfc = GetReferenceDeployFiles (false); + foreach (DeployFile df in dfc) + df.RelativeTargetPath = Path.Combine ("bin", df.RelativeTargetPath); + files.AddRange (dfc); + + //add the compiled output file + string outputFile = this.GetOutputFileName (); + if ( !string.IsNullOrEmpty (outputFile)) + files.Add (new DeployFile (outputFile, Path.Combine ("bin", Path.GetFileName (outputFile)), TargetDirectory.ProgramFiles)); + + return files; + } + #region build/prebuild/execute protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context) @@ -157,14 +208,6 @@ namespace AspNetAddIn } } - protected override void DoPreBuild (IProgressMonitor monitor) - { - AspNetAppProjectConfiguration conf = (AspNetAppProjectConfiguration) ActiveConfiguration; - conf.SourceDirectory = BaseDirectory; - - base.DoPreBuild (monitor); - } - #endregion #region File utility methods diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs index 3434d8c816..c456a9fa99 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/DesignerHost.cs @@ -74,8 +74,15 @@ namespace AspNetEdit.Editor.ComponentModel {
get { return container; }
}
-
- public IComponent CreateComponent (Type componentClass, string name)
+ + public IComponent CreateComponent (Type componentClass, string name) + { + //add to document, unless loading + bool addToDoc = (this.RootDocument != null); + return CreateComponent (componentClass, name, addToDoc); + } +
+ internal IComponent CreateComponent (Type componentClass, string name, bool addToDoc)
{ System.Diagnostics.Trace.WriteLine("Attempting to create component "+name);
//check arguments
@@ -91,19 +98,18 @@ namespace AspNetEdit.Editor.ComponentModel IComponent component = (IComponent) Activator.CreateInstance (componentClass);
//and add to container
- container.Add (component, name);
-
- //add to document, unless loading - if (RootDocument != null) { + container.Add (component, name); + + if (addToDoc) { ((Control)RootComponent).Controls.Add ((Control) component); RootDocument.AddControl ((Control)component); - } - //select it - ISelectionService sel = this.GetService (typeof (ISelectionService)) as ISelectionService; - if (sel != null) - sel.SetSelectedComponents (new IComponent[] {component});
-
+ //select it + ISelectionService sel = this.GetService (typeof (ISelectionService)) as ISelectionService; + if (sel != null) + sel.SetSelectedComponents (new IComponent[] {component});
+ } +
System.Diagnostics.Trace.WriteLine("Created component "+name);
return component;
}
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs index 34bfa115d1..11cda93139 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/Document.cs @@ -71,8 +71,9 @@ namespace AspNetEdit.Editor.ComponentModel public Document (Control parent, DesignerHost host, string document, string fileName) { initDocument (parent, host); - this.document = DeserializeAndAdd (document); - + + Control[] controls; + aspParser.ProcessFragment (document, out controls, out this.document); GetView (); } @@ -241,20 +242,15 @@ namespace AspNetEdit.Editor.ComponentModel return serializedDoc; } - ///<summary>Converts a ASP.NET fragment to a a designer document fragment, - /// and adds the controls and directives etc to the host.</summary> - public string DeserializeAndAdd (string aspFragment) + public void InitialiseControls (IEnumerable controls) { - string document; - Control[] controls; - - aspParser.ParseDocument (aspFragment, out controls, out document);
- - foreach (Control c in controls) { - OnInitMethodInfo.Invoke (c, new object[] {EventArgs.Empty}); - } - - return document; + foreach (Control c in controls) + InitialiseControl(c); + } + + public static void InitialiseControl (Control control) + { + OnInitMethodInfo.Invoke (control, new object[] {EventArgs.Empty}); } //modes for the Serializing parser @@ -333,9 +329,14 @@ namespace AspNetEdit.Editor.ComponentModel } #region add/remove/update controls + + bool suppressAddControl = false; public void AddControl (Control control)
{ + if (suppressAddControl) return; + + System.Console.WriteLine("AddControl method called"); OnInitMethodInfo.Invoke (control, new object[] {EventArgs.Empty});
view.AddControl (control);
}
@@ -352,7 +353,15 @@ namespace AspNetEdit.Editor.ComponentModel public void InsertFragment (string fragment) { - view.InsertFragment (fragment); + Control[] controls; + string doc; + aspParser.ProcessFragment (fragment, out controls, out doc); + view.InsertFragment (doc); + + //FIXME: when controls are inserted en masse using InsertFragment, the designer surface + //doesn't seem to display then properly till they've been updated + foreach (Control c in controls) + view.UpdateRender (c); }
#endregion
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs index 818dae819d..7a5bdf34aa 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor.ComponentModel/NameCreationService.cs @@ -48,16 +48,12 @@ namespace AspNetEdit.Editor.ComponentModel //check existing components with name of same form
// and make suffixNumber bigger than the greatest of them
foreach (IComponent comp in container.Components) {
- if (comp.Site.Name.StartsWith (dataType.Name)) {
- string str = comp.Site.Name.Remove (0, dataType.Name.Length);
- //TODO: Use int.TryParse in .NET 2.0 - try { - int val = int.Parse (str);
- if (val >= suffixNumber)
- suffixNumber = val + 1; - } - catch (Exception ex) {}
- }
+ if (comp.Site.Name.ToLowerInvariant().StartsWith (dataType.Name.ToLowerInvariant())) {
+ string str = comp.Site.Name.Substring(dataType.Name.Length); + int val;
+ if (int.TryParse(str, out val) && val >= suffixNumber)
+ suffixNumber = val + 1; + }
}
return dataType.Name + suffixNumber.ToString ();
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/DesignTimeParser.cs b/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/DesignTimeParser.cs index 6cef890733..8aa48b0bbd 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/DesignTimeParser.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/DesignTimeParser.cs @@ -66,7 +66,7 @@ namespace AspNetEdit.Editor.Persistence /// </summary>
/// <param name="fragment">The document fragment to parse</param>
/// <returns>The document with all controls, directives and script blocks replaced by placeholders</returns>
- public void ParseDocument (string fragment, out Control[] controls, out string designDocument)
+ public void ProcessFragment (string fragment, out Control[] controls, out string substText)
{
AspParser parser = InitialiseParser (fragment); @@ -74,16 +74,13 @@ namespace AspNetEdit.Editor.Persistence rootParsingObject = new RootParsingObject(host);
openObject = rootParsingObject; - parser.Parse ();
+ parser.Parse (); if (openObject != rootParsingObject) {
throw new Exception ("The tag " + openObject.TagID + " was left unclosed");
- }
-
- object[] objects;
- rootParsingObject.BuildObject(out objects, out designDocument);
- controls = new Control[objects.Length];
- objects.CopyTo (controls, 0);
+ } +
+ rootParsingObject.GetParsedContent (out controls, out substText);
}
private AspParser InitialiseParser (string parseText)
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/RootParsingObject.cs b/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/RootParsingObject.cs index b2d31d8be8..e726d3a75b 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/RootParsingObject.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/RootParsingObject.cs @@ -30,7 +30,8 @@ using System;
using System.Text;
-using System.Web.UI.Design;
+using System.Web.UI.Design; +using System.Web.UI;
using System.Collections;
using System.ComponentModel.Design;
@@ -53,7 +54,7 @@ namespace AspNetEdit.Editor.Persistence }
public override void AddText (string text)
- {
+ { stringBuilder.Append (text);
}
@@ -62,9 +63,9 @@ namespace AspNetEdit.Editor.Persistence controls.Add (control);
}
- public void BuildObject (out object[] controls, out string documentText)
+ public void GetParsedContent (out Control[] controls, out string documentText)
{
- controls = this.controls.ToArray ();
+ controls = (Control[]) this.controls.ToArray (typeof(System.Web.UI.Control));
documentText = stringBuilder.ToString ();
} diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/ServerControlParsingObject.cs b/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/ServerControlParsingObject.cs index 9694f5510c..9ec55d545a 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/ServerControlParsingObject.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor.Persistence/ServerControlParsingObject.cs @@ -59,10 +59,10 @@ namespace AspNetEdit.Editor.Persistence //note: this automatically adds to parent's container, as some controls //need to be sited e.g. if they use site dictionaries //TODO: should this action be passed up the tree so controls can intercept? - obj = base.DesignerHost.CreateComponent (type, attributes["ID"] as string); + obj = ((AspNetEdit.Editor.ComponentModel.DesignerHost) base.DesignerHost).CreateComponent (type, attributes["ID"] as string, false); else obj = Activator.CreateInstance (type);
-
+
//and populate it from the attributes
pdc = TypeDescriptor.GetProperties (obj);
foreach (DictionaryEntry de in attributes) {
@@ -87,19 +87,19 @@ namespace AspNetEdit.Editor.Persistence else
throw new Exception ("Could not find event " + str[0].Remove(0,2));
}
-
+
object loopObj = obj;
for (int i = 0; i < str.Length; i++ )
{
if (pd == null)
throw new Exception ("Could not find property " + (string)de.Key);
- Console.WriteLine (pd.Converter.ToString() + " " + pd.Name);
+
if (i == str.Length - 1) {
pd.SetValue (obj, pd.Converter.ConvertFromString ((string) de.Value));
break;
}
-
+
loopObj = pd.GetValue (loopObj);
pd = TypeDescriptor.GetProperties (loopObj).Find (str[0], true);
@@ -155,7 +155,8 @@ namespace AspNetEdit.Editor.Persistence break; } } - }
+ } +
}
public override void AddText (string text)
@@ -193,13 +194,16 @@ namespace AspNetEdit.Editor.Persistence public override ParsingObject CloseObject (string closingTagText)
{
//we do this here in case we have tags inside
- if (mode == ParseChildrenMode.DefaultProperty) {
+ if (mode == ParseChildrenMode.DefaultProperty && !string.IsNullOrEmpty(innerText)) {
PropertyDescriptor pd = pdc[parseAtt.DefaultProperty];
pd.SetValue(obj, pd.Converter.ConvertFromString(innerText));
}
//FIME: what if it isn't?
- if (obj is Control)
- base.AddText ( Document.RenderDesignerControl ((Control)obj));
+ if (obj is Control) { + Control c = (Control) obj; + Document.InitialiseControl (c);
+ base.AddText (Document.RenderDesignerControl (c)); // add initial rendered text representation + }
base.AddControl (obj);
return base.CloseObject (closingTagText);
}
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor.UI/RootDesignerView.cs b/Extras/AspNetEdit/AspNetEdit.Editor.UI/RootDesignerView.cs index 33b681d2a3..18e8ccef1d 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor.UI/RootDesignerView.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor.UI/RootDesignerView.cs @@ -147,13 +147,16 @@ namespace AspNetEdit.Editor.UI void changeService_ComponentChanged (object sender, ComponentChangedEventArgs e)
{
if (!active) return;
-
- Control control = e.Component as Control;
+ UpdateRender (e.Component as Control);
+ } + + public void UpdateRender (Control control) + { if (control == null)
- throw new InvalidOperationException ("The changed component is not a System.UI.WebControl");
+ throw new InvalidOperationException ("The updated component is not a System.UI.WebControl");
string ctext = Document.RenderDesignerControl (control);
- comm.JSCall (GeckoFunctions.UpdateControl, null, control.UniqueID, ctext);
+ comm.JSCall (GeckoFunctions.UpdateControl, null, control.UniqueID, ctext); }
#endregion
@@ -406,18 +409,18 @@ namespace AspNetEdit.Editor.UI ///<summary>
/// Name: DeserializeAndAdd
- /// Deserialises a fragment of ASP.NET code into a Gecko designer document fragment
- /// and adds the controls, directives etc to the host.
+ /// Handles any ASP.NET code that gets pasted into the designer.
/// Arguments:
/// string designerDocumentFragment: the ASP.NET document fragment
- /// Returns: the deserialised document
+ /// Returns: none
///</summary>
private string JSDeserializeAndAdd (string[] args)
{
if (args.Length != 1)
throw new InvalidJSArgumentException ("DeserializeAndAdd", -1);
- return host.RootDocument.DeserializeAndAdd (args [0]);
+ host.RootDocument.InsertFragment (args [0]); + return string.Empty;
}
#endregion
diff --git a/Extras/AspNetEdit/AspNetEdit.Editor/EditorHost.cs b/Extras/AspNetEdit/AspNetEdit.Editor/EditorHost.cs index 6b36ff8b06..05c1f681a8 100644 --- a/Extras/AspNetEdit/AspNetEdit.Editor/EditorHost.cs +++ b/Extras/AspNetEdit/AspNetEdit.Editor/EditorHost.cs @@ -115,13 +115,48 @@ namespace AspNetEdit.Editor public void UseToolboxNode (ItemToolboxNode node) { + //invoke in GUI thread as it catches and displays exceptions nicely + Gtk.Application.Invoke ( delegate { handleToolboxNode (node); }); + } + + private void handleToolboxNode (ItemToolboxNode node) + { ToolboxItemToolboxNode tiNode = node as ToolboxItemToolboxNode; - + if (tiNode != null) { - //load the type into this process + //load the type into this process and get the ToolboxItem tiNode.Type.Load (); - System.Drawing.Design.ToolboxItem ti = tiNode.GetToolboxItem (); + + //web controls have sample HTML that need to be deserialised, in a ToolboxDataAttribute + //TODO: Fix WebControlToolboxItem and (mono classlib's use of it) so we don't have to mess around with type lookups and attributes here + if (ti.AssemblyName != null && ti.TypeName != null) { + //look up and register the type + ITypeResolutionService typeRes = (ITypeResolutionService) host.GetService(typeof(ITypeResolutionService)); + typeRes.ReferenceAssembly (ti.AssemblyName); + Type controlType = typeRes.GetType (ti.TypeName, true); + + //read the WebControlToolboxItem data from the attribute + AttributeCollection atts = TypeDescriptor.GetAttributes (controlType); + + System.Web.UI.ToolboxDataAttribute tda = (System.Web.UI.ToolboxDataAttribute) atts[typeof(System.Web.UI.ToolboxDataAttribute)]; + + //if it's present + if (tda != null && tda.Data.Length > 0) { + //look up the tag's prefix and insert it into the data + System.Web.UI.Design.IWebFormReferenceManager webRef = host.GetService (typeof (System.Web.UI.Design.IWebFormReferenceManager)) as System.Web.UI.Design.IWebFormReferenceManager; + if (webRef == null) + throw new Exception("Host does not provide an IWebFormReferenceManager"); + string aspText = String.Format (tda.Data, webRef.GetTagPrefix (controlType)); + System.Diagnostics.Trace.WriteLine ("Toolbox processing ASP.NET item data: " + aspText); + + //and add it to the document + host.RootDocument.InsertFragment (aspText);
+ return; + } + } + + //No ToolboxDataAttribute? Get the ToolboxItem to create the components itself ti.CreateComponents (host); } } @@ -129,10 +164,13 @@ namespace AspNetEdit.Editor public void LoadDocument (string document, string fileName) { System.Diagnostics.Trace.WriteLine ("Copying document to editor."); - host.Reset (); - host.Load (document, fileName); - host.Activate (); + //invoke in GUI thread as it catches and displays exceptions nicely + Gtk.Application.Invoke ( delegate { + host.Reset (); + host.Load (document, fileName); + host.Activate (); + }); } public string GetDocument () @@ -140,7 +178,7 @@ namespace AspNetEdit.Editor MonoDevelop.Core.Gui.Services.DispatchService.AssertGuiThread (); string doc = ""; - System.Diagnostics.Trace.WriteLine ("persisting document"); + System.Diagnostics.Trace.WriteLine ("Persisting document."); doc = host.PersistDocument (); return doc; @@ -151,7 +189,7 @@ namespace AspNetEdit.Editor bool disposed = false; public virtual void Dispose () { - System.Diagnostics.Trace.WriteLine ("disposing editor host"); + System.Diagnostics.Trace.WriteLine ("Disposing editor host."); if (disposed) return; diff --git a/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs b/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs index f77ad2235d..6065e90716 100644 --- a/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs +++ b/Extras/AspNetEdit/AspNetEdit.Integration/AspNetEditViewContent.cs @@ -40,7 +40,6 @@ using MonoDevelop.Core; using MonoDevelop.Core.Execution; using MonoDevelop.DesignerSupport.Toolbox; using MonoDevelop.DesignerSupport; -using MonoDevelop.Ide.Gui.Content; using AspNetEdit.Editor; namespace AspNetEdit.Integration diff --git a/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs b/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs index 24c67df583..ba03597d6e 100644 --- a/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs +++ b/Extras/AspNetEdit/AspNetEdit.Integration/EditorProcess.cs @@ -166,6 +166,7 @@ namespace AspNetEdit.Editor host.Dispose (); base.Dispose (); + System.Diagnostics.Trace.WriteLine ("AspNetEdit editor process disposed"); } } } diff --git a/Extras/AspNetEdit/AspNetEdit.mdp b/Extras/AspNetEdit/AspNetEdit.mdp index 1d9a05e828..c44e2670b0 100644 --- a/Extras/AspNetEdit/AspNetEdit.mdp +++ b/Extras/AspNetEdit/AspNetEdit.mdp @@ -19,21 +19,12 @@ <File name="./AspNetEdit.Integration" subtype="Directory" buildaction="Compile" /> <File name="./AspNetEdit.Integration/AspNetEditDisplayBinding.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.addin.xml" subtype="Code" buildaction="Nothing" /> - <File name="./AspNetEdit.Editor.Persistence/AspParser.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/AspTokenizer.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.Persistence/ControlPersister.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.Persistence/DesignTimeParser.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/Directive.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.Persistence/HtmlParsingObject.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/ILocation.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/Location.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/ParseException.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.Persistence/ParsingObject.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.Persistence/RootParsingObject.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.Persistence/ServerControlParsingObject.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/StrUtils.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/TagAttributes.cs" subtype="Code" buildaction="Compile" /> - <File name="./AspNetEdit.Editor.Persistence/TagType.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.ComponentModel/DesignContainer.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.ComponentModel/DesignerHost.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.ComponentModel/Document.cs" subtype="Code" buildaction="Compile" /> @@ -52,8 +43,6 @@ <File name="./AspNetEdit.Editor.ComponentModel/WebFormReferenceManager.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.UI/PropertyGrid.cs" subtype="Code" buildaction="Compile" /> <File name="./AspNetEdit.Editor.UI/RootDesignerView.cs" subtype="Code" buildaction="Compile" /> - <File name="./chrome/ChangeLog" subtype="Code" buildaction="Nothing" /> - <File name="./chrome/chrome.manifest" subtype="Code" buildaction="Nothing" /> <File name="./chrome/install.rdf" subtype="Code" buildaction="Nothing" /> <File name="./chrome/Makefile.am" subtype="Code" buildaction="Nothing" /> <File name="./chrome/README" subtype="Code" buildaction="Nothing" /> @@ -75,31 +64,41 @@ <File name="./AspNetEdit.Integration/ToolboxProvider.cs" subtype="Code" buildaction="Compile" /> <File name="./data" subtype="Directory" buildaction="Compile" /> <File name="./data/WebControlsToolbox.xml" subtype="Code" buildaction="Compile" /> + <File name="./chrome/aspdesigner.manifest.in" subtype="Code" buildaction="Nothing" /> </Contents> <References> <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <ProjectReference type="Gac" localcopy="True" refto="gecko-sharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ccf7d78a55e9f021" /> <ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> - <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.DesignerSupport" /> <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Core" /> <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Core.Gui" /> <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Ide" /> <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Projects" /> - <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Projects.Gui" /> <ProjectReference type="Project" localcopy="True" refto="AspNetAddIn" /> <ProjectReference type="Gac" localcopy="True" refto="jscall, Version=0.0.2.0, Culture=neutral, PublicKeyToken=db10596f4718e9c9" /> <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Components" /> <ProjectReference type="Gac" localcopy="True" refto="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> - <ProjectReference type="Gac" localcopy="True" refto="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <ProjectReference type="Gac" localcopy="True" refto="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <ProjectReference type="Gac" localcopy="True" refto="System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <ProjectReference type="Gac" localcopy="True" refto="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp, Version=2.16.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.SourceEditor" /> </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../"> + <BuildFilesVar Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> <DeploymentInformation strategy="File"> <excludeFiles /> </DeploymentInformation> diff --git a/Extras/AspNetEdit/ChangeLog b/Extras/AspNetEdit/ChangeLog index 1d8fece6b1..2c14f2a81b 100644 --- a/Extras/AspNetEdit/ChangeLog +++ b/Extras/AspNetEdit/ChangeLog @@ -1,3 +1,57 @@ +2007-02-24 Michael Hutchinson <m.j.hutchinson@gmail.com> + + * AspNetEdit.Editor.UI/RootDesignerView.cs: New UpdateRender method. + Change behaviour of JSDeserializeAndAdd. It's a one-way function now; + JS can give just offload pasted ASP.NET code to host and forget about + it. The C# host will take it from there. + + * AspNetEdit.Editor/EditorHost.cs: + Bump some code into GUI thread so it can handle exceptions. It's less + fragile than remoting. + Use ToolboxDataAttribute attributes when handling toolbox items. Relies + on improvements to Document.InsertFragment. + + * AspNetEdit.Editor.ComponentModel/Document.cs, + * AspNetEdit.Editor.ComponentModel/DesignerHost.cs, + * AspNetEdit.Editor.Persistence/ServerControlParsingObject.cs: + Change the places in which controls are created, initialised + and added to document. + Document.InsertFragment now handles ASP.NET code. + + * AspNetEdit.Editor.Persistence/ServerControlParsingObject.cs: + Don't allow a tag's innerText to overwrite value from property if it's + empty. + + * AspNetEdit.Editor.Persistence/DesignTimeParser.cs: + Rename ParseDocument to ProcessFragment. + + * AspNetEdit.Editor.Persistence/RootParsingObject.cs: + Rename BuildObject to GetParsedContent and change signature. + + * AspNetEdit.Editor.ComponentModel/NameCreationService.cs: + Make name generation case insensitive, becuase ASP.NET is. + + * AspNetEdit.Integration/EditorProcess.cs: Add a trace statement. + + * AspNetEdit.Integration/AspNetEditViewContent.cs: Remove extra "using" + + * chrome/content/aspdesigner/editor.js: Remove debugging alert. + + * Makefile.am. + * AspNetEdit.mdp: Updated. Enable some autotools integration. + +2007-02-24 Michael Hutchinson <m.j.hutchinson@gmail.com> + + * Makefile.am: Eliminate unnecessary copy during build. + + * chrome/content/aspdesigner/xpcom.js, + * chrome/content/aspdesigner/editor.js: Fixed some JS warnings. + Fixed aspdesigner initialisation bug with Mozilla/Gecko >= 1.8, such + as Firefox >= 1.5. + + * AspNetEdit.Editor.ComponentModel/NameCreationService.cs: Use + Int.TryParse now instead of catching exceptions. + 2007-02-16 Lluis Sanchez Gual <lluis@novell.com> * AspNetEdit.addin.xml: Change add-in versions to 0.13. diff --git a/Extras/AspNetEdit/Makefile.am b/Extras/AspNetEdit/Makefile.am index e6a77595f0..b53d3666b4 100644 --- a/Extras/AspNetEdit/Makefile.am +++ b/Extras/AspNetEdit/Makefile.am @@ -5,25 +5,26 @@ endif ADDIN_BUILD = $(top_builddir)/build/AddIns/AspNetEdit ASSEMBLY = $(ADDIN_BUILD)/AspNetEdit.dll -REFS = -r:System \ - -r:System.Xml \ - -r:System.Web \ - -r:System.Design \ - -r:System.Drawing \ - -r:System.Drawing.Design \ - -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ +REFS = \ + $(GECKO_SHARP_LIBS) \ + $(GLADE_SHARP_LIBS) \ + $(GNOME_SHARP_LIBS) \ + $(GTK_SHARP_LIBS) \ + -pkg:jscall-sharp \ + -r:$(top_builddir)/build/AddIns/AspNetAddIn/AspNetAddIn.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Components.dll \ -r:$(top_builddir)/build/AddIns/MonoDevelop.Core.Gui.dll \ - -r:$(top_builddir)/build/AddIns/MonoDevelop.SourceEditor.dll \ - -r:$(top_builddir)/build/AddIns/MonoDevelop.Projects.dll \ - -r:$(top_builddir)/build/AddIns/MonoDevelop.Ide.dll \ - -r:$(top_builddir)/build/AddIns/MonoDevelop.Components.dll \ -r:$(top_builddir)/build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll \ - -r:$(top_builddir)/build/AddIns/AspNetAddIn/AspNetAddIn.dll \ - $(GTK_SHARP_LIBS) \ - $(GNOME_SHARP_LIBS) \ - $(GLADE_SHARP_LIBS) \ - $(GECKO_SHARP_LIBS) \ - $(JSCALL_LIBS) + -r:$(top_builddir)/build/AddIns/MonoDevelop.Ide.dll \ + -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:System \ + -r:System.Design \ + -r:System.Drawing \ + -r:System.Drawing.Design \ + -r:System.Web \ + -r:System.Xml FILES = \ AssemblyInfo.cs \ @@ -64,13 +65,12 @@ FILES = \ AspNetEdit.Integration/EditorProcess.cs -RES = \ - # +RES = # DATA_FILES = \ data/WebControlsToolbox.xml -DATA_FILE_BUILD = $(addprefix $(ADDIN_BUILD), $(DATA_FILES)) +DATA_FILE_BUILD = $(addprefix $(ADDIN_BUILD)/, $(notdir $(DATA_FILES))) ADDIN = AspNetEdit.addin.xml diff --git a/Extras/AspNetEdit/chrome/content/aspdesigner/editor.js b/Extras/AspNetEdit/chrome/content/aspdesigner/editor.js index 9a6216a0d6..5acf8131bc 100644 --- a/Extras/AspNetEdit/chrome/content/aspdesigner/editor.js +++ b/Extras/AspNetEdit/chrome/content/aspdesigner/editor.js @@ -30,7 +30,8 @@ var editor = null;
var host = null;
-var gDirectivePlaceholder = '';
+var gDirectivePlaceholder = ''; +var clip = null;
@@ -164,7 +165,7 @@ aspNetHost.prototype = throwException: function (location, msg)
{
JSCallPlaceClrCall ('ThrowException', '', new Array(location, msg));
- },
+ }
}
@@ -305,7 +306,11 @@ var controlTable = { // The editor class and initialization
//_____________________________________________________________________________
function aspNetEditor_initialize()
-{
+{ + //host XUL doc's onload event fires twice for some reason + if (editor != null) + return; +
dump ("Initialising...");
editor = new aspNetEditor ();
dump ("\tCreated editor, initialising...");
@@ -410,7 +415,9 @@ aspNetEditor.prototype = editor instanceof Components.interfaces.nsIPlaintextEditor;
editor instanceof Components.interfaces.nsIHTMLEditor;
- } catch (e) {}
+ } catch (e) { + dump("Could not obtain nsIHTMLEditor: " + e); + }
return editor;
},
@@ -886,7 +893,8 @@ aspNetEditor.prototype = insertFragment: function (aHtml)
{
- if(aHtml) {
+ if(aHtml) { + this.hideResizers ();
var insertionPoint =
{insertIn: null, destinationOffset: 0};
this.findInsertionPoint (insertionPoint);
@@ -1073,7 +1081,7 @@ aspNetEditor.prototype = while((table = aTables.nextNode ()) != null) {
table.setAttribute ('cancelUI', 'true');
}
- },
+ }
};
//* ___________________________________________________________________________
@@ -1175,7 +1183,7 @@ function detectDoubleClick(aEvent) host.click (DOUBLE_CLICK, controlId);
- alert (editor.getPage ());
+ //alert (editor.getPage ());
}
function handleContextMenu(aEvent)
@@ -1345,4 +1353,4 @@ function dump(aTxtAppend) { if(DEBUG) {
JSCallPlaceClrCall ('DebugStatement', '', new Array(aTxtAppend));
}
-}
\ No newline at end of file +} diff --git a/Extras/AspNetEdit/chrome/content/aspdesigner/xpcom.js b/Extras/AspNetEdit/chrome/content/aspdesigner/xpcom.js index 15e6803703..51fcca9a02 100644 --- a/Extras/AspNetEdit/chrome/content/aspdesigner/xpcom.js +++ b/Extras/AspNetEdit/chrome/content/aspdesigner/xpcom.js @@ -63,7 +63,7 @@ var gNsISelectionListenerImplementation = { // Make sure we can't focus a control //TODO: make it account for md-can-drop="true" controls, which // should be able to recieve focus - if(sel.isCollapsed) { + if(sel.isCollapsed && editor && editor.base) { var focusNode = sel.focusNode; var parentControl = editor.base.getElementOrParentByTagName (CONTROL_TAG_NAME, @@ -312,7 +312,7 @@ var gNsIEditActionListenerImplementation = { WillSplitNode: function(existingRightNode, offset) { //alert ('Will split node'); - }, + } } // nsIHTMLObjectResizeListener implementation |