Skip to content

Commit

Permalink
Add running state, tree expansion and statistics update
Browse files Browse the repository at this point in the history
  • Loading branch information
gyk4j committed Feb 19, 2024
1 parent dac7efc commit 24bf3af
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion JShim/Javax/Swing/SwingWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions WreckCli/Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ public void UnauthorizedAccessException(UnauthorizedAccessException ex)
}
}
}

22 changes: 21 additions & 1 deletion WreckGui/Controller/GuiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public void PropertyChange(PropertyChangeEvent evt)
if(controller.Worker != null && controller.Worker.IsDone())
controller.Done();
}

bool running = SwingWorker<int, FileVisit>.StateValue.Started.Equals(state);
controller.View.GetMain().SetAppState(running);
}
else if (R.Strings.PropertyProgress.Equals(evt.PropertyName))
{
Expand Down Expand Up @@ -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));
}
}
}
10 changes: 8 additions & 2 deletions WreckGui/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit 24bf3af

Please sign in to comment.