[Monodevelop-patches-list] r1816 - in trunk/MonoDevelop/src: Libraries/MonoDevelop.Core Libraries/MonoDevelop.Core/Services Main/Base Main/Base/Commands/ProjectBrowserCommands Main/Base/Gui/Dialogs
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Wed Jun 23 22:57:32 EDT 2004
Author: tberman
Date: 2004-06-23 22:57:32 -0400 (Wed, 23 Jun 2004)
New Revision: 1816
Modified:
trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog
trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/ServiceManager.cs
trunk/MonoDevelop/src/Main/Base/ChangeLog
trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs
trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs
Log:
fix the new file stuff from the project browser, small service manager change.
Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog 2004-06-24 02:05:41 UTC (rev 1815)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/ChangeLog 2004-06-24 02:57:32 UTC (rev 1816)
@@ -1,5 +1,9 @@
2004-06-23 Todd Berman <tberman at off.net>
+ * Services/ServiceManager.cs: protected ctor added.
+
+2004-06-23 Todd Berman <tberman at off.net>
+
* Services/ServiceManager.cs: make GetService a static method, hide
the instance everywhere.
Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/ServiceManager.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/ServiceManager.cs 2004-06-24 02:05:41 UTC (rev 1815)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Core/Services/ServiceManager.cs 2004-06-24 02:57:32 UTC (rev 1816)
@@ -29,6 +29,11 @@
Hashtable servicesHashtable = new Hashtable();
static ServiceManager defaultServiceManager = new ServiceManager();
+
+ protected ServiceManager ()
+ {
+ }
+
public static IService GetService (Type serviceType) {
return defaultServiceManager.FetchService (serviceType);
}
Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-06-24 02:05:41 UTC (rev 1815)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-06-24 02:57:32 UTC (rev 1816)
@@ -1,5 +1,11 @@
2004-06-23 Todd Berman <tberman at off.net>
+ * Gui/Dialogs/NewFileDialog.cs: add an event for when Ok is pressed.
+ * Commands/ProjectBrowserCommands/FolderNodeCommands.cs: fix
+ new file dialog from here.
+
+2004-06-23 Todd Berman <tberman at off.net>
+
* Gui/CompletionDatabaseWizard: removed directory, as its unused.
* Makefile.am: updated to reflect above.
Modified: trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs 2004-06-24 02:05:41 UTC (rev 1815)
+++ trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs 2004-06-24 02:57:32 UTC (rev 1816)
@@ -93,68 +93,75 @@
public class AddNewFileEvent : AbstractMenuCommand
{
+ string baseFolderPath;
+ AbstractBrowserNode node;
+ ProjectBrowserView browser;
+
public override void Run()
{
- ProjectBrowserView browser = (ProjectBrowserView)Owner;
+ browser = (ProjectBrowserView)Owner;
if (browser == null || browser.SelectedNode == null) {
return;
}
- AbstractBrowserNode node = (AbstractBrowserNode)browser.SelectedNode;
- string baseFolderPath = NewFolderEvent.SearchBasePath(node);
+ node = (AbstractBrowserNode)browser.SelectedNode;
+ baseFolderPath = NewFolderEvent.SearchBasePath(node);
if (baseFolderPath == null || baseFolderPath.Length == 0) {
return;
}
NewFileDialog nfd = new NewFileDialog ();
- if (nfd.Run() == (int)Gtk.ResponseType.Ok) {
- IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
- int count = 1;
-
- string baseName = Path.GetFileNameWithoutExtension(window.ViewContent.UntitledName);
- string extension = Path.GetExtension(window.ViewContent.UntitledName);
-
- // first try the default untitled name of the viewcontent filename
- FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService));
- string fileName = fileUtilityService.GetDirectoryNameWithSeparator(baseFolderPath) + baseName + extension;
-
- // if it is already in the project, or it does exists we try to get a name that is
- // untitledName + Numer + extension
- while (node.Project.IsFileInProject(fileName) || System.IO.File.Exists(fileName)) {
- fileName = fileUtilityService.GetDirectoryNameWithSeparator(baseFolderPath) + baseName + count.ToString() + extension;
- ++count;
- }
-
- // now we have a valid filename which we could use
- window.ViewContent.Save(fileName);
-
- ProjectFile newFileInformation = new ProjectFile(fileName, BuildAction.Compile);
-
- AbstractBrowserNode newNode = new FileNode(newFileInformation);
- newNode.ContextmenuAddinTreePath = FileNode.ProjectFileContextMenuPath;
-
- // Assume that the parent node of a 'leaf' (e.g. file) is
- // a folder or project
- AbstractBrowserNode parentNode = node;
- if (!(parentNode is ProjectBrowserNode || parentNode is DirectoryNode)) {
- parentNode = (AbstractBrowserNode)node.Parent;
- }
-
- parentNode.Nodes.Add(newNode);
- parentNode.Project.ProjectFiles.Add(newFileInformation);
- window.ViewContent.Project = parentNode.Project;
-
- newNode.EnsureVisible();
- browser.StealFocus ();
- Console.WriteLine (((Gtk.Window)WorkbenchSingleton.Workbench).Focus);
- browser.SelectedNode = newNode;
- browser.StartLabelEdit();
-
- IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IProjectService));
- projectService.SaveCombine();
+ nfd.OnOked += new EventHandler (newfileOked);
+ }
+
+ void newfileOked (object o, EventArgs e)
+ {
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+ int count = 1;
+
+ string baseName = Path.GetFileNameWithoutExtension(window.ViewContent.UntitledName);
+ string extension = Path.GetExtension(window.ViewContent.UntitledName);
+
+ // first try the default untitled name of the viewcontent filename
+ FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService));
+ string fileName = fileUtilityService.GetDirectoryNameWithSeparator(baseFolderPath) + baseName + extension;
+
+ // if it is already in the project, or it does exists we try to get a name that is
+ // untitledName + Numer + extension
+ while (node.Project.IsFileInProject(fileName) || System.IO.File.Exists(fileName)) {
+ fileName = fileUtilityService.GetDirectoryNameWithSeparator(baseFolderPath) + baseName + count.ToString() + extension;
+ ++count;
}
+
+ // now we have a valid filename which we could use
+ window.ViewContent.Save(fileName);
+
+ ProjectFile newFileInformation = new ProjectFile(fileName, BuildAction.Compile);
+
+ AbstractBrowserNode newNode = new FileNode(newFileInformation);
+ newNode.ContextmenuAddinTreePath = FileNode.ProjectFileContextMenuPath;
+
+ // Assume that the parent node of a 'leaf' (e.g. file) is
+ // a folder or project
+ AbstractBrowserNode parentNode = node;
+ if (!(parentNode is ProjectBrowserNode || parentNode is DirectoryNode)) {
+ parentNode = (AbstractBrowserNode)node.Parent;
+ }
+
+ parentNode.Nodes.Add(newNode);
+ parentNode.Project.ProjectFiles.Add(newFileInformation);
+ window.ViewContent.Project = parentNode.Project;
+
+ newNode.EnsureVisible();
+ browser.StealFocus ();
+ browser.SelectedNode = newNode;
+ browser.StartLabelEdit();
+
+ IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IProjectService));
+ projectService.SaveCombine();
+
}
}
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs 2004-06-24 02:05:41 UTC (rev 1815)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs 2004-06-24 02:57:32 UTC (rev 1816)
@@ -191,7 +191,9 @@
IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IFileService));
fileService.NewFile(filename, languageName, content);
}
-
+
+ public event EventHandler OnOked;
+
void OpenEvent(object sender, EventArgs e)
{
TreeModel mdl;
@@ -224,6 +226,8 @@
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.SelectWindow();
}
+ if (OnOked != null)
+ OnOked (null, null);
}
}
More information about the Monodevelop-patches-list
mailing list