Author: lluis
Date: 2007-07-10 07:34:39 -0400 (Tue, 10 Jul 2007)
New Revision: 81696
Modified:
trunk/monodevelop/Extras/MonoDevelop.GtkCore/ChangeLog
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
Log:
* MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs,
MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs,
MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs,
MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs,
MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs: Properly rename
fields when the widget name is changed. Fixes bug #81976.
Modified: trunk/monodevelop/Extras/MonoDevelop.GtkCore/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.GtkCore/ChangeLog 2007-07-10
10:55:23 UTC (rev 81695)
+++ trunk/monodevelop/Extras/MonoDevelop.GtkCore/ChangeLog 2007-07-10
11:34:39 UTC (rev 81696)
@@ -1,3 +1,12 @@
+2007-07-10 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs,
+ MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs,
+ MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs,
+ MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs,
+ MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs: Properly rename
+ fields when the widget name is changed. Fixes bug #81976.
+
2007-07-09 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProjectPad.cs: Update the
Modified:
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
2007-07-10 10:55:23 UTC (rev 81695)
+++
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs
2007-07-10 11:34:39 UTC (rev 81696)
@@ -127,7 +127,7 @@
// will not save the code to disk.
GtkDesignInfo info = GtkCoreService.GetGtkInfo
(project.Project);
if (info != null && info.GeneratePartialClasses)
-
GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)project.Project,
designer.RootComponent, false, false);
+
GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)project.Project,
designer.RootComponent, null, false, false);
}
base.ShowPage (npage);
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
2007-07-10 10:55:23 UTC (rev 81695)
+++
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs
2007-07-10 11:34:39 UTC (rev 81696)
@@ -146,7 +146,7 @@
if (obj == targetObject)
return; // The root widget name can only be
changed internally.
else
- cls = GetClass ();
+ cls = GetClass (false);
string newName = GetObjectName (obj);
if (newName.Length == 0)
@@ -250,10 +250,15 @@
public IClass GetClass ()
{
+ return GetClass (true);
+ }
+
+ public IClass GetClass (bool getUserClass)
+ {
if (targetObject == null)
return null;
- IClass cls = gproject.FindClass (className);
+ IClass cls = gproject.FindClass (className,
getUserClass);
if (cls != null)
return cls;
Modified:
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
2007-07-10 10:55:23 UTC (rev 81695)
+++
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs
2007-07-10 11:34:39 UTC (rev 81696)
@@ -429,7 +429,7 @@
public Stetic.ActionGroupInfo GetActionGroupForFile (string
fileName)
{
foreach (Stetic.ActionGroupInfo group in
SteticProject.ActionGroups) {
- if (fileName == GetSourceCodeFile (group))
+ if (fileName == GetSourceCodeFile (group, true))
return group;
}
return null;
@@ -442,7 +442,12 @@
public string GetSourceCodeFile (Stetic.ProjectItemInfo obj)
{
- IClass cls = GetClass (obj);
+ return GetSourceCodeFile (obj, true);
+ }
+
+ public string GetSourceCodeFile (Stetic.ProjectItemInfo obj,
bool getUserClass)
+ {
+ IClass cls = GetClass (obj, getUserClass);
GtkDesignInfo info = GtkCoreService.GetGtkInfo
(project);
if (cls != null) {
@@ -456,25 +461,34 @@
return null;
}
- IClass GetClass (Stetic.ProjectItemInfo obj)
+ IClass GetClass (Stetic.ProjectItemInfo obj, bool getUserClass)
{
string name = CodeBinder.GetClassName (obj);
- return FindClass (name);
+ return FindClass (name, getUserClass);
}
public IClass FindClass (string className)
{
+ return FindClass (className, true);
+ }
+
+ public IClass FindClass (string className, bool getUserClass)
+ {
GtkDesignInfo info = GtkCoreService.GetGtkInfo
(project);
IParserContext ctx = GetParserContext ();
IClass[] classes = ctx.GetProjectContents ();
foreach (IClass cls in classes) {
if (cls.FullyQualifiedName == className) {
- // Return this class only if it is
declared outside the gtk-gui
- // folder. Generated partial classes
will be ignored.
- foreach (IClass part in cls.Parts) {
- if
(!part.Region.FileName.StartsWith (info.GtkGuiFolder))
- return part;
+ if (getUserClass) {
+ // Return this class only if it
is declared outside the gtk-gui
+ // folder. Generated partial
classes will be ignored.
+ foreach (IClass part in
cls.Parts) {
+ if
(!part.Region.FileName.StartsWith (info.GtkGuiFolder))
+ return part;
+ }
}
+ else
+ return cls;
}
}
return null;
Modified:
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
2007-07-10 10:55:23 UTC (rev 81695)
+++
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs
2007-07-10 11:34:39 UTC (rev 81696)
@@ -271,15 +271,15 @@
public static string GenerateSteticCodeStructure (DotNetProject
project, Stetic.ProjectItemInfo item, bool saveToFile, bool overwrite)
{
- return GenerateSteticCodeStructure (project, item,
null, saveToFile, overwrite);
+ return GenerateSteticCodeStructure (project, item,
null, null, saveToFile, overwrite);
}
- public static string GenerateSteticCodeStructure (DotNetProject
project, Stetic.Component component, bool saveToFile, bool overwrite)
+ public static string GenerateSteticCodeStructure (DotNetProject
project, Stetic.Component component, Stetic.ComponentNameEventArgs args, bool
saveToFile, bool overwrite)
{
- return GenerateSteticCodeStructure (project, null,
component, saveToFile, overwrite);
+ return GenerateSteticCodeStructure (project, null,
component, args, saveToFile, overwrite);
}
- static string GenerateSteticCodeStructure (DotNetProject
project, Stetic.ProjectItemInfo item, Stetic.Component component, bool
saveToFile, bool overwrite)
+ static string GenerateSteticCodeStructure (DotNetProject
project, Stetic.ProjectItemInfo item, Stetic.Component component,
Stetic.ComponentNameEventArgs args, bool saveToFile, bool overwrite)
{
// Generate a class which contains fields for all bound
widgets of the component
@@ -314,10 +314,14 @@
cns.Types.Add (type);
foreach (Stetic.ObjectBindInfo binfo in
component.GetObjectBindInfo ()) {
+ // When a component is being renamed,
we have to generate the
+ // corresponding field using the old
name, since it will be renamed
+ // later using refactory
+ string nname = args != null &&
args.Component.Name == binfo.Name ? args.OldName : binfo.Name;
type.Members.Add (
new CodeMemberField (
binfo.TypeName,
- binfo.Name
+ nname
)
);
}
@@ -334,7 +338,6 @@
if (provider == null)
throw new UserException ("Code generation not
supported for language: " + project.LanguageName);
- ICodeGenerator gen = provider.CreateGenerator ();
TextWriter fileStream;
if (saveToFile)
fileStream = new StreamWriter (fileName);
@@ -342,7 +345,7 @@
fileStream = new StringWriter ();
try {
- gen.GenerateCodeFromCompileUnit (cu,
fileStream, new CodeGeneratorOptions ());
+ provider.GenerateCodeFromCompileUnit (cu,
fileStream, new CodeGeneratorOptions ());
} finally {
fileStream.Close ();
}
@@ -450,7 +453,6 @@
if (provider == null)
throw new UserException ("Code generation not
supported in language: " + project.LanguageName);
- ICodeGenerator gen = provider.CreateGenerator ();
string basePath = Path.GetDirectoryName
(info.SteticGeneratedFile);
string ext = Path.GetExtension
(info.SteticGeneratedFile);
@@ -462,7 +464,7 @@
fname = Path.Combine (basePath,
unit.Name) + ext;
StreamWriter fileStream = new StreamWriter
(fname);
try {
- gen.GenerateCodeFromCompileUnit (unit,
fileStream, new CodeGeneratorOptions ());
+ provider.GenerateCodeFromCompileUnit
(unit, fileStream, new CodeGeneratorOptions ());
} finally {
fileStream.Close ();
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
2007-07-10 10:55:23 UTC (rev 81695)
+++
trunk/monodevelop/Extras/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs
2007-07-10 11:34:39 UTC (rev 81696)
@@ -203,7 +203,7 @@
// will not save the code to disk.
GtkDesignInfo info = GtkCoreService.GetGtkInfo
(gproject.Project);
if (info != null && info.GeneratePartialClasses)
-
GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project,
designer.RootComponent, false, false);
+
GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project,
designer.RootComponent, null, false, false);
}
base.ShowPage (npage);
}
@@ -220,7 +220,21 @@
void OnComponentNameChanged (object s,
Stetic.ComponentNameEventArgs args)
{
- codeBinder.UpdateField (args.Component, args.OldName);
+ try {
+ // Make sure the fields in the partial class
are up to date.
+ // Provide the args parameter to
GenerateSteticCodeStructure, in this
+ // way the component that has been renamed will
be generated with the
+ // old name, and UpdateField will be able to
find it (to rename the
+ // references to the field, it needs to have
the old name).
+ GtkDesignInfo info = GtkCoreService.GetGtkInfo
(gproject.Project);
+ if (info != null && info.GeneratePartialClasses)
+
GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project,
designer.RootComponent, args, false, false);
+
+ codeBinder.UpdateField (args.Component,
args.OldName);
+ }
+ catch (Exception ex) {
+ IdeApp.Services.MessageService.ShowError (ex);
+ }
}
void OnComponentTypesChanged (object s, EventArgs a)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches