[longomatch/redesign2: 120/140] Add method to update templates and use it where needed



commit ba3e304eb65f7f68ced3fc598353a1217fb91a12
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Apr 10 18:53:55 2011 +0200

    Add method to update templates and use it where needed

 LongoMatch/Gui/Component/TemplatesEditorBase.cs |    2 +-
 LongoMatch/Gui/Dialog/TemplatesManager.cs       |    2 +-
 LongoMatch/Services/TemplatesService.cs         |    8 ++++++++
 3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/TemplatesEditorBase.cs b/LongoMatch/Gui/Component/TemplatesEditorBase.cs
index 3b6a25b..84ce908 100644
--- a/LongoMatch/Gui/Component/TemplatesEditorBase.cs
+++ b/LongoMatch/Gui/Component/TemplatesEditorBase.cs
@@ -166,7 +166,7 @@ namespace LongoMatch.Gui.Component
 					                                    );
 					if(md.Run() == (int)ResponseType.Yes){
 						Template.Name = dialog.Text;
-						provider.Save (Template);
+						provider.Update (Template);
 					}
 					md.Destroy();
 				}
diff --git a/LongoMatch/Gui/Dialog/TemplatesManager.cs b/LongoMatch/Gui/Dialog/TemplatesManager.cs
index 6501797..5d1a01e 100644
--- a/LongoMatch/Gui/Dialog/TemplatesManager.cs
+++ b/LongoMatch/Gui/Dialog/TemplatesManager.cs
@@ -134,7 +134,7 @@ namespace LongoMatch.Gui.Dialog
 		
 		private void SaveTemplate() {
 			selectedTemplate = templatesWidget.Template;
-			templatesProvider.Save(selectedTemplate);
+			templatesProvider.Update(selectedTemplate);
 		}
 
 		private void SelectTemplate(string name) {
diff --git a/LongoMatch/Services/TemplatesService.cs b/LongoMatch/Services/TemplatesService.cs
index f46cbb0..1086ac1 100644
--- a/LongoMatch/Services/TemplatesService.cs
+++ b/LongoMatch/Services/TemplatesService.cs
@@ -210,6 +210,14 @@ namespace LongoMatch.Services
 			template.Save(filename);
 		}
 		
+		public void Update (ITemplate<U> template) {
+			string filename =  GetPath(template.Name);
+			
+			Log.Information("Updating template " + filename);
+			/* Don't cach the Exception here to chain it up */
+			template.Save(filename);
+		}
+		
 		public void Copy(string orig, string copy) {
 			if (File.Exists(copy)) {
 				throw new Exception (Catalog.GetString("A template already exixts with " +



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]