[Monodevelop-patches-list] r2352 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Gui/Pads/ProjectPad Gui/Pads/SolutionPad Internal/Project/Project/Collections
Lluis Sanchez <lluis@ximian.com>
lluis at mono-cvs.ximian.com
Tue Mar 15 10:13:09 EST 2005
Author: lluis
Date: 2005-03-15 10:13:09 -0500 (Tue, 15 Mar 2005)
New Revision: 2352
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/FolderNodeBuilder.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectFileNodeBuilder.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectNodeBuilder.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/ITreeBuilder.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectFileCollection.cs
Log:
2005-03-15 Lluis Sanchez Gual <lluis at novell.com>
* Pads/SolutionPad/TreeViewPad.cs: implemented ITreeBuilder.UpdateAll()
method in TreeBuilder.
* Pads/SolutionPad/ITreeBuilder.cs: Added UpdateAll method and some
documentation.
* Pads/ProjectPad/ProjectNodeBuilder.cs: Don't remove files from the
tree if ShowAllFiles option is set.
* Pads/ProjectPad/ProjectFileNodeBuilder.cs: Removed unused class.
* Pads/ProjectPad/FolderNodeBuilder.cs: When adding a file, don't
duplicate nodes if ShowAllFiles option is set.
* Internal/Project/Project/Collections/ProjectFileCollection.cs:
When removing a file, unset the ProjectFile's project. Removed
indexer setter. Nobody uses it and it adds complexity.
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-03-15 10:13:20 UTC (rev 2351)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-03-15 15:13:09 UTC (rev 2352)
@@ -1,3 +1,18 @@
+2005-03-15 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Pads/SolutionPad/TreeViewPad.cs: implemented ITreeBuilder.UpdateAll()
+ method in TreeBuilder.
+ * Pads/SolutionPad/ITreeBuilder.cs: Added UpdateAll method and some
+ documentation.
+ * Pads/ProjectPad/ProjectNodeBuilder.cs: Don't remove files from the
+ tree if ShowAllFiles option is set.
+ * Pads/ProjectPad/ProjectFileNodeBuilder.cs: Removed unused class.
+ * Pads/ProjectPad/FolderNodeBuilder.cs: When adding a file, don't
+ duplicate nodes if ShowAllFiles option is set.
+ * Internal/Project/Project/Collections/ProjectFileCollection.cs:
+ When removing a file, unset the ProjectFile's project. Removed
+ indexer setter. Nobody uses it and it adds complexity.
+
2005-03-14 Lluis Sanchez Gual <lluis at novell.com>
* Commands/MenuItemBuilders.cs
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/FolderNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/FolderNodeBuilder.cs 2005-03-15 10:13:20 UTC (rev 2351)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/FolderNodeBuilder.cs 2005-03-15 15:13:09 UTC (rev 2352)
@@ -90,6 +90,8 @@
}
if (file.Subtype == Subtype.Directory)
builder.AddChild (new ProjectFolder (file.FilePath, project));
+ else if (builder.Options ["ShowAllFiles"])
+ builder.UpdateChildren ();
else
builder.AddChild (file);
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectFileNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectFileNodeBuilder.cs 2005-03-15 10:13:20 UTC (rev 2351)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectFileNodeBuilder.cs 2005-03-15 15:13:09 UTC (rev 2352)
@@ -129,57 +129,4 @@
{
}
}
-
-
- public class ExNodeBuilder: NodeBuilderExtension
- {
- public override bool CanBuildNode (Type dataType)
- {
- return typeof(ProjectFile).IsAssignableFrom (dataType);
- }
-
- public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
- {
- ProjectFile file = (ProjectFile) dataObject;
- if (GetParentFile (file) != null && treeNavigator.GetParentDataItem (typeof(ProjectFile), true) == null)
- attributes |= NodeAttributes.Hidden;
- }
-
- public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
- {
- ProjectFile file = (ProjectFile) dataObject;
- ProjectFile depFile = GetDependentFile (file);
- if (depFile != null)
- treeBuilder.AddChild (depFile);
- }
-
- public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
- {
- ProjectFile file = (ProjectFile) dataObject;
- return GetDependentFile (file) != null;
- }
-
- ProjectFile GetDependentFile (ProjectFile file)
- {
- Project p = file.Project;
- if (p == null) return null;
-
- if (file.Name.EndsWith (".cs"))
- return p.GetProjectFile (file.Name.Substring (0, file.Name.Length - 2) + "ex.cs");
- else
- return null;
- }
-
- ProjectFile GetParentFile (ProjectFile file)
- {
- Project p = file.Project;
- if (p == null) return null;
-
- if (file.Name.EndsWith (".ex.cs"))
- return p.GetProjectFile (file.Name.Substring (0, file.Name.Length - 5) + "cs");
- else
- return null;
- }
- }
-
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectNodeBuilder.cs 2005-03-15 10:13:20 UTC (rev 2351)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ProjectPad/ProjectNodeBuilder.cs 2005-03-15 15:13:09 UTC (rev 2352)
@@ -133,7 +133,12 @@
void OnRemoveFile (object sender, ProjectFileEventArgs e)
{
ITreeBuilder tb = Context.GetTreeBuilder (e.ProjectFile);
- if (tb != null) tb.Remove ();
+ if (tb != null) {
+ if (tb.Options ["ShowAllFiles"] && File.Exists (e.ProjectFile.Name))
+ tb.UpdateAll ();
+ else
+ tb.Remove ();
+ }
}
void OnRenameFile (object sender, ProjectFileRenamedEventArgs e)
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/ITreeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/ITreeBuilder.cs 2005-03-15 10:13:20 UTC (rev 2351)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/ITreeBuilder.cs 2005-03-15 15:13:09 UTC (rev 2352)
@@ -32,11 +32,27 @@
{
public interface ITreeBuilder: ITreeNavigator
{
+ // Updates the current node and its children
+ void UpdateAll ();
+
+ // Updates the label and icon of the current node
void Update ();
+
+ // Updates the children of the current node
void UpdateChildren ();
+
+ // Removes the current node
void Remove ();
+
+ // Removes de current node and if moveToParent is true, it moves
+ // to the parent node.
void Remove (bool moveToParent);
+
+ // Adds a child to the current node
void AddChild (object dataObject);
+
+ // Adds a child to the current node and if moveToChild is true, it
+ // moves to the new child.
void AddChild (object dataObject, bool moveToChild);
}
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs 2005-03-15 10:13:20 UTC (rev 2351)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs 2005-03-15 15:13:09 UTC (rev 2352)
@@ -721,10 +721,8 @@
if (dataObject != null) found = builder.MoveToObject (dataObject);
else found = builder.MoveToRoot ();
- if (found) {
- builder.Update ();
- builder.UpdateChildren ();
- }
+ if (found)
+ builder.UpdateAll ();
}
internal bool GetIterFromNamePath (string path, out Gtk.TreeIter iter)
@@ -841,8 +839,7 @@
ClearOptions (iter);
TreeBuilder tb = new TreeBuilder (this, iter);
- tb.Update ();
- tb.UpdateChildren ();
+ tb.UpdateAll ();
}
void OnPopupMenu (object o, Gtk.PopupMenuArgs args)
@@ -1210,6 +1207,12 @@
return store.IterHasChild (currentIter);
}
+ public void UpdateAll ()
+ {
+ Update ();
+ UpdateChildren ();
+ }
+
public void Update ()
{
object data = store.GetValue (currentIter, TreeViewPad.DataItemColumn);
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectFileCollection.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectFileCollection.cs 2005-03-15 10:13:20 UTC (rev 2351)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectFileCollection.cs 2005-03-15 15:13:09 UTC (rev 2352)
@@ -56,17 +56,6 @@
get {
return ((ProjectFile)(List[index]));
}
- set {
- if (project != null)
- project.NotifyFileRemovedFromProject ((ProjectFile)List[index]);
-
- List[index] = value;
-
- if (project != null) {
- value.SetProject (project);
- project.NotifyFileAddedToProject (value);
- }
- }
}
/// <summary>
@@ -81,6 +70,8 @@
public int Add(ProjectFile value) {
int i = List.Add(value);
if (project != null) {
+ if (value.Project != null)
+ throw new InvalidOperationException ("ProjectFile already belongs to a project");
value.SetProject (project);
project.NotifyFileAddedToProject (value);
}
@@ -176,6 +167,8 @@
public void Insert(int index, ProjectFile value) {
List.Insert(index, value);
if (project != null) {
+ if (value.Project != null)
+ throw new InvalidOperationException ("ProjectFile already belongs to a project");
value.SetProject (project);
project.NotifyFileAddedToProject (value);
}
@@ -199,9 +192,11 @@
/// <returns><para>None.</para></returns>
/// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
public void Remove(ProjectFile value) {
- List.Remove(value);
- if (project != null)
+ List.Remove (value);
+ if (project != null) {
+ value.SetProject (null);
project.NotifyFileRemovedFromProject (value);
+ }
}
public class ProjectFileEnumerator : object, IEnumerator {
More information about the Monodevelop-patches-list
mailing list