diff --git a/Wreck/Controller/AbstractController.cs b/Wreck/Controller/AbstractController.cs index fbd1755..a1a8a96 100644 --- a/Wreck/Controller/AbstractController.cs +++ b/Wreck/Controller/AbstractController.cs @@ -22,7 +22,7 @@ public abstract class AbstractController : IController private static readonly StatisticsCollector STATS = StatisticsCollector.Instance; - private FileSystemInfo startPath; + protected FileSystemInfo startPath; private readonly WreckService service; @@ -59,7 +59,7 @@ public virtual void Error() Console.Error.WriteLine(startPath + " is invalid."); } - public void Start(string startPath) + public virtual void Start(string startPath) { if(Directory.Exists(startPath)) this.startPath = new DirectoryInfo(startPath); @@ -75,7 +75,7 @@ public void Start(string startPath) } } - public void Stop() + public virtual void Stop() { LOG.Info("Stopping and cleaning up..."); try diff --git a/WreckGui/Controller/GuiController.cs b/WreckGui/Controller/GuiController.cs index 8bbc648..c7700d0 100644 --- a/WreckGui/Controller/GuiController.cs +++ b/WreckGui/Controller/GuiController.cs @@ -2,16 +2,18 @@ using System; using System.Collections.Generic; using System.IO; -using System.Windows.Forms; using Java.Beans; using Javax.Swing; using log4net; using Wreck.Entity; using Wreck.IO; +using Wreck.IO.Reader; using Wreck.IO.Task; +using Wreck.IO.Writer; using Wreck.Model; using Wreck.Resources; +using Wreck.Time; using Wreck.Util.Logging; using WreckGui.View; @@ -54,14 +56,54 @@ public GuiWorker Worker set { worker = value; } } + /* + public override void Start(string startPath) + { + try + { + this.startPath = TimestampFormatter.IsValidPath(startPath); + Init(); + View.GetMain().Show(); + } + catch(Exception e) + { + LOG.ErrorFormat("Invalid path: {0}", e.Message); + Application.Exit(); + } + } + + public override void Stop() + { + LOG.Info("Stopping and cleaning up..."); + try + { + if(WriterFactory.IsInitialized()) + { + LOG.Info("Closing writers..."); + WriterFactory.Instance.Dispose(); + } + + if(ReaderFactory.IsInitialized()) { + LOG.Info("Closing readers..."); + ReaderFactory.Instance.Dispose(); + } + } + catch (Exception e) + { + LOG.Error(e.StackTrace); + } + } + */ + + private void Init() + { + string title = startPath.FullName + " - " + R.Strings.AppTitle; + + } + public override void Error() { - MessageBox.Show( - StartPath + " is invalid.", - "Invalid path", - MessageBoxButtons.OK, - MessageBoxIcon.Error); - Application.Exit(); + View.GetMain().Error(StartPath.FullName); } private void PrefillPaths() @@ -108,7 +150,7 @@ public override void Run(CorrectionMode mode, FileSystemInfo fsi) // FIXME: To check GUI control checkbox and textbox DateTime customDateTime = DateTime.Now; - + ITask task = Service.Run(fsi, mode, sources, corrections, customDateTime); PropertyChangeListener propertyChangeListener = new ProgressPropertyChangeListener(this); @@ -145,13 +187,13 @@ public void PropertyChange(PropertyChangeEvent evt) else if (R.Strings.PropertyProgress.Equals(evt.PropertyName)) { int progress = (int)evt.NewValue; - LOG.InfoFormat("Progress: {0}% MessageLoop: {1}", progress, Application.MessageLoop); + LOG.InfoFormat("Progress: {0}%", progress); controller.View.GetMain().SetProgress(progress); } else if (R.Strings.PropertyVisits.Equals(evt.PropertyName)) { FileVisit visit = (FileVisit) evt.NewValue; - LOG.InfoFormat("Progress: {0}% - Visit: {1} MessageLoop: {2}", visit.Progress, visit.File.Name, Application.MessageLoop); + LOG.InfoFormat("Progress: {0}% - Visit: {1}", visit.Progress, visit.File.Name); controller.View.GetMain().SetProgress(visit.Progress); controller.View.GetMain().SetAction(visit); } diff --git a/WreckGui/MainForm.cs b/WreckGui/MainForm.cs index 83e39e4..610d8a9 100644 --- a/WreckGui/MainForm.cs +++ b/WreckGui/MainForm.cs @@ -308,5 +308,15 @@ public void Done() rootNode.ExpandAll(); toolStripProgressBar.Visible = false; } + + public void Error(string startPath) + { + MessageBox.Show( + startPath + " is invalid.", + "Invalid path", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + Application.Exit(); + } } } diff --git a/WreckGui/Model/GuiModel.cs b/WreckGui/Model/GuiModel.cs index e464081..830db78 100644 --- a/WreckGui/Model/GuiModel.cs +++ b/WreckGui/Model/GuiModel.cs @@ -1,5 +1,6 @@  using System; +using System.Collections.Generic; using Java.Beans; using Javax.Swing; using Wreck.Entity; @@ -17,14 +18,10 @@ public class GuiModel : IModel private readonly SampleTableModel tableModel; // private readonly ButtonModel metadataModel; -// private readonly IDictionary sourceModel; -// private readonly Document dateTimeDocument; -// private readonly SpinnerNumberModel customDateTimeYearModel; -// private readonly SpinnerNumberModel customDateTimeMonthModel; -// private readonly SpinnerNumberModel customDateTimeDayModel; -// private readonly SpinnerDateModel customDateTimeModel; + private IDictionary sourceModel; + private DateTime customDateTimeModel; -// private readonly IDictionary correctionModel; + private IDictionary correctionModel; // private readonly DefaultButtonModel backupModel; // private readonly DefaultButtonModel restoreModel; @@ -48,6 +45,10 @@ public GuiModel() this.propertyChangeSupport = new PropertyChangeSupport(this); this.tableModel = new SampleTableModel(typeof(FileBean)); + this.sourceModel = new Dictionary(); + this.customDateTimeModel = new DateTime(); + this.correctionModel = new Dictionary(); + this.fileStatisticsTableModel = new SampleTableModel(typeof(FileStatisticsBean)); this.metadataStatisticsTableModel = new SampleTableModel(typeof(MetadataStatisticsBean)); this.extensionStatisticsTableModel = new SampleTableModel(typeof(ExtensionStatisticsBean)); @@ -55,6 +56,24 @@ public GuiModel() this.scanningProgressModel = new DefaultBoundedRangeModel(); } + public IDictionary SourceModel + { + get { return sourceModel; } + set { sourceModel = value; } + } + + public DateTime CustomDateTimeModel + { + get { return customDateTimeModel; } + set { customDateTimeModel = value; } + } + + public IDictionary CorrectionModel + { + get { return correctionModel; } + set { correctionModel = value; } + } + public SampleTableModel TableModel { get { return tableModel; }