[mapguide-commits] r6500 - in trunk/Tools/Maestro: Maestro.Base/UI Maestro.Editors/Diff OSGeo.MapGuide.MaestroAPI/Resource/Comparison

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Feb 12 06:04:04 EST 2012


Author: jng
Date: 2012-02-12 03:04:04 -0800 (Sun, 12 Feb 2012)
New Revision: 6500

Modified:
   trunk/Tools/Maestro/Maestro.Base/UI/DirtyStateConfirmationDialog.cs
   trunk/Tools/Maestro/Maestro.Editors/Diff/TextDiffView.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/BinaryData.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/CharData.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/DiffEngine.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/TextFile.cs
Log:
#1950: Some small refactorings for the diff engine
 - Use generics instead of ArrayList
 - Rename some classes

Modified: trunk/Tools/Maestro/Maestro.Base/UI/DirtyStateConfirmationDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/DirtyStateConfirmationDialog.cs	2012-02-12 10:40:54 UTC (rev 6499)
+++ trunk/Tools/Maestro/Maestro.Base/UI/DirtyStateConfirmationDialog.cs	2012-02-12 11:04:04 UTC (rev 6500)
@@ -1,21 +1,21 @@
-#region Disclaimer / License
-// Copyright (C) 2012, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
+#region Disclaimer / License
+// Copyright (C) 2012, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
 #endregion
 using System;
 using System.Collections.Generic;
@@ -62,8 +62,8 @@
 
         private void btnDiff_Click(object sender, EventArgs e)
         {
-            DiffList_TextFile sLF = null;
-            DiffList_TextFile dLF = null;
+            TextFileDiffList sLF = null;
+            TextFileDiffList dLF = null;
             string sourceFile = Path.GetTempFileName();
             string targetFile = Path.GetTempFileName();
             try
@@ -75,8 +75,8 @@
                     File.WriteAllText(sourceFile, source.ReadToEnd());
                     File.WriteAllText(targetFile, target.ReadToEnd());
 
-                    sLF = new DiffList_TextFile(sourceFile);
-                    dLF = new DiffList_TextFile(targetFile);
+                    sLF = new TextFileDiffList(sourceFile);
+                    dLF = new TextFileDiffList(targetFile);
                 }
             }
             catch (Exception ex)
@@ -98,8 +98,9 @@
                 DiffEngine de = new DiffEngine();
                 time = de.ProcessDiff(sLF, dLF, DiffEngineLevel.SlowPerfect);
 
-                ArrayList rep = de.DiffReport();
+                var rep = de.DiffReport();
                 TextDiffView dlg = new TextDiffView(sLF, dLF, rep, time);
+                dlg.Text += " - " + _edSvc.ResourceID;
                 dlg.ShowDialog();
                 dlg.Dispose();
             }

Modified: trunk/Tools/Maestro/Maestro.Editors/Diff/TextDiffView.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Diff/TextDiffView.cs	2012-02-12 10:40:54 UTC (rev 6499)
+++ trunk/Tools/Maestro/Maestro.Editors/Diff/TextDiffView.cs	2012-02-12 11:04:04 UTC (rev 6500)
@@ -41,11 +41,9 @@
             InitializeComponent();
         }
 
-        public TextDiffView(DiffList_TextFile source, DiffList_TextFile destination, ArrayList DiffLines, double seconds)
+        public TextDiffView(TextFileDiffList source, TextFileDiffList destination, List<DiffResultSpan> DiffLines, double seconds)
             : this()
         {
-            //this.Text = string.Format("Results: {0} secs.",seconds.ToString("#0.00"));
-
             ListViewItem lviS;
             ListViewItem lviD;
             int cnt = 1;

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/BinaryData.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/BinaryData.cs	2012-02-12 10:40:54 UTC (rev 6499)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/BinaryData.cs	2012-02-12 11:04:04 UTC (rev 6500)
@@ -29,11 +29,11 @@
 
 namespace OSGeo.MapGuide.MaestroAPI.Resource.Comparison
 {
-    public class DiffList_BinaryFile : IDiffList
+    public class BinaryFileDiffList : IDiffList
     {
         private byte[] _byteList;
 
-        public DiffList_BinaryFile(string fileName)
+        public BinaryFileDiffList(string fileName)
         {
             FileStream fs = null;
             BinaryReader br = null;

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/CharData.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/CharData.cs	2012-02-12 10:40:54 UTC (rev 6499)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/CharData.cs	2012-02-12 11:04:04 UTC (rev 6500)
@@ -28,11 +28,11 @@
 
 namespace OSGeo.MapGuide.MaestroAPI.Resource.Comparison
 {
-    public class DiffList_CharData : IDiffList
+    public class CharDataDiffList : IDiffList
     {
         private char[] _charList;
 
-        public DiffList_CharData(string charData)
+        public CharDataDiffList(string charData)
         {
             _charList = charData.ToCharArray();
         }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/DiffEngine.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/DiffEngine.cs	2012-02-12 10:40:54 UTC (rev 6499)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/DiffEngine.cs	2012-02-12 11:04:04 UTC (rev 6500)
@@ -41,7 +41,6 @@
         Matched = 1,
         NoMatch = -1,
         Unknown = -2
-
     }
 
     internal class DiffState
@@ -75,6 +74,7 @@
                 return len;
             }
         }
+
         public DiffStatus Status
         {
             get
@@ -266,7 +266,7 @@
     {
         private IDiffList _source;
         private IDiffList _dest;
-        private ArrayList _matchList;
+        private List<DiffResultSpan> _matchList;
 
         private DiffEngineLevel _level;
 
@@ -437,7 +437,7 @@
             DateTime dt = DateTime.Now;
             _source = source;
             _dest = destination;
-            _matchList = new ArrayList();
+            _matchList = new List<DiffResultSpan>();
 
             int dcount = _dest.Count();
             int scount = _source.Count();
@@ -455,7 +455,7 @@
 
 
         private bool AddChanges(
-            ArrayList report,
+            List<DiffResultSpan> report,
             int curDest,
             int nextDest,
             int curSource,
@@ -502,9 +502,9 @@
             return retval;
         }
 
-        public ArrayList DiffReport()
+        public List<DiffResultSpan> DiffReport()
         {
-            ArrayList retval = new ArrayList();
+            var retval = new List<DiffResultSpan>();
             int dcount = _dest.Count();
             int scount = _source.Count();
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/TextFile.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/TextFile.cs	2012-02-12 10:40:54 UTC (rev 6499)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Comparison/TextFile.cs	2012-02-12 11:04:04 UTC (rev 6500)
@@ -51,14 +51,14 @@
     }
 
 
-    public class DiffList_TextFile : IDiffList
+    public class TextFileDiffList : IDiffList
     {
         private const int MaxLineLength = 1024;
-        private ArrayList _lines;
+        private List<TextLine> _lines;
 
-        public DiffList_TextFile(string fileName)
+        public TextFileDiffList(string fileName)
         {
-            _lines = new ArrayList();
+            _lines = new List<TextLine>();
             using (StreamReader sr = new StreamReader(fileName))
             {
                 String line;
@@ -85,7 +85,7 @@
 
         public IComparable GetByIndex(int index)
         {
-            return (TextLine)_lines[index];
+            return _lines[index];
         }
 
         #endregion



More information about the mapguide-commits mailing list