[longomatch/redesign] Use the template base class for serialization



commit aae30d32716e6c07d5eb76d44c218fa183c93bdc
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Dec 22 01:31:53 2010 +0100

    Use the template base class for serialization

 LongoMatch/Gui/Component/ProjectDetailsWidget.cs  |    6 +-
 LongoMatch/Gui/Component/ProjectTemplateWidget.cs |    9 +-
 LongoMatch/Gui/Dialog/TemplatesEditor.cs          |   14 ++--
 LongoMatch/IO/SectionsReader.cs                   |  103 ---------------------
 LongoMatch/IO/SectionsWriter.cs                   |  101 --------------------
 LongoMatch/LongoMatch.mdp                         |    4 +-
 LongoMatch/Main.cs                                |    3 +-
 LongoMatch/Makefile.am                            |    2 -
 8 files changed, 15 insertions(+), 227 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/ProjectDetailsWidget.cs b/LongoMatch/Gui/Component/ProjectDetailsWidget.cs
index ad86aa1..81258c6 100644
--- a/LongoMatch/Gui/Component/ProjectDetailsWidget.cs
+++ b/LongoMatch/Gui/Component/ProjectDetailsWidget.cs
@@ -414,8 +414,7 @@ namespace LongoMatch.Gui.Component
 				i++;
 			}
 			tagscombobox.Active = index;
-			var reader = new CategoriesReader(System.IO.Path.Combine(MainClass.TemplatesDir(),SectionsFile));
-			Categories = reader.GetCategories();
+			Categories = Categories.Load(System.IO.Path.Combine(MainClass.TemplatesDir(),SectionsFile));
 		}
 
 		private void FillTeamsTemplate() {
@@ -537,8 +536,7 @@ namespace LongoMatch.Gui.Component
 
 		protected virtual void OnCombobox1Changed(object sender, System.EventArgs e)
 		{
-			var reader = new CategoriesReader(System.IO.Path.Combine(MainClass.TemplatesDir(),SectionsFile));
-			Categories = reader.GetCategories();
+			Categories = Categories.Load(System.IO.Path.Combine(MainClass.TemplatesDir(),SectionsFile));
 		}
 
 		protected virtual void OnVisitorcomboboxChanged(object sender, System.EventArgs e)
diff --git a/LongoMatch/Gui/Component/ProjectTemplateWidget.cs b/LongoMatch/Gui/Component/ProjectTemplateWidget.cs
index 6e01435..1df0aaa 100644
--- a/LongoMatch/Gui/Component/ProjectTemplateWidget.cs
+++ b/LongoMatch/Gui/Component/ProjectTemplateWidget.cs
@@ -167,10 +167,6 @@ namespace LongoMatch.Gui.Component
 			Edited = true;
 		}
 		
-		private void SaveTemplate(string templateName){
-			CategoriesWriter.UpdateTemplate(templateName+".sct", Categories);
-		}
-
 		protected virtual void OnNewAfter(object sender, EventArgs args) {
 			AddCategory(categories.CategoriesList.IndexOf(selectedCategories[0])+1);
 		}
@@ -233,10 +229,11 @@ namespace LongoMatch.Gui.Component
 					                                                       "Do you want to overwrite it ?")
 					                                   );
 					if (md.Run() == (int)ResponseType.Yes)
-						SaveTemplate(dialog.Text);
+						Categories.Save(dialog.Text);
 					md.Destroy();
 				}					
-				else SaveTemplate(dialog.Text);
+				else
+					Categories.Save(dialog.Text);
 			}	
 			dialog.Destroy();
 		}
diff --git a/LongoMatch/Gui/Dialog/TemplatesEditor.cs b/LongoMatch/Gui/Dialog/TemplatesEditor.cs
index ba747fd..468a9d0 100644
--- a/LongoMatch/Gui/Dialog/TemplatesEditor.cs
+++ b/LongoMatch/Gui/Dialog/TemplatesEditor.cs
@@ -21,7 +21,6 @@
 using System;
 using System.Collections.Generic;
 using Gtk;
-using LongoMatch.IO;
 using LongoMatch.Store.Templates;
 using Mono.Unix;
 
@@ -107,14 +106,14 @@ namespace LongoMatch.Gui.Dialog
 		}
 
 		private void UpdateCategories() {
-			CategoriesReader sr = new CategoriesReader(templateName);
-			selectedCategoriesTemplate = sr.GetCategories();
-			SetCategoriesTemplate(sr.GetCategories());
+			selectedCategoriesTemplate = Categories.Load(templateName);
+			SetCategoriesTemplate(selectedCategoriesTemplate);
 			SetSensitive(true);
 		}
 
 		private void UpdateTeamTemplate() {
-			SetTeamTemplate(TeamTemplate.Load(templateName));
+			selectedTeamTemplate = TeamTemplate.Load(templateName);
+			SetTeamTemplate(selectedTeamTemplate);
 			SetSensitive(true);
 		}
 
@@ -148,7 +147,7 @@ namespace LongoMatch.Gui.Dialog
 		private void SaveTemplate() {
 			if (useType == UseType.CategoriesTemplate) {
 				selectedCategoriesTemplate = sectionspropertieswidget1.Categories;
-				CategoriesWriter.UpdateTemplate(templateName,selectedCategoriesTemplate);
+				selectedCategoriesTemplate.Save(templateName);
 			}
 			else {
 				selectedTeamTemplate = teamtemplatewidget1.TeamTemplate;
@@ -215,7 +214,8 @@ namespace LongoMatch.Gui.Dialog
 						System.IO.File.Copy(System.IO.Path.Combine(MainClass.TemplatesDir(),ed.SelectedTemplate),
 						                    System.IO.Path.Combine(MainClass.TemplatesDir(),name+fileExtension));
 				else if (useType == UseType.CategoriesTemplate){
-					CategoriesWriter.CreateNewTemplate(name+fileExtension);
+					Categories cat = Categories.DefaultTemplate();
+					cat.Save(name+fileExtension);
 				}
 				else {
 					TeamTemplate tt = TeamTemplate.DefaultTemplate(count);
diff --git a/LongoMatch/LongoMatch.mdp b/LongoMatch/LongoMatch.mdp
index 9b1388c..5ea01ef 100644
--- a/LongoMatch/LongoMatch.mdp
+++ b/LongoMatch/LongoMatch.mdp
@@ -158,9 +158,6 @@
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.EndCaptureDialog.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.BusyDialog.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/TreeView/ListTreeViewBase.cs" />
-    <File subtype="Code" buildaction="Compile" name="IO/XMLReader.cs" />
-    <File subtype="Code" buildaction="Compile" name="IO/SectionsReader.cs" />
-    <File subtype="Code" buildaction="Compile" name="IO/SectionsWriter.cs" />
     <File subtype="Directory" buildaction="Compile" name="Store" />
     <File subtype="Directory" buildaction="Compile" name="DB" />
     <File subtype="Directory" buildaction="Compile" name="DB" />
@@ -196,6 +193,7 @@
     <File subtype="Code" buildaction="Compile" name="Store/Templates/TagsTemplate.cs" />
     <File subtype="Code" buildaction="Compile" name="Store/Templates/TeamTemplate.cs" />
     <File subtype="Code" buildaction="Compile" name="Store/Templates/Template.cs" />
+    <File subtype="Code" buildaction="Compile" name="IO/XMLReader.cs" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index 25ffdaa..6dd3ba7 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -139,7 +139,8 @@ namespace LongoMatch
 			string fConfig;
 			fConfig = System.IO.Path.Combine(TemplatesDir(),"default.sct");
 			if (!System.IO.File.Exists(fConfig)) {
-				CategoriesWriter.CreateNewTemplate("default.sct");
+				Categories cat = Categories.DefaultTemplate();
+				cat.Save("default.sct");
 			}
 
 			fConfig = System.IO.Path.Combine(TemplatesDir(),"default.tem");
diff --git a/LongoMatch/Makefile.am b/LongoMatch/Makefile.am
index faaa255..fee9477 100644
--- a/LongoMatch/Makefile.am
+++ b/LongoMatch/Makefile.am
@@ -178,8 +178,6 @@ FILES = \
 	Handlers/HotKeysManager.cs \
 	Handlers/VideoDrawingsManager.cs\
 	IO/CSVExport.cs \
-	IO/SectionsReader.cs \
-	IO/SectionsWriter.cs \
 	IO/XMLReader.cs \
 	Main.cs \
 	Playlist/IPlayList.cs \



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