[Monodevelop-patches-list] r1817 - in trunk/MonoDevelop/src/Main/Base: . Commands Commands/ProjectBrowserCommands Gui/Dialogs
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Wed Jun 23 23:53:35 EDT 2004
Author: tberman
Date: 2004-06-23 23:53:34 -0400 (Wed, 23 Jun 2004)
New Revision: 1817
Modified:
trunk/MonoDevelop/src/Main/Base/ChangeLog
trunk/MonoDevelop/src/Main/Base/Commands/FileCommands.cs
trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/CombineNodeCommands.cs
trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs
Log:
use the new dispatcher service, now it is all async and shit.
Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-06-24 02:57:32 UTC (rev 1816)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-06-24 03:53:34 UTC (rev 1817)
@@ -1,3 +1,10 @@
+2004-06-24 Todd Berman <tberman at off.net>
+
+ * Gui/Dialogs/NewSolutionDialog.cs:
+ * Commands/ProjectBrowserCommands/CombineNodeCommands.cs:
+ * Commands/FileCommands.cs: convert to using new async dispatcher
+ stuff.
+
2004-06-23 Todd Berman <tberman at off.net>
* Gui/Dialogs/NewFileDialog.cs: add an event for when Ok is pressed.
Modified: trunk/MonoDevelop/src/Main/Base/Commands/FileCommands.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Commands/FileCommands.cs 2004-06-24 02:57:32 UTC (rev 1816)
+++ trunk/MonoDevelop/src/Main/Base/Commands/FileCommands.cs 2004-06-24 03:53:34 UTC (rev 1817)
@@ -26,10 +26,7 @@
{
public override void Run()
{
- IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IProjectService));
-
NewProjectDialog npdlg = new NewProjectDialog(true);
- npdlg.Run ();
}
}
Modified: trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/CombineNodeCommands.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/CombineNodeCommands.cs 2004-06-24 02:57:32 UTC (rev 1816)
+++ trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/CombineNodeCommands.cs 2004-06-24 03:53:34 UTC (rev 1817)
@@ -30,61 +30,77 @@
{
public class AddNewProjectToCombine : AbstractMenuCommand
{
+ NewProjectDialog npdlg;
+ ProjectBrowserView browser;
+ CombineBrowserNode node;
+ MessageService msg;
+ IProjectService projectService;
+
public override void Run()
{
- IProjectService projectService = (IProjectService)ServiceManager.GetService(typeof(IProjectService));
- ProjectBrowserView browser = (ProjectBrowserView)Owner;
- CombineBrowserNode node = browser.SelectedNode as CombineBrowserNode;
- MessageService msg = (MessageService)ServiceManager.GetService (typeof (MessageService));
+ projectService = (IProjectService)ServiceManager.GetService(typeof(IProjectService));
+ browser = (ProjectBrowserView)Owner;
+ node = browser.SelectedNode as CombineBrowserNode;
+ msg = (MessageService)ServiceManager.GetService (typeof (MessageService));
if (node != null) {
- NewProjectDialog npdlg = new NewProjectDialog(false);
- if (npdlg.Run() == (int)Gtk.ResponseType.Ok) {
- //System.Console.WriteLine("inside if");
- try
- {
- int newNodeIndex = node.Nodes.Add(ProjectBrowserView.BuildProjectTreeNode((IProject)node.Combine.AddEntry(npdlg.NewProjectLocation)));
- projectService.SaveCombine();
- // expand to the new node
- node.Nodes[newNodeIndex].Expand();
- }
- catch
- {
- msg.ShowError (GettextCatalog.GetString ("Invalid Project File"));
- }
- }
- }
- //System.Console.WriteLine("end");
+ npdlg = new NewProjectDialog(false);
+ npdlg.OnOked += new EventHandler (Oked);
+ }
}
+
+ void Oked (object o, EventArgs e)
+ {
+ try
+ {
+ int newNodeIndex = node.Nodes.Add(ProjectBrowserView.BuildProjectTreeNode((IProject)node.Combine.AddEntry(npdlg.NewProjectLocation)));
+ projectService.SaveCombine();
+ // expand to the new node
+ node.Nodes[newNodeIndex].Expand();
+ }
+ catch
+ {
+ msg.ShowError (GettextCatalog.GetString ("Invalid Project File"));
+ }
+ }
}
public class AddNewCombineToCombine : AbstractMenuCommand
{
+ IProjectService projectService;
+ ProjectBrowserView browser;
+ CombineBrowserNode node;
+ MessageService msg;
+ NewProjectDialog npdlg;
+
public override void Run()
{
- IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IProjectService));
- ProjectBrowserView browser = (ProjectBrowserView)Owner;
- CombineBrowserNode node = browser.SelectedNode as CombineBrowserNode;
- MessageService msg = (MessageService)ServiceManager.GetService (typeof (MessageService));
+ projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IProjectService));
+ browser = (ProjectBrowserView)Owner;
+ node = browser.SelectedNode as CombineBrowserNode;
+ msg = (MessageService)ServiceManager.GetService (typeof (MessageService));
if (node != null) {
- NewProjectDialog npdlg = new NewProjectDialog(false);
- if (npdlg.Run() == (int)Gtk.ResponseType.Ok) {
- try
- {
- int newNodeIndex = node.Nodes.Add(ProjectBrowserView.BuildCombineTreeNode((Combine)node.Combine.AddEntry(npdlg.NewCombineLocation)));
- projectService.SaveCombine();
-
- // expand to the new node
- node.Nodes[newNodeIndex].Expand();
- }
- catch
- {
- msg.ShowError (GettextCatalog.GetString ("Invalid Solution File"));
- }
- }
+ npdlg = new NewProjectDialog(false);
+ npdlg.OnOked += new EventHandler (Oked);
}
}
+
+ void Oked (object o, EventArgs e)
+ {
+ try
+ {
+ int newNodeIndex = node.Nodes.Add(ProjectBrowserView.BuildCombineTreeNode((Combine)node.Combine.AddEntry(npdlg.NewCombineLocation)));
+ projectService.SaveCombine();
+
+ // expand to the new node
+ node.Nodes[newNodeIndex].Expand();
+ }
+ catch
+ {
+ msg.ShowError (GettextCatalog.GetString ("Invalid Solution File"));
+ }
+ }
}
public class AddProjectToCombine : AbstractMenuCommand
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs 2004-06-24 02:57:32 UTC (rev 1816)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs 2004-06-24 03:53:34 UTC (rev 1817)
@@ -54,25 +54,16 @@
StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
PropertyService propertyService = (PropertyService)ServiceManager.GetService(typeof(PropertyService));
MessageService messageService = (MessageService)ServiceManager.GetService(typeof(MessageService));
+ DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
bool openCombine;
public NewProjectDialog (bool openCombine)
{
this.openCombine = openCombine;
new Glade.XML (null, "Base.glade", "NewProjectDialog", null).Autoconnect (this);
- dialog.TransientFor = (Window) WorkbenchSingleton.Workbench;
-
- InitializeComponents();
- InitializeTemplates();
- InitializeView();
+ dialog.TransientFor = (Window) WorkbenchSingleton.Workbench;
- catStore.SetSortColumnId (0, SortType.Ascending);
-
- TreeIter first;
- if (catStore.GetIterFirst (out first))
- lst_template_types.Selection.SelectIter (first);
-
- dialog.ShowAll ();
+ dispatcher.BackgroundDispatch (new MessageHandler (InitializeTemplates));
}
void InitializeView()
@@ -84,6 +75,11 @@
break;
}
}*/
+ catStore.SetSortColumnId (0, SortType.Ascending);
+ TreeIter first;
+ if (catStore.GetIterFirst (out first))
+ lst_template_types.Selection.SelectIter (first);
+ dialog.ShowAll ();
}
void InsertCategories (TreeIter node, ArrayList catarray)
@@ -121,6 +117,7 @@
// titem.Selected = true;
alltemplates.Add(titem);
}
+ dispatcher.GuiDispatch (new MessageHandler (InitializeComponents));
}
void CategoryChange(object sender, EventArgs e)
@@ -231,76 +228,45 @@
chk_combine_directory.Active);
if (TemplateView.CurrentlySelected != null && name.Length != 0) {
- ProjectTemplate item = (ProjectTemplate) TemplateView.CurrentlySelected;
-
- try
- {
- System.IO.Directory.CreateDirectory (ProjectSolution);
- }
- catch (UnauthorizedAccessException accessException)
- {
- messageService.ShowError (String.Format (GettextCatalog.GetString ("You do not have permission to create to {0}"), ProjectSolution));
- return;
- }
-
- ProjectCreateInformation cinfo = new ProjectCreateInformation ();
-
- cinfo.CombinePath = ProjectLocation;
- cinfo.ProjectBasePath = ProjectSolution;
-// cinfo.Description = stringParserService.Parse(item.Template.Description);
-
- cinfo.ProjectName = name;
-// cinfo.ProjectTemplate = item.Template;
-
- NewCombineLocation = item.CreateProject (cinfo);
- if (NewCombineLocation == null || NewCombineLocation.Length == 0)
- return;
-
- if (openCombine)
- item.OpenCreatedCombine();
-
- // TODO :: THIS DOESN'T WORK !!!
- NewProjectLocation = System.IO.Path.ChangeExtension(NewCombineLocation, ".prjx");
-
- //DialogResult = DialogResult.OK;
- dialog.Respond(Gtk.ResponseType.Ok);
- dialog.Hide ();
-
-#if false // from .98
- if (item.Template.LanguageName != null && item.Template.LanguageName.Length > 0) {
-
- }
-
- if (item.Template.WizardPath != null) {
- IProperties customizer = new DefaultProperties();
- customizer.SetProperty("Template", item.Template);
- customizer.SetProperty("Creator", this);
- WizardDialog wizard = new WizardDialog("Project Wizard", customizer, item.Template.WizardPath);
- if (wizard.ShowDialog() == DialogResult.OK) {
- DialogResult = DialogResult.OK;
- }
- }
-
- NewCombineLocation = fileUtilityService.GetDirectoryNameWithSeparator(ProjectLocation) + ((TextBox)ControlDictionary["nameTextBox"]).Text + ".cmbx";
-
- if (File.Exists(NewCombineLocation)) {
- DialogResult result = MessageBox.Show(String.Format (Gettext.GetString ("Combine file {0} already exists, do you want to overwrite\nthe existing file ?"), NewCombineLocation), Gettext.GetString ("File already exists"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
- switch(result) {
- case DialogResult.Yes:
- cmb.SaveCombine(NewCombineLocation);
- break;
- case DialogResult.No:
- break;
- }
- } else {
- cmb.SaveCombine(NewCombineLocation);
- }
- } else {
- MessageBox.Show(GettextCatalog.GetString ("The project or source entry is empty, can't create project."), GettextCatalog.GetString ("Warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ ProjectTemplate item = (ProjectTemplate) TemplateView.CurrentlySelected;
+
+ try
+ {
+ System.IO.Directory.CreateDirectory (ProjectSolution);
}
-#endif
+ catch (UnauthorizedAccessException accessException)
+ {
+ messageService.ShowError (String.Format (GettextCatalog.GetString ("You do not have permission to create to {0}"), ProjectSolution));
+ return;
+ }
+
+ ProjectCreateInformation cinfo = new ProjectCreateInformation ();
+
+ cinfo.CombinePath = ProjectLocation;
+ cinfo.ProjectBasePath = ProjectSolution;
+// cinfo.Description = stringParserService.Parse(item.Template.Description);
+
+ cinfo.ProjectName = name;
+// cinfo.ProjectTemplate = item.Template;
+
+ NewCombineLocation = item.CreateProject (cinfo);
+ if (NewCombineLocation == null || NewCombineLocation.Length == 0)
+ return;
+
+ if (openCombine)
+ item.OpenCreatedCombine();
+
+ // TODO :: THIS DOESN'T WORK !!!
+ NewProjectLocation = System.IO.Path.ChangeExtension(NewCombineLocation, ".prjx");
+
+ //DialogResult = DialogResult.OK;
+ if (OnOked != null)
+ OnOked (null, null);
+ dialog.Destroy ();
}
}
+
+ public event EventHandler OnOked;
// icon view event handlers
void SelectedIndexChange(object sender, EventArgs e)
@@ -315,14 +281,9 @@
void cancelClicked (object o, EventArgs e)
{
- dialog.Hide ();
+ dialog.Destroy ();
}
- public int Run ()
- {
- return dialog.Run ();
- }
-
void ActivateIfReady ()
{
if (TemplateView.CurrentlySelected == null || txt_name.Text.Trim () == "")
@@ -332,8 +293,7 @@
}
void InitializeComponents()
- {
-
+ {
catStore = new Gtk.TreeStore (typeof (string), typeof (Category));
lst_template_types.Model = catStore;
lst_template_types.WidthRequest = 160;
@@ -365,6 +325,7 @@
TemplateView.IconSelected += new EventHandler(SelectedIndexChange);
TemplateView.IconDoubleClicked += new EventHandler(OpenEvent);
entry_location.PathChanged += new EventHandler (PathChanged);
+ InitializeView ();
}
/// <summary>
More information about the Monodevelop-patches-list
mailing list