From b14adb06f13fc1278cfae067960ab445d72f82c1 Mon Sep 17 00:00:00 2001 From: "harald.martini@student.tugraz.at" <harald.martini@student.tugraz.at> Date: Tue, 25 May 2021 10:46:01 +0200 Subject: [PATCH] Added Document Viewmodel for not editable jobs --- VECTO3GUI2020/VECTO3GUI2020.csproj | 1 + .../Document/DeclarationJobViewModel.cs | 6 ++ .../DeclarationTrailerJobDocumentViewModel.cs | 6 ++ .../Document/SimulationOnlyDeclarationJob.cs | 62 +++++++++++++++++++ .../Implementation/JobListViewModel.cs | 20 ++++-- .../Interfaces/Document/IDocumentViewModel.cs | 2 + .../MultistageJobViewModel_v0_1.cs | 6 ++ 7 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs diff --git a/VECTO3GUI2020/VECTO3GUI2020.csproj b/VECTO3GUI2020/VECTO3GUI2020.csproj index adba1d390f..a35f39dac5 100644 --- a/VECTO3GUI2020/VECTO3GUI2020.csproj +++ b/VECTO3GUI2020/VECTO3GUI2020.csproj @@ -188,6 +188,7 @@ <Compile Include="ViewModel\Implementation\Document\DeclarationJobViewModel.cs" /> <Compile Include="ViewModel\Implementation\Document\DeclarationTrailerJobDocumentViewModel.cs" /> <Compile Include="Model\Interfaces\IAuxiliaryModelFactory.cs" /> + <Compile Include="ViewModel\Implementation\Document\SimulationOnlyDeclarationJob.cs" /> <Compile Include="ViewModel\Implementation\MessageEntry.cs" /> <Compile Include="ViewModel\Interfaces\Document\IDocumentViewModel.cs" /> <Compile Include="ViewModel\Interfaces\Document\IDocumentViewModelFactory.cs" /> diff --git a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs index a84917bc92..7f3cc8db43 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationJobViewModel.cs @@ -32,6 +32,12 @@ namespace VECTO3GUI2020.ViewModel.Implementation.Document set => SetProperty(ref _selected, value); } + public bool CanBeEdited + { + get => false; + set => throw new System.NotImplementedException(); + } + #endregion #region Members diff --git a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs index 435206562a..9362ab868a 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/Document/DeclarationTrailerJobDocumentViewModel.cs @@ -26,6 +26,12 @@ namespace VECTO3GUI2020.ViewModel.Implementation.Document set => throw new System.NotImplementedException(); } + public bool CanBeEdited + { + get => false; + set => throw new System.NotImplementedException(); + } + IEditViewModel IDocumentViewModel.EditViewModel => throw new System.NotImplementedException(); private IXMLInputDataReader _xMLInputDataReader; diff --git a/VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs b/VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs new file mode 100644 index 0000000000..9c6a69dc8f --- /dev/null +++ b/VECTO3GUI2020/ViewModel/Implementation/Document/SimulationOnlyDeclarationJob.cs @@ -0,0 +1,62 @@ +using System.Configuration; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.Utils; +using VECTO3GUI2020.ViewModel.Implementation.Common; +using VECTO3GUI2020.ViewModel.Interfaces; +using VECTO3GUI2020.ViewModel.Interfaces.Document; + +namespace VECTO3GUI2020.ViewModel.Implementation.Document +{ + public class SimulationOnlyDeclarationJob : ViewModelBase, IDocumentViewModel, IJobViewModel + { + #region Implementation of IDocumentViewModel + + public string DocumentName + { + get => _documentName; + set => _documentName = value; + } + + public XmlDocumentType DocumentType + { + get => _documentType; + set => _documentType = value; + } + + public DataSource DataSource + { + get => _dataSource; + set => _dataSource = value; + } + + public IEditViewModel EditViewModel { get; set; } + + private bool _selected; + private XmlDocumentType _documentType; + private string _documentName; + private DataSource _dataSource; + + public bool Selected + { + get => _selected; + set => SetProperty(ref _selected, value); + } + + public bool CanBeEdited + { + get => false; + set => throw new System.NotImplementedException(); + } + + #endregion + + public SimulationOnlyDeclarationJob(DataSource dataSource, string name, XmlDocumentType documentType) + { + _documentType = documentType; + _dataSource = dataSource; + _documentName = name; + } + + } + +} \ No newline at end of file diff --git a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs index 53ef91bd26..70c23b77c8 100644 --- a/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Implementation/JobListViewModel.cs @@ -38,6 +38,7 @@ using VECTO3GUI2020.Helper; using VECTO3GUI2020.Model.Interfaces; using VECTO3GUI2020.Properties; using VECTO3GUI2020.ViewModel.Implementation.Common; +using VECTO3GUI2020.ViewModel.Implementation.Document; using VECTO3GUI2020.ViewModel.Interfaces; using VECTO3GUI2020.ViewModel.Interfaces.Document; using VECTO3GUI2020.ViewModel.MultiStage.Implementation; @@ -556,7 +557,15 @@ namespace VECTO3GUI2020.ViewModel.Implementation if (documentType == XmlDocumentType.MultistageOutputData) { var inputDataProvider = _inputDataReader.Create(fileName) as IMultistageBusInputDataProvider; return Task.FromResult(_multiStageViewModelFactory.GetMultiStageJobViewModel(inputDataProvider) as IDocumentViewModel); - } else { + } else if (documentType == XmlDocumentType.DeclarationJobData) { + //Remove + var inputDataProvider = _inputDataReader.CreateDeclaration(fileName); + var result = new SimulationOnlyDeclarationJob(inputDataProvider.DataSource, + inputDataProvider.JobInputData.JobName, XmlDocumentType.DeclarationJobData) as IDocumentViewModel; + return Task.FromResult(result); + + + }else { throw new VectoXMLException($"{documentType.ToString()} not supported"); } @@ -581,8 +590,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation private void AddJobExecute() { - //Another possibility is to use IsAsync true property of Binding. - IsLoading = true; + IsLoading = true; var filename = _dialogHelper.OpenXMLFileDialog(); if (filename != null) { @@ -605,9 +613,9 @@ namespace VECTO3GUI2020.ViewModel.Implementation get { return _editJobCommand ?? new Util.RelayCommand<IJobViewModel>(EditJobExecute, - (IJobViewModel jobentry) => - { - return (jobentry != null); + (IJobViewModel jobentry) => { + var canExecute = jobentry != null && jobentry.CanBeEdited; + return canExecute; }); } set diff --git a/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs b/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs index e345cf9e5f..60b6f9edec 100644 --- a/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs +++ b/VECTO3GUI2020/ViewModel/Interfaces/Document/IDocumentViewModel.cs @@ -12,5 +12,7 @@ namespace VECTO3GUI2020.ViewModel.Interfaces.Document IEditViewModel EditViewModel { get; } bool Selected { get; set; } + + bool CanBeEdited { get; set; } } } diff --git a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs index eec000a313..20c6bda442 100644 --- a/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs +++ b/VECTO3GUI2020/ViewModel/MultiStage/Implementation/MultistageJobViewModel_v0_1.cs @@ -314,6 +314,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation set => SetProperty(ref _selected, value); } + public bool CanBeEdited + { + get => true; + set => throw new NotImplementedException(); + } + #endregion #region Implementation of IMultistageVIFInputData -- GitLab