From 24bf3af7d62d1c7fd533889e22cec6dcdc709288 Mon Sep 17 00:00:00 2001 From: gyk4j <147011991+gyk4j@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:42:40 +0800 Subject: [PATCH] Add running state, tree expansion and statistics update --- JShim/Javax/Swing/SwingWorker.cs | 2 +- WreckCli/Logging/Logger.cs | 1 + WreckGui/Controller/GuiController.cs | 22 +++++++++++++++++++++- WreckGui/MainForm.cs | 10 ++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/JShim/Javax/Swing/SwingWorker.cs b/JShim/Javax/Swing/SwingWorker.cs index d226c22..152efa2 100644 --- a/JShim/Javax/Swing/SwingWorker.cs +++ b/JShim/Javax/Swing/SwingWorker.cs @@ -150,12 +150,12 @@ public void Execute() backgroundWorker.WorkerReportsProgress = true; backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.RunWorkerAsync(); + SetState(StateValue.Started); } } void DoWork(object sender, DoWorkEventArgs e) { - state = StateValue.Started; cancelled = e.Cancel; log.DebugFormat("DoWork: {0}", e.ToString()); diff --git a/WreckCli/Logging/Logger.cs b/WreckCli/Logging/Logger.cs index 4698b4d..92e779e 100644 --- a/WreckCli/Logging/Logger.cs +++ b/WreckCli/Logging/Logger.cs @@ -88,3 +88,4 @@ public void UnauthorizedAccessException(UnauthorizedAccessException ex) } } } + diff --git a/WreckGui/Controller/GuiController.cs b/WreckGui/Controller/GuiController.cs index 7354153..b0f0d37 100644 --- a/WreckGui/Controller/GuiController.cs +++ b/WreckGui/Controller/GuiController.cs @@ -111,6 +111,9 @@ public void PropertyChange(PropertyChangeEvent evt) if(controller.Worker != null && controller.Worker.IsDone()) controller.Done(); } + + bool running = SwingWorker.StateValue.Started.Equals(state); + controller.View.GetMain().SetAppState(running); } else if (R.Strings.PropertyProgress.Equals(evt.PropertyName)) { @@ -166,8 +169,25 @@ public override void Done() UpdateForecastStatistics(); UpdateRestoreState(); -// View.GetScanningDialog().Close(); + View.GetMain().Done(); // Worker = null; } + + protected override void UpdateStatistics() + { + base.UpdateStatistics(); + Statistics stats = new Statistics(); + stats.Directories = STATS.Get(FileEvent.DirectoryFound); + stats.Files = STATS.Get(FileEvent.FileFound); + stats.Skipped = STATS.Get(FileEvent.FileError); + View.GetMain().Statistics(stats); + + LOG.DebugFormat("Dir Found: {0}", STATS.Get(FileEvent.DirectoryFound)); + LOG.DebugFormat("File Found: {0}", STATS.Get(FileEvent.FileFound)); + LOG.DebugFormat("File Error: {0}", STATS.Get(FileEvent.FileError)); + LOG.DebugFormat("Fixed Creation: {0}", STATS.Get(FileEvent.CorrectibleCreation)); + LOG.DebugFormat("Fixed Modified: {0}", STATS.Get(FileEvent.CorrectibleModified)); + LOG.DebugFormat("Fixed Accessed: {0}", STATS.Get(FileEvent.CorrectibleAccessed)); + } } } diff --git a/WreckGui/MainForm.cs b/WreckGui/MainForm.cs index 6134dc6..9a067c1 100644 --- a/WreckGui/MainForm.cs +++ b/WreckGui/MainForm.cs @@ -248,16 +248,22 @@ public void SetAction(FileVisit visit) string path = visit.File.FullName; this.CurrentPath(path); } - else if(File.Exists(visit.File.FullName)) + else if(visit.File is FileInfo) { FileInfo fi = (FileInfo) visit.File; this.CurrentFile(fi); } - else if(Directory.Exists(visit.File.FullName)) + else if(visit.File is DirectoryInfo) { DirectoryInfo di = (DirectoryInfo) visit.File; this.CurrentDirectory(di); } } + + public void Done() + { + SetCurrentFile(string.Empty); + rootNode.ExpandAll(); + } } }