diff --git a/VECTO3GUI2020/VECTO3GUI2020.csproj b/VECTO3GUI2020/VECTO3GUI2020.csproj index adba1d390fb12b3c631e4fb029cb722db63531a0..a35f39dac5d04e413f0b94ee7e3178d1fc05f9d5 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 a84917bc92057c93c020aee4a6f5e161ee655551..7f3cc8db43acad0a5b3e2b4ecbe8edd1a12cfbbb 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 435206562afabef6c00c34e48c96a561974247fd..9362ab868a256c06784589a8304023be9c092de4 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 0000000000000000000000000000000000000000..9c6a69dc8fb23d839e59699d46d28fac7a7b74a5 --- /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 53ef91bd260fc2da3d2bacc250b0b840c0325c4b..70c23b77c853ba41eea6c099979a0a5cadf06c45 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 e345cf9e5f89547dccf870b55b93a00863248933..60b6f9edecc3c4896fe5312feb8b61675b6a5afb 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 eec000a3137613fc0b1544d7b8c6ee991eaf9067..20c6bda442c575dc5b4f0d21e4ac0ffbf2cec6ef 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