[Monodevelop-patches-list] r2598 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Gui/Dialogs/ReferenceDialog Services/Project
John Luke <jluke@cfl.rr.com>
jluke at mono-cvs.ximian.com
Wed Jun 15 15:42:12 EDT 2005
Author: jluke
Date: 2005-06-15 15:42:11 -0400 (Wed, 15 Jun 2005)
New Revision: 2598
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/SelectReferenceDialog.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs
Log:
reuse the slow to create SelectReferenceDialog
as much as possible
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-06-13 14:54:44 UTC (rev 2597)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-06-15 19:42:11 UTC (rev 2598)
@@ -1,3 +1,14 @@
+2005-06-15 John Luke <john.luke at gmail.com>
+
+ * Services/Project/ProjectService.cs: don't recreate SelectReferenceDialog
+ every time, just set the project instead
+ * Gui/Dialogs/ReferenceDialog/SelectReferenceDialog.cs: allow it to be
+ reused and just change the project to show the correct info
+ * Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs: add a SetProject
+ that updates the info appropriately, remove old code
+ * Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs: add Reset method
+ to update the info for a new project
+
2005-06-10 Jacob Ilsø Christensen <jacobilsoe at gmail.com>
* Gui/Dialogs/ReferenceDialog/SelectReferenceDialog.cs: Make sure
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs 2005-06-13 14:54:44 UTC (rev 2597)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/GacReferencePanel.cs 2005-06-15 19:42:11 UTC (rev 2598)
@@ -6,17 +6,12 @@
// </file>
using System;
-using System.Text;
-using System.Drawing;
-using System.Collections;
-using System.ComponentModel;
-using MonoDevelop.Internal.Project;
+using System.IO;
+using MonoDevelop.Internal.Project;
using MonoDevelop.Core.Services;
using MonoDevelop.Services;
-using System.IO;
-
using Gtk;
namespace MonoDevelop.Gui.Dialogs
@@ -60,6 +55,12 @@
ShowAll ();
BorderWidth = 6;
}
+
+ public void Reset ()
+ {
+ store.Clear ();
+ PrintCache ();
+ }
public void AddReference(object sender, Gtk.ToggledArgs e)
{
@@ -97,49 +98,6 @@
void PrintCache()
{
-#if false
- IApplicationContext applicationContext = null;
- IAssemblyEnum assemblyEnum = null;
- IAssemblyName assemblyName = null;
-
- Fusion.CreateAssemblyEnum(out assemblyEnum, null, null, 2, 0);
-
- while (assemblyEnum.GetNextAssembly(out applicationContext, out assemblyName, 0) == 0) {
- uint nChars = 0;
- assemblyName.GetDisplayName(null, ref nChars, 0);
-
- StringBuilder sb = new StringBuilder((int)nChars);
- assemblyName.GetDisplayName(sb, ref nChars, 0);
-
- string[] info = sb.ToString().Split(',');
-
- string aName = info[0];
- string aVersion = info[1].Substring(info[1].LastIndexOf('=') + 1);
- ListViewItem item = new ListViewItem(new string[] {aName, aVersion});
- item.Tag = sb.ToString();
- Items.Add(item);
- }
-#endif
- #if false
- System.Reflection.MethodInfo gac = typeof (System.Environment).GetMethod ("internalGetGacPath", System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.NonPublic);
- if (gac == null) {
- Runtime.LoggingService.Info (GettextCatalog.GetString ("ERROR: non-mono runtime detected, please use the mono runtime for this piece of MonoDevelop for the time being"));
- Environment.Exit (1);
- }
- string gac_path = System.IO.Path.Combine ((string)gac.Invoke (null, null), "");
- DirectoryInfo d = new DirectoryInfo (System.IO.Path.Combine (System.IO.Path.Combine (gac_path, "mono"), "gac"));
- foreach (DirectoryInfo namedDir in d.GetDirectories ()) {
- foreach (DirectoryInfo assemblyDir in namedDir.GetDirectories ()) {
- FileInfo[] files = assemblyDir.GetFiles ("*.dll");
- try {
- System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName (files[0].FullName);
-
- store.AppendValues (an.Name, an.Version.ToString (), System.IO.Path.GetFileName (files[0].FullName), false, an.FullName);
- } catch {
- }
- }
- }
- #endif
foreach (string assemblyPath in Runtime.SystemAssemblyService.AssemblyPaths) {
try {
System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName (assemblyPath);
@@ -150,3 +108,4 @@
}
}
}
+
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs 2005-06-13 14:54:44 UTC (rev 2597)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs 2005-06-15 19:42:11 UTC (rev 2598)
@@ -5,11 +5,8 @@
// <version value="$version"/>
// </file>
using System;
-using System.Drawing;
-using System.Collections;
-using System.ComponentModel;
-using MonoDevelop.Internal.Project;
+using MonoDevelop.Internal.Project;
using MonoDevelop.Core.Services;
using MonoDevelop.Services;
@@ -23,7 +20,7 @@
TreeStore store;
TreeView treeView;
- public ProjectReferencePanel (SelectReferenceDialog selectDialog, Project configureProject) : base (false, 6)
+ public ProjectReferencePanel (SelectReferenceDialog selectDialog) : base (false, 6)
{
this.selectDialog = selectDialog;
@@ -50,7 +47,6 @@
treeView.AppendColumn (firstColumn);
treeView.AppendColumn (GettextCatalog.GetString ("Directory"), new CellRendererText (), "text", 1);
- PopulateListView (configureProject);
ScrolledWindow sc = new ScrolledWindow ();
sc.ShadowType = Gtk.ShadowType.In;
sc.Add (treeView);
@@ -58,6 +54,12 @@
ShowAll ();
BorderWidth = 6;
}
+
+ public void SetProject (Project configureProject)
+ {
+ store.Clear ();
+ PopulateListView (configureProject);
+ }
public void AddReference(object sender, Gtk.ToggledArgs e)
{
@@ -115,43 +117,5 @@
}
}
}
-
-/* public class ProjectReferencePanel : ListView//, IReferencePanel
- {
- SelectReferenceDialog selectDialog;
-
- public ProjectReferencePanel(SelectReferenceDialog selectDialog)
- {
- this.selectDialog = selectDialog;
- ResourceService resourceService = (ResourceService)ServiceManager.Services.GetService(typeof(IResourceService));
- ColumnHeader nameHeader = new ColumnHeader();
- nameHeader.Text = resourceService.GetString("Dialog.SelectReferenceDialog.ProjectReferencePanel.NameHeader");
- nameHeader.Width = 160;
- Columns.Add(nameHeader);
-
- ColumnHeader directoryHeader = new ColumnHeader();
- directoryHeader.Text = resourceService.GetString("Dialog.SelectReferenceDialog.ProjectReferencePanel.DirectoryHeader");
- directoryHeader.Width = 70;
- Columns.Add(directoryHeader);
-
- View = View.Details;
- Dock = DockStyle.Fill;
- FullRowSelect = true;
-
- ItemActivate += new EventHandler(AddReference);
- PopulateListView();
- }
-
- public void AddReference(object sender, EventArgs e)
- {
- foreach (ListViewItem item in SelectedItems) {
- Project project = (Project)item.Tag;
- selectDialog.AddReference(ReferenceType.Project,
- project.Name,
- project.GetOutputFileName());
- }
- }
-
-
- }*/
}
+
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/SelectReferenceDialog.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/SelectReferenceDialog.cs 2005-06-13 14:54:44 UTC (rev 2597)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReferenceDialog/SelectReferenceDialog.cs 2005-06-15 19:42:11 UTC (rev 2598)
@@ -6,16 +6,13 @@
// </file>
using System;
-using System.Drawing;
-using System.Collections;
-using System.Diagnostics;
-using System.ComponentModel;
using MonoDevelop.Internal.Project;
using MonoDevelop.Core.Services;
using MonoDevelop.Services;
using Gtk;
+using Glade;
namespace MonoDevelop.Gui.Dialogs
{
@@ -25,17 +22,15 @@
public class SelectReferenceDialog
{
-
- Gtk.TreeStore refTreeStore;
- [Glade.Widget] Gtk.Dialog AddReferenceDialog;
- [Glade.Widget] Gtk.TreeView ReferencesTreeView;
- [Glade.Widget] Gtk.Button okbutton;
- [Glade.Widget] Gtk.Button cancelbutton;
- [Glade.Widget] Gtk.Button RemoveReferenceButton;
- [Glade.Widget] Gtk.Notebook mainBook;
+ TreeStore refTreeStore;
+ [Widget] Dialog AddReferenceDialog;
+ [Widget] TreeView ReferencesTreeView;
+ [Widget] Button okbutton;
+ [Widget] Button cancelbutton;
+ [Widget] Button RemoveReferenceButton;
+ [Widget] Notebook mainBook;
GacReferencePanel gacRefPanel;
- Project configureProject;
ProjectReferencePanel projectRefPanel;
public ProjectReferenceCollection ReferenceInformations {
@@ -46,7 +41,6 @@
return referenceInformations;
}
do {
- //Debug.Assert(item.Tag != null);
referenceInformations.Add ((ProjectReference) refTreeStore.GetValue(looping_iter, 3));
} while (refTreeStore.IterNext (ref looping_iter));
return referenceInformations;
@@ -62,46 +56,55 @@
{
AddReferenceDialog.Hide ();
}
+
+ public void SetProject (Project configureProject)
+ {
+ ((TreeStore) ReferencesTreeView.Model).Clear ();
+
+ projectRefPanel.SetProject (configureProject);
+ gacRefPanel.Reset ();
+
+ foreach (ProjectReference refInfo in configureProject.ProjectReferences) {
+ switch (refInfo.ReferenceType) {
+ case ReferenceType.Assembly:
+ case ReferenceType.Project:
+ AddNonGacReference (refInfo);
+ break;
+ case ReferenceType.Gac:
+ AddGacReference (refInfo, configureProject);
+ break;
+ }
+ }
+
+ OnChanged (null, null);
+ }
public SelectReferenceDialog(Project configureProject)
{
- this.configureProject = configureProject;
-
Glade.XML refXML = new Glade.XML (null, "Base.glade", "AddReferenceDialog", null);
refXML.Autoconnect (this);
- refTreeStore = new Gtk.TreeStore (typeof (string), typeof(string), typeof(string), typeof(ProjectReference));
+ refTreeStore = new TreeStore (typeof (string), typeof(string), typeof(string), typeof(ProjectReference));
ReferencesTreeView.Model = refTreeStore;
ReferencesTreeView.AppendColumn (GettextCatalog.GetString("Reference Name"), new CellRendererText (), "text", 0);
ReferencesTreeView.AppendColumn (GettextCatalog.GetString ("Type"), new CellRendererText (), "text", 1);
ReferencesTreeView.AppendColumn (GettextCatalog.GetString ("Location"), new CellRendererText (), "text", 2);
+ projectRefPanel = new ProjectReferencePanel (this);
gacRefPanel = new GacReferencePanel (this);
- projectRefPanel = new ProjectReferencePanel (this, configureProject);
+ SetProject (configureProject);
- foreach (ProjectReference refInfo in configureProject.ProjectReferences) {
- switch (refInfo.ReferenceType) {
- case ReferenceType.Assembly:
- case ReferenceType.Project:
- AddNonGacReference (refInfo);
- break;
- case ReferenceType.Gac:
- AddGacReference (refInfo, configureProject);
- break;
- }
- }
mainBook.RemovePage (mainBook.CurrentPage);
- mainBook.AppendPage (gacRefPanel, new Gtk.Label (GettextCatalog.GetString ("Global Assembly Cache")));
- mainBook.AppendPage (projectRefPanel, new Gtk.Label (GettextCatalog.GetString ("Projects")));
- mainBook.AppendPage (new AssemblyReferencePanel (this), new Gtk.Label (GettextCatalog.GetString (".Net Assembly")));
- //comTabPage.Controls.Add(new COMReferencePanel(this));
- ReferencesTreeView.Selection.Changed += new EventHandler (onChanged);
+ mainBook.AppendPage (gacRefPanel, new Label (GettextCatalog.GetString ("Global Assembly Cache")));
+ mainBook.AppendPage (projectRefPanel, new Label (GettextCatalog.GetString ("Projects")));
+ mainBook.AppendPage (new AssemblyReferencePanel (this), new Label (GettextCatalog.GetString (".Net Assembly")));
+ ReferencesTreeView.Selection.Changed += new EventHandler (OnChanged);
AddReferenceDialog.ShowAll ();
- onChanged (null, null);
+ OnChanged (null, null);
}
- void onChanged (object o, EventArgs e)
+ void OnChanged (object o, EventArgs e)
{
if (ReferencesTreeView.Selection.CountSelectedRows () > 0)
RemoveReferenceButton.Sensitive = true;
@@ -125,7 +128,7 @@
public void RemoveReference (ReferenceType referenceType, string referenceName, string referenceLocation)
{
- Gtk.TreeIter looping_iter;
+ TreeIter looping_iter;
if (!refTreeStore.GetIterFirst (out looping_iter))
return;
do {
@@ -138,7 +141,7 @@
public void AddReference(ReferenceType referenceType, string referenceName, string referenceLocation)
{
- Gtk.TreeIter looping_iter;
+ TreeIter looping_iter;
if (refTreeStore.GetIterFirst (out looping_iter)) {
do {
try {
@@ -163,20 +166,14 @@
break;
}
- Gtk.TreeIter ni = refTreeStore.AppendValues (referenceName, referenceType.ToString (), referenceLocation, tag);
+ TreeIter ni = refTreeStore.AppendValues (referenceName, referenceType.ToString (), referenceLocation, tag);
ReferencesTreeView.ScrollToCell (refTreeStore.GetPath (ni), null, false, 0, 0);
}
- void SelectReference(object sender, EventArgs e)
- {
- //IReferencePanel refPanel = (IReferencePanel)referenceTabControl.SelectedTab.Controls[0];
- //refPanel.AddReference(null, null);
- }
-
void RemoveReference(object sender, EventArgs e)
{
- Gtk.TreeIter iter;
- Gtk.TreeModel mdl;
+ TreeIter iter;
+ TreeModel mdl;
if (ReferencesTreeView.Selection.GetSelected (out mdl, out iter)) {
switch (((ProjectReference)refTreeStore.GetValue (iter, 3)).ReferenceType) {
case ReferenceType.Gac:
@@ -186,12 +183,12 @@
projectRefPanel.SignalRefChange ((string)refTreeStore.GetValue (iter, 0), false);
break;
}
- Gtk.TreeIter newIter = iter;
+ TreeIter newIter = iter;
if (refTreeStore.IterNext (ref newIter)) {
ReferencesTreeView.Selection.SelectIter (newIter);
refTreeStore.Remove (ref iter);
} else {
- Gtk.TreePath path = refTreeStore.GetPath (iter);
+ TreePath path = refTreeStore.GetPath (iter);
if (path.Prev ()) {
ReferencesTreeView.Selection.SelectPath (path);
refTreeStore.Remove (ref iter);
@@ -203,3 +200,4 @@
}
}
}
+
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs 2005-06-13 14:54:44 UTC (rev 2597)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs 2005-06-15 19:42:11 UTC (rev 2598)
@@ -52,6 +52,7 @@
ICompilerResult lastResult = new DefaultCompilerResult ();
GuiHelper guiHelper = new GuiHelper ();
+ SelectReferenceDialog selDialog = null;
public Project CurrentSelectedProject {
get {
@@ -806,7 +807,11 @@
{
bool res = false;
- SelectReferenceDialog selDialog = new SelectReferenceDialog(project);
+ if (selDialog == null)
+ selDialog = new SelectReferenceDialog(project);
+ else
+ selDialog.SetProject (project);
+
if (selDialog.Run() == (int)Gtk.ResponseType.Ok) {
ProjectReferenceCollection newRefs = selDialog.ReferenceInformations;
@@ -848,7 +853,7 @@
projectBindings = (ProjectBindingCodon[])(AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/ProjectBindings").BuildChildItems(null)).ToArray(typeof(ProjectBindingCodon));
}
-
+
string MakeValidName(string str)
{
string tmp = "";
More information about the Monodevelop-patches-list
mailing list