From 441a15a3c91bbe83f2988ebb1106965ec302a247 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 18 May 2020 16:23:41 +0200 Subject: [PATCH] vecto3 gui: handle missing files in joblist --- VECTO3GUI/Model/JobListModel.cs | 13 ++++++++++++- VECTO3GUI/ViewModel/Impl/JobEntry.cs | 9 ++++++++- VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs | 6 +++--- VECTO3GUI/Views/JoblistView.xaml | 9 +++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/VECTO3GUI/Model/JobListModel.cs b/VECTO3GUI/Model/JobListModel.cs index ebfb93345d..821d1bca37 100644 --- a/VECTO3GUI/Model/JobListModel.cs +++ b/VECTO3GUI/Model/JobListModel.cs @@ -61,7 +61,11 @@ namespace VECTO3GUI.Model for (int i = 0; i < jobEntries.Count; i++) { JobList.Add - ( + ( jobEntries[i].Missing ? new JobListEntry() { + JobFilePath = jobEntries[i].JobEntryFilePath, + IsSelected = false, + JobTypeName = JobType.Unknown.GetLabel(), + }: new JobListEntry { JobTypeName = jobEntries[i].Header.JobType.GetLabel(), @@ -81,6 +85,13 @@ namespace VECTO3GUI.Model for (int i = 0; i < JobList.Count; i++) { + if (!File.Exists(JobList[i].JobFilePath)) { + jobEntries.Add(new JobEntry() { + JobEntryFilePath = JobList[i].JobFilePath, + Missing = true + }); + continue; + } var jobType = JobTypeHelper.Parse(JobList[i].JobTypeName); JobEntry jobEntry; diff --git a/VECTO3GUI/ViewModel/Impl/JobEntry.cs b/VECTO3GUI/ViewModel/Impl/JobEntry.cs index d1c437cf9b..15d1500f62 100644 --- a/VECTO3GUI/ViewModel/Impl/JobEntry.cs +++ b/VECTO3GUI/ViewModel/Impl/JobEntry.cs @@ -73,11 +73,12 @@ namespace VECTO3GUI.ViewModel.Impl private JobBody _body; private bool _selected; private string _jobEntryFilePath; + private bool _missing; [JsonIgnore] public bool Selected { - get { return _selected; } + get { return !Missing && _selected; } set { SetProperty(ref _selected, value); } } @@ -99,6 +100,12 @@ namespace VECTO3GUI.ViewModel.Impl set { SetProperty(ref _body, value); } } + public bool Missing + { + get { return _missing; } + set { SetProperty(ref _missing, value); } + } + public string GetAbsoluteFilePath(string propertyFilePath) { if (IsFileName(propertyFilePath)) { diff --git a/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs b/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs index 79951ff5f6..ffcbd5b9c1 100644 --- a/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs +++ b/VECTO3GUI/ViewModel/Impl/JoblistViewModel.cs @@ -412,7 +412,7 @@ namespace VECTO3GUI.ViewModel.Impl } private bool CanEditCompletedFile(JobEntry jobEntry) { - return jobEntry != null && + return jobEntry != null && !jobEntry.Missing && (IsJobEntry(jobEntry) || jobEntry.Header.JobType == JobType.CompletedXml); } @@ -777,8 +777,8 @@ namespace VECTO3GUI.ViewModel.Impl private bool IsJobEntry(JobEntry jobEntry) { - return jobEntry.Header.JobType == JobType.CompletedBusJob || - jobEntry.Header.JobType == JobType.SingleBusJob; + return !jobEntry.Missing && (jobEntry.Header.JobType == JobType.CompletedBusJob || + jobEntry.Header.JobType == JobType.SingleBusJob); } private bool IsXmlFile(string filePath) diff --git a/VECTO3GUI/Views/JoblistView.xaml b/VECTO3GUI/Views/JoblistView.xaml index 8b0238b8e4..032f30a0b4 100644 --- a/VECTO3GUI/Views/JoblistView.xaml +++ b/VECTO3GUI/Views/JoblistView.xaml @@ -152,6 +152,15 @@ </DataGridTextColumn> </DataGrid.Columns> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell"> + <Style.Triggers> + <DataTrigger Binding="{Binding Missing}" Value="True"> + <Setter Property="Foreground" Value="Red"/> + </DataTrigger> + </Style.Triggers> + </Style> + </DataGrid.CellStyle> </DataGrid> </Grid> -- GitLab