diff --git a/src/PKSim.Assets.Images/PKSim.Assets.Images.csproj b/src/PKSim.Assets.Images/PKSim.Assets.Images.csproj index eba2299f1..020f4a425 100644 --- a/src/PKSim.Assets.Images/PKSim.Assets.Images.csproj +++ b/src/PKSim.Assets.Images/PKSim.Assets.Images.csproj @@ -26,8 +26,8 @@ - - + + diff --git a/src/PKSim.Assets/PKSim.Assets.csproj b/src/PKSim.Assets/PKSim.Assets.csproj index 71868d1c8..901cf887a 100644 --- a/src/PKSim.Assets/PKSim.Assets.csproj +++ b/src/PKSim.Assets/PKSim.Assets.csproj @@ -26,8 +26,8 @@ - - + + diff --git a/src/PKSim.BatchTool/BatchRegister.cs b/src/PKSim.BatchTool/BatchRegister.cs index 8ca16c691..da52b60a4 100644 --- a/src/PKSim.BatchTool/BatchRegister.cs +++ b/src/PKSim.BatchTool/BatchRegister.cs @@ -19,7 +19,7 @@ public override void RegisterInContainer(IContainer container) scan.WithDefaultConvention(); }); - container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); container.Register(); container.Register(); container.Register(); diff --git a/src/PKSim.BatchTool/PKSim.BatchTool.csproj b/src/PKSim.BatchTool/PKSim.BatchTool.csproj index 0c042942f..d04fc407f 100644 --- a/src/PKSim.BatchTool/PKSim.BatchTool.csproj +++ b/src/PKSim.BatchTool/PKSim.BatchTool.csproj @@ -59,8 +59,8 @@ - - + + diff --git a/src/PKSim.CLI.Core/PKSim.CLI.Core.csproj b/src/PKSim.CLI.Core/PKSim.CLI.Core.csproj index 6d759cbdf..7de5e2a24 100644 --- a/src/PKSim.CLI.Core/PKSim.CLI.Core.csproj +++ b/src/PKSim.CLI.Core/PKSim.CLI.Core.csproj @@ -27,9 +27,9 @@ - + - + diff --git a/src/PKSim.CLI/PKSim.CLI.csproj b/src/PKSim.CLI/PKSim.CLI.csproj index 81fce9b0e..aa1fa1b8e 100644 --- a/src/PKSim.CLI/PKSim.CLI.csproj +++ b/src/PKSim.CLI/PKSim.CLI.csproj @@ -61,9 +61,9 @@ - - - + + + diff --git a/src/PKSim.Core/Model/CompoundProcessParameterMapping.cs b/src/PKSim.Core/Model/CompoundProcessParameterMapping.cs index 5d4d808f3..8215a05e7 100644 --- a/src/PKSim.Core/Model/CompoundProcessParameterMapping.cs +++ b/src/PKSim.Core/Model/CompoundProcessParameterMapping.cs @@ -21,13 +21,13 @@ public interface ICompoundProcessParameterMapping /// /// Path to the mapped parameter (e.g. ORGANISM/Liver/Volume) /// - IObjectPath MappedParameterPath { get; set; } + ObjectPath MappedParameterPath { get; set; } } public class CompoundProcessParameterMapping : ICompoundProcessParameterMapping { public string ProcessName { get; set; } public string ParameterName { get; set; } - public IObjectPath MappedParameterPath { get; set; } + public ObjectPath MappedParameterPath { get; set; } } } \ No newline at end of file diff --git a/src/PKSim.Core/Model/FormulaFactory.cs b/src/PKSim.Core/Model/FormulaFactory.cs index 7e815a3d3..29384118f 100644 --- a/src/PKSim.Core/Model/FormulaFactory.cs +++ b/src/PKSim.Core/Model/FormulaFactory.cs @@ -210,7 +210,7 @@ public IFormula DoseFromDosePerBodySurfaceAreaFor(IFormulaCache formulaCache) return RateFor(CoreConstants.CalculationMethod.APPLICATION_PARAMETER_HUMAN, CoreConstants.Rate.APPLICATION_DOSE_FROM_DOSE_PER_BODY_SURFACE_AREA, formulaCache); } - private IFormulaUsablePath pathInParentContainerFor(IParameter parameter, string alias) + private FormulaUsablePath pathInParentContainerFor(IParameter parameter, string alias) { return _objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER, parameter.Name) .WithAlias(alias) @@ -338,7 +338,7 @@ private IFormula createFormula(RateKey rateKey) foreach (var rateObjectPath in _rateObjectPathsRepository.ObjectPathsFor(rateKey)) { - formula.AddObjectPath(rateObjectPath.Clone()); + formula.AddObjectPath(rateObjectPath.Clone()); } addTimeReferenceIfNeeded(formula); @@ -395,8 +395,8 @@ private IFormula createTableFormulaWithOffset(RateKey rateKey) if (tableObjectPath == null || offsetObjectPath == null) throw new ArgumentException(PKSimConstants.Error.TableFormulaWithOffsetMissingRefs(rateKey.ToString(), CoreConstants.Alias.TABLE, CoreConstants.Alias.OFFSET)); - formula.AddTableObjectPath(tableObjectPath.Clone()); - formula.AddOffsetObjectPath(offsetObjectPath.Clone()); + formula.AddTableObjectPath(tableObjectPath.Clone()); + formula.AddOffsetObjectPath(offsetObjectPath.Clone()); //Table formula with offest has the same dimension as its referenced table object formula.Dimension = tableObjectPath.Dimension; diff --git a/src/PKSim.Core/Model/MoleculeStartFormula.cs b/src/PKSim.Core/Model/MoleculeStartFormula.cs index 18849ff78..8ddc4af77 100644 --- a/src/PKSim.Core/Model/MoleculeStartFormula.cs +++ b/src/PKSim.Core/Model/MoleculeStartFormula.cs @@ -10,7 +10,7 @@ public interface IMoleculeStartFormula /// /// Database path to the molecule, e.g. "ORGANISM\Liver\Plasma\DRUG" /// - IObjectPath MoleculePath { get; } + ObjectPath MoleculePath { get; } /// /// Calculation method and rate for given formula @@ -20,13 +20,13 @@ public interface IMoleculeStartFormula public class MoleculeStartFormula : IMoleculeStartFormula { - public MoleculeStartFormula(IObjectPath moleculePath, string calculationMethod, string rate) + public MoleculeStartFormula(ObjectPath moleculePath, string calculationMethod, string rate) { MoleculePath = moleculePath; RateKey = new RateKey(calculationMethod, rate); } - public IObjectPath MoleculePath { get; private set; } + public ObjectPath MoleculePath { get; private set; } public RateKey RateKey { get; private set; } } } \ No newline at end of file diff --git a/src/PKSim.Core/Model/PKSimBuildingBlock.cs b/src/PKSim.Core/Model/PKSimBuildingBlock.cs index e33672aa7..3259dfd27 100644 --- a/src/PKSim.Core/Model/PKSimBuildingBlock.cs +++ b/src/PKSim.Core/Model/PKSimBuildingBlock.cs @@ -125,6 +125,8 @@ public virtual ContainerMode Mode } public virtual IReadOnlyList Children => Root.Children; + + public ObjectPath ParentPath { get; set; } public IEnumerator GetEnumerator() { diff --git a/src/PKSim.Core/Model/RateObjectPaths.cs b/src/PKSim.Core/Model/RateObjectPaths.cs index 7fc376131..36aa06912 100644 --- a/src/PKSim.Core/Model/RateObjectPaths.cs +++ b/src/PKSim.Core/Model/RateObjectPaths.cs @@ -7,13 +7,13 @@ public interface IRateObjectPaths { string Rate { get; } string CalculationMethod { get; } - IEnumerable ObjectPaths { get; } - void AddObjectPath(IFormulaUsablePath objectPath); + IEnumerable ObjectPaths { get; } + void AddObjectPath(FormulaUsablePath objectPath); } public class RateObjectPaths : IRateObjectPaths { - private readonly IList _objectPaths; + private readonly IList _objectPaths; public string Rate { get; private set; } public string CalculationMethod { get; private set; } @@ -21,15 +21,15 @@ public RateObjectPaths(string calculationMethod, string rate) { CalculationMethod = calculationMethod; Rate = rate; - _objectPaths = new List(); + _objectPaths = new List(); } - public IEnumerable ObjectPaths + public IEnumerable ObjectPaths { get { return _objectPaths; } } - public void AddObjectPath(IFormulaUsablePath objectPath) + public void AddObjectPath(FormulaUsablePath objectPath) { _objectPaths.Add(objectPath); } @@ -40,12 +40,12 @@ public class NullObjectPaths : IRateObjectPaths public string Rate { get; private set; } public string CalculationMethod { get; private set; } - public IEnumerable ObjectPaths + public IEnumerable ObjectPaths { - get { return new List(); } + get { return new List(); } } - public void AddObjectPath(IFormulaUsablePath objectPath) + public void AddObjectPath(FormulaUsablePath objectPath) { } } diff --git a/src/PKSim.Core/PKSim.Core.csproj b/src/PKSim.Core/PKSim.Core.csproj index a5fc8275e..81ad34f57 100644 --- a/src/PKSim.Core/PKSim.Core.csproj +++ b/src/PKSim.Core/PKSim.Core.csproj @@ -30,10 +30,10 @@ - - - - + + + + diff --git a/src/PKSim.Core/Repositories/ICompoundProcessParameterMappingRepository.cs b/src/PKSim.Core/Repositories/ICompoundProcessParameterMappingRepository.cs index d8da312eb..99f126d2c 100644 --- a/src/PKSim.Core/Repositories/ICompoundProcessParameterMappingRepository.cs +++ b/src/PKSim.Core/Repositories/ICompoundProcessParameterMappingRepository.cs @@ -13,7 +13,7 @@ public interface ICompoundProcessParameterMappingRepository : IRepository /// Internal name of the compound process /// Name of parameter - IObjectPath MappedParameterPathFor(string compoundProcessName, string processParameterName); + ObjectPath MappedParameterPathFor(string compoundProcessName, string processParameterName); /// /// Returns true if a mapping is available for the give{Process, ParameterName} otherwise false diff --git a/src/PKSim.Core/Repositories/IModelContainerMoleculeRepository.cs b/src/PKSim.Core/Repositories/IModelContainerMoleculeRepository.cs index e81e5d3af..822bb2bdd 100644 --- a/src/PKSim.Core/Repositories/IModelContainerMoleculeRepository.cs +++ b/src/PKSim.Core/Repositories/IModelContainerMoleculeRepository.cs @@ -31,13 +31,13 @@ public interface IModelContainerMoleculeRepository : IStartableRepository - bool IsPresent(string modelName, IObjectPath containerPath, string moleculeName); + bool IsPresent(string modelName, ObjectPath containerPath, string moleculeName); /// /// Checks if molecule is available in container (for given model). /// Default behaviour for the case no entry for {model, container, molecule} is found: return false /// - bool NegativeValuesAllowed(string modelName, IObjectPath containerPath, string moleculeName); + bool NegativeValuesAllowed(string modelName, ObjectPath containerPath, string moleculeName); } } diff --git a/src/PKSim.Core/Repositories/IMoleculeStartFormulaRepository.cs b/src/PKSim.Core/Repositories/IMoleculeStartFormulaRepository.cs index 0e7def28b..6d8bfc8f8 100644 --- a/src/PKSim.Core/Repositories/IMoleculeStartFormulaRepository.cs +++ b/src/PKSim.Core/Repositories/IMoleculeStartFormulaRepository.cs @@ -14,6 +14,6 @@ public interface IMoleculeStartFormulaRepository : IStartableRepository must be a database path to the molecule (e.g. "ORGANISM\Liver\Plasma\DRUG") /// /// Rate key if found, null if not found - RateKey RateKeyFor(IObjectPath moleculePath, ModelProperties modelProperties); + RateKey RateKeyFor(ObjectPath moleculePath, ModelProperties modelProperties); } } \ No newline at end of file diff --git a/src/PKSim.Core/Repositories/IRateObjectPathsRepository.cs b/src/PKSim.Core/Repositories/IRateObjectPathsRepository.cs index 9e30a25e5..c0f8bd188 100644 --- a/src/PKSim.Core/Repositories/IRateObjectPathsRepository.cs +++ b/src/PKSim.Core/Repositories/IRateObjectPathsRepository.cs @@ -7,12 +7,12 @@ namespace PKSim.Core.Repositories { public interface IRateObjectPathsRepository : IStartableRepository { - IEnumerable ObjectPathsFor(string rate, string calculationMethod); - IEnumerable ObjectPathsFor(RateKey rateKey); + IEnumerable ObjectPathsFor(string rate, string calculationMethod); + IEnumerable ObjectPathsFor(RateKey rateKey); /// /// returns the first path defined for the ratekey with the given alias. If not path is found, returns null /// - IFormulaUsablePath PathWithAlias(RateKey rateKey, string alias); + FormulaUsablePath PathWithAlias(RateKey rateKey, string alias); } } \ No newline at end of file diff --git a/src/PKSim.Core/Services/DataRepositoryFromResultsCreator.cs b/src/PKSim.Core/Services/DataRepositoryFromResultsCreator.cs index 39d46b63e..e0747d72f 100644 --- a/src/PKSim.Core/Services/DataRepositoryFromResultsCreator.cs +++ b/src/PKSim.Core/Services/DataRepositoryFromResultsCreator.cs @@ -87,11 +87,11 @@ private bool columnIsSelected(DataColumn column, OutputSelections outputSelectio /// /// /// - private Tuple quantityAndPathFrom(Simulation simulation, IEnumerable path) + private Tuple quantityAndPathFrom(Simulation simulation, IReadOnlyList path) { var objectPath = _objectPathFactory.CreateObjectPathFrom(path).AndAddAtFront(simulation.Name); var quantity = objectPath.TryResolve(simulation.Model.Root); - return new Tuple(quantity, objectPath); + return new Tuple(quantity, objectPath); } private DataRepository createDataRepositoryWithBaseGrid(Simulation simulation) diff --git a/src/PKSim.Core/Services/DistributedParameterToTableParameterConverter.cs b/src/PKSim.Core/Services/DistributedParameterToTableParameterConverter.cs index 18cdd798b..c56a78de9 100644 --- a/src/PKSim.Core/Services/DistributedParameterToTableParameterConverter.cs +++ b/src/PKSim.Core/Services/DistributedParameterToTableParameterConverter.cs @@ -226,7 +226,7 @@ private void createPlasmaProteinOntogenyTable(IBuildConfiguration buildConfigura private void createParameterValueVersionOntogenyTableParameter( IParameter ontogenyFactorParameter, IBuildConfiguration buildConfiguration, - IObjectPath ontogenyFactorPath, + ObjectPath ontogenyFactorPath, IndividualMolecule molecule) { var psv = buildConfiguration.ParameterStartValues; @@ -345,7 +345,7 @@ PopulationSimulation populationSimulation } } - private void createPopulationOntogenyTableParameter(IParameter ontogenyFactorParameter, IObjectPath ontogenyFactorPath, IndividualMolecule molecule, PopulationSimulation populationSimulation) + private void createPopulationOntogenyTableParameter(IParameter ontogenyFactorParameter, ObjectPath ontogenyFactorPath, IndividualMolecule molecule, PopulationSimulation populationSimulation) { addAgingDataToPopulationSimulation(populationSimulation, ontogenyFactorPath.ToString(), ontogenyFactorParameter, p => createOntogenyTableFormulaFrom(p.Parameter, molecule.Ontogeny, p.OriginData, populationSimulation.RandomGenerator)); diff --git a/src/PKSim.Core/Services/InteractionKineticUpdaterSpecificationBase.cs b/src/PKSim.Core/Services/InteractionKineticUpdaterSpecificationBase.cs index 33f9ea9f6..651eb289b 100644 --- a/src/PKSim.Core/Services/InteractionKineticUpdaterSpecificationBase.cs +++ b/src/PKSim.Core/Services/InteractionKineticUpdaterSpecificationBase.cs @@ -150,24 +150,24 @@ protected virtual IReadOnlyList AllInteractionProcessesFor(s return _interactionTask.AllInteractionProcessesFor(moleculeName, _interactionType, simulation, compoundName); } - private IFormulaUsablePath kiPath(string kiParameter, Compound inhibitor, InteractionProcess process, string kiAlias) + private FormulaUsablePath kiPath(string kiParameter, Compound inhibitor, InteractionProcess process, string kiAlias) { return _objectPathFactory.CreateFormulaUsablePathFrom(inhibitor.Name, process.Name, kiParameter) .WithAlias(kiAlias) .WithDimension(_dimensionRepository.MolarConcentration); } - private IFormulaUsablePath inhibitorConcentrationPath(Compound inhibitor, string inhibitorAlias, IContainer processParameterContainer) + private FormulaUsablePath inhibitorConcentrationPath(Compound inhibitor, string inhibitorAlias, IContainer processParameterContainer) { return localInhibitorParameterPath(inhibitor, Constants.Parameters.CONCENTRATION, inhibitorAlias, processParameterContainer, _dimensionRepository.MolarConcentration); } - private IFormulaUsablePath kwaterPath(Compound inhibitor, string kwaterAlias, IContainer processParameterContainer) + private FormulaUsablePath kwaterPath(Compound inhibitor, string kwaterAlias, IContainer processParameterContainer) { return localInhibitorParameterPath(inhibitor, CoreConstants.Parameters.K_WATER, kwaterAlias, processParameterContainer, _dimensionRepository.NoDimension); } - private IFormulaUsablePath localInhibitorParameterPath(Compound inhibitor, string parameterName, string parameterAlias, IContainer processParameterContainer, IDimension dimension) + private FormulaUsablePath localInhibitorParameterPath(Compound inhibitor, string parameterName, string parameterAlias, IContainer processParameterContainer, IDimension dimension) { var objectPath = _objectPathFactory.CreateFormulaUsablePathFrom(inhibitor.Name, parameterName) .WithAlias(parameterAlias) diff --git a/src/PKSim.Core/Services/PKSimMoleculeStartValuesCreator.cs b/src/PKSim.Core/Services/PKSimMoleculeStartValuesCreator.cs index ced281bb0..cd265e607 100644 --- a/src/PKSim.Core/Services/PKSimMoleculeStartValuesCreator.cs +++ b/src/PKSim.Core/Services/PKSimMoleculeStartValuesCreator.cs @@ -58,7 +58,7 @@ public IMoleculeStartValuesBuildingBlock CreateFor(IBuildConfiguration buildConf return defaultStartValues.WithName(simulation.Name); } - private IEnumerable moleculesInvolvedInExpression(Individual individual, IndividualMolecule molecule, + private IEnumerable moleculesInvolvedInExpression(Individual individual, IndividualMolecule molecule, IReadOnlyList compoundPropertiesList) { foreach (var container in individual.AllPhysicalContainersWithMoleculeFor(molecule)) @@ -69,7 +69,7 @@ private IEnumerable moleculesInvolvedInExpression(Individual indivi { foreach (var moleculeName in compoundProperties.Processes.AllInducedMoleculeNames(molecule)) { - yield return containerPath.Clone().AndAdd(moleculeName); + yield return containerPath.Clone().AndAdd(moleculeName); } } } @@ -98,7 +98,7 @@ private void setStartFormulasForStaticMolecules(IMoleculeStartValuesBuildingBloc moleculeStartValue.NegativeValuesAllowed = false; } - var moleculeDbPath = moleculeStartValue.ContainerPath.Clone(); + var moleculeDbPath = moleculeStartValue.ContainerPath.Clone(); moleculeDbPath.Add(dbMoleculeName); diff --git a/src/PKSim.Core/Services/RenameAbsolutePathVisitor.cs b/src/PKSim.Core/Services/RenameAbsolutePathVisitor.cs index 9c34870a5..a2c491aef 100644 --- a/src/PKSim.Core/Services/RenameAbsolutePathVisitor.cs +++ b/src/PKSim.Core/Services/RenameAbsolutePathVisitor.cs @@ -48,10 +48,10 @@ private void renameAbsolutePathIn(IFormula formula) if (formula == null || formula.IsConstant()) return; - formula.ObjectPaths.Where(isAbsolutePath).Each(renameObjectPath); + formula.ObjectPaths.Where(x => isAbsolutePath(x.PathAsString)).Each(renameObjectPath); } - private void renameObjectPath(IObjectPath objectPath) + private void renameObjectPath(ObjectPath objectPath) { objectPath.Replace(_oldName, _newName); } diff --git a/src/PKSim.Core/Snapshots/Mappers/FormulaUsablePathMapper.cs b/src/PKSim.Core/Snapshots/Mappers/FormulaUsablePathMapper.cs index e885d9865..944e8c17d 100644 --- a/src/PKSim.Core/Snapshots/Mappers/FormulaUsablePathMapper.cs +++ b/src/PKSim.Core/Snapshots/Mappers/FormulaUsablePathMapper.cs @@ -6,7 +6,7 @@ namespace PKSim.Core.Snapshots.Mappers { - public class FormulaUsablePathMapper : SnapshotMapperBase + public class FormulaUsablePathMapper : SnapshotMapperBase { private readonly IDimensionRepository _dimensionRepository; @@ -15,7 +15,7 @@ public FormulaUsablePathMapper(IDimensionRepository dimensionRepository) _dimensionRepository = dimensionRepository; } - public override Task MapToSnapshot(IFormulaUsablePath formulaUsablePath) + public override Task MapToSnapshot(OSPSuite.Core.Domain.FormulaUsablePath formulaUsablePath) { return SnapshotFrom(formulaUsablePath, x => { @@ -25,9 +25,9 @@ public override Task MapToSnapshot(IFormulaUsablePath }); } - public override Task MapToModel(SnapshotFormulaUsablePath snapshot, SnapshotContext snapshotContext) + public override Task MapToModel(SnapshotFormulaUsablePath snapshot, SnapshotContext snapshotContext) { - IFormulaUsablePath formulaUsablePath; + OSPSuite.Core.Domain.FormulaUsablePath formulaUsablePath; if (snapshot.Alias == Constants.TIME) formulaUsablePath = new TimePath(); else diff --git a/src/PKSim.Infrastructure/ORM/Mappers/FlatObjectPathToObjectPathMapper.cs b/src/PKSim.Infrastructure/ORM/Mappers/FlatObjectPathToObjectPathMapper.cs index 4ce3ac2c9..18779741e 100644 --- a/src/PKSim.Infrastructure/ORM/Mappers/FlatObjectPathToObjectPathMapper.cs +++ b/src/PKSim.Infrastructure/ORM/Mappers/FlatObjectPathToObjectPathMapper.cs @@ -6,7 +6,7 @@ namespace PKSim.Infrastructure.ORM.Mappers { - public interface IFlatObjectPathToObjectPathMapper : IMapper + public interface IFlatObjectPathToObjectPathMapper : IMapper { } @@ -21,9 +21,9 @@ public FlatObjectPathToObjectPathMapper(IFlatContainerRepository flatContainerRe _relativeObjectPathMapper = relativeObjectPathMapper; } - public IObjectPath MapFrom(FlatObjectPath flatObjectPath) + public ObjectPath MapFrom(FlatObjectPath flatObjectPath) { - IObjectPath objectPath; + ObjectPath objectPath; if (flatObjectPath.IsAbsolutePath) { diff --git a/src/PKSim.Infrastructure/ORM/Mappers/FlatRateObjectPathsToObjectPathsMapper.cs b/src/PKSim.Infrastructure/ORM/Mappers/FlatRateObjectPathsToObjectPathsMapper.cs index 02076e771..e50a67b3c 100644 --- a/src/PKSim.Infrastructure/ORM/Mappers/FlatRateObjectPathsToObjectPathsMapper.cs +++ b/src/PKSim.Infrastructure/ORM/Mappers/FlatRateObjectPathsToObjectPathsMapper.cs @@ -6,7 +6,7 @@ namespace PKSim.Infrastructure.ORM.Mappers { - public interface IFlatRateObjectToFormulaUsablePathMapper : IMapper + public interface IFlatRateObjectToFormulaUsablePathMapper : IMapper { } @@ -25,7 +25,7 @@ public FlatRateObjectToFormulaUsablePathMapper(IFlatObjectPathToObjectPathMapper _dimensionRepository = dimensionRepository; } - public IFormulaUsablePath MapFrom(FlatRateObjectPath flatRateObjectPath) + public FormulaUsablePath MapFrom(FlatRateObjectPath flatRateObjectPath) { var rateObjectContainerPath = _objectPathMapper.MapFrom(flatRateObjectPath); diff --git a/src/PKSim.Infrastructure/ORM/Mappers/FlatRelativeObjectPathToObjectPathMapper.cs b/src/PKSim.Infrastructure/ORM/Mappers/FlatRelativeObjectPathToObjectPathMapper.cs index 8c6205e33..9ac170d65 100644 --- a/src/PKSim.Infrastructure/ORM/Mappers/FlatRelativeObjectPathToObjectPathMapper.cs +++ b/src/PKSim.Infrastructure/ORM/Mappers/FlatRelativeObjectPathToObjectPathMapper.cs @@ -7,7 +7,7 @@ namespace PKSim.Infrastructure.ORM.Mappers { - public interface IFlatRelativeObjectPathToObjectPathMapper : IMapper + public interface IFlatRelativeObjectPathToObjectPathMapper : IMapper { } @@ -16,13 +16,13 @@ public class FlatRelativeObjectPathToObjectPathMapper : IFlatRelativeObjectPathT private readonly IFlatRelativeObjectPathRepository _flatObjectPathRepo; private readonly IObjectPathFactory _objectPathFactory; - public FlatRelativeObjectPathToObjectPathMapper(IFlatRelativeObjectPathRepository flatRelativeObjectPathRepo,IObjectPathFactory objectPathFactory) + public FlatRelativeObjectPathToObjectPathMapper(IFlatRelativeObjectPathRepository flatRelativeObjectPathRepo, IObjectPathFactory objectPathFactory) { _flatObjectPathRepo = flatRelativeObjectPathRepo; _objectPathFactory = objectPathFactory; } - public IObjectPath MapFrom(long flatObjectPathId) + public ObjectPath MapFrom(long flatObjectPathId) { FlatRelativeObjectPath flatObjectPath = _flatObjectPathRepo.FlatRelativeObjectPathFor(flatObjectPathId); diff --git a/src/PKSim.Infrastructure/ORM/Queries/ModelObserverQuery.cs b/src/PKSim.Infrastructure/ORM/Queries/ModelObserverQuery.cs index 4afff7a02..b66918001 100644 --- a/src/PKSim.Infrastructure/ORM/Queries/ModelObserverQuery.cs +++ b/src/PKSim.Infrastructure/ORM/Queries/ModelObserverQuery.cs @@ -241,7 +241,7 @@ private void addLiverZoneCompartmentObserver(IObserverBuilder observerBuilder, s observerBuildingBlock.AddFormula(formula); } - private IFormulaUsablePath createZoneAmountPath(string compartment, string zone, string alias) + private FormulaUsablePath createZoneAmountPath(string compartment, string zone, string alias) { return _objectPathFactory.CreateFormulaUsablePathFrom(Constants.ORGANISM, CoreConstants.Organ.LIVER, zone, compartment, ObjectPathKeywords.MOLECULE) .WithAlias(alias) @@ -324,7 +324,7 @@ private IFormula getFractionFormula(IObserverBuildingBlock observerBuildingBlock return fractionFormula; } - private IFormulaUsablePath createTotalDrugMassObjectPath(string pathToDrugMass) + private FormulaUsablePath createTotalDrugMassObjectPath(string pathToDrugMass) { return _objectPathFactory.CreateFormulaUsablePathFrom(pathToDrugMass, CoreConstants.Parameters.TOTAL_DRUG_MASS) .WithAlias(TOTAL_DRUG_MASS_ALIAS) diff --git a/src/PKSim.Infrastructure/ORM/Repositories/CompoundProcessParameterMappingRepository.cs b/src/PKSim.Infrastructure/ORM/Repositories/CompoundProcessParameterMappingRepository.cs index 04e5d0a40..e03778dde 100644 --- a/src/PKSim.Infrastructure/ORM/Repositories/CompoundProcessParameterMappingRepository.cs +++ b/src/PKSim.Infrastructure/ORM/Repositories/CompoundProcessParameterMappingRepository.cs @@ -43,7 +43,7 @@ protected override void DoStart() } } - public IObjectPath MappedParameterPathFor(string compoundProcessName, string processParameterName) + public ObjectPath MappedParameterPathFor(string compoundProcessName, string processParameterName) { Start(); diff --git a/src/PKSim.Infrastructure/ORM/Repositories/FlatContainerRepository.cs b/src/PKSim.Infrastructure/ORM/Repositories/FlatContainerRepository.cs index 774ba86d5..c672664f6 100644 --- a/src/PKSim.Infrastructure/ORM/Repositories/FlatContainerRepository.cs +++ b/src/PKSim.Infrastructure/ORM/Repositories/FlatContainerRepository.cs @@ -15,7 +15,7 @@ public interface IFlatContainerRepository : IMetaDataRepository FlatContainer ContainerFrom(string containerPath); - IObjectPath ContainerPathFrom(int? containerId); + ObjectPath ContainerPathFrom(int? containerId); } public class FlatContainerRepository : MetaDataRepository, IFlatContainerRepository @@ -65,7 +65,7 @@ public FlatContainer ContainerFrom(string containerPath) return _flatContainersCachedByPath[containerPath]; } - public IObjectPath ContainerPathFrom(int? containerId) + public ObjectPath ContainerPathFrom(int? containerId) { Start(); var path = new ObjectPath(); diff --git a/src/PKSim.Infrastructure/ORM/Repositories/ModelContainerMoleculeRepository.cs b/src/PKSim.Infrastructure/ORM/Repositories/ModelContainerMoleculeRepository.cs index f5be9396c..70627eb78 100644 --- a/src/PKSim.Infrastructure/ORM/Repositories/ModelContainerMoleculeRepository.cs +++ b/src/PKSim.Infrastructure/ORM/Repositories/ModelContainerMoleculeRepository.cs @@ -88,7 +88,7 @@ public bool IsPresent(string modelName, int containerId, string moleculeName) return _mcmProperties[key].IsPresent; } - public bool IsPresent(string modelName, IObjectPath containerPath, string moleculeName) + public bool IsPresent(string modelName, ObjectPath containerPath, string moleculeName) { Start(); @@ -96,7 +96,7 @@ public bool IsPresent(string modelName, IObjectPath containerPath, string molecu return IsPresent(modelName, container.Id, moleculeName); } - public bool NegativeValuesAllowed(string modelName, IObjectPath containerPath, string moleculeName) + public bool NegativeValuesAllowed(string modelName, ObjectPath containerPath, string moleculeName) { Start(); diff --git a/src/PKSim.Infrastructure/ORM/Repositories/MoleculeStartFormulaRepository.cs b/src/PKSim.Infrastructure/ORM/Repositories/MoleculeStartFormulaRepository.cs index 540e48bf6..83122a7f4 100644 --- a/src/PKSim.Infrastructure/ORM/Repositories/MoleculeStartFormulaRepository.cs +++ b/src/PKSim.Infrastructure/ORM/Repositories/MoleculeStartFormulaRepository.cs @@ -39,7 +39,7 @@ protected override void DoStart() } } - public RateKey RateKeyFor(IObjectPath moleculePath, ModelProperties modelProperties) + public RateKey RateKeyFor(ObjectPath moleculePath, ModelProperties modelProperties) { Start(); diff --git a/src/PKSim.Infrastructure/ORM/Repositories/RateObjectPathsRepository.cs b/src/PKSim.Infrastructure/ORM/Repositories/RateObjectPathsRepository.cs index 7da1194ac..c599c0840 100644 --- a/src/PKSim.Infrastructure/ORM/Repositories/RateObjectPathsRepository.cs +++ b/src/PKSim.Infrastructure/ORM/Repositories/RateObjectPathsRepository.cs @@ -66,18 +66,18 @@ private IRateObjectPaths rateObjectPathsFor(string calculationMethod, string rat return rateObjectPaths; } - public IEnumerable ObjectPathsFor(string rate, string calculationMethod) + public IEnumerable ObjectPathsFor(string rate, string calculationMethod) { return ObjectPathsFor(new RateKey(calculationMethod, rate)); } - public IEnumerable ObjectPathsFor(RateKey rateKey) + public IEnumerable ObjectPathsFor(RateKey rateKey) { Start(); return _rateObjectPaths[rateKey].ObjectPaths; } - public IFormulaUsablePath PathWithAlias(RateKey rateKey, string alias) + public FormulaUsablePath PathWithAlias(RateKey rateKey, string alias) { return ObjectPathsFor(rateKey).FirstOrDefault(path => string.Equals(path.Alias, alias)); } diff --git a/src/PKSim.Infrastructure/PKSim.Infrastructure.csproj b/src/PKSim.Infrastructure/PKSim.Infrastructure.csproj index f70424cb5..cc9a29c0d 100644 --- a/src/PKSim.Infrastructure/PKSim.Infrastructure.csproj +++ b/src/PKSim.Infrastructure/PKSim.Infrastructure.csproj @@ -41,15 +41,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/PKSim.Infrastructure/Serialization/Xml/Serializers/ObjectPathXmlAttributeMapper.cs b/src/PKSim.Infrastructure/Serialization/Xml/Serializers/ObjectPathXmlAttributeMapper.cs index b731fa246..b6639fc1b 100644 --- a/src/PKSim.Infrastructure/Serialization/Xml/Serializers/ObjectPathXmlAttributeMapper.cs +++ b/src/PKSim.Infrastructure/Serialization/Xml/Serializers/ObjectPathXmlAttributeMapper.cs @@ -5,9 +5,9 @@ namespace PKSim.Infrastructure.Serialization.Xml.Serializers { - public class ObjectPathXmlAttributeMapper : AttributeMapper + public class ObjectPathXmlAttributeMapper : AttributeMapper { - public override string Convert(IObjectPath objectPath, SerializationContext context) + public override string Convert(ObjectPath objectPath, SerializationContext context) { return objectPath == null ? string.Empty : objectPath.ToString(); } diff --git a/src/PKSim.Infrastructure/Services/SettingsPersistor.cs b/src/PKSim.Infrastructure/Services/SettingsPersistor.cs index 04107df51..2896a353e 100644 --- a/src/PKSim.Infrastructure/Services/SettingsPersistor.cs +++ b/src/PKSim.Infrastructure/Services/SettingsPersistor.cs @@ -31,9 +31,14 @@ public virtual void Save(TSettings userSettings) public virtual TSettings Load() { + if (!ExistingFilesForSettings().Any()) + { + return CreateLoadFailDefaultsFrom(_defaultSettings); + } + try { - foreach (var filePath in SettingsFilePaths.Where(FileHelper.FileExists)) + foreach (var filePath in ExistingFilesForSettings()) { var xmlContent = XmlHelper.XmlContentFromFile(filePath); return _stringSerializer.Deserialize(xmlContent); @@ -42,12 +47,22 @@ public virtual TSettings Load() //We do not want to have a crash if the user has edited the configuration by hand catch (Exception) { - return _defaultSettings; + return CreateLoadFailDefaultsFrom(_defaultSettings); } + return CreateLoadFailDefaultsFrom(_defaultSettings); + } + + protected virtual TSettings CreateLoadFailDefaultsFrom(TSettings defaultSettings) + { return _defaultSettings; } + protected IReadOnlyList ExistingFilesForSettings() + { + return SettingsFilePaths.Where(FileHelper.FileExists).ToList(); + } + protected abstract IEnumerable SettingsFilePaths { get; } public void SaveCurrent() diff --git a/src/PKSim.Infrastructure/Services/UserSettingsPersistor.cs b/src/PKSim.Infrastructure/Services/UserSettingsPersistor.cs index edcddc35e..25eae7944 100644 --- a/src/PKSim.Infrastructure/Services/UserSettingsPersistor.cs +++ b/src/PKSim.Infrastructure/Services/UserSettingsPersistor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using PKSim.Core; using PKSim.Core.Services; using PKSim.Presentation; @@ -13,6 +14,12 @@ public UserSettingsPersistor(IStringSerializer stringSerializer, IUserSettings d { } + protected override IUserSettings CreateLoadFailDefaultsFrom(IUserSettings defaultSettings) + { + defaultSettings.ActiveSkin = CoreConstants.DEFAULT_SKIN; + return defaultSettings; + } + public override void Save(IUserSettings userSettings) { userSettings.SaveLayout(); diff --git a/src/PKSim.Matlab/PKSim.Matlab.csproj b/src/PKSim.Matlab/PKSim.Matlab.csproj index a04a8e05c..07c32ea1b 100644 --- a/src/PKSim.Matlab/PKSim.Matlab.csproj +++ b/src/PKSim.Matlab/PKSim.Matlab.csproj @@ -26,9 +26,9 @@ - + - + diff --git a/src/PKSim.Presentation/PKSim.Presentation.csproj b/src/PKSim.Presentation/PKSim.Presentation.csproj index 5929d4759..7aa50a978 100644 --- a/src/PKSim.Presentation/PKSim.Presentation.csproj +++ b/src/PKSim.Presentation/PKSim.Presentation.csproj @@ -27,11 +27,11 @@ - + - - + + diff --git a/src/PKSim.Presentation/PresenterRegister.cs b/src/PKSim.Presentation/PresenterRegister.cs index ede83cee0..abb6bc412 100644 --- a/src/PKSim.Presentation/PresenterRegister.cs +++ b/src/PKSim.Presentation/PresenterRegister.cs @@ -1,8 +1,6 @@ using OSPSuite.Assets; using OSPSuite.Core; -using OSPSuite.Core.Domain.Mappers; using OSPSuite.Presentation.Core; -using OSPSuite.Presentation.Mappers; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.Comparisons; using OSPSuite.Presentation.Presenters.Journal; @@ -12,12 +10,9 @@ using OSPSuite.Utility.Format; using PKSim.Assets; using PKSim.Core; -using PKSim.Core.Mappers; using PKSim.Core.Model; -using PKSim.Core.Services; using PKSim.Presentation.Core; using PKSim.Presentation.DTO.Mappers; -using PKSim.Presentation.Mappers; using PKSim.Presentation.Presenters; using PKSim.Presentation.Presenters.ContextMenus; using PKSim.Presentation.Presenters.Individuals; @@ -35,7 +30,7 @@ namespace PKSim.Presentation { - public class PresenterRegister : Register + public abstract class BasePresenterRegister : Register { public override void RegisterInContainer(IContainer container) { @@ -43,7 +38,7 @@ public override void RegisterInContainer(IContainer container) { scan.AssemblyContainingType(); - //Main Presenters that should be registered as singletong + //Main Presenters that should be registered as singleton scan.ExcludeNamespaceContainingType(); //Context menu will be registered with another convention @@ -52,20 +47,12 @@ public override void RegisterInContainer(IContainer container) //UI Commands will be registered with another convention scan.ExcludeNamespaceContainingType(); - //This specific objects needs to be register as Singleton - scan.ExcludeType(); - scan.ExcludeType(); - scan.ExcludeType(); - - //This objects were already registered in Bootstrap - scan.ExcludeType(); - scan.ExcludeType(); + ExcludeTypes(scan); scan.RegisterAs(LifeStyle.Transient); scan.WithConvention(); }); - container.AddScanner(scan => { scan.AssemblyContainingType(); @@ -79,15 +66,7 @@ public override void RegisterInContainer(IContainer container) }); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); + RegisterMainViewPresenters(container); registerContextMenus(container); @@ -133,6 +112,20 @@ public override void RegisterInContainer(IContainer container) Captions.MoleculePath = PKSimConstants.UI.Molecule; } + protected virtual void ExcludeTypes(IAssemblyScanner scan) + { + //This specific objects needs to be register as Singleton + scan.ExcludeType(); + scan.ExcludeType(); + scan.ExcludeType(); + + //This objects were already registered in Bootstrap + scan.ExcludeType(); + scan.ExcludeType(); + } + + protected abstract void RegisterMainViewPresenters(IContainer container); + private static void registerSingleStartPresenters(IContainer container) { container.AddScanner(scan => @@ -163,4 +156,21 @@ private static void registerContextMenus(IContainer container) }); } } + + public class PresenterRegister : BasePresenterRegister + { + + protected override void RegisterMainViewPresenters(IContainer container) + { + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); + } + } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockContextMenu.cs index ad02fc46d..760ade4a4 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockContextMenu.cs @@ -3,6 +3,7 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.MenuAndBars; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Assets; using PKSim.Core.Model; using PKSim.Presentation.UICommands; @@ -11,8 +12,8 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public abstract class BuildingBlockContextMenu : ContextMenu where TBuildingBlock : class, IPKSimBuildingBlock { - protected BuildingBlockContextMenu(TBuildingBlock buildingBlock) - : base(buildingBlock) + protected BuildingBlockContextMenu(TBuildingBlock buildingBlock, IContainer container) + : base(buildingBlock, container) { } @@ -74,45 +75,45 @@ protected IEnumerable EditContextMenusFor(TBuildingBlock protected IMenuBarItem RenameMenuFor(TBuildingBlock buildingBlock) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Rename) - .WithCommandFor(buildingBlock) + .WithCommandFor(buildingBlock, _container) .WithIcon(ApplicationIcons.Rename); } protected IMenuBarItem EditMenuFor(TBuildingBlock buildingBlock) where TCommand : IEditBuildingBlockUICommand { - return GenericMenu.EditMenuFor(buildingBlock); + return GenericMenu.EditMenuFor(buildingBlock, _container); } protected IMenuBarItem DescriptionMenuFor(TBuildingBlock buildingBlock) { - return GenericMenu.EditDescriptionMenuFor(buildingBlock); + return GenericMenu.EditDescriptionMenuFor(buildingBlock, _container); } protected IMenuBarItem CloneMenuFor(TBuildingBlock buildingBlock) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Clone) - .WithCommandFor, TBuildingBlock>(buildingBlock) + .WithCommandFor, TBuildingBlock>(buildingBlock, _container) .WithIcon(ApplicationIcons.Clone); } protected IMenuBarItem DeleteMenuFor(TBuildingBlock buildingBlock) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Delete) - .WithCommandFor(buildingBlock) + .WithCommandFor(buildingBlock, _container) .WithIcon(ApplicationIcons.Delete); } protected IMenuBarItem SaveAsUserTemplateMenuFor(TBuildingBlock buildingBlock) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SaveAsTemplate) - .WithCommandFor, IReadOnlyList>(new[] {buildingBlock,}) + .WithCommandFor, IReadOnlyList>(new[] {buildingBlock,}, _container) .WithIcon(ApplicationIcons.SaveAsTemplate); } protected IMenuBarItem SaveAsSystemTemplateMenuFor(TBuildingBlock buildingBlock) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SaveAsSystemTemplate) - .WithCommandFor, IReadOnlyList>(new[] {buildingBlock,}) + .WithCommandFor, IReadOnlyList>(new[] {buildingBlock,}, _container) .WithIcon(ApplicationIcons.SaveAsTemplate) .ForDeveloper(); } @@ -120,14 +121,14 @@ protected IMenuBarItem SaveAsSystemTemplateMenuFor(TBuildingBlock buildingBlock) protected IMenuBarItem ParameterValueDebugMenuFor(TBuildingBlock buildingBlock) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Parameter Value Export")) - .WithCommandFor(buildingBlock) + .WithCommandFor(buildingBlock, _container) .ForDeveloper(); } - protected IMenuBarItem AddToJournalMenuFor(TBuildingBlock buildingBlock) => GenericMenu.AddToJournal(buildingBlock); + protected IMenuBarItem AddToJournalMenuFor(TBuildingBlock buildingBlock) => GenericMenu.AddToJournal(buildingBlock, _container); - protected IMenuBarItem ExportSnapshotMenuFor(TBuildingBlock buildingBlock) => GenericMenu.ExportSnapshotMenuFor(buildingBlock); + protected IMenuBarItem ExportSnapshotMenuFor(TBuildingBlock buildingBlock) => GenericMenu.ExportSnapshotMenuFor(buildingBlock, _container); - protected IMenuBarItem ExportMarkdownMenuFor(TBuildingBlock buildingBlock) => GenericMenu.ExportMarkdownMenuFor(buildingBlock); + protected IMenuBarItem ExportMarkdownMenuFor(TBuildingBlock buildingBlock) => GenericMenu.ExportMarkdownMenuFor(buildingBlock, _container); } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockFolderContextMenu.cs index 39894b26d..f92651142 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/BuildingBlockFolderContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; using OSPSuite.Utility.Extensions; using PKSim.Core.Model; using PKSim.Core.Repositories; @@ -10,11 +11,11 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public abstract class BuildingBlockFolderContextMenu : ContextMenu where TBuildingBlock : class, IPKSimBuildingBlock { - protected BuildingBlockFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, params MenuBarItemId[] staticMenus) + protected BuildingBlockFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container, params MenuBarItemId[] staticMenus) : base(container) { staticMenus.Each(menu => _view.AddMenuItem(repository[menu])); - _view.AddMenuItem(GenericMenu.LoadBuildingBlockFromSnapshot()); + _view.AddMenuItem(GenericMenu.LoadBuildingBlockFromSnapshot(container)); var allBuildingBlocks = buildingBlockRepository.All(); if (!allBuildingBlocks.Any()) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ComparisonFolderTreeNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ComparisonFolderTreeNodeContextMenu.cs index 4f8067dec..c6c206387 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ComparisonFolderTreeNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ComparisonFolderTreeNodeContextMenu.cs @@ -7,12 +7,13 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class ComparisonFolderTreeNodeContextMenu : ContextMenu { - public ComparisonFolderTreeNodeContextMenu(ITreeNode treeNode, ISimulationExplorerPresenter presenter) + public ComparisonFolderTreeNodeContextMenu(ITreeNode treeNode, ISimulationExplorerPresenter presenter, IContainer container) : base(container) { _view.AddMenuItem(ClassificationCommonContextMenuItems.CreateClassificationUnderMenu(treeNode, presenter)); _view.AddMenuItem(ClassificationCommonContextMenuItems.RemoveClassificationFolderMainMenu(treeNode, presenter).AsGroupStarter()); @@ -21,14 +22,17 @@ public ComparisonFolderTreeNodeContextMenu(ITreeNode treeNode, ISi public class ComparisonFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { - public ComparisonFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository) - : base(RootNodeTypes.ComparisonFolder, repository) + private readonly IContainer _container; + + public ComparisonFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) + : base(RootNodeTypes.ComparisonFolder, repository) { + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new ComparisonFolderTreeNodeContextMenu(treeNode, presenter.DowncastTo()); + return new ComparisonFolderTreeNodeContextMenu(treeNode, presenter.DowncastTo(), _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/CompoundContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/CompoundContextMenu.cs index 10a76a0e3..5288a4a73 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/CompoundContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/CompoundContextMenu.cs @@ -5,6 +5,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Assets; using PKSim.Core.Model; using PKSim.Presentation.UICommands; @@ -13,8 +14,8 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class CompoundContextMenu : BuildingBlockContextMenu { - public CompoundContextMenu(Compound compound) - : base(compound) + public CompoundContextMenu(Compound compound, IContainer container) + : base(compound, container) { } @@ -27,19 +28,26 @@ protected override IEnumerable AllMenuItemsFor(Compound compound) return allMenuItems; } - private static IMenuBarButton addObservedDataMenuFor(Compound compound) + private IMenuBarButton addObservedDataMenuFor(Compound compound) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AddObservedData) - .WithCommandFor(compound) + .WithCommandFor(compound, _container) .WithIcon(ApplicationIcons.ObservedData); } } public class CompoundTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public CompoundTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(Compound compound, IPresenterWithContextMenu presenter) { - return new CompoundContextMenu(compound); + return new CompoundContextMenu(compound, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/CompoundFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/CompoundFolderContextMenu.cs index a9096b088..6cdacc053 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/CompoundFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/CompoundFolderContextMenu.cs @@ -7,13 +7,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class CompoundFolderContextMenu : BuildingBlockFolderContextMenu { - public CompoundFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewCompound, MenuBarItemIds.LoadCompound) + public CompoundFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewCompound, MenuBarItemIds.LoadCompound) { } } @@ -21,16 +22,18 @@ public CompoundFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlo public class CompoundFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public CompoundFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public CompoundFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.CompoundFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new CompoundFolderContextMenu(_repository, _buildingBlockRepository); + return new CompoundFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/CompoundProcessContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/CompoundProcessContextMenu.cs index 2ff2ce4f5..b5ffcd08f 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/CompoundProcessContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/CompoundProcessContextMenu.cs @@ -8,13 +8,14 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public abstract class CompoundProcessContextMenu : ContextMenu where TCompoundProcess : PKSim.Core.Model.CompoundProcess { - protected CompoundProcessContextMenu(TCompoundProcess compoundProcess, ICompoundProcessesPresenter presenter) - : base(compoundProcess, presenter) + protected CompoundProcessContextMenu(TCompoundProcess compoundProcess, ICompoundProcessesPresenter presenter, IContainer container) + : base(compoundProcess, presenter, container) { } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/EnzymaticStabilityProcessFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/EnzymaticStabilityProcessFolderContextMenu.cs index 8520195e1..3a1d06f91 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/EnzymaticStabilityProcessFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/EnzymaticStabilityProcessFolderContextMenu.cs @@ -9,13 +9,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class EnzymaticStabilityProcessFolderContextMenu : ContextMenu { - public EnzymaticStabilityProcessFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter presenter) - : base(nodeRequestingContextMenu, presenter) + public EnzymaticStabilityProcessFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter presenter, IContainer container) + : base(nodeRequestingContextMenu, presenter, container) { } @@ -30,13 +31,16 @@ protected override IEnumerable AllMenuItemsFor(ITreeNode nodeReque public class EnzymaticStabilityProcessFolderTreeNodeContextMenuFactory : CompoundProcessFolderTreeNodeContextMenuFactory { - public EnzymaticStabilityProcessFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository) : base(PKSimRootNodeTypes.CompoundMetabolizingEnzymes, repository) + private readonly IContainer _container; + + public EnzymaticStabilityProcessFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.CompoundMetabolizingEnzymes, repository) { + _container = container; } protected override IContextMenu CreateFor(ITreeNode treeNode, ICompoundProcessesPresenter presenter) { - return new EnzymaticStabilityProcessFolderContextMenu(treeNode, presenter); + return new EnzymaticStabilityProcessFolderContextMenu(treeNode, presenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/EventContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/EventContextMenu.cs index 794a9f3d9..5b50e00ed 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/EventContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/EventContextMenu.cs @@ -3,6 +3,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core.Model; using PKSim.Presentation.UICommands; @@ -10,8 +11,8 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class EventContextMenu : BuildingBlockContextMenu { - public EventContextMenu(PKSimEvent pkSimEvent) - : base(pkSimEvent) + public EventContextMenu(PKSimEvent pkSimEvent, IContainer container) + : base(pkSimEvent, container) { } @@ -23,9 +24,16 @@ protected override IEnumerable AllMenuItemsFor(PKSimEvent pkSimEve public class EventTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public EventTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(PKSimEvent pkSimEvent, IPresenterWithContextMenu presenter) { - return new EventContextMenu(pkSimEvent); + return new EventContextMenu(pkSimEvent, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/EventFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/EventFolderContextMenu.cs index 1a9693c3b..b44be1789 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/EventFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/EventFolderContextMenu.cs @@ -7,13 +7,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class EventFolderContextMenu : BuildingBlockFolderContextMenu { - public EventFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewEvent, MenuBarItemIds.LoadEvent) + public EventFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewEvent, MenuBarItemIds.LoadEvent) { } } @@ -21,16 +22,18 @@ public EventFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockR public class EventFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public EventFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public EventFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.EventFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new EventFolderContextMenu(_repository, _buildingBlockRepository); + return new EventFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileContextMenu.cs index cba56e97c..190217bd0 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileContextMenu.cs @@ -5,6 +5,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Assets; using PKSim.Core.Model; using PKSim.Presentation.UICommands; @@ -13,7 +14,7 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class ExpressionProfileContextMenu : BuildingBlockContextMenu { - public ExpressionProfileContextMenu(ExpressionProfile expressionProfile) : base(expressionProfile) + public ExpressionProfileContextMenu(ExpressionProfile expressionProfile, IContainer container) : base(expressionProfile, container) { } @@ -42,16 +43,23 @@ private IEnumerable extendedExportMenus(ExpressionProfile expressi private IMenuBarItem ExportToPkml(ExpressionProfile expressionProfile) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportToPKML) - .WithCommandFor(expressionProfile) + .WithCommandFor(expressionProfile, _container) .WithIcon(ApplicationIcons.PKMLSave); } } public class ExpressionProfileTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public ExpressionProfileTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(ExpressionProfile expressionProfile, IPresenterWithContextMenu presenter) { - return new ExpressionProfileContextMenu(expressionProfile); + return new ExpressionProfileContextMenu(expressionProfile, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileFolderContextMenu.cs index f67d160ce..33d29f098 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ExpressionProfileFolderContextMenu.cs @@ -3,6 +3,7 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; using PKSim.Core.Model; using PKSim.Core.Repositories; using PKSim.Presentation.Core; @@ -12,8 +13,8 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class ExpressionProfileFolderContextMenu : BuildingBlockFolderContextMenu { - public ExpressionProfileFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewExpressionProfile, MenuBarItemIds.LoadExpressionProfile) + public ExpressionProfileFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewExpressionProfile, MenuBarItemIds.LoadExpressionProfile) { } } @@ -21,16 +22,18 @@ public ExpressionProfileFolderContextMenu(IMenuBarItemRepository repository, IBu public class ExpressionProfileFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public ExpressionProfileFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public ExpressionProfileFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.ExpressionProfileFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new ExpressionProfileFolderContextMenu(_repository, _buildingBlockRepository); + return new ExpressionProfileFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/FormulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/FormulationContextMenu.cs index 6ce911da9..37f6a2277 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/FormulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/FormulationContextMenu.cs @@ -5,12 +5,13 @@ using PKSim.Presentation.UICommands; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class FormulationContextMenu : BuildingBlockContextMenu { - public FormulationContextMenu(Formulation formulation) : base(formulation) + public FormulationContextMenu(Formulation formulation, IContainer container) : base(formulation, container) { } @@ -22,9 +23,16 @@ protected override IEnumerable AllMenuItemsFor(Formulation formula public class FormulationTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public FormulationTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(Formulation formulation, IPresenterWithContextMenu presenter) { - return new FormulationContextMenu(formulation); + return new FormulationContextMenu(formulation, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/FormulationFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/FormulationFolderContextMenu.cs index e291e1396..daf4d030c 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/FormulationFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/FormulationFolderContextMenu.cs @@ -7,13 +7,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class FormulationFolderContextMenu : BuildingBlockFolderContextMenu { - public FormulationFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewFormulation, MenuBarItemIds.LoadFormulationFromTemplate) + public FormulationFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewFormulation, MenuBarItemIds.LoadFormulationFromTemplate) { } } @@ -21,16 +22,18 @@ public FormulationFolderContextMenu(IMenuBarItemRepository repository, IBuilding public class FormulationFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public FormulationFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public FormulationFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.FormulationFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new FormulationFolderContextMenu(_repository, _buildingBlockRepository); + return new FormulationFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/GenericMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/GenericMenu.cs index 4b2b00045..fe3b3df65 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/GenericMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/GenericMenu.cs @@ -7,59 +7,61 @@ using OSPSuite.Presentation.UICommands; using OSPSuite.Assets; using PKSim.Core.Model; +using IContainer = OSPSuite.Utility.Container.IContainer; +using System.ComponentModel; namespace PKSim.Presentation.Presenters.ContextMenus { public static class GenericMenu { - public static IMenuBarItem EditDescriptionMenuFor(T objectBase) where T : IObjectBase + public static IMenuBarItem EditDescriptionMenuFor(T objectBase, IContainer container) where T : IObjectBase { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Description) .WithIcon(ApplicationIcons.Description) - .WithCommandFor(objectBase); + .WithCommandFor(objectBase, container); } - public static IMenuBarItem ExportSnapshotMenuFor(T objectToExport) where T : class, IObjectBase + public static IMenuBarItem ExportSnapshotMenuFor(T objectToExport, IContainer container) where T : class, IObjectBase { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Save Snapshot")) - .WithCommandFor, T>(objectToExport) + .WithCommandFor, T>(objectToExport, container) .WithIcon(ApplicationIcons.SnapshotExport) .ForDeveloper(); } - public static IMenuBarItem ExportMarkdownMenuFor(T objectToExport) where T : class, IObjectBase + public static IMenuBarItem ExportMarkdownMenuFor(T objectToExport, IContainer container) where T : class, IObjectBase { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Save Markdown")) - .WithCommandFor, T>(objectToExport) + .WithCommandFor, T>(objectToExport, container) // .WithIcon(ApplicationIcons.SnapshotExport) .ForDeveloper(); } - public static IMenuBarItem LoadBuildingBlockFromSnapshot() where T:class, IPKSimBuildingBlock + public static IMenuBarItem LoadBuildingBlockFromSnapshot(IContainer container) where T:class, IPKSimBuildingBlock { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Load from Snapshot")) - .WithCommand>() + .WithCommand>(container) .WithIcon(ApplicationIcons.SnapshotImport) .ForDeveloper(); } - public static IMenuBarItem EditMenuFor(T objectToEdit) where T : class where TCommand : IObjectUICommand + public static IMenuBarItem EditMenuFor(T objectToEdit, IContainer container) where T : class where TCommand : IObjectUICommand { return CreateMenuButton.WithCaption(MenuNames.Edit) - .WithCommandFor(objectToEdit) + .WithCommandFor(objectToEdit, container) .WithIcon(ApplicationIcons.Edit); } - public static IMenuBarItem AddToJournal(T objectBase) where T : IObjectBase + public static IMenuBarItem AddToJournal(T objectBase, IContainer container) where T : IObjectBase { - return ObjectBaseCommonContextMenuItems.AddToJournal(objectBase); + return ObjectBaseCommonContextMenuItems.AddToJournal(objectBase, container); } - public static IMenuBarItem RenameMenuFor(T objectToRename) where T : IWithName + public static IMenuBarItem RenameMenuFor(T objectToRename, IContainer container) where T : IWithName { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Rename) - .WithCommandFor(objectToRename) + .WithCommandFor(objectToRename, container) .WithIcon(ApplicationIcons.Rename); } } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ImportPopulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ImportPopulationContextMenu.cs index 4457fe8b6..634b8fcbe 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ImportPopulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ImportPopulationContextMenu.cs @@ -2,22 +2,30 @@ using PKSim.Core.Model; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class ImportPopulationContextMenu : PopulationContextMenu { - public ImportPopulationContextMenu(ImportPopulation randomPopulation) - : base(randomPopulation) + public ImportPopulationContextMenu(ImportPopulation randomPopulation, IContainer container) + : base(randomPopulation, container) { } } public class ImportPopulationTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public ImportPopulationTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(ImportPopulation importPopulation, IPresenterWithContextMenu presenter) { - return new ImportPopulationContextMenu(importPopulation); + return new ImportPopulationContextMenu(importPopulation, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualContextMenu.cs index fce821b30..68a2db978 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualContextMenu.cs @@ -6,6 +6,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Assets; using PKSim.Core.Model; using PKSim.Presentation.UICommands; @@ -14,7 +15,7 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class IndividualContextMenu : BuildingBlockContextMenu { - public IndividualContextMenu(Individual individual) : base(individual) + public IndividualContextMenu(Individual individual, IContainer container) : base(individual, container) { } @@ -40,31 +41,38 @@ protected override IEnumerable AllMenuItemsFor(Individual individu private IMenuBarItem exportToPkml(Individual individual) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportToPKML) - .WithCommandFor(individual) + .WithCommandFor(individual, _container) .WithIcon(ApplicationIcons.PKMLSave); } - private static IMenuBarButton newPopulationMenuFor(Individual individual) + private IMenuBarButton newPopulationMenuFor(Individual individual) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewPopulation) .WithIcon(ApplicationIcons.Population) - .WithCommandFor(individual); + .WithCommandFor(individual, _container); } - private static IMenuBarButton scaleIndividualMenuFor(Individual individual) + private IMenuBarButton scaleIndividualMenuFor(Individual individual) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Scale) .WithIcon(ApplicationIcons.ScaleIndividual) - .WithCommandFor(individual) + .WithCommandFor(individual, _container) .AsGroupStarter(); } } public class IndividualTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public IndividualTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(Individual individual, IPresenterWithContextMenu presenter) { - return new IndividualContextMenu(individual); + return new IndividualContextMenu(individual, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualFolderContextMenu.cs index 9b11c94fd..174283db7 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualFolderContextMenu.cs @@ -7,13 +7,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class IndividualFolderContextMenu : BuildingBlockFolderContextMenu { - public IndividualFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewIndividual, MenuBarItemIds.LoadIndividual) + public IndividualFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewIndividual, MenuBarItemIds.LoadIndividual) { } } @@ -21,16 +22,18 @@ public IndividualFolderContextMenu(IMenuBarItemRepository repository, IBuildingB public class IndividualFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public IndividualFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public IndividualFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.IndividualFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new IndividualFolderContextMenu(_repository, _buildingBlockRepository); + return new IndividualFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculeContextMenu.cs index 5cf228134..5f5231f01 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculeContextMenu.cs @@ -9,13 +9,14 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class IndividualMoleculeContextMenu : ContextMenu { - public IndividualMoleculeContextMenu(IndividualMolecule molecule, IMoleculesPresenter moleculesPresenter) - : base(molecule, moleculesPresenter) + public IndividualMoleculeContextMenu(IndividualMolecule molecule, IMoleculesPresenter moleculesPresenter, IContainer container) + : base(molecule, moleculesPresenter, container) { } @@ -31,6 +32,13 @@ protected override IEnumerable AllMenuItemsFor(IndividualMolecule public class IndividualMoleculeTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public IndividualMoleculeTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) { return base.IsSatisfiedBy(treeNode, presenter) && presenter.IsAnImplementationOf(); @@ -38,7 +46,7 @@ public override bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu public override IContextMenu CreateFor(IndividualMolecule individualMolecule, IPresenterWithContextMenu presenter) { - return new IndividualMoleculeContextMenu(individualMolecule, presenter.DowncastTo()); + return new IndividualMoleculeContextMenu(individualMolecule, presenter.DowncastTo(), _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculesContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculesContextMenu.cs index dd8caa3c2..ed0e08629 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculesContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualMoleculesContextMenu.cs @@ -12,6 +12,7 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { @@ -21,7 +22,7 @@ public abstract class IndividualMoleculesContextMenu : ContextMenu wh private readonly string _addProteinCaption; private readonly ApplicationIcon _addProteinIcon; - protected IndividualMoleculesContextMenu(IMoleculesPresenter presenter, string addProteinCaption, ApplicationIcon addProteinIcon) + protected IndividualMoleculesContextMenu(IMoleculesPresenter presenter, string addProteinCaption, ApplicationIcon addProteinIcon, IContainer container) : base(container) { _addProteinCaption = addProteinCaption; _addProteinIcon = addProteinIcon; @@ -40,24 +41,24 @@ private IEnumerable allMenuItemsFor(IMoleculesPresenter presenter) public class EnzymesContextMenu : IndividualMoleculesContextMenu { - public EnzymesContextMenu(IMoleculesPresenter presenter) - : base(presenter, PKSimConstants.UI.AddMetabolizingEnzyme, ApplicationIcons.Enzyme) + public EnzymesContextMenu(IMoleculesPresenter presenter, IContainer container) + : base(presenter, PKSimConstants.UI.AddMetabolizingEnzyme, ApplicationIcons.Enzyme, container) { } } public class OtherProteinsContextMenu : IndividualMoleculesContextMenu { - public OtherProteinsContextMenu(IMoleculesPresenter presenter) - : base(presenter, PKSimConstants.UI.AddSpecificBindingPartner, ApplicationIcons.Protein) + public OtherProteinsContextMenu(IMoleculesPresenter presenter, IContainer container) + : base(presenter, PKSimConstants.UI.AddSpecificBindingPartner, ApplicationIcons.Protein, container) { } } public class TransportersContextMenu : IndividualMoleculesContextMenu { - public TransportersContextMenu(IMoleculesPresenter presenter) - : base(presenter, PKSimConstants.UI.AddTransportProtein, ApplicationIcons.Transporter) + public TransportersContextMenu(IMoleculesPresenter presenter, IContainer container) + : base(presenter, PKSimConstants.UI.AddTransportProtein, ApplicationIcons.Transporter, container) { } } @@ -84,37 +85,46 @@ public override IContextMenu CreateFor(ITreeNode treeNode, IPresen public class EnzymesTreeNodeContextMenuFactory : IndividualMoleculesContextMenuContextMenuFactory { - public EnzymesTreeNodeContextMenuFactory(IMenuBarItemRepository repository) : base(PKSimRootNodeTypes.IndividualMetabolizingEnzymes, repository) + private readonly IContainer _container; + + public EnzymesTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.IndividualMetabolizingEnzymes, repository) { + _container = container; } public override IContextMenu CreateFor(RootNode proteinsNode, IMoleculesPresenter moleculesPresenter) { - return new EnzymesContextMenu(moleculesPresenter); + return new EnzymesContextMenu(moleculesPresenter, _container); } } public class OtherProteinsContextMenuFactory : IndividualMoleculesContextMenuContextMenuFactory { - public OtherProteinsContextMenuFactory(IMenuBarItemRepository repository) : base(PKSimRootNodeTypes.IndividualProteinBindingPartners, repository) + private readonly IContainer _container; + + public OtherProteinsContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.IndividualProteinBindingPartners, repository) { + _container = container; } public override IContextMenu CreateFor(RootNode proteinsNode, IMoleculesPresenter presenter) { - return new OtherProteinsContextMenu(presenter); + return new OtherProteinsContextMenu(presenter, _container); } } public class TransportersContextMenuFactory : IndividualMoleculesContextMenuContextMenuFactory { - public TransportersContextMenuFactory(IMenuBarItemRepository repository) : base(PKSimRootNodeTypes.IndividualTransportProteins, repository) + private readonly IContainer _container; + + public TransportersContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.IndividualTransportProteins, repository) { + _container = container; } public override IContextMenu CreateFor(RootNode proteinsNode, IMoleculesPresenter presenter) { - return new TransportersContextMenu(presenter); + return new TransportersContextMenu(presenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualSimulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualSimulationContextMenu.cs index ae5c17d5a..b6ff7e9a2 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/IndividualSimulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/IndividualSimulationContextMenu.cs @@ -5,6 +5,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Assets; using PKSim.Core.Model; using PKSim.Presentation.UICommands; @@ -13,7 +14,7 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class IndividualSimulationContextMenu : SimulationContextMenu { - public IndividualSimulationContextMenu(IndividualSimulation individualSimulation) : base(individualSimulation) + public IndividualSimulationContextMenu(IndividualSimulation individualSimulation, IContainer container) : base(individualSimulation, container) { } @@ -26,14 +27,14 @@ protected override IEnumerable ActionMenuItemsSpecificToType(Indiv protected override IEnumerable ExportMenuItemsSpecificToType(IndividualSimulation individualSimulation) { var exportToExcel = CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportSimulationResultsToExcel) - .WithCommandFor(individualSimulation) + .WithCommandFor(individualSimulation, _container) .WithIcon(ApplicationIcons.ExportToExcel); exportToExcel.Enabled = simulationHasResult(individualSimulation); yield return exportToExcel; var exportToCSV = CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportSimulationResultsToCSV) - .WithCommandFor(individualSimulation) + .WithCommandFor(individualSimulation, _container) .WithIcon(ApplicationIcons.ExportToCSV); exportToCSV.Enabled = simulationHasResult(individualSimulation); @@ -41,13 +42,13 @@ protected override IEnumerable ExportMenuItemsSpecificToType(Indiv yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportSimulationModelToFile) .WithIcon(ApplicationIcons.Report) - .WithCommandFor(individualSimulation); + .WithCommandFor(individualSimulation, _container); } protected override IEnumerable DebugMenuFor(IndividualSimulation simulation) { yield return CreateMenuButton.WithCaption(MenuNames.ExportSimModelXml) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .AsGroupStarter() .ForDeveloper(); @@ -56,19 +57,19 @@ protected override IEnumerable DebugMenuFor(IndividualSimulation s yield return ExportODEForRMenuItem(simulation); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Parameter Ids Export")) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .ForDeveloper(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Simulation Serialization Xml Export")) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .ForDeveloper(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Simulation Parameter Export To CSV")) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .ForDeveloper(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Save Snapshot")) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .WithIcon(ApplicationIcons.SnapshotExport) .ForDeveloper(); @@ -77,12 +78,12 @@ protected override IEnumerable DebugMenuFor(IndividualSimulation s protected IMenuBarItem CreateParameterIdentificationMenuItemFor(IndividualSimulation simulation) { - return ParameterIdentificationContextMenuItems.CreateParameterIdentificationFor(new[] {simulation}); + return ParameterIdentificationContextMenuItems.CreateParameterIdentificationFor(new[] {simulation}, _container); } protected IMenuBarItem CreateSensitivityAnalysisMenuItemFor(IndividualSimulation simulation) { - return SensitivityAnalysisContextMenuItems.CreateSensitivityAnalysisFor(simulation); + return SensitivityAnalysisContextMenuItems.CreateSensitivityAnalysisFor(simulation, _container); } private bool simulationHasResult(Simulation simulation) @@ -96,9 +97,16 @@ private bool simulationHasResult(Simulation simulation) public class IndividualSimulationTreeNodeContextMenuFactory : SimulationTreeNodeContextMenuFactory { + private readonly IContainer _container; + + public IndividualSimulationTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + protected override IContextMenu CreateFor(IndividualSimulation simulation, IPresenterWithContextMenu presenter) { - return new IndividualSimulationContextMenu(simulation); + return new IndividualSimulationContextMenu(simulation, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/InductionProcessFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/InductionProcessFolderContextMenu.cs index 73b3984d0..68aae2580 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/InductionProcessFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/InductionProcessFolderContextMenu.cs @@ -11,13 +11,14 @@ using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; using OSPSuite.Assets; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class InductionProcessFolderContextMenu : ContextMenu { - public InductionProcessFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter context) - : base(nodeRequestingContextMenu, context) + public InductionProcessFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter context, IContainer container) + : base(nodeRequestingContextMenu, context, container) { } @@ -32,13 +33,16 @@ protected override IEnumerable AllMenuItemsFor(ITreeNode nodeReque public class InductionProcessFolderTreeNodeContextMenuFactory : CompoundProcessFolderTreeNodeContextMenuFactory { - public InductionProcessFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository) : base(PKSimRootNodeTypes.InductionProcess, repository) + private readonly IContainer _container; + + public InductionProcessFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.InductionProcess, repository) { + _container = container; } protected override IContextMenu CreateFor(ITreeNode treeNode, ICompoundProcessesPresenter presenter) { - return new InductionProcessFolderContextMenu(treeNode, presenter); + return new InductionProcessFolderContextMenu(treeNode, presenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/InhibitionProcessFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/InhibitionProcessFolderContextMenu.cs index 87c75d65b..d341b8c6f 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/InhibitionProcessFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/InhibitionProcessFolderContextMenu.cs @@ -11,13 +11,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class InhibitionProcessFolderContextMenu : ContextMenu { - public InhibitionProcessFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter context) - : base(nodeRequestingContextMenu, context) + public InhibitionProcessFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter context, IContainer container) + : base(nodeRequestingContextMenu, context, container) { } @@ -32,14 +33,17 @@ protected override IEnumerable AllMenuItemsFor(ITreeNode nodeReque public class InhibitionProcessFolderTreeNodeContextMenuFactory : CompoundProcessFolderTreeNodeContextMenuFactory { - public InhibitionProcessFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository) + private readonly IContainer _container; + + public InhibitionProcessFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.InhibitionProcess, repository) { + _container = container; } protected override IContextMenu CreateFor(ITreeNode treeNode, ICompoundProcessesPresenter presenter) { - return new InhibitionProcessFolderContextMenu(treeNode, presenter); + return new InhibitionProcessFolderContextMenu(treeNode, presenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MdiChildViewContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MdiChildViewContextMenu.cs index d533744a0..07f90fce0 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MdiChildViewContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MdiChildViewContextMenu.cs @@ -8,12 +8,13 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.UICommands; using OSPSuite.Presentation.Views; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class MdiChildViewContextMenu : ContextMenu { - public MdiChildViewContextMenu(IMdiChildView view) : base(view) + public MdiChildViewContextMenu(IMdiChildView view, IContainer container) : base(view, container) { } @@ -21,16 +22,16 @@ protected override IEnumerable AllMenuItemsFor(IMdiChildView view) { yield return CreateMenuButton.WithCaption(PKSimConstants.UI.CloseView) .WithIcon(ApplicationIcons.Close) - .WithCommandFor(view); + .WithCommandFor(view, _container); yield return CreateMenuButton.WithCaption(PKSimConstants.UI.CloseAll) - .WithCommand(); + .WithCommand(_container); yield return CreateMenuButton.WithCaption(PKSimConstants.UI.CloseAllButThis) - .WithCommandFor(view); + .WithCommandFor(view, _container); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Rename) - .WithCommandFor(view) + .WithCommandFor(view, _container) .WithIcon(ApplicationIcons.Rename) .AsGroupStarter(); } @@ -38,9 +39,16 @@ protected override IEnumerable AllMenuItemsFor(IMdiChildView view) public class MdiChildViewContextMenuFactory : IContextMenuSpecificationFactory { + private readonly IContainer _container; + + public MdiChildViewContextMenuFactory(IContainer container) + { + _container = container; + } + public IContextMenu CreateFor(IMdiChildView view, IPresenterWithContextMenu presenter) { - return new MdiChildViewContextMenu(view); + return new MdiChildViewContextMenu(view, _container); } public bool IsSatisfiedBy(IMdiChildView view, IPresenterWithContextMenu presenter) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleBuildingBlockNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleBuildingBlockNodeContextMenu.cs index d336f6074..99067aab5 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleBuildingBlockNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleBuildingBlockNodeContextMenu.cs @@ -9,18 +9,20 @@ using PKSim.Core; using PKSim.Core.Model; using PKSim.Presentation.UICommands; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation.Presenters.ContextMenus { public abstract class MultipleBuildingBlockNodeContextMenu : ContextMenu>, IExecutionContext> where TBuildingBlock : class, IPKSimBuildingBlock { - protected MultipleBuildingBlockNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext) - : this(buildingBlocks.Select(bb => new NamedBuildingBlock(bb, bb.Name)).ToList(), executionContext) + + protected MultipleBuildingBlockNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext, IContainer container) + : this(buildingBlocks.Select(bb => new NamedBuildingBlock(bb, bb.Name)).ToList(), executionContext, container) { } - protected MultipleBuildingBlockNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext) - : base(buildingBlocks, executionContext) + protected MultipleBuildingBlockNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext, IContainer container) + : base(buildingBlocks, executionContext, container) { } @@ -37,7 +39,7 @@ protected override IEnumerable AllMenuItemsFor(IReadOnlyList> buildingBlocks, IExecutionContext executionContext) + protected IMenuBarItem CompareBuildingBlocks(IReadOnlyList> buildingBlocks, IExecutionContext executionContext) { var buildingBlockList = buildingBlocks.Select(x => x.BuildingBlock).ToList(); var objectBaseList = buildingBlockList.Cast().ToList(); @@ -45,7 +47,7 @@ protected static IMenuBarItem CompareBuildingBlocks(IReadOnlyList x.Name).ToList(); if (canStartComparisonFor(buildingBlockList)) - return ComparisonCommonContextMenuItems.CompareObjectsMenu(objectBaseList, buildingBlockNames, executionContext); + return ComparisonCommonContextMenuItems.CompareObjectsMenu(objectBaseList, buildingBlockNames, executionContext, _container); return comparisonNotPossibleMenu(buildingBlockList, executionContext); } @@ -54,7 +56,7 @@ protected IMenuBarItem SaveAsUserTemplateMenuFor(IReadOnlyList x.BuildingBlock).ToList(); return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SaveAsTemplate) - .WithCommandFor, IReadOnlyList>(buildingBlockList) + .WithCommandFor, IReadOnlyList>(buildingBlockList, _container) .WithIcon(ApplicationIcons.SaveAsTemplate); } @@ -62,24 +64,24 @@ protected IMenuBarItem SaveAsSystemTemplateMenuFor(IReadOnlyList x.BuildingBlock).ToList(); return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SaveAsSystemTemplate) - .WithCommandFor, IReadOnlyList>(buildingBlockList) + .WithCommandFor, IReadOnlyList>(buildingBlockList, _container) .WithIcon(ApplicationIcons.SaveAsTemplate) .ForDeveloper(); } - protected static IMenuBarItem AddToJournal(IReadOnlyList> buildingBlocks) + protected IMenuBarItem AddToJournal(IReadOnlyList> buildingBlocks) { var objectBaseList = buildingBlocks.Select(x => x.BuildingBlock).Cast().ToList(); - return ObjectBaseCommonContextMenuItems.AddToJournal(objectBaseList); + return ObjectBaseCommonContextMenuItems.AddToJournal(objectBaseList, _container); } - protected static IMenuBarButton DeleteSelectedBuildingBlockMenuItem(IReadOnlyList> buildingBlocks) + protected IMenuBarButton DeleteSelectedBuildingBlockMenuItem(IReadOnlyList> buildingBlocks) { var buildingBlockList = buildingBlocks.Select(x => x.BuildingBlock).ToList(); return CreateMenuButton.WithCaption(MenuNames.Delete) - .WithCommandFor>(buildingBlockList) + .WithCommandFor>(buildingBlockList, _container) .WithIcon(ApplicationIcons.Delete) .AsGroupStarter(); } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleComparisonNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleComparisonNodeContextMenu.cs index 1b1920a36..dd96e775f 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleComparisonNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleComparisonNodeContextMenu.cs @@ -9,19 +9,20 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleComparisonNodeContextMenu : ContextMenu, IExecutionContext> { - public MultipleComparisonNodeContextMenu(IReadOnlyList simulationComparisons, IExecutionContext executionContext) : base(simulationComparisons, executionContext) + public MultipleComparisonNodeContextMenu(IReadOnlyList simulationComparisons, IExecutionContext executionContext, IContainer container) : base(simulationComparisons, executionContext, container) { } protected override IEnumerable AllMenuItemsFor(IReadOnlyList simulationComparisons, IExecutionContext executionContext) { yield return CreateMenuButton.WithCaption(MenuNames.Delete) - .WithCommandFor>(simulationComparisons) + .WithCommandFor>(simulationComparisons, _container) .WithIcon(ApplicationIcons.Delete); } } @@ -29,15 +30,17 @@ protected override IEnumerable AllMenuItemsFor(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleComparisonNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleComparisonNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList classifiableComparisons, IPresenterWithContextMenu> presenter) { - return new MultipleComparisonNodeContextMenu(classifiableComparisons.Select(x => x.Subject).ToList(), _executionContext); + return new MultipleComparisonNodeContextMenu(classifiableComparisons.Select(x => x.Subject).ToList(), _executionContext, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleCompoundNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleCompoundNodeContextMenu.cs index a9203281f..8b07e97ef 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleCompoundNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleCompoundNodeContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -9,13 +10,13 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleCompoundNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleCompoundNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext) - : base(buildingBlocks, executionContext) + public MultipleCompoundNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext, IContainer container) + : base(buildingBlocks, executionContext, container) { } - public MultipleCompoundNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext) - : base(buildingBlocks, executionContext) + public MultipleCompoundNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext, IContainer container) + : base(buildingBlocks, executionContext, container) { } } @@ -23,15 +24,17 @@ public MultipleCompoundNodeContextMenu(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleCompoundNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleCompoundNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList buildingBlocks, IPresenterWithContextMenu> presenter) { - return new MultipleCompoundNodeContextMenu(buildingBlocks, _executionContext); + return new MultipleCompoundNodeContextMenu(buildingBlocks, _executionContext, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleEventNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleEventNodeContextMenu.cs index 2d65f1869..c5bfe3f42 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleEventNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleEventNodeContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -9,11 +10,11 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleEventNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleEventNodeContextMenu(IReadOnlyList events, IExecutionContext executionContext) : base(events, executionContext) + public MultipleEventNodeContextMenu(IReadOnlyList events, IExecutionContext executionContext, IContainer container) : base(events, executionContext, container) { } - public MultipleEventNodeContextMenu(IReadOnlyList> events, IExecutionContext executionContext) : base(events, executionContext) + public MultipleEventNodeContextMenu(IReadOnlyList> events, IExecutionContext executionContext, IContainer container) : base(events, executionContext, container) { } } @@ -21,15 +22,17 @@ public MultipleEventNodeContextMenu(IReadOnlyList public class MultipleEventNodeContextMenuFactory : MultipleNodeContextMenuFactory { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleEventNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleEventNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList events, IPresenterWithContextMenu> presenter) { - return new MultipleEventNodeContextMenu(events, _executionContext); + return new MultipleEventNodeContextMenu(events, _executionContext, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleExpressionProfileNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleExpressionProfileNodeContextMenu.cs index d0cb38bc6..4a933adf9 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleExpressionProfileNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleExpressionProfileNodeContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -11,11 +12,11 @@ namespace PKSim.Presentation.Presenters.ContextMenus public class MultipleExpressionProfileNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleExpressionProfileNodeContextMenu(IReadOnlyList expressionProfiles, IExecutionContext executionContext) : base(expressionProfiles, executionContext) + public MultipleExpressionProfileNodeContextMenu(IReadOnlyList expressionProfiles, IExecutionContext executionContext, IContainer container) : base(expressionProfiles, executionContext, container) { } - public MultipleExpressionProfileNodeContextMenu(IReadOnlyList> expressionProfiles, IExecutionContext executionContext) : base(expressionProfiles, executionContext) + public MultipleExpressionProfileNodeContextMenu(IReadOnlyList> expressionProfiles, IExecutionContext executionContext, IContainer container) : base(expressionProfiles, executionContext, container) { } } @@ -23,15 +24,17 @@ public MultipleExpressionProfileNodeContextMenu(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleExpressionProfileNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleExpressionProfileNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList events, IPresenterWithContextMenu> presenter) { - return new MultipleExpressionProfileNodeContextMenu(events, _executionContext); + return new MultipleExpressionProfileNodeContextMenu(events, _executionContext, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleFormulationNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleFormulationNodeContextMenu.cs index e99cc3f73..9cb741657 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleFormulationNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleFormulationNodeContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -9,11 +10,11 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleFormulationNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleFormulationNodeContextMenu(IReadOnlyList formulations, IExecutionContext executionContext) : base(formulations, executionContext) + public MultipleFormulationNodeContextMenu(IReadOnlyList formulations, IExecutionContext executionContext, IContainer container) : base(formulations, executionContext, container) { } - public MultipleFormulationNodeContextMenu(IReadOnlyList> formulations, IExecutionContext executionContext) : base(formulations, executionContext) + public MultipleFormulationNodeContextMenu(IReadOnlyList> formulations, IExecutionContext executionContext, IContainer container) : base(formulations, executionContext, container) { } } @@ -21,15 +22,17 @@ public MultipleFormulationNodeContextMenu(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleFormulationNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleFormulationNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList formulations, IPresenterWithContextMenu> presenter) { - return new MultipleFormulationNodeContextMenu(formulations, _executionContext); + return new MultipleFormulationNodeContextMenu(formulations, _executionContext, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleIndividualNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleIndividualNodeContextMenu.cs index f266fa8e2..f20866ea2 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleIndividualNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleIndividualNodeContextMenu.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using System.Linq; using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -10,11 +10,11 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleIndividualNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleIndividualNodeContextMenu(IReadOnlyList individuals, IExecutionContext executionContext) : base(individuals, executionContext) + public MultipleIndividualNodeContextMenu(IReadOnlyList individuals, IExecutionContext executionContext, IContainer container) : base(individuals, executionContext, container) { } - public MultipleIndividualNodeContextMenu(IReadOnlyList> individuals, IExecutionContext executionContext) : base(individuals, executionContext) + public MultipleIndividualNodeContextMenu(IReadOnlyList> individuals, IExecutionContext executionContext, IContainer container) : base(individuals, executionContext, container) { } } @@ -22,15 +22,17 @@ public MultipleIndividualNodeContextMenu(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleIndividualNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleIndividualNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList individuals, IPresenterWithContextMenu> presenter) { - return new MultipleIndividualNodeContextMenu(individuals, _executionContext); + return new MultipleIndividualNodeContextMenu(individuals, _executionContext, _container); } } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleObserverSetNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleObserverSetNodeContextMenu.cs index 5379c3a23..96592ee0d 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleObserverSetNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleObserverSetNodeContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -9,13 +10,13 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleObserverSetNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleObserverSetNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext) - : base(buildingBlocks, executionContext) + public MultipleObserverSetNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext, IContainer container) + : base(buildingBlocks, executionContext, container) { } - public MultipleObserverSetNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext) - : base(buildingBlocks, executionContext) + public MultipleObserverSetNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext, IContainer container) + : base(buildingBlocks, executionContext, container) { } } @@ -23,15 +24,17 @@ public MultipleObserverSetNodeContextMenu(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleObserverSetNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleObserverSetNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList buildingBlocks, IPresenterWithContextMenu> presenter) { - return new MultipleObserverSetNodeContextMenu(buildingBlocks, _executionContext); + return new MultipleObserverSetNodeContextMenu(buildingBlocks, _executionContext, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultiplePopulationNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultiplePopulationNodeContextMenu.cs index a19bd5b1f..65d7f4773 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultiplePopulationNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultiplePopulationNodeContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -9,13 +10,13 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultiplePopulationNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultiplePopulationNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext) - : base(buildingBlocks, executionContext) + public MultiplePopulationNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext, IContainer container) + : base(buildingBlocks, executionContext, container) { } - public MultiplePopulationNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext) - : base(buildingBlocks, executionContext) + public MultiplePopulationNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext, IContainer container) + : base(buildingBlocks, executionContext, container) { } } @@ -23,15 +24,17 @@ public MultiplePopulationNodeContextMenu(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultiplePopulationNodeContextMenuFactory(IExecutionContext executionContext) + public MultiplePopulationNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList buildingBlocks, IPresenterWithContextMenu> presenter) { - return new MultiplePopulationNodeContextMenu(buildingBlocks, _executionContext); + return new MultiplePopulationNodeContextMenu(buildingBlocks, _executionContext, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleProtocolNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleProtocolNodeContextMenu.cs index a0801ebe7..52e58e5ed 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleProtocolNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleProtocolNodeContextMenu.cs @@ -2,6 +2,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; @@ -9,11 +10,11 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleProtocolNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleProtocolNodeContextMenu(IReadOnlyList protocols, IExecutionContext executionContext) : base(protocols, executionContext) + public MultipleProtocolNodeContextMenu(IReadOnlyList protocols, IExecutionContext executionContext, IContainer container) : base(protocols, executionContext, container) { } - public MultipleProtocolNodeContextMenu(IReadOnlyList> protocols, IExecutionContext executionContext) : base(protocols, executionContext) + public MultipleProtocolNodeContextMenu(IReadOnlyList> protocols, IExecutionContext executionContext, IContainer container) : base(protocols, executionContext, container) { } } @@ -21,15 +22,17 @@ public MultipleProtocolNodeContextMenu(IReadOnlyList { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleProtocolNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleProtocolNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList protocols, IPresenterWithContextMenu> presenter) { - return new MultipleProtocolNodeContextMenu(protocols, _executionContext); + return new MultipleProtocolNodeContextMenu(protocols, _executionContext, _container); } } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleSimulationNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleSimulationNodeContextMenu.cs index 841238622..b3226f514 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleSimulationNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleSimulationNodeContextMenu.cs @@ -6,33 +6,36 @@ using PKSim.Core.Model; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleSimulationNodeContextMenuFactory : MultipleNodeContextMenuFactory { private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleSimulationNodeContextMenuFactory(IExecutionContext executionContext) + public MultipleSimulationNodeContextMenuFactory(IExecutionContext executionContext, IContainer container) { _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList classifiableSimulations, IPresenterWithContextMenu> presenter) { - return new MultipleSimulationNodeContextMenu(classifiableSimulations.Select(x => x.Subject).ToList(), _executionContext); + return new MultipleSimulationNodeContextMenu(classifiableSimulations.Select(x => x.Subject).ToList(), _executionContext, _container); } } public class MultipleSimulationNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleSimulationNodeContextMenu(IReadOnlyList simulations, IExecutionContext executionContext) - : base(simulations, executionContext) + public MultipleSimulationNodeContextMenu(IReadOnlyList simulations, IExecutionContext executionContext, IContainer container) + : base(simulations, executionContext, container) { } - public MultipleSimulationNodeContextMenu(IReadOnlyList> simulations, IExecutionContext executionContext) - : base(simulations, executionContext) + public MultipleSimulationNodeContextMenu(IReadOnlyList> simulations, IExecutionContext executionContext, IContainer container) + : base(simulations, executionContext, container) { } @@ -42,14 +45,14 @@ protected override IEnumerable AllMenuItemsFor(IReadOnlyList> simulations) + private IMenuBarItem startParameterIdentification(IReadOnlyList> simulations) { - return ParameterIdentificationContextMenuItems.CreateParameterIdentificationFor(simulations.Select(x => x.BuildingBlock)); + return ParameterIdentificationContextMenuItems.CreateParameterIdentificationFor(simulations.Select(x => x.BuildingBlock), _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedBuildingBlockNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedBuildingBlockNodeContextMenu.cs index e7ba22d77..ea04c0f99 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedBuildingBlockNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedBuildingBlockNodeContextMenu.cs @@ -4,6 +4,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core; using PKSim.Core.Model; using PKSim.Core.Services; @@ -12,11 +13,11 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleUsedBuildingBlockNodeContextMenu : MultipleBuildingBlockNodeContextMenu { - public MultipleUsedBuildingBlockNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext) : base(buildingBlocks, executionContext) + public MultipleUsedBuildingBlockNodeContextMenu(IReadOnlyList buildingBlocks, IExecutionContext executionContext, IContainer container) : base(buildingBlocks, executionContext, container) { } - public MultipleUsedBuildingBlockNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext) : base(buildingBlocks, executionContext) + public MultipleUsedBuildingBlockNodeContextMenu(IReadOnlyList> buildingBlocks, IExecutionContext executionContext, IContainer container) : base(buildingBlocks, executionContext, container) { } @@ -34,17 +35,19 @@ public class MultipleUsedBuildingBlockNodeContextMenuFactory : MultipleNodeConte { private readonly IBuildingBlockInProjectManager _buildingBlockInProjectManager; private readonly IExecutionContext _executionContext; + private readonly IContainer _container; - public MultipleUsedBuildingBlockNodeContextMenuFactory(IBuildingBlockInProjectManager buildingBlockInProjectManager, IExecutionContext executionContext) + public MultipleUsedBuildingBlockNodeContextMenuFactory(IBuildingBlockInProjectManager buildingBlockInProjectManager, IExecutionContext executionContext, IContainer container) { _buildingBlockInProjectManager = buildingBlockInProjectManager; _executionContext = executionContext; + _container = container; } protected override IContextMenu CreateFor(IReadOnlyList usedBuildingBlock, IPresenterWithContextMenu> presenter) { var buildingBlocks = loadedBuildingBlocksBasedOn(usedBuildingBlock); - return new MultipleUsedBuildingBlockNodeContextMenu(buildingBlocks, _executionContext); + return new MultipleUsedBuildingBlockNodeContextMenu(buildingBlocks, _executionContext, _container); } private IReadOnlyList> loadedBuildingBlocksBasedOn(IEnumerable usedBuildingBlocks) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedObservedDataContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedObservedDataContextMenu.cs index 8064625c8..2a2185936 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedObservedDataContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/MultipleUsedObservedDataContextMenu.cs @@ -7,19 +7,20 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation.Presenters.ContextMenus { public class MultipleUsedObservedDataContextMenu : ContextMenu> { - public MultipleUsedObservedDataContextMenu(IReadOnlyList usedObservedData) : base(usedObservedData) + public MultipleUsedObservedDataContextMenu(IReadOnlyList usedObservedData, IContainer container) : base(usedObservedData, container) { } protected override IEnumerable AllMenuItemsFor(IReadOnlyList usedObservedData) { yield return CreateMenuButton.WithCaption(MenuNames.Remove) - .WithCommandFor>(usedObservedData) + .WithCommandFor>(usedObservedData, _container) .WithIcon(ApplicationIcons.Remove) .AsGroupStarter(); } @@ -27,9 +28,16 @@ protected override IEnumerable AllMenuItemsFor(IReadOnlyList { + private readonly IContainer _container; + + public MultipleUsedObservedDataContextMenuFactory(IContainer container) + { + _container = container; + } + protected override IContextMenu CreateFor(IReadOnlyList usedObservedData, IPresenterWithContextMenu> presenter) { - return new MultipleUsedObservedDataContextMenu(usedObservedData); + return new MultipleUsedObservedDataContextMenu(usedObservedData, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataContextMenu.cs index cd5ce30e3..344d01e48 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataContextMenu.cs @@ -20,8 +20,8 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class ObservedDataContextMenu : ContextMenu { - public ObservedDataContextMenu(DataRepository dataRepository, Simulation activeSimulation) - : base(dataRepository, activeSimulation) + public ObservedDataContextMenu(DataRepository dataRepository, Simulation activeSimulation, IContainer container) + : base(dataRepository, activeSimulation, container) { } @@ -29,34 +29,34 @@ public ObservedDataContextMenu(DataRepository dataRepository, Simulation activeS protected override IEnumerable AllMenuItemsFor(DataRepository dataRepository, Simulation activeSimulation) { yield return CreateMenuButton.WithCaption(MenuNames.Edit) - .WithCommandFor, DataRepository>(dataRepository) + .WithCommandFor, DataRepository>(dataRepository, _container) .WithIcon(ApplicationIcons.Edit); yield return CreateMenuButton.WithCaption(MenuNames.Rename) - .WithCommandFor(dataRepository) + .WithCommandFor(dataRepository, _container) .WithIcon(ApplicationIcons.Rename); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SaveAsTemplate) - .WithCommandFor(dataRepository) + .WithCommandFor(dataRepository, _container) .WithIcon(ApplicationIcons.SaveAsTemplate) .AsGroupStarter(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ReloadAllRelated.WithEllipsis()) - .WithCommandFor(dataRepository) + .WithCommandFor(dataRepository, _container) .AsDisabledIf(string.IsNullOrEmpty(dataRepository.ConfigurationId)) .WithIcon(ApplicationIcons.RefreshAll); yield return CreateMenuButton.WithCaption(Captions.ExportToExcel.WithEllipsis()) - .WithCommandFor(dataRepository) + .WithCommandFor(dataRepository, _container) .WithIcon(ApplicationIcons.Excel); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportToPKML) - .WithCommandFor(dataRepository) + .WithCommandFor(dataRepository, _container) .WithIcon(ApplicationIcons.PKMLSave); - yield return GenericMenu.AddToJournal(dataRepository); + yield return GenericMenu.AddToJournal(dataRepository, _container); - yield return GenericMenu.ExportSnapshotMenuFor(dataRepository); + yield return GenericMenu.ExportSnapshotMenuFor(dataRepository, _container); if (activeSimulation != null && !activeSimulation.UsesObservedData(dataRepository)) yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AddObservedDataToSimulation(activeSimulation.Name)) @@ -64,7 +64,7 @@ protected override IEnumerable AllMenuItemsFor(DataRepository data .WithIcon(ApplicationIcons.Simulation); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Delete) - .WithCommandFor(dataRepository) + .WithCommandFor(dataRepository, _container) .WithIcon(ApplicationIcons.Delete) .AsGroupStarter(); } @@ -73,10 +73,12 @@ protected override IEnumerable AllMenuItemsFor(DataRepository data public class ObservedDataTreeNodeContextMenuFactory : IContextMenuSpecificationFactory { private readonly IActiveSubjectRetriever _activeSubjectRetriever; + private readonly IContainer _container; - public ObservedDataTreeNodeContextMenuFactory(IActiveSubjectRetriever activeSubjectRetriever) + public ObservedDataTreeNodeContextMenuFactory(IActiveSubjectRetriever activeSubjectRetriever, IContainer container) { _activeSubjectRetriever = activeSubjectRetriever; + _container = container; } public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) @@ -86,7 +88,7 @@ public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new ObservedDataContextMenu(treeNode.DowncastTo().Tag.Repository,_activeSubjectRetriever.Active< Simulation>()); + return new ObservedDataContextMenu(treeNode.DowncastTo().Tag.Repository,_activeSubjectRetriever.Active< Simulation>(), _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataFolderContextMenu.cs index 7f05704fa..1dea06696 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ObservedDataFolderContextMenu.cs @@ -15,6 +15,7 @@ using OSPSuite.Presentation.Repositories; using OSPSuite.Assets; using System; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { @@ -25,7 +26,7 @@ public ObservedDataFolderContextMenu( IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IBuildingBlockExplorerPresenter presenter, - IUserSettings userSettings) + IUserSettings userSettings, IContainer container) : base(container) { var allCompounds = buildingBlockRepository.All().ToList(); @@ -37,7 +38,7 @@ public ObservedDataFolderContextMenu( foreach (var compound in allCompounds) { addObservedDataFor.AddItem(CreateMenuButton.WithCaption(compound.Name) - .WithCommandFor(compound)); + .WithCommandFor(compound, container)); } _view.AddMenuItem(repository[MenuBarItemIds.AddObservedData]); @@ -49,18 +50,18 @@ public ObservedDataFolderContextMenu( _view.AddMenuItem(CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) - .WithCommand() + .WithCommand(container) .WithIcon(ApplicationIcons.LoadFromTemplate) .AsGroupStarter()); _view.AddMenuItem(CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Load from Snapshot")) - .WithCommand() + .WithCommand(container) .WithIcon(ApplicationIcons.SnapshotImport) .ForDeveloper()); if (treeNode.AllLeafNodes.OfType().Any()) - _view.AddMenuItem(ObservedDataClassificationCommonContextMenuItems.EditMultipleMetaData(treeNode).AsGroupStarter()); + _view.AddMenuItem(ObservedDataClassificationCommonContextMenuItems.EditMultipleMetaData(treeNode, container).AsGroupStarter()); _view.AddMenuItem(ClassificationCommonContextMenuItems.CreateClassificationUnderMenu(treeNode, presenter)); @@ -94,17 +95,19 @@ public class ObservedDataFolderTreeNodeContextMenuFactory : RootNodeContextMenuF { private readonly IBuildingBlockRepository _buildingBlockRepository; private readonly IUserSettings _userSettings; + private readonly IContainer _container; - public ObservedDataFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IUserSettings userSettings) + public ObservedDataFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IUserSettings userSettings, IContainer container) : base(RootNodeTypes.ObservedDataFolder, repository) { _buildingBlockRepository = buildingBlockRepository; _userSettings = userSettings; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new ObservedDataFolderContextMenu(treeNode, _repository, _buildingBlockRepository, presenter.DowncastTo(), _userSettings); + return new ObservedDataFolderContextMenu(treeNode, _repository, _buildingBlockRepository, presenter.DowncastTo(), _userSettings, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetContextMenu.cs index 3f97fdfe0..aa5ed4040 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetContextMenu.cs @@ -3,6 +3,7 @@ using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using PKSim.Core.Model; using PKSim.Presentation.UICommands; @@ -10,7 +11,7 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class ObserverSetContextMenu : BuildingBlockContextMenu { - public ObserverSetContextMenu(ObserverSet observerSet) : base(observerSet) + public ObserverSetContextMenu(ObserverSet observerSet, IContainer container) : base(observerSet, container) { } @@ -22,9 +23,16 @@ protected override IEnumerable AllMenuItemsFor(ObserverSet observe public class ObserverSetTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public ObserverSetTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(ObserverSet observerSet, IPresenterWithContextMenu presenter) { - return new ObserverSetContextMenu(observerSet); + return new ObserverSetContextMenu(observerSet, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetFolderContextMenu.cs index 552066c57..ac9e1b06b 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ObserverSetFolderContextMenu.cs @@ -3,6 +3,7 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; using PKSim.Core.Model; using PKSim.Core.Repositories; using PKSim.Presentation.Core; @@ -12,8 +13,8 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class ObserverSetFolderContextMenu : BuildingBlockFolderContextMenu { - public ObserverSetFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewObserverSet, MenuBarItemIds.LoadObserverSet) + public ObserverSetFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewObserverSet, MenuBarItemIds.LoadObserverSet) { } } @@ -21,16 +22,18 @@ public ObserverSetFolderContextMenu(IMenuBarItemRepository repository, IBuilding public class ObserverSetFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public ObserverSetFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public ObserverSetFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.ObserverSetFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new ObserverSetFolderContextMenu(_repository, _buildingBlockRepository); + return new ObserverSetFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ParameterEditContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ParameterEditContextMenu.cs index b32a3a3f0..e85b880ff 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ParameterEditContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ParameterEditContextMenu.cs @@ -8,13 +8,14 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class ParameterEditContextMenu : ContextMenu { - public ParameterEditContextMenu(IParameterDTO parameterDTO, IParameterSetPresenter presenter) - : base(parameterDTO, presenter) + public ParameterEditContextMenu(IParameterDTO parameterDTO, IParameterSetPresenter presenter, IContainer container) + : base(parameterDTO, presenter, container) { } @@ -31,9 +32,16 @@ protected override IEnumerable AllMenuItemsFor(IParameterDTO param public class ParameterEditContextMenuFactory : IContextMenuSpecificationFactory { + private readonly IContainer _container; + + public ParameterEditContextMenuFactory(IContainer container) + { + _container = container; + } + public IContextMenu CreateFor(IParameterDTO parameterDTO, IPresenterWithContextMenu presenter) { - return new ParameterEditContextMenu(parameterDTO, presenter.DowncastTo()); + return new ParameterEditContextMenu(parameterDTO, presenter.DowncastTo(), _container); } public bool IsSatisfiedBy(IParameterDTO parameterDTO, IPresenterWithContextMenu presenter) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ParameterIdentificationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ParameterIdentificationContextMenu.cs index 1b6ad2b16..21609a573 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ParameterIdentificationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ParameterIdentificationContextMenu.cs @@ -9,18 +9,19 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using PKSim.Assets; using PKSim.Presentation.UICommands; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation.Presenters.ContextMenus { public class ParameterIdentificationContextMenu : ContextMenu { - public ParameterIdentificationContextMenu(ParameterIdentification parameterIdentification) : base(parameterIdentification) + public ParameterIdentificationContextMenu(ParameterIdentification parameterIdentification, IContainer container) : base(parameterIdentification, container) { } protected override IEnumerable AllMenuItemsFor(ParameterIdentification parameterIdentification) { - return new List(ParameterIdentificationContextMenuItems.ContextMenuItemsFor(parameterIdentification)) + return new List(ParameterIdentificationContextMenuItems.ContextMenuItemsFor(parameterIdentification, _container)) { exportParameterIdentificationToR(parameterIdentification) }; @@ -29,7 +30,7 @@ protected override IEnumerable AllMenuItemsFor(ParameterIdentifica private IMenuBarItem exportParameterIdentificationToR(ParameterIdentification parameterIdentification) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Export for R®")) - .WithCommandFor(parameterIdentification) + .WithCommandFor(parameterIdentification, _container) .WithIcon(ApplicationIcons.R) .AsGroupStarter() .ForDeveloper(); @@ -38,9 +39,16 @@ private IMenuBarItem exportParameterIdentificationToR(ParameterIdentification pa public class ParameterIdentificationContextMenuTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public ParameterIdentificationContextMenuTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(ClassifiableParameterIdentification classifiableParameterIdentification, IPresenterWithContextMenu presenter) { - return new ParameterIdentificationContextMenu(classifiableParameterIdentification.ParameterIdentification); + return new ParameterIdentificationContextMenu(classifiableParameterIdentification.ParameterIdentification, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessContextMenu.cs index b0bf6bcab..377f99ea5 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessContextMenu.cs @@ -7,13 +7,14 @@ using OSPSuite.Assets; using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class PartialProcessContextMenu : CompoundProcessContextMenu { - public PartialProcessContextMenu(PartialProcess compoundProcess, ICompoundProcessesPresenter presenter) - : base(compoundProcess, presenter) + public PartialProcessContextMenu(PartialProcess compoundProcess, ICompoundProcessesPresenter presenter, IContainer container) + : base(compoundProcess, presenter, container) { } @@ -29,9 +30,16 @@ protected override IEnumerable AllMenuItemsFor(PartialProcess part public class PartialProcessTreeNodeContextMenuFactory : CompoundProcessTreeNodeContextMenuFactory { + private readonly IContainer _container; + + public PartialProcessTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + protected override IContextMenu CreateFor(PartialProcess compoundProcess, ICompoundProcessesPresenter compoundProcessesPresenter) { - return new PartialProcessContextMenu(compoundProcess, compoundProcessesPresenter); + return new PartialProcessContextMenu(compoundProcess, compoundProcessesPresenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessMoleculeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessMoleculeContextMenu.cs index 179d37612..e8f129f9f 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessMoleculeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PartialProcessMoleculeContextMenu.cs @@ -10,13 +10,14 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class PartialProcessMoleculeContextMenu : ContextMenu { - public PartialProcessMoleculeContextMenu(PartialProcessMoleculeNode partialProcessMoleculeNode, ICompoundProcessesPresenter presenter) - : base(partialProcessMoleculeNode, presenter) + public PartialProcessMoleculeContextMenu(PartialProcessMoleculeNode partialProcessMoleculeNode, ICompoundProcessesPresenter presenter, IContainer container) + : base(partialProcessMoleculeNode, presenter, container) { } @@ -36,9 +37,16 @@ protected override IEnumerable AllMenuItemsFor(PartialProcessMolec public class PartialProcessMoleculeTreeNodeContextMenuFactory : IContextMenuSpecificationFactory { + private readonly IContainer _container; + + public PartialProcessMoleculeTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new PartialProcessMoleculeContextMenu(treeNode.DowncastTo(), presenter.DowncastTo()); + return new PartialProcessMoleculeContextMenu(treeNode.DowncastTo(), presenter.DowncastTo(), _container); } public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDataFieldContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDataFieldContextMenu.cs index eb95cea5e..129b8b72c 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDataFieldContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDataFieldContextMenu.cs @@ -8,13 +8,14 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class PopulationAnalysisDataFieldContextMenu : ContextMenu { - public PopulationAnalysisDataFieldContextMenu(PopulationAnalysisDataField populationAnalysisDataField, IPopulationAnalysisFieldsPresenter presenter) - : base(populationAnalysisDataField, presenter) + public PopulationAnalysisDataFieldContextMenu(PopulationAnalysisDataField populationAnalysisDataField, IPopulationAnalysisFieldsPresenter presenter, IContainer container) + : base(populationAnalysisDataField, presenter, container) { } @@ -41,10 +42,17 @@ protected override IEnumerable AllMenuItemsFor(PopulationAnalysisD public class PopulationAnalysisDataFieldContextMenuFactory : IContextMenuSpecificationFactory { + private readonly IContainer _container; + + public PopulationAnalysisDataFieldContextMenuFactory(IContainer container) + { + _container = container; + } + public IContextMenu CreateFor(IPopulationAnalysisField populationAnalysisField, IPresenterWithContextMenu presenter) { return new PopulationAnalysisDataFieldContextMenu(populationAnalysisField.DowncastTo(), - presenter.DowncastTo()); + presenter.DowncastTo(), _container); } public bool IsSatisfiedBy(IPopulationAnalysisField populationAnalysisField, IPresenterWithContextMenu presenter) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDerivedFieldContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDerivedFieldContextMenu.cs index 5d90dcdc8..9c350c375 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDerivedFieldContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationAnalysisDerivedFieldContextMenu.cs @@ -8,13 +8,14 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class PopulationAnalysisDerivedFieldContextMenu : ContextMenu { - public PopulationAnalysisDerivedFieldContextMenu(PopulationAnalysisDerivedField populationAnalysisDerivedField, IPopulationAnalysisFieldsPresenter presenter) - : base(populationAnalysisDerivedField, presenter) + public PopulationAnalysisDerivedFieldContextMenu(PopulationAnalysisDerivedField populationAnalysisDerivedField, IPopulationAnalysisFieldsPresenter presenter, IContainer container) + : base(populationAnalysisDerivedField, presenter, container) { } @@ -38,10 +39,17 @@ protected override IEnumerable AllMenuItemsFor(PopulationAnalysisD public class PopulationAnalysisDerivedFieldContextMenuFactory : IContextMenuSpecificationFactory { + private readonly IContainer _container; + + public PopulationAnalysisDerivedFieldContextMenuFactory(IContainer container) + { + _container = container; + } + public IContextMenu CreateFor(IPopulationAnalysisField populationAnalysisField, IPresenterWithContextMenu presenter) { return new PopulationAnalysisDerivedFieldContextMenu(populationAnalysisField.DowncastTo(), - presenter.DowncastTo()); + presenter.DowncastTo(), _container); } public bool IsSatisfiedBy(IPopulationAnalysisField populationAnalysisField, IPresenterWithContextMenu presenter) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationContextMenu.cs index bef0b0709..c8dec530e 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationContextMenu.cs @@ -5,13 +5,14 @@ using PKSim.Presentation.UICommands; using OSPSuite.Assets; using OSPSuite.Presentation.Core; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public abstract class PopulationContextMenu : BuildingBlockContextMenu { - protected PopulationContextMenu(Population population) - : base(population) + protected PopulationContextMenu(Population population, IContainer container) + : base(population, container) { } @@ -27,18 +28,18 @@ protected override IEnumerable AllMenuItemsFor(Population populati return allMenuItems; } - private static IMenuBarButton exportPopulationToCSVMenuFor(Population population) + private IMenuBarButton exportPopulationToCSVMenuFor(Population population) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportToCSV) .WithIcon(ApplicationIcons.PopulationExportToCSV) - .WithCommandFor(population); + .WithCommandFor(population, _container); } - private static IMenuBarButton extractIndividualsMenuFor(Population population) + private IMenuBarButton extractIndividualsMenuFor(Population population) { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExtractIndividualsMenu) .WithIcon(ApplicationIcons.Individual) - .WithCommandFor(population); + .WithCommandFor(population, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationFolderContextMenu.cs index 0203443fb..703c64a15 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationFolderContextMenu.cs @@ -7,13 +7,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class PopulationFolderContextMenu : BuildingBlockFolderContextMenu { - public PopulationFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewPopulation, MenuBarItemIds.LoadPopulation, MenuBarItemIds.ImportPopulation) + public PopulationFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewPopulation, MenuBarItemIds.LoadPopulation, MenuBarItemIds.ImportPopulation) { } } @@ -21,16 +22,18 @@ public PopulationFolderContextMenu(IMenuBarItemRepository repository, IBuildingB public class PopulationFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public PopulationFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public PopulationFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.PopulationFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new PopulationFolderContextMenu(_repository, _buildingBlockRepository); + return new PopulationFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationInSimulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationInSimulationContextMenu.cs index 94a54e8f0..8c4885b09 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationInSimulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationInSimulationContextMenu.cs @@ -1,12 +1,13 @@ using OSPSuite.Assets; +using OSPSuite.Utility.Container; using PKSim.Core.Model; namespace PKSim.Presentation.Presenters.ContextMenus { - public class PopulationInSimulationContextMenu : UsedBuidlingBlockInSimulationContextMenu + public class PopulationInSimulationContextMenu : UsedBuildingBlockInSimulationContextMenu { - public PopulationInSimulationContextMenu(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Population templatePopulation) - : base(simulation, usedBuildingBlock, templatePopulation) + public PopulationInSimulationContextMenu(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Population templatePopulation, IContainer container) + : base(simulation, usedBuildingBlock, templatePopulation, container) { } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationSimulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationSimulationContextMenu.cs index 75a7dd6de..fd200aac0 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/PopulationSimulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/PopulationSimulationContextMenu.cs @@ -8,51 +8,52 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class PopulationSimulationContextMenu : SimulationContextMenu { - public PopulationSimulationContextMenu(PopulationSimulation populationSimulation) - : base(populationSimulation) + public PopulationSimulationContextMenu(PopulationSimulation populationSimulation, IContainer container) + : base(populationSimulation, container) { } protected override IEnumerable ExportMenuItemsSpecificToType(PopulationSimulation populationSimulation) { yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadPopulationAnalysisWorkflowFromTemplate) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.LoadFromTemplate) .AsGroupStarter(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SavePopulationAnalysisWorkflowToTemplate) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.SaveAsTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportPopulationToCSV) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.PopulationExportToCSV) .AsGroupStarter(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportSimulationResultsToCSV) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.ExportToCSV); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportPKAnalysesToCSV) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.PKAnalysesExportToCSV); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportForClusterComputations) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.ClusterExport); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ImportSimulationResultsFromCSV) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.ResultsImportFromCSV) .AsGroupStarter(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ImportPKAnalysesFromCSV) - .WithCommandFor(populationSimulation) + .WithCommandFor(populationSimulation, _container) .WithIcon(ApplicationIcons.PKAnalysesImportFromCSV); } @@ -64,9 +65,16 @@ protected override IEnumerable ActionMenuItemsSpecificToType(Popul public class PopulationSimulationTreeNodeContextMenuFactory : SimulationTreeNodeContextMenuFactory { + private readonly IContainer _container; + + public PopulationSimulationTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + protected override IContextMenu CreateFor(PopulationSimulation simulation, IPresenterWithContextMenu presenter) { - return new PopulationSimulationContextMenu(simulation); + return new PopulationSimulationContextMenu(simulation, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolContextMenu.cs index b2c007ad5..0663593ce 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolContextMenu.cs @@ -5,12 +5,13 @@ using PKSim.Presentation.UICommands; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class ProtocolContextMenu : BuildingBlockContextMenu { - public ProtocolContextMenu(Protocol protocol) : base(protocol) + public ProtocolContextMenu(Protocol protocol, IContainer container) : base(protocol, container) { } @@ -22,9 +23,16 @@ protected override IEnumerable AllMenuItemsFor(Protocol protocol) public class ProtocolTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public ProtocolTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(Protocol protocol, IPresenterWithContextMenu presenter) { - return new ProtocolContextMenu(protocol); + return new ProtocolContextMenu(protocol, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolFolderContextMenu.cs index 357417752..d9ffad65e 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolFolderContextMenu.cs @@ -3,6 +3,7 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; using PKSim.Core.Model; using PKSim.Core.Repositories; using PKSim.Presentation.Core; @@ -12,8 +13,8 @@ namespace PKSim.Presentation.Presenters.ContextMenus { public class ProtocolFolderContextMenu : BuildingBlockFolderContextMenu { - public ProtocolFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) - : base(repository, buildingBlockRepository, MenuBarItemIds.NewProtocol, MenuBarItemIds.LoadProtocol) + public ProtocolFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) + : base(repository, buildingBlockRepository, container, MenuBarItemIds.NewProtocol, MenuBarItemIds.LoadProtocol) { } } @@ -21,16 +22,18 @@ public ProtocolFolderContextMenu(IMenuBarItemRepository repository, IBuildingBlo public class ProtocolFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { private readonly IBuildingBlockRepository _buildingBlockRepository; + private readonly IContainer _container; - public ProtocolFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository) + public ProtocolFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IBuildingBlockRepository buildingBlockRepository, IContainer container) : base(PKSimRootNodeTypes.ProtocolFolder, repository) { _buildingBlockRepository = buildingBlockRepository; + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new ProtocolFolderContextMenu(_repository, _buildingBlockRepository); + return new ProtocolFolderContextMenu(_repository, _buildingBlockRepository, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolInSimulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolInSimulationContextMenu.cs index 23989b4ba..39cfb8100 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolInSimulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/ProtocolInSimulationContextMenu.cs @@ -1,12 +1,13 @@ using OSPSuite.Assets; +using OSPSuite.Utility.Container; using PKSim.Core.Model; namespace PKSim.Presentation.Presenters.ContextMenus { - public class ProtocolInSimulationContextMenu : UsedBuidlingBlockInSimulationContextMenu + public class ProtocolInSimulationContextMenu : UsedBuildingBlockInSimulationContextMenu { - public ProtocolInSimulationContextMenu(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Protocol templateProtocol) - : base(simulation, usedBuildingBlock, templateProtocol) + public ProtocolInSimulationContextMenu(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Protocol templateProtocol, IContainer container) + : base(simulation, usedBuildingBlock, templateProtocol, container) { } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/RandomPopulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/RandomPopulationContextMenu.cs index fa732566c..9d573c58d 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/RandomPopulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/RandomPopulationContextMenu.cs @@ -2,21 +2,29 @@ using PKSim.Core.Model; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class RandomPopulationContextMenu : PopulationContextMenu { - public RandomPopulationContextMenu(RandomPopulation randomPopulation) : base(randomPopulation) + public RandomPopulationContextMenu(RandomPopulation randomPopulation, IContainer container) : base(randomPopulation, container) { } } public class RandomPopulationTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public RandomPopulationTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(RandomPopulation randomPopulation, IPresenterWithContextMenu presenter) { - return new RandomPopulationContextMenu(randomPopulation); + return new RandomPopulationContextMenu(randomPopulation, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SensitivityAnalysisContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SensitivityAnalysisContextMenu.cs index 8c1d7914e..82e3725f6 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SensitivityAnalysisContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SensitivityAnalysisContextMenu.cs @@ -5,26 +5,34 @@ using OSPSuite.Core.Domain.SensitivityAnalyses; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation.Presenters.ContextMenus { public class SensitivityAnalysisContextMenuTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public SensitivityAnalysisContextMenuTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(ClassifiableSensitivityAnalysis classifiableSensitivityAnalysis, IPresenterWithContextMenu presenter) { - return new SensitivityAnalysisContextMenu(classifiableSensitivityAnalysis.SensitivityAnalysis); + return new SensitivityAnalysisContextMenu(classifiableSensitivityAnalysis.SensitivityAnalysis, _container); } } public class SensitivityAnalysisContextMenu : ContextMenu { - public SensitivityAnalysisContextMenu(SensitivityAnalysis sensitivityAnalysis) : base(sensitivityAnalysis) + public SensitivityAnalysisContextMenu(SensitivityAnalysis sensitivityAnalysis, IContainer container) : base(sensitivityAnalysis, container) { } protected override IEnumerable AllMenuItemsFor(SensitivityAnalysis sensitivityAnalysis) { - return SensitivityAnalysisContextMenuItems.ContextMenuItemsFor(sensitivityAnalysis); + return SensitivityAnalysisContextMenuItems.ContextMenuItemsFor(sensitivityAnalysis, _container); } } } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationAnalysisPresenterContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationAnalysisPresenterContextMenu.cs index 3f783864d..82c093c6b 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationAnalysisPresenterContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationAnalysisPresenterContextMenu.cs @@ -6,13 +6,14 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class SimulationAnalysisPresenterContextMenu : ContextMenu { - public SimulationAnalysisPresenterContextMenu(ISimulationAnalysisPresenter simulationAnalysisPresenter, IEditAnalyzablePresenter editAnalyzablePresenter) - : base(simulationAnalysisPresenter, editAnalyzablePresenter) + public SimulationAnalysisPresenterContextMenu(ISimulationAnalysisPresenter simulationAnalysisPresenter, IEditAnalyzablePresenter editAnalyzablePresenter, IContainer container) + : base(simulationAnalysisPresenter, editAnalyzablePresenter, container) { } @@ -29,16 +30,23 @@ protected override IEnumerable AllMenuItemsFor(ISimulationAnalysis yield return CreateMenuButton.WithCaption(PKSimConstants.UI.RemoveAll) .WithActionCommand(editAnalyzablePresenter.RemoveAllAnalyses); - yield return GenericMenu.RenameMenuFor(simulationAnalysisPresenter.Analysis) + yield return GenericMenu.RenameMenuFor(simulationAnalysisPresenter.Analysis, _container) .AsGroupStarter(); } } public class SimulationAnalysisPresenterInEditAnalyzablePresenterContextMenuFactory : IContextMenuSpecificationFactory { + private readonly IContainer _container; + + public SimulationAnalysisPresenterInEditAnalyzablePresenterContextMenuFactory(IContainer container) + { + _container = container; + } + public IContextMenu CreateFor(ISimulationAnalysisPresenter simulationAnalysisPresenter, IPresenterWithContextMenu presenter) { - return new SimulationAnalysisPresenterContextMenu(simulationAnalysisPresenter, presenter.DowncastTo()); + return new SimulationAnalysisPresenterContextMenu(simulationAnalysisPresenter, presenter.DowncastTo(), _container); } public bool IsSatisfiedBy(ISimulationAnalysisPresenter simulationAnalysisPresenter, IPresenterWithContextMenu presenter) diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationComparisonContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationComparisonContextMenu.cs index 66be02f8d..48492b9a2 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationComparisonContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationComparisonContextMenu.cs @@ -8,34 +8,35 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class SimulationComparisonContextMenu : ContextMenu { - public SimulationComparisonContextMenu(ISimulationComparison summaryChart) : base(summaryChart) + public SimulationComparisonContextMenu(ISimulationComparison summaryChart, IContainer container) : base(summaryChart, container) { } protected override IEnumerable AllMenuItemsFor(ISimulationComparison simulationComparison) { - yield return GenericMenu.EditMenuFor, ISimulationComparison>(simulationComparison); + yield return GenericMenu.EditMenuFor, ISimulationComparison>(simulationComparison, _container); - yield return GenericMenu.RenameMenuFor(simulationComparison); + yield return GenericMenu.RenameMenuFor(simulationComparison, _container); - yield return GenericMenu.EditDescriptionMenuFor(simulationComparison) + yield return GenericMenu.EditDescriptionMenuFor(simulationComparison, _container) .AsGroupStarter(); var populationSimulationComparison = simulationComparison as PopulationSimulationComparison; if (populationSimulationComparison != null) { yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Configure) - .WithCommandFor(populationSimulationComparison) + .WithCommandFor(populationSimulationComparison, _container) .AsGroupStarter(); } yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Delete) - .WithCommandFor>(new[] {simulationComparison}) + .WithCommandFor>(new[] {simulationComparison}, _container) .WithIcon(ApplicationIcons.Delete) .AsGroupStarter(); } @@ -43,9 +44,16 @@ protected override IEnumerable AllMenuItemsFor(ISimulationComparis public class SimulationComparisonTreeNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public SimulationComparisonTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override IContextMenu CreateFor(ClassifiableComparison classifiableComparison, IPresenterWithContextMenu presenter) { - return new SimulationComparisonContextMenu(classifiableComparison.Comparison); + return new SimulationComparisonContextMenu(classifiableComparison.Comparison, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationContextMenu.cs index 56c61716f..6cc0dab5b 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationContextMenu.cs @@ -10,12 +10,13 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public abstract class SimulationContextMenu : BuildingBlockContextMenu where TSimulation : Simulation { - protected SimulationContextMenu(TSimulation simulation) : base(simulation) + protected SimulationContextMenu(TSimulation simulation, IContainer container) : base(simulation, container) { } @@ -47,7 +48,7 @@ private IEnumerable deleteMenuFor(TSimulation simulation) protected IMenuBarItem ExportSimulationToCppMenuItem(TSimulation simulation) { return CreateMenuButton.WithCaption(MenuNames.ExportForCpp) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .ForDeveloper(); } @@ -55,7 +56,7 @@ protected IMenuBarItem ExportSimulationToCppMenuItem(TSimulation simulation) protected IMenuBarItem ExportODEForMatlabMenuItem(TSimulation simulation) { return CreateMenuButton.WithCaption(MenuNames.AsDeveloperOnly(MenuNames.ExportODEForMatlab)) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .WithIcon(ApplicationIcons.Matlab) .ForDeveloper(); } @@ -63,21 +64,21 @@ protected IMenuBarItem ExportODEForMatlabMenuItem(TSimulation simulation) protected IMenuBarItem ExportODEForRMenuItem(TSimulation simulation) { return CreateMenuButton.WithCaption(MenuNames.AsDeveloperOnly(MenuNames.ExportODEForR)) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .WithIcon(ApplicationIcons.R) .ForDeveloper(); } private IEnumerable commonItemsForSimulations(TSimulation simulation) { - yield return GenericMenu.EditMenuFor(simulation); + yield return GenericMenu.EditMenuFor(simulation, _container); yield return RenameMenuFor(simulation); yield return DescriptionMenuFor(simulation) .AsGroupStarter(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Clone) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .WithIcon(ApplicationIcons.SimulationClone) .AsDisabledIf(simulation.IsImported) .AsGroupStarter(); @@ -85,10 +86,10 @@ private IEnumerable commonItemsForSimulations(TSimulation simulati yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Configure) .AsDisabledIf(simulation.IsImported) .WithIcon(ApplicationIcons.SimulationConfigure) - .WithCommandFor(simulation); + .WithCommandFor(simulation, _container); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Run) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .WithIcon(ApplicationIcons.Run) .AsGroupStarter(); } @@ -96,13 +97,13 @@ private IEnumerable commonItemsForSimulations(TSimulation simulati private IEnumerable commonExportItemsFormSimulation(TSimulation simulation) { yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportToMoBi) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .WithIcon(ApplicationIcons.MoBi) .AsGroupStarter() .AsDisabledIf(simulation.IsImported); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SaveToMoBiSimulation) - .WithCommandFor(simulation) + .WithCommandFor(simulation, _container) .WithIcon(ApplicationIcons.PKMLSave) .AsDisabledIf(simulation.IsImported); diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFavoritesNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFavoritesNodeContextMenu.cs index 8368828f9..74361afa7 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFavoritesNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFavoritesNodeContextMenu.cs @@ -11,25 +11,33 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.UICommands; using OSPSuite.Assets; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation.Presenters.ContextMenus { public class SimulationFavoritesNodeContextMenu : ContextMenu { - public SimulationFavoritesNodeContextMenu(IGroup group, IParameterGroupsPresenter presenter) : base(group, presenter) + public SimulationFavoritesNodeContextMenu(IGroup group, IParameterGroupsPresenter presenter, IContainer container) : base(group, presenter, container) { } protected override IEnumerable AllMenuItemsFor(IGroup group, IParameterGroupsPresenter presenter) { yield return CreateMenuButton.WithCaption(MenuNames.StartParameterIdentification) - .WithCommandFor>(presenter.AllParametersInSelectedGroup) + .WithCommandFor>(presenter.AllParametersInSelectedGroup, _container) .WithIcon(ApplicationIcons.ParameterIdentification); } } public class SimulationFavoritesNodeContextMenuFactory : NodeContextMenuFactory { + private readonly IContainer _container; + + public SimulationFavoritesNodeContextMenuFactory(IContainer container) + { + _container = container; + } + public override bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) { return base.IsSatisfiedBy(treeNode, presenter) && @@ -57,7 +65,7 @@ private bool nodeIsFavoriteNode(ITreeNode treeNode) public override IContextMenu CreateFor(IGroup group, IPresenterWithContextMenu presenter) { - return new SimulationFavoritesNodeContextMenu(group, presenter.DowncastTo()); + return new SimulationFavoritesNodeContextMenu(group, presenter.DowncastTo(), _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFolderTreeNodeContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFolderTreeNodeContextMenu.cs index 21d1139ca..0a42d8a6a 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFolderTreeNodeContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SimulationFolderTreeNodeContextMenu.cs @@ -10,17 +10,20 @@ using OSPSuite.Presentation.Repositories; using OSPSuite.Utility.Extensions; using PKSim.Assets; -using PKSim.Core.Model; using PKSim.Presentation.Core; using PKSim.Presentation.Presenters.Main; using PKSim.Presentation.UICommands; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation.Presenters.ContextMenus { public class SimulationFolderTreeNodeContextMenu : ContextMenu { - public SimulationFolderTreeNodeContextMenu(ITreeNode treeNode, IMenuBarItemRepository repository, ISimulationExplorerPresenter presenter) + private readonly IContainer _container; + + public SimulationFolderTreeNodeContextMenu(ITreeNode treeNode, IMenuBarItemRepository repository, ISimulationExplorerPresenter presenter, IContainer container) : base(container) { + _container = container; _view.AddMenuItem(repository[MenuBarItemIds.NewSimulation]); _view.AddMenuItem(ClassificationCommonContextMenuItems.CreateClassificationUnderMenu(treeNode, presenter).AsGroupStarter()); @@ -34,10 +37,10 @@ public SimulationFolderTreeNodeContextMenu(ITreeNode treeNode, IMe _view.AddMenuItem(loadSimulationFromSnapshot().AsGroupStarter()); } - private static IMenuBarItem loadSimulationFromSnapshot() + private IMenuBarItem loadSimulationFromSnapshot() { return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AsDeveloperOnly("Load from Snapshot")) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.SnapshotImport) .ForDeveloper(); } @@ -58,13 +61,16 @@ private static IMenuBarSubMenu createGroupByMenu(ITreeNode tree public class SimulationFolderTreeNodeContextMenuFactory : RootNodeContextMenuFactory { - public SimulationFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository) : base(RootNodeTypes.SimulationFolder, repository) + private readonly IContainer _container; + + public SimulationFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(RootNodeTypes.SimulationFolder, repository) { + _container = container; } public override IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new SimulationFolderTreeNodeContextMenu(treeNode, _repository, presenter.DowncastTo()); + return new SimulationFolderTreeNodeContextMenu(treeNode, _repository, presenter.DowncastTo(), _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SpecificBindingFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SpecificBindingFolderContextMenu.cs index c5086d4d6..e4212b77c 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SpecificBindingFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SpecificBindingFolderContextMenu.cs @@ -9,13 +9,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class SpecificBindingFolderContextMenu : ContextMenu { - public SpecificBindingFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter presenter) - : base(nodeRequestingContextMenu, presenter) + public SpecificBindingFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter presenter, IContainer container) + : base(nodeRequestingContextMenu, presenter, container) { } @@ -30,14 +31,17 @@ protected override IEnumerable AllMenuItemsFor(ITreeNode nodeReque public class SpecificBindingFolderTreeNodeContextMenuFactory: CompoundProcessFolderTreeNodeContextMenuFactory { - public SpecificBindingFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository) + private readonly IContainer _container; + + public SpecificBindingFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.CompoundProteinBindingPartners, repository) { + _container = container; } protected override IContextMenu CreateFor(ITreeNode treeNode, ICompoundProcessesPresenter presenter) { - return new SpecificBindingFolderContextMenu(treeNode, presenter); + return new SpecificBindingFolderContextMenu(treeNode, presenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessContextMenu.cs index 56bfaa5d6..bc54f6087 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessContextMenu.cs @@ -7,13 +7,14 @@ using OSPSuite.Assets; using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class SystemicProcessContextMenu : CompoundProcessContextMenu { - public SystemicProcessContextMenu(SystemicProcess clearanceProcess, ICompoundProcessesPresenter presenter) - : base(clearanceProcess, presenter) + public SystemicProcessContextMenu(SystemicProcess clearanceProcess, ICompoundProcessesPresenter presenter, IContainer container) + : base(clearanceProcess, presenter, container) { } @@ -29,9 +30,16 @@ protected override IEnumerable AllMenuItemsFor(SystemicProcess sys public class SystemicProcessTreeNodeContextMenuFactory : CompoundProcessTreeNodeContextMenuFactory { + private readonly IContainer _container; + + public SystemicProcessTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + protected override IContextMenu CreateFor(SystemicProcess compoundProcess, ICompoundProcessesPresenter compoundProcessesPresenter) { - return new SystemicProcessContextMenu(compoundProcess, compoundProcessesPresenter); + return new SystemicProcessContextMenu(compoundProcess, compoundProcessesPresenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessFolderContextMenu.cs index 41b10af20..76ae8b416 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/SystemicProcessFolderContextMenu.cs @@ -10,13 +10,14 @@ using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class SystemicProcessFolderContextMenu : ContextMenu { - public SystemicProcessFolderContextMenu(SystemicProcessNodeType systemicProcessNodeType, ICompoundProcessesPresenter presenter) - : base(systemicProcessNodeType, presenter) + public SystemicProcessFolderContextMenu(SystemicProcessNodeType systemicProcessNodeType, ICompoundProcessesPresenter presenter, IContainer container) + : base(systemicProcessNodeType, presenter, container) { } @@ -32,10 +33,12 @@ protected override IEnumerable AllMenuItemsFor(SystemicProcessNode public abstract class SystemicProcessFolderTreeNodeContextMenuFactory : IContextMenuSpecificationFactory { private readonly SystemicProcessNodeType _systemicProcessNodeType; + private readonly IContainer _container; - protected SystemicProcessFolderTreeNodeContextMenuFactory(SystemicProcessNodeType systemicProcessNodeType) + protected SystemicProcessFolderTreeNodeContextMenuFactory(SystemicProcessNodeType systemicProcessNodeType, IContainer container) { _systemicProcessNodeType = systemicProcessNodeType; + _container = container; } public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) @@ -47,27 +50,27 @@ public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) { - return new SystemicProcessFolderContextMenu(_systemicProcessNodeType, presenter.DowncastTo()); + return new SystemicProcessFolderContextMenu(_systemicProcessNodeType, presenter.DowncastTo(), _container); } } public class HepaticSystemicProcessFolderTreeNodeContextMenuFactory : SystemicProcessFolderTreeNodeContextMenuFactory { - public HepaticSystemicProcessFolderTreeNodeContextMenuFactory() : base(SystemicProcessNodeType.HepaticClearance) + public HepaticSystemicProcessFolderTreeNodeContextMenuFactory(IContainer container) : base(SystemicProcessNodeType.HepaticClearance, container) { } } public class RenalSystemicProcessFolderTreeNodeContextMenuFactory : SystemicProcessFolderTreeNodeContextMenuFactory { - public RenalSystemicProcessFolderTreeNodeContextMenuFactory() : base(SystemicProcessNodeType.RenalClearance) + public RenalSystemicProcessFolderTreeNodeContextMenuFactory(IContainer container) : base(SystemicProcessNodeType.RenalClearance, container) { } } public class BiliarySystemicProcessFolderTreeNodeContextMenuFactory : SystemicProcessFolderTreeNodeContextMenuFactory { - public BiliarySystemicProcessFolderTreeNodeContextMenuFactory() : base(SystemicProcessNodeType.BiliaryClearance) + public BiliarySystemicProcessFolderTreeNodeContextMenuFactory(IContainer container) : base(SystemicProcessNodeType.BiliaryClearance, container) { } } diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/TransportFolderContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/TransportFolderContextMenu.cs index 09eced45f..2db4ce675 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/TransportFolderContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/TransportFolderContextMenu.cs @@ -11,13 +11,14 @@ using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Presenters.Nodes; using OSPSuite.Presentation.Repositories; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { public class TransportFolderContextMenu : ContextMenu { - public TransportFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter presenter) - : base(nodeRequestingContextMenu, presenter) + public TransportFolderContextMenu(ITreeNode nodeRequestingContextMenu, ICompoundProcessesPresenter presenter, IContainer container) + : base(nodeRequestingContextMenu, presenter, container) { } @@ -32,14 +33,17 @@ protected override IEnumerable AllMenuItemsFor(ITreeNode nodeReque public class TransportFolderTreeNodeContextMenuFactory : CompoundProcessFolderTreeNodeContextMenuFactory { - public TransportFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository) + private readonly IContainer _container; + + public TransportFolderTreeNodeContextMenuFactory(IMenuBarItemRepository repository, IContainer container) : base(PKSimRootNodeTypes.CompoundTransportProteins, repository) { + _container = container; } protected override IContextMenu CreateFor(ITreeNode treeNode, ICompoundProcessesPresenter presenter) { - return new TransportFolderContextMenu(treeNode, presenter); + return new TransportFolderContextMenu(treeNode, presenter, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuidlingBlockInSimulationContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuildingBlockInSimulationContextMenu.cs similarity index 91% rename from src/PKSim.Presentation/Presenters/ContextMenus/UsedBuidlingBlockInSimulationContextMenu.cs rename to src/PKSim.Presentation/Presenters/ContextMenus/UsedBuildingBlockInSimulationContextMenu.cs index a64313362..00992dc73 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuidlingBlockInSimulationContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuildingBlockInSimulationContextMenu.cs @@ -7,16 +7,17 @@ using PKSim.Presentation.Core; using OSPSuite.Presentation.Core; using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; namespace PKSim.Presentation.Presenters.ContextMenus { - public class UsedBuidlingBlockInSimulationContextMenu : ContextMenu where TBuildingBlock : class, IPKSimBuildingBlock + public class UsedBuildingBlockInSimulationContextMenu : ContextMenu where TBuildingBlock : class, IPKSimBuildingBlock { protected readonly Simulation _simulation; protected readonly UsedBuildingBlock _usedBuildingBlock; private readonly TBuildingBlock _templateBuildingBlock; - public UsedBuidlingBlockInSimulationContextMenu(Simulation simulation, UsedBuildingBlock usedBuildingBlock, TBuildingBlock templateBuildingBlock) + public UsedBuildingBlockInSimulationContextMenu(Simulation simulation, UsedBuildingBlock usedBuildingBlock, TBuildingBlock templateBuildingBlock, IContainer container) : base(container) { _simulation = simulation; _usedBuildingBlock = usedBuildingBlock; diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuildingBlockInSimulationTreeNodeContextMenuFactory.cs b/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuildingBlockInSimulationTreeNodeContextMenuFactory.cs index a033f4a1c..5d75f3290 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuildingBlockInSimulationTreeNodeContextMenuFactory.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/UsedBuildingBlockInSimulationTreeNodeContextMenuFactory.cs @@ -1,14 +1,22 @@ using OSPSuite.Presentation.Nodes; +using OSPSuite.Presentation.Presenters; +using OSPSuite.Presentation.Presenters.ContextMenus; +using OSPSuite.Utility.Container; using OSPSuite.Utility.Extensions; using PKSim.Core.Model; using PKSim.Presentation.Nodes; -using OSPSuite.Presentation.Presenters; -using OSPSuite.Presentation.Presenters.ContextMenus; namespace PKSim.Presentation.Presenters.ContextMenus { public abstract class UsedBuildingBlockInSimulationTreeNodeContextMenuFactory : IContextMenuSpecificationFactory { + protected readonly IContainer _container; + + protected UsedBuildingBlockInSimulationTreeNodeContextMenuFactory(IContainer container) + { + _container = container; + } + protected abstract IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, TBuildingBlock buildingBlock); public IContextMenu CreateFor(ITreeNode treeNode, IPresenterWithContextMenu presenter) @@ -27,58 +35,85 @@ public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu { + public UsedIndividualInSimulationTreeNodeContextMenuFactory(IContainer container) : base(container) + { + } + protected override IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Individual individual) { - return new UsedBuidlingBlockInSimulationContextMenu(simulation, usedBuildingBlock, individual); + return new UsedBuildingBlockInSimulationContextMenu(simulation, usedBuildingBlock, individual, _container); } } public class UsedCompoundInSimulationTreeNodeContextMenuFactory : UsedBuildingBlockInSimulationTreeNodeContextMenuFactory { + public UsedCompoundInSimulationTreeNodeContextMenuFactory(IContainer container) : base(container) + { + } + protected override IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Compound compound) { - return new UsedBuidlingBlockInSimulationContextMenu(simulation, usedBuildingBlock, compound); + return new UsedBuildingBlockInSimulationContextMenu(simulation, usedBuildingBlock, compound, _container); } } public class UsedFormulationInSimulationTreeNodeContextMenuFactory : UsedBuildingBlockInSimulationTreeNodeContextMenuFactory { + public UsedFormulationInSimulationTreeNodeContextMenuFactory(IContainer container) : base(container) + { + } + protected override IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Formulation formulation) { - return new UsedBuidlingBlockInSimulationContextMenu(simulation, usedBuildingBlock, formulation); + return new UsedBuildingBlockInSimulationContextMenu(simulation, usedBuildingBlock, formulation, _container); } } public class UsedProtocolInSimulationTreeNodeContextMenuFactory : UsedBuildingBlockInSimulationTreeNodeContextMenuFactory { + public UsedProtocolInSimulationTreeNodeContextMenuFactory(IContainer container) : base(container) + { + } + protected override IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Protocol protocol) { - return new ProtocolInSimulationContextMenu(simulation, usedBuildingBlock, protocol); + return new ProtocolInSimulationContextMenu(simulation, usedBuildingBlock, protocol, _container); } } public class UsedEventInSimulationTreeNodeContextMenuFactory : UsedBuildingBlockInSimulationTreeNodeContextMenuFactory { + public UsedEventInSimulationTreeNodeContextMenuFactory(IContainer container) : base(container) + { + } + protected override IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, PKSimEvent pkSimEvent) { - return new UsedBuidlingBlockInSimulationContextMenu(simulation, usedBuildingBlock, pkSimEvent); + return new UsedBuildingBlockInSimulationContextMenu(simulation, usedBuildingBlock, pkSimEvent, _container); } } public class UsedPopulationInSimulationTreeNodeContextMenuFactory : UsedBuildingBlockInSimulationTreeNodeContextMenuFactory { + public UsedPopulationInSimulationTreeNodeContextMenuFactory(IContainer container) : base(container) + { + } + protected override IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, Population population) { - return new PopulationInSimulationContextMenu(simulation, usedBuildingBlock, population); + return new PopulationInSimulationContextMenu(simulation, usedBuildingBlock, population, _container); } } - public class UsedObserverSetInSimulationTreeNodeContextMenuFactory : UsedBuildingBlockInSimulationTreeNodeContextMenuFactory { + public UsedObserverSetInSimulationTreeNodeContextMenuFactory(IContainer container) : base(container) + { + } + protected override IContextMenu CreateFor(Simulation simulation, UsedBuildingBlock usedBuildingBlock, ObserverSet observerSet) { - return new UsedBuidlingBlockInSimulationContextMenu(simulation, usedBuildingBlock, observerSet); + return new UsedBuildingBlockInSimulationContextMenu(simulation, usedBuildingBlock, observerSet, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/ContextMenus/UsedObservedDataTreeNodeInSimulationExplorerContextMenu.cs b/src/PKSim.Presentation/Presenters/ContextMenus/UsedObservedDataTreeNodeInSimulationExplorerContextMenu.cs index ed2068075..584961c85 100644 --- a/src/PKSim.Presentation/Presenters/ContextMenus/UsedObservedDataTreeNodeInSimulationExplorerContextMenu.cs +++ b/src/PKSim.Presentation/Presenters/ContextMenus/UsedObservedDataTreeNodeInSimulationExplorerContextMenu.cs @@ -10,13 +10,15 @@ using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.Presenters.ContextMenus; using OSPSuite.Assets; +using System.ComponentModel; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation.Presenters.ContextMenus { public class UsedObservedDataTreeNodeInSimulationExplorerContextMenu : ContextMenu { - public UsedObservedDataTreeNodeInSimulationExplorerContextMenu(UsedObservedData usedObservedData) - : base(usedObservedData) + public UsedObservedDataTreeNodeInSimulationExplorerContextMenu(UsedObservedData usedObservedData, IContainer container) + : base(usedObservedData, container) { } @@ -31,6 +33,13 @@ protected override IEnumerable AllMenuItemsFor(UsedObservedData us public class UsedObservedDataTreeNodeInSimulationExplorerContextMenuFactory : IContextMenuSpecificationFactory { + private readonly IContainer _container; + + public UsedObservedDataTreeNodeInSimulationExplorerContextMenuFactory(IContainer container) + { + _container = container; + } + public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) { return treeNode.IsAnImplementationOf() && @@ -40,7 +49,7 @@ public bool IsSatisfiedBy(ITreeNode treeNode, IPresenterWithContextMenu presenter) { var usedObservedDataNode = treeNode.DowncastTo(); - return new UsedObservedDataTreeNodeInSimulationExplorerContextMenu(usedObservedDataNode.Tag); + return new UsedObservedDataTreeNodeInSimulationExplorerContextMenu(usedObservedDataNode.Tag, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/Individuals/CreateIndividualPresenter.cs b/src/PKSim.Presentation/Presenters/Individuals/CreateIndividualPresenter.cs index 9c13412b9..ea72bba03 100644 --- a/src/PKSim.Presentation/Presenters/Individuals/CreateIndividualPresenter.cs +++ b/src/PKSim.Presentation/Presenters/Individuals/CreateIndividualPresenter.cs @@ -1,29 +1,36 @@ +using System.Collections.Generic; +using System.Linq; using OSPSuite.Core.Services; +using OSPSuite.Presentation.Core; +using OSPSuite.Presentation.DTO; +using OSPSuite.Presentation.Presenters; +using OSPSuite.Utility.Extensions; using PKSim.Core.Commands; +using PKSim.Core.Model; using PKSim.Presentation.DTO.Core; using PKSim.Presentation.DTO.Mappers; using PKSim.Presentation.Views; using PKSim.Presentation.Views.Individuals; -using OSPSuite.Presentation.Core; -using OSPSuite.Presentation.DTO; -using OSPSuite.Presentation.Presenters; namespace PKSim.Presentation.Presenters.Individuals { - public interface ICreateIndividualPresenter : IWizardPresenter, IIndividualPresenter, ICreateBuildingBlockPresenter + public interface ICreateIndividualPresenter : IWizardPresenter, IIndividualPresenter, ICreateBuildingBlockPresenter { void CreateIndividual(); } - public class CreateIndividualPresenter : PKSimWizardPresenter, ICreateIndividualPresenter + public abstract class AbstractCreateIndividualPresenter : + PKSimWizardPresenter, + ICreateIndividualPresenter { - private ObjectBaseDTO _individualPropertiesDTO; - private readonly IBuildingBlockPropertiesMapper _propertiesMapper; - private readonly IObjectBaseDTOFactory _buildingBlockDTOFactory; - - public CreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemManager subPresenterItemManager, IDialogCreator dialogCreator, - IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory) - : base(view, subPresenterItemManager,IndividualItems.All, dialogCreator) + protected ObjectBaseDTO _individualPropertiesDTO; + protected readonly IBuildingBlockPropertiesMapper _propertiesMapper; + protected readonly IObjectBaseDTOFactory _buildingBlockDTOFactory; + + protected AbstractCreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemManager subPresenterItemManager, + IDialogCreator dialogCreator, + IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory, IReadOnlyList subPresenterItems) + : base(view, subPresenterItemManager, subPresenterItems, dialogCreator) { _propertiesMapper = propertiesMapper; _buildingBlockDTOFactory = buildingBlockDTOFactory; @@ -32,7 +39,7 @@ public CreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemMa public IPKSimCommand Create() { - _individualPropertiesDTO = _buildingBlockDTOFactory.CreateFor(); + _individualPropertiesDTO = _buildingBlockDTOFactory.CreateFor(); _view.BindToProperties(_individualPropertiesDTO); PresenterAt(IndividualItems.Settings).PrepareForCreating(); @@ -52,33 +59,26 @@ protected override bool HasData() return PresenterAt(IndividualItems.Settings).IndividualCreated; } - public PKSim.Core.Model.Individual BuildingBlock => Individual; + public Individual BuildingBlock => Individual; private void updateIndividualProperties() { _propertiesMapper.MapProperties(_individualPropertiesDTO, Individual); } - protected override void UpdateControls(int indexThatWillHaveFocus) - { - UpdateViewStatus(); - _view.NextEnabled = PresenterAt(IndividualItems.Settings).CanClose && indexThatWillHaveFocus != IndividualItems.Expression.Index; - _view.OkEnabled = CanClose; - _view.SetControlEnabled(IndividualItems.Expression, PresenterAt(IndividualItems.Settings).IndividualCreated); - _view.SetControlEnabled(IndividualItems.Parameters, PresenterAt(IndividualItems.Settings).IndividualCreated); - } - public override bool CanClose => base.CanClose && PresenterAt(IndividualItems.Settings).IndividualCreated; - public void CreateIndividual() + public virtual void CreateIndividual() { - if (PresenterAt(IndividualItems.Settings).IndividualCreated) return; + if (PresenterAt(IndividualItems.Settings).IndividualCreated) + return; //reset commands before generating a new individual _macroCommand.Clear(); PresenterAt(IndividualItems.Settings).CreateIndividual(); - if (Individual == null) return; - PresenterAt(IndividualItems.Parameters).EditIndividual(Individual); - PresenterAt(IndividualItems.Expression).EditIndividual(Individual); + if (Individual == null) + return; + + AllButSettingsPresenter.Each(x => x.EditIndividual(Individual)); } public override void WizardNext(int previousIndex) @@ -92,9 +92,40 @@ public override void WizardNext(int previousIndex) base.WizardNext(previousIndex); } - public PKSim.Core.Model.Individual Individual + protected abstract IReadOnlyList AllButSettingsPresenter { get; } + + protected override void UpdateControls(int indexThatWillHaveFocus) + { + UpdateViewStatus(); + _view.NextEnabled = PresenterAt(IndividualItems.Settings).CanClose && indexThatWillHaveFocus != _subPresenterItems.Last().Index; + _view.OkEnabled = CanClose; + _subPresenterItems.Except(new[] { _subPresenterItems.First() }).Each(x => _view.SetControlEnabled(x, PresenterAt(IndividualItems.Settings).IndividualCreated)); + } + + public Individual Individual => PresenterAt(IndividualItems.Settings).Individual; + } + + public class CreateIndividualPresenter : AbstractCreateIndividualPresenter + { + public CreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemManager subPresenterItemManager, + IDialogCreator dialogCreator, + IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory) + : base(view, subPresenterItemManager, dialogCreator, propertiesMapper, buildingBlockDTOFactory, IndividualItems.All) { - get { return PresenterAt(IndividualItems.Settings).Individual; } } + + protected override IReadOnlyList AllButSettingsPresenter => new List { PresenterAt(IndividualItems.Expression), PresenterAt(IndividualItems.Parameters) }; + } + + public class CreateIndividualPresenterForMoBi : AbstractCreateIndividualPresenter + { + public CreateIndividualPresenterForMoBi(ICreateIndividualView view, ISubPresenterItemManager subPresenterItemManager, + IDialogCreator dialogCreator, + IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory) + : base(view, subPresenterItemManager, dialogCreator, propertiesMapper, buildingBlockDTOFactory, IndividualItems.AllExceptExpression) + { + } + + protected override IReadOnlyList AllButSettingsPresenter => new List { PresenterAt(IndividualItems.Parameters) }; } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Presenters/Individuals/IndividualItem.cs b/src/PKSim.Presentation/Presenters/Individuals/IndividualItem.cs index 81ad2f687..4464681d6 100644 --- a/src/PKSim.Presentation/Presenters/Individuals/IndividualItem.cs +++ b/src/PKSim.Presentation/Presenters/Individuals/IndividualItem.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using OSPSuite.Presentation.Core; namespace PKSim.Presentation.Presenters.Individuals @@ -9,7 +10,8 @@ public static class IndividualItems public static readonly IndividualItem Parameters = new IndividualItem(); public static readonly IndividualItem Expression = new IndividualItem(); - public static readonly IReadOnlyList All = new List {Settings, Parameters, Expression}; + public static readonly IReadOnlyList All = new List { Settings, Parameters, Expression }; + public static readonly IReadOnlyList AllExceptExpression = All.Except(new[] { Expression }).ToList(); } public static class ScaleIndividualItems @@ -18,7 +20,7 @@ public static class ScaleIndividualItems public static readonly IndividualItem Scaling = new IndividualItem(); public static readonly IndividualItem Parameters = new IndividualItem(); public static readonly IndividualItem Expressions = new IndividualItem(); - public static readonly IReadOnlyList All = new List { Settings,Scaling, Parameters, Expressions }; + public static readonly IReadOnlyList All = new List { Settings, Scaling, Parameters, Expressions }; } public class IndividualItem : SubPresenterItem where TIndividualItemPresenter : IIndividualItemPresenter { diff --git a/src/PKSim.Presentation/Presenters/Individuals/IndividualMoleculesPresenter.cs b/src/PKSim.Presentation/Presenters/Individuals/IndividualMoleculesPresenter.cs index d6f4ac1cb..08f514d62 100644 --- a/src/PKSim.Presentation/Presenters/Individuals/IndividualMoleculesPresenter.cs +++ b/src/PKSim.Presentation/Presenters/Individuals/IndividualMoleculesPresenter.cs @@ -1,12 +1,12 @@ using OSPSuite.Core.Services; using PKSim.Core.Model; using PKSim.Core.Services; -using PKSim.Presentation.Nodes; using PKSim.Presentation.Presenters.Individuals.Mappers; using PKSim.Presentation.Presenters.Parameters; using PKSim.Presentation.Views.Individuals; using OSPSuite.Presentation.Presenters.ContextMenus; using PKSim.Presentation.Services; +using ITreeNodeFactory = PKSim.Presentation.Nodes.ITreeNodeFactory; namespace PKSim.Presentation.Presenters.Individuals { @@ -16,10 +16,12 @@ public interface IIndividualMoleculesPresenter : IMoleculesPresenter, IIndividua public class IndividualMoleculesPresenter : MoleculesPresenter, IIndividualMoleculesPresenter { - public IndividualMoleculesPresenter(IMoleculesView view, IEditMoleculeTask editMoleculeTask, ITreeNodeFactory treeNodeFactory, + public IndividualMoleculesPresenter(IMoleculesView view, IEditMoleculeTask editMoleculeTask, ITreeNodeFactory treeNodeFactory, ITreeNodeContextMenuFactory contextMenuFactory, IDialogCreator dialogCreator, IEntityTask entityTask, - IRootNodeToIndividualExpressionsPresenterMapper expressionsPresenterMapper, INoItemInSelectionPresenter noItemInSelectionPresenter) - : base(view, editMoleculeTask, treeNodeFactory, contextMenuFactory, dialogCreator, entityTask, expressionsPresenterMapper, noItemInSelectionPresenter) + IRootNodeToIndividualExpressionsPresenterMapper expressionsPresenterMapper, + INoItemInSelectionPresenter noItemInSelectionPresenter) + : base(view, editMoleculeTask, treeNodeFactory, contextMenuFactory, dialogCreator, entityTask, expressionsPresenterMapper, + noItemInSelectionPresenter) { } diff --git a/src/PKSim.Presentation/Presenters/Parameters/ParameterGroupsPresenter.cs b/src/PKSim.Presentation/Presenters/Parameters/ParameterGroupsPresenter.cs index e930d15be..6afee23c7 100644 --- a/src/PKSim.Presentation/Presenters/Parameters/ParameterGroupsPresenter.cs +++ b/src/PKSim.Presentation/Presenters/Parameters/ParameterGroupsPresenter.cs @@ -10,6 +10,7 @@ using OSPSuite.Utility.Collections; using OSPSuite.Utility.Events; using OSPSuite.Utility.Extensions; +using PKSim.Core; using PKSim.Core.Model; using PKSim.Core.Services; using PKSim.Presentation.Mappers; diff --git a/src/PKSim.Presentation/Repositories/MenuBarItemRepository.cs b/src/PKSim.Presentation/Repositories/MenuBarItemRepository.cs index b0915bd83..c976c0db9 100644 --- a/src/PKSim.Presentation/Repositories/MenuBarItemRepository.cs +++ b/src/PKSim.Presentation/Repositories/MenuBarItemRepository.cs @@ -23,41 +23,41 @@ protected override IEnumerable AllMenuBarItems() { yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewProject) .WithId(MenuBarItemIds.NewProject) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ProjectNew) .WithDescription(PKSimConstants.UI.NewProjectDescription) .WithShortcut(Keys.Control | Keys.N); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.OpenProject) .WithId(MenuBarItemIds.OpenProject) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.OpenProjectDescription) .WithIcon(ApplicationIcons.ProjectOpen) .WithShortcut(Keys.Control | Keys.O); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ProjectDescription) .WithId(MenuBarItemIds.ProjectDescription) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.ProjectDescriptionDescription) .WithIcon(ApplicationIcons.ProjectDescription) .WithShortcut(Keys.Control | Keys.D); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportProjectToSnapshot) .WithId(MenuBarItemIds.ExportProjectToSnapshot) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.ExportProjectToSnapshotDescription) .WithIcon(ApplicationIcons.SnapshotExport); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadProjectFromSnapshot) .WithId(MenuBarItemIds.LoadProjectFromSnahpshot) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.LoadProjectFromSnapshotDescription) .WithIcon(ApplicationIcons.SnapshotImport); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.CloseProject) .WithId(MenuBarItemIds.CloseProject) .WithDescription(PKSimConstants.UI.CloseProjectDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Close); yield return CreateSubMenu.WithCaption(PKSimConstants.MenuNames.SaveProject) @@ -68,7 +68,7 @@ protected override IEnumerable AllMenuBarItems() yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SaveProject) .WithId(MenuBarItemIds.SaveProject) .WithDescription(PKSimConstants.UI.SaveProjectDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Save) .WithShortcut(Keys.Control | Keys.S); @@ -76,103 +76,103 @@ protected override IEnumerable AllMenuBarItems() .WithId(MenuBarItemIds.SaveProjectAs) .WithDescription(PKSimConstants.UI.SaveProjectAsDescription) .WithIcon(ApplicationIcons.SaveAs) - .WithCommand(); + .WithCommand(_container); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewSimulation) .WithId(MenuBarItemIds.NewSimulation) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewSimulationDescription) .WithIcon(ApplicationIcons.Simulation) .WithShortcut(Keys.Control | Keys.Alt | Keys.S); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ImportIndividualSimulation) .WithId(MenuBarItemIds.NewImportIndividualSimulation) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.ImportIndividualSimulationDescription) .WithIcon(ApplicationIcons.IndividualSimulationLoad); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ImportPopulationSimulation) .WithId(MenuBarItemIds.NewImportPopulationSimulation) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.ImportPopulationSimulationDescription) .WithIcon(ApplicationIcons.PopulationSimulationLoad); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewIndividual) .WithId(MenuBarItemIds.NewIndividual) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewIndividualDescription) .WithIcon(ApplicationIcons.Individual) .WithShortcut(Keys.Control | Keys.Alt | Keys.I); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadIndividual) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewPopulation) .WithId(MenuBarItemIds.NewPopulation) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewPopulationDescription) .WithIcon(ApplicationIcons.Population) .WithShortcut(Keys.Control | Keys.Alt | Keys.P); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ImportPopulation) .WithId(MenuBarItemIds.ImportPopulation) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.ImportPopulationDescription) .WithIcon(ApplicationIcons.MergePopulation); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadPopulation) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewAdministrationProtocol) .WithId(MenuBarItemIds.NewProtocol) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewProtocolDescription) .WithIcon(ApplicationIcons.Protocol) .WithShortcut(Keys.Control | Keys.Alt | Keys.A); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadProtocol) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewFormulation) .WithId(MenuBarItemIds.NewFormulation) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewFormulationDescription) .WithIcon(ApplicationIcons.Formulation) .WithShortcut(Keys.Control | Keys.Alt | Keys.F); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadFormulationFromTemplate) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewEvent) .WithId(MenuBarItemIds.NewEvent) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewEventDescription) .WithIcon(ApplicationIcons.Event) .WithShortcut(Keys.Control | Keys.Alt | Keys.E); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadEvent) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewObservers) .WithId(MenuBarItemIds.NewObserverSet) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewObserversDescription) .WithIcon(ApplicationIcons.Observer); // .WithShortcut(Keys.Control | Keys.Alt | Keys.O); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadObserverSet) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); var newExpressionProfile = CreateSubMenu.WithCaption(MenuNames.NewExpressionProfile) @@ -182,17 +182,17 @@ protected override IEnumerable AllMenuBarItems() var newEnzyme = CreateMenuButton.WithCaption(PKSimConstants.UI.AddMetabolizingEnzyme) .WithId(MenuBarItemIds.NewExpressionProfileEnzyme) - .WithCommand>() + .WithCommand>(_container) .WithIcon(ApplicationIcons.Enzyme); var newTransporter = CreateMenuButton.WithCaption(PKSimConstants.UI.AddTransportProtein) .WithId(MenuBarItemIds.NewExpressionProfileTransporter) - .WithCommand>() + .WithCommand>(_container) .WithIcon(ApplicationIcons.Transporter); var newSpecificBinding = CreateMenuButton.WithCaption(PKSimConstants.UI.AddSpecificBindingPartner) .WithId(MenuBarItemIds.NewExpressionProfileSpecificBindingPartner) - .WithCommand>() + .WithCommand>(_container) .WithIcon(ApplicationIcons.SpecificBinding); newExpressionProfile.AddItem(newEnzyme); @@ -203,60 +203,60 @@ protected override IEnumerable AllMenuBarItems() yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadExpressionProfile) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.About) .WithId(MenuBarItemIds.About) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Info) .WithDescription(PKSimConstants.UI.AboutThisApplication); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.NewCompound) .WithId(MenuBarItemIds.NewCompound) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.NewCompoundDescription) .WithIcon(ApplicationIcons.Compound) .WithShortcut(Keys.Control | Keys.Alt | Keys.C); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadFromTemplate) .WithId(MenuBarItemIds.LoadCompound) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.LoadFromTemplate); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.GarbageCollection) .WithId(MenuBarItemIds.GarbageCollection) - .WithCommand() + .WithCommand(_container) .ForDeveloper(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.GenerateCalculationMethods) .WithId(MenuBarItemIds.GenerateCalculationMethods) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.DistributionCalculation) .ForDeveloper(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.GeneratePKMLTemplates) .WithId(MenuBarItemIds.GeneratePKMLTemplates) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PKML) .ForDeveloper(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.GenerateGroupsTemplate) .WithId(MenuBarItemIds.GenerateGroupsTemplate) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PKML) .ForDeveloper(); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Options) .WithId(MenuBarItemIds.Options) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.OptionsDescription) .WithIcon(ApplicationIcons.Settings) .WithShortcut(Keys.Control | Keys.Shift | Keys.O); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Exit) .WithId(MenuBarItemIds.Exit) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.ExitDescription) .WithIcon(ApplicationIcons.Exit) .WithShortcut(Keys.Alt | Keys.F4); @@ -264,120 +264,120 @@ protected override IEnumerable AllMenuBarItems() yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Run) .WithId(MenuBarItemIds.Run) .WithDescription(PKSimConstants.UI.RunDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Run) .WithShortcut(Keys.F5); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.RunWithSettings) .WithId(MenuBarItemIds.RunWithSettings) .WithDescription(PKSimConstants.UI.RunWithSettingsDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ConfigureAndRun); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Stop) .WithId(MenuBarItemIds.Stop) .WithDescription(PKSimConstants.UI.StopDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Stop); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.TimeProfileAnalysis) .WithId(MenuBarItemIds.ShowIndividualResults) .WithDescription(PKSimConstants.UI.ShowIndividualResultsDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.TimeProfileAnalysis); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.BoxWhiskerAnalysis) .WithId(MenuBarItemIds.BoxWhiskerAnalysis) .WithDescription(PKSimConstants.UI.BoxWhiskerAnalysisDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.BoxWhiskerAnalysis); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ScatterAnalysis) .WithId(MenuBarItemIds.ScatterAnalysis) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.ScatterAnalysisDescription) .WithIcon(ApplicationIcons.ScatterAnalysis); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.RangeAnalysis) .WithId(MenuBarItemIds.RangeAnalysis) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.RangeAnalysisDescription) .WithIcon(ApplicationIcons.RangeAnalysis); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.TimeProfileAnalysis) .WithId(MenuBarItemIds.TimeProfileAnalysis) - .WithCommand() + .WithCommand(_container) .WithDescription(PKSimConstants.UI.TimeProfileAnalysisDescription) .WithIcon(ApplicationIcons.TimeProfileAnalysis); yield return CreateMenuButton.WithCaption(Captions.SimulationUI.PredictedVsObservedSimulation) .WithId(MenuBarItemIds.PredictedVsObservedSimulationAnalysis) .WithDescription(MenuDescriptions.PredictedVsObservedAnalysisDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PredictedVsObservedAnalysis); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.IndividualSimulationComparison) .WithId(MenuBarItemIds.IndividualSimulationComparison) .WithDescription(PKSimConstants.UI.IndividualSimulationComparisonDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.IndividualSimulationComparison); yield return CreateMenuButton.WithCaption(Captions.SimulationUI.ResidualsVsTimeSimulation) .WithId(MenuBarItemIds.ResidualsVsTimeSimulationAnalysis) .WithDescription(MenuDescriptions.ResidualsVsTimeAnalysisDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ResidualVsTimeAnalysis); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Comparison) .WithId(MenuBarItemIds.IndividualSimulationComparisonInAnalyze) .WithDescription(PKSimConstants.UI.IndividualSimulationComparisonDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.IndividualSimulationComparison); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.PopulationPopulationComparison) .WithId(MenuBarItemIds.PopulationSimulationComparison) .WithDescription(PKSimConstants.UI.PopulationSimulationComparisonDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PopulationSimulationComparison); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.Comparison) .WithId(MenuBarItemIds.PopulationSimulationComparisonInAnalyze) .WithDescription(PKSimConstants.UI.PopulationSimulationComparisonDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PopulationSimulationComparison); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.HistoryView) .WithId(MenuBarItemIds.HistoryView) .WithDescription(PKSimConstants.UI.HistoryViewDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.History) .WithShortcut(Keys.Control | Keys.Shift | Keys.H); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ComparisonView) .WithId(MenuBarItemIds.ComparisonView) .WithDescription(PKSimConstants.UI.ComparisonViewDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Comparison) .WithShortcut(Keys.Control | Keys.Shift | Keys.N); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SimulationExplorerView) .WithId(MenuBarItemIds.SimulationExplorerView) .WithDescription(PKSimConstants.UI.SimulationExplorerViewDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.SimulationExplorer) .WithShortcut(Keys.Control | Keys.Shift | Keys.S); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.BuildingBlockExplorerView) .WithId(MenuBarItemIds.BuildingBlockExplorerView) .WithDescription(PKSimConstants.UI.BuildingBlockExplorerViewDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.BuildingBlockExplorer) .WithShortcut(Keys.Control | Keys.Shift | Keys.B); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.AddObservedData) .WithId(MenuBarItemIds.AddObservedData) .WithDescription(PKSimConstants.UI.AddObservedDataDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ObservedData); yield return CreateSubMenu.WithCaption(PKSimConstants.MenuNames.ExportHistory) @@ -387,131 +387,131 @@ protected override IEnumerable AllMenuBarItems() yield return CreateMenuButton.WithCaption(MenuNames.ExportToExcel) .WithId(MenuBarItemIds.HistoryReportExcel) .WithDescription(PKSimConstants.UI.ExportHistoryToExcelDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Excel); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.CloneMenu) .WithId(MenuBarItemIds.CloneActiveSimulation) .WithDescription(PKSimConstants.UI.CloneSimulation) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.SimulationClone); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ConfigureShortMenu) .WithId(MenuBarItemIds.ConfigureActiveSimulation) .WithDescription(PKSimConstants.UI.ConfigureSimulationDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.SimulationConfigure); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportToMoBiShortMEnu) .WithId(MenuBarItemIds.ExportActiveSimulationToMoBi) .WithDescription(PKSimConstants.UI.ExportActiveSimulationToMoBiDescription) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.MoBi); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportToPKMLShortMenu) .WithId(MenuBarItemIds.ExportActiveSimulationToPkml) .WithDescription(PKSimConstants.UI.ExportSimulationToMoBiTitle) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PKMLSave); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportSimulationResultsToExcelMenu) .WithId(MenuBarItemIds.ExportActiveSimulationResultsToExcel) .WithDescription(PKSimConstants.UI.ExportSimulationResultsToExcel) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ExportToExcel); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportSimulationResultsToCSVMenu) .WithId(MenuBarItemIds.ExportActiveSimulationResultsToCSV) .WithDescription(PKSimConstants.UI.ExportSimulationResultsToCSV) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ExportToCSV); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportPopulationToCSVMenu) .WithId(MenuBarItemIds.ExportActiveSimulationPopulationToExcel) .WithDescription(PKSimConstants.UI.ExportPopulationToCSVTitle) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PopulationExportToCSV); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportPKAnalysesToCSVMenu) .WithId(MenuBarItemIds.ExportActiveSimulationPKAnalysesToCSV) .WithDescription(PKSimConstants.MenuNames.ExportPKAnalysesToCSV) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.PKAnalysesExportToCSV); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ExportForClusterComputationsMenu) .WithId(MenuBarItemIds.ExportActiveSimulationForClusterComputations) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ClusterExport); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ImportSimulationResultsFromCSVMenu) .WithId(MenuBarItemIds.ImportActiveSimulationResults) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.ResultsImportFromCSV); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.ImportPKAnalysesFromCSVMenu) .WithId(MenuBarItemIds.ImportActiveSimulationPKParameters) .WithIcon(ApplicationIcons.PKAnalysesImportFromCSV) - .WithCommand(); + .WithCommand(_container); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.LoadPopulationAnalysisWorkflowFromTemplateMenu) .WithId(MenuBarItemIds.LoadPopulationSimulationWorkflow) .WithDescription(PKSimConstants.UI.LoadPopulationAnalysisWorkflowFromTemplateDescription) .WithIcon(ApplicationIcons.AnalysesLoad) - .WithCommand(); + .WithCommand(_container); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.SavePopulationAnalysisWorkflowToTemplateMenu) .WithId(MenuBarItemIds.SavePopulationSimulationWorkflow) .WithDescription(PKSimConstants.UI.SavePopulationAnalysisWorkflowToTemplateDescription) .WithIcon(ApplicationIcons.AnalysesSave) - .WithCommand(); + .WithCommand(_container); yield return CreateMenuButton.WithCaption(PKSimConstants.MenuNames.RemoveUnusedContent) .WithId(MenuBarItemIds.RemoveUnusedContent) - .WithCommand() + .WithCommand(_container) .WithIcon(ApplicationIcons.Delete) .ForDeveloper(); - yield return CommonMenuBarButtons.ManageUserDisplayUnits(MenuBarItemIds.ManageUserDisplayUnits); - yield return CommonMenuBarButtons.ManageProjectDisplayUnits(MenuBarItemIds.ManageProjectDisplayUnits); - yield return CommonMenuBarButtons.UpdateAllToDisplayUnits(MenuBarItemIds.UpdateAllToDisplayUnits); - yield return CommonMenuBarButtons.ClearHistory(MenuBarItemIds.ClearHistory); - yield return CommonMenuBarButtons.Help(MenuBarItemIds.Help); - - yield return JournalMenuBarButtons.JournalView(MenuBarItemIds.JournalView); - yield return JournalMenuBarButtons.CreateJournalPage(MenuBarItemIds.CreateJournalPage); - yield return JournalMenuBarButtons.SelectJournal(MenuBarItemIds.SelectJournal); - yield return JournalMenuBarButtons.JournalEditorView(MenuBarItemIds.JournalEditorView); - yield return CommonMenuBarButtons.JournalDiagramView(MenuBarItemIds.JournalDiagramView); - yield return JournalMenuBarButtons.SearchJournal(MenuBarItemIds.SearchJournal); - yield return CommonMenuBarButtons.LoadFavoritesFromFile(MenuBarItemIds.LoadFavorites); - yield return CommonMenuBarButtons.SaveFavoritesToFile(MenuBarItemIds.SaveFavorites); - yield return JournalMenuBarButtons.ExportJournal(MenuBarItemIds.ExportJournal); - yield return JournalMenuBarButtons.RefreshJournal(MenuBarItemIds.RefreshJournal); - - yield return ParameterIdentificationMenuBarButtons.CreateParameterIdentification(MenuBarItemIds.CreateParameterIdentification); - yield return ParameterIdentificationMenuBarButtons.RunParameterIdentification(MenuBarItemIds.RunParameterIdentification); - yield return ParameterIdentificationMenuBarButtons.StopParameterIdentification(MenuBarItemIds.StopParameterIdentification); - yield return ParameterIdentificationMenuBarButtons.TimeProfileParameterIdentification(MenuBarItemIds.TimeProfileParameterIdentification); + yield return CommonMenuBarButtons.ManageUserDisplayUnits(MenuBarItemIds.ManageUserDisplayUnits, _container); + yield return CommonMenuBarButtons.ManageProjectDisplayUnits(MenuBarItemIds.ManageProjectDisplayUnits, _container); + yield return CommonMenuBarButtons.UpdateAllToDisplayUnits(MenuBarItemIds.UpdateAllToDisplayUnits, _container); + yield return CommonMenuBarButtons.ClearHistory(MenuBarItemIds.ClearHistory, _container); + yield return CommonMenuBarButtons.Help(MenuBarItemIds.Help, _container); + + yield return JournalMenuBarButtons.JournalView(MenuBarItemIds.JournalView, _container); + yield return JournalMenuBarButtons.CreateJournalPage(MenuBarItemIds.CreateJournalPage, _container); + yield return JournalMenuBarButtons.SelectJournal(MenuBarItemIds.SelectJournal, _container); + yield return JournalMenuBarButtons.JournalEditorView(MenuBarItemIds.JournalEditorView, _container); + yield return CommonMenuBarButtons.JournalDiagramView(MenuBarItemIds.JournalDiagramView, _container); + yield return JournalMenuBarButtons.SearchJournal(MenuBarItemIds.SearchJournal, _container); + yield return CommonMenuBarButtons.LoadFavoritesFromFile(MenuBarItemIds.LoadFavorites, _container); + yield return CommonMenuBarButtons.SaveFavoritesToFile(MenuBarItemIds.SaveFavorites, _container); + yield return JournalMenuBarButtons.ExportJournal(MenuBarItemIds.ExportJournal, _container); + yield return JournalMenuBarButtons.RefreshJournal(MenuBarItemIds.RefreshJournal, _container); + + yield return ParameterIdentificationMenuBarButtons.CreateParameterIdentification(MenuBarItemIds.CreateParameterIdentification, _container); + yield return ParameterIdentificationMenuBarButtons.RunParameterIdentification(MenuBarItemIds.RunParameterIdentification, _container); + yield return ParameterIdentificationMenuBarButtons.StopParameterIdentification(MenuBarItemIds.StopParameterIdentification, _container); + yield return ParameterIdentificationMenuBarButtons.TimeProfileParameterIdentification(MenuBarItemIds.TimeProfileParameterIdentification, _container); yield return ParameterIdentificationMenuBarButtons.PredictedVsObservedParameterIdentification(MenuBarItemIds - .PredictedVsObservedParameterIdentification); + .PredictedVsObservedParameterIdentification, _container); yield return ParameterIdentificationMenuBarButtons.ResidualsVsTimeParameterIdentification(MenuBarItemIds - .ResidualsVsTimeParameterIdentifcation); + .ResidualsVsTimeParameterIdentifcation, _container); yield return ParameterIdentificationMenuBarButtons.ResidualHistogramParameterIdentification(MenuBarItemIds - .ResidualHistogramParameterIdentification); + .ResidualHistogramParameterIdentification, _container); yield return ParameterIdentificationMenuBarButtons.CorrelationMatrixParameterIdentification(MenuBarItemIds - .CorrelationMatrixParameterIdentification); + .CorrelationMatrixParameterIdentification, _container); yield return ParameterIdentificationMenuBarButtons.CovarianceMatrixParameterIdentification(MenuBarItemIds - .CovarianceMatrixParameterIdentification); - yield return ParameterIdentificationMenuBarButtons.ParameterIdentificationFeedbackView(MenuBarItemIds.ParameterIdentificationFeedbackView); - yield return ParameterIdentificationMenuBarButtons.TimeProfilePredictionInterval(MenuBarItemIds.TimeProfilePredictionInterval); - yield return ParameterIdentificationMenuBarButtons.TimeProfileVPCInterval(MenuBarItemIds.TimeProfileVPCInterval); - yield return ParameterIdentificationMenuBarButtons.TimeProfileConfidenceInterval(MenuBarItemIds.TimeProfileConfidenceInterval); - - yield return SensitivityAnalysisMenuBarButtons.SensitivityAnalysisPKParameterAnalysis(MenuBarItemIds.SensitivityAnalysisPKParameterAnalysis); - yield return SensitivityAnalysisMenuBarButtons.CreateSensitivityAnalysis(MenuBarItemIds.CreateSensitivityAnalysis); - yield return SensitivityAnalysisMenuBarButtons.SensitivityAnalysisFeedbackView(MenuBarItemIds.SensitivityAnalysisFeedbackView); - yield return SensitivityAnalysisMenuBarButtons.RunSensitivityAnalysis(MenuBarItemIds.RunSensitivityAnalysis); - yield return SensitivityAnalysisMenuBarButtons.StopSensitivityAnalysis(MenuBarItemIds.StopSensitivityAnalysis); + .CovarianceMatrixParameterIdentification, _container); + yield return ParameterIdentificationMenuBarButtons.ParameterIdentificationFeedbackView(MenuBarItemIds.ParameterIdentificationFeedbackView, _container); + yield return ParameterIdentificationMenuBarButtons.TimeProfilePredictionInterval(MenuBarItemIds.TimeProfilePredictionInterval, _container); + yield return ParameterIdentificationMenuBarButtons.TimeProfileVPCInterval(MenuBarItemIds.TimeProfileVPCInterval, _container); + yield return ParameterIdentificationMenuBarButtons.TimeProfileConfidenceInterval(MenuBarItemIds.TimeProfileConfidenceInterval, _container); + + yield return SensitivityAnalysisMenuBarButtons.SensitivityAnalysisPKParameterAnalysis(MenuBarItemIds.SensitivityAnalysisPKParameterAnalysis, _container); + yield return SensitivityAnalysisMenuBarButtons.CreateSensitivityAnalysis(MenuBarItemIds.CreateSensitivityAnalysis, _container); + yield return SensitivityAnalysisMenuBarButtons.SensitivityAnalysisFeedbackView(MenuBarItemIds.SensitivityAnalysisFeedbackView, _container); + yield return SensitivityAnalysisMenuBarButtons.RunSensitivityAnalysis(MenuBarItemIds.RunSensitivityAnalysis, _container); + yield return SensitivityAnalysisMenuBarButtons.StopSensitivityAnalysis(MenuBarItemIds.StopSensitivityAnalysis, _container); } } } \ No newline at end of file diff --git a/src/PKSim.Presentation/Services/RenameBuildingBlockTask.cs b/src/PKSim.Presentation/Services/RenameBuildingBlockTask.cs index 1d3b96397..4aa0d129c 100644 --- a/src/PKSim.Presentation/Services/RenameBuildingBlockTask.cs +++ b/src/PKSim.Presentation/Services/RenameBuildingBlockTask.cs @@ -223,14 +223,14 @@ private void renameFormulaPathInFormulas(IReadOnlyCollection refe } } - private IFormulaUsablePath formulaUsablePathReferencing(IUsingFormula usingFormula, IFormulaUsable reference) + private FormulaUsablePath formulaUsablePathReferencing(IUsingFormula usingFormula, IFormulaUsable reference) { var parameter = usingFormula as IParameter; return formulaUsablePathReferencing(usingFormula.Formula, reference) ?? formulaUsablePathReferencing(parameter?.RHSFormula, reference); } - private IFormulaUsablePath formulaUsablePathReferencing(IFormula formula, IFormulaUsable reference) + private FormulaUsablePath formulaUsablePathReferencing(IFormula formula, IFormulaUsable reference) { if (formula == null) return null; diff --git a/src/PKSim.R/PKSim.R.csproj b/src/PKSim.R/PKSim.R.csproj index df33e0862..8238a03f1 100644 --- a/src/PKSim.R/PKSim.R.csproj +++ b/src/PKSim.R/PKSim.R.csproj @@ -49,9 +49,9 @@ - + - + diff --git a/src/PKSim.UI.Starter/ApplicationStartup.cs b/src/PKSim.UI.Starter/ApplicationStartup.cs index eea7790e5..aeaeeee47 100644 --- a/src/PKSim.UI.Starter/ApplicationStartup.cs +++ b/src/PKSim.UI.Starter/ApplicationStartup.cs @@ -1,29 +1,26 @@ using System.Globalization; using System.Threading; +using DevExpress.LookAndFeel; +using DevExpress.XtraBars.Docking; +using DevExpress.XtraBars.Ribbon; using OSPSuite.Assets; -using OSPSuite.Core.Commands.Core; -using OSPSuite.Core.Journal; -using OSPSuite.Core.Services; -using OSPSuite.Infrastructure.Import.Services; using OSPSuite.Presentation; using OSPSuite.Presentation.Core; -using OSPSuite.Presentation.DTO; +using OSPSuite.Presentation.Presenters.Journal; +using OSPSuite.Presentation.Presenters.Main; using OSPSuite.Presentation.Services; using OSPSuite.Presentation.Views; -using OSPSuite.UI.Mappers; -using OSPSuite.UI.Services; +using OSPSuite.UI; +using OSPSuite.UI.Views; using OSPSuite.Utility.Container; using OSPSuite.Utility.Exceptions; +using OSPSuite.Utility.Format; using PKSim.CLI.Core.MinimalImplementations; using PKSim.Core; using PKSim.Core.Services; using PKSim.Infrastructure; using PKSim.Presentation; -using PKSim.Presentation.DTO.Mappers; -using PKSim.Presentation.Presenters.ExpressionProfiles; -using PKSim.Presentation.Services; -using PKSim.Presentation.Views.ExpressionProfiles; -using PKSim.UI.Views.ExpressionProfiles; +using PKSim.Presentation.UICommands; namespace PKSim.UI.Starter { @@ -31,76 +28,66 @@ public static class ApplicationStartup { static IContainer _container; - public static IContainer Initialize(IShell shell) + public static IContainer Initialize() { if (_container != null) return _container; - _container = initializeForStartup(shell); + _container = initializeForStartup(IoC.Container); return _container; } - private static IContainer initializeForStartup(IShell shell) + private static IContainer initializeForStartup(IContainer moBiContainer) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en"); ApplicationIcons.DefaultIcon = ApplicationIcons.PKSim; + var pkSimContainer = InfrastructureRegister.Initialize(registerContainerAsStatic: false); - var container = InfrastructureRegister.Initialize(registerContainerAsStatic: false); - container.RegisterImplementationOf(SynchronizationContext.Current); - - container.Register(LifeStyle.Singleton); - container.Register(LifeStyle.Singleton); - - // registerImplementationsFromCore(container); - registerMinimalImplementations(container); - - - using (container.OptimizeDependencyResolution()) + using (pkSimContainer.OptimizeDependencyResolution()) { - container.RegisterImplementationOf(shell); - container.AddRegister(x => x.FromType()); - container.AddRegister(x => x.FromType()); - container.Register(); - container.Register(); - container.Register(); - container.Register(); - container.Register(LifeStyle.Singleton); - container.Register(); - container.Register(); - container.Register(); - container.Register>(); - InfrastructureRegister.LoadSerializers(container); + // Register base DevExpress components + pkSimContainer.RegisterImplementationOf(new DockManager()); + pkSimContainer.RegisterImplementationOf(new RibbonBarManager(new RibbonControl())); + pkSimContainer.RegisterImplementationOf(UserLookAndFeel.Default); + pkSimContainer.RegisterImplementationOf(new DevExpress.XtraBars.BarManager()); + + // Cross register the main view and presentation components from MoBi into the PKSim + // container so that modal dialogs can be viewed within the MoBi shell + IShell shell = moBiContainer.Resolve(); + pkSimContainer.RegisterImplementationOf(shell as BaseShell); + pkSimContainer.RegisterImplementationOf(shell); + pkSimContainer.RegisterImplementationOf(moBiContainer.Resolve()); + pkSimContainer.RegisterImplementationOf(moBiContainer.Resolve()); + pkSimContainer.RegisterImplementationOf(moBiContainer.Resolve()); + + pkSimContainer.RegisterImplementationOf(NumericFormatterOptions.Instance); + pkSimContainer.RegisterImplementationOf(SynchronizationContext.Current); + pkSimContainer.Register(LifeStyle.Singleton); + pkSimContainer.Register(LifeStyle.Singleton); + pkSimContainer.Register(LifeStyle.Singleton); + + // Full registration of OSPSuite Core UI and Presentation + pkSimContainer.AddRegister(x => x.FromType()); + pkSimContainer.AddRegister(x => x.FromType()); + + // Full registration of PKSim Core and Infrastructure + pkSimContainer.AddRegister(x => x.FromType()); + pkSimContainer.AddRegister(x => x.FromType()); + + // Registration of PKSim presentation and UI for starter + pkSimContainer.AddRegister(x => x.FromType()); + pkSimContainer.AddRegister(x => x.FromType()); + + pkSimContainer.Register(LifeStyle.Singleton); + InfrastructureRegister.LoadSerializers(pkSimContainer); + pkSimContainer.Register(LifeStyle.Singleton); + InfrastructureRegister.RegisterWorkspace(pkSimContainer); } - return container; - } - - // /// - // /// Use this method to register all dependencies in Core.UI and Core.Presentation - // /// - // private static void registerImplementationsFromCore(IContainer container) - // { - // container.Register(LifeStyle.Singleton); - // container.AddRegister(x => x.FromType()); - // container.AddRegister(x => x.FromType()); - // } - - /// - /// Use this method to register and refine the minimal implementations for dependencies - /// - private static void registerMinimalImplementations(IContainer container) - { - container.Register(); - container.Register(); - container.Register(); - container.Register(); - container.Register(); - container.Register(); - container.Register(); - container.Register(); + return pkSimContainer; } } diff --git a/src/PKSim.UI.Starter/ExpressionProfileCreator.cs b/src/PKSim.UI.Starter/ExpressionProfileCreator.cs index bcb843b53..c434d19ae 100644 --- a/src/PKSim.UI.Starter/ExpressionProfileCreator.cs +++ b/src/PKSim.UI.Starter/ExpressionProfileCreator.cs @@ -9,24 +9,24 @@ namespace PKSim.UI.Starter { public static class ExpressionProfileCreator { - public static object CreateIndividualEnzymeExpressionProfile(IShell shell) + public static object CreateIndividualEnzymeExpressionProfile() { - return createExpressionProfile(shell); + return createExpressionProfile(); } - public static object CreateTransporterExpressionProfile(IShell shell) + public static object CreateTransporterExpressionProfile() { - return createExpressionProfile(shell); + return createExpressionProfile(); } - public static object CreateBindingPartnerExpressionProfile(IShell shell) + public static object CreateBindingPartnerExpressionProfile() { - return createExpressionProfile(shell); + return createExpressionProfile(); } - private static object createExpressionProfile(IShell shell) where T : IndividualMolecule + private static object createExpressionProfile() where T : IndividualMolecule { - var container = ApplicationStartup.Initialize(shell); + var container = ApplicationStartup.Initialize(); using (var presenter = container.Resolve()) { diff --git a/src/PKSim.UI.Starter/IndividualCreator.cs b/src/PKSim.UI.Starter/IndividualCreator.cs new file mode 100644 index 000000000..38b076872 --- /dev/null +++ b/src/PKSim.UI.Starter/IndividualCreator.cs @@ -0,0 +1,29 @@ +using OSPSuite.Core.Commands.Core; +using PKSim.Core.Model; +using PKSim.Presentation; +using PKSim.Presentation.Mappers; +using PKSim.Presentation.Presenters.Individuals; + +namespace PKSim.UI.Starter +{ + public static class IndividualCreator + { + public static object CreateIndividual() + { + var container = ApplicationStartup.Initialize(); + + using (var presenter = container.Resolve()) + { + presenter.Initialize(); + var workspace = container.Resolve(); + workspace.Project = new PKSimProject(); + + if (presenter.Create().IsEmpty()) + return null; + + var mapper = container.Resolve(); + return mapper.MapFrom(presenter.Individual); + } + } + } +} \ No newline at end of file diff --git a/src/PKSim.UI.Starter/PKSim.UI.Starter.csproj b/src/PKSim.UI.Starter/PKSim.UI.Starter.csproj index 342320e0a..25864e69a 100644 --- a/src/PKSim.UI.Starter/PKSim.UI.Starter.csproj +++ b/src/PKSim.UI.Starter/PKSim.UI.Starter.csproj @@ -4,8 +4,10 @@ netstandard2.0 true 12.0.0 + 12.0.0 12.0.0 12.0.0 + 12.0.0 @@ -21,10 +23,10 @@ - - - - + + + + diff --git a/src/PKSim.UI.Starter/PKSimStarterPresenterRegister.cs b/src/PKSim.UI.Starter/PKSimStarterPresenterRegister.cs new file mode 100644 index 000000000..426465d68 --- /dev/null +++ b/src/PKSim.UI.Starter/PKSimStarterPresenterRegister.cs @@ -0,0 +1,26 @@ +using OSPSuite.Utility.Container; +using PKSim.Presentation; +using PKSim.Presentation.Presenters.Individuals; + +namespace PKSim.UI.Starter +{ + public class PKSimStarterPresenterRegister : BasePresenterRegister + { + public override void RegisterInContainer(IContainer container) + { + base.RegisterInContainer(container); + container.Register(); + } + + protected override void ExcludeTypes(IAssemblyScanner scan) + { + base.ExcludeTypes(scan); + scan.ExcludeType(); + } + + protected override void RegisterMainViewPresenters(IContainer container) + { + + } + } +} \ No newline at end of file diff --git a/src/PKSim.UI.Starter/PKSimStarterUserInterfaceRegister.cs b/src/PKSim.UI.Starter/PKSimStarterUserInterfaceRegister.cs new file mode 100644 index 000000000..37596fda1 --- /dev/null +++ b/src/PKSim.UI.Starter/PKSimStarterUserInterfaceRegister.cs @@ -0,0 +1,25 @@ +using OSPSuite.Utility.Container; +using PKSim.Core; +using PKSim.Presentation.UICommands; +using PKSim.UI.UICommands; +using System; + +namespace PKSim.UI.Starter +{ + public class PKSimStarterUserInterfaceRegister : Register + { + public override void RegisterInContainer(IContainer container) + { + container.AddScanner(scan => + { + scan.AssemblyContainingType(); + scan.WithConvention(); + scan.IncludeNamespaceContainingType(); + scan.IncludeNamespaceContainingType(); + scan.IncludeNamespaceContainingType(); + }); + container.Register(LifeStyle.Transient); + container.Register(); + } + } +} \ No newline at end of file diff --git a/src/PKSim.UI.Starter/UIStarterUserSettings.cs b/src/PKSim.UI.Starter/UIStarterUserSettings.cs deleted file mode 100644 index 19fef38de..000000000 --- a/src/PKSim.UI.Starter/UIStarterUserSettings.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using System.Drawing; -using OSPSuite.Assets; -using OSPSuite.Core.Comparison; -using OSPSuite.Core.Diagram; -using OSPSuite.Core.Domain; -using OSPSuite.Presentation; -using OSPSuite.Presentation.Diagram.Elements; -using OSPSuite.Presentation.Presenters.ParameterIdentifications; -using OSPSuite.Presentation.Presenters.SensitivityAnalyses; -using OSPSuite.Presentation.Settings; -using PKSim.CLI.Core.MinimalImplementations; - -namespace PKSim.UI.Starter -{ - public class UIStarterUserSettings : CLIUserSettings, IPresentationUserSettings - { - public UIStarterUserSettings() - { - DisplayUnits = new DisplayUnitsManager(); - ComparerSettings = new ComparerSettings { CompareHiddenEntities = false }; - ProjectFiles = new List(); - DiagramOptions = new DiagramOptions(); - JournalPageEditorSettings = new JournalPageEditorSettings(); - ParameterIdentificationFeedbackEditorSettings = new ParameterIdentificationFeedbackEditorSettings(); - SensitivityAnalysisFeedbackEditorSettings = new SensitivityAnalysisFeedbackEditorSettings(); - - ResetToDefault(); - } - - public string DefaultChartEditorLayout { get; set; } - public string ActiveSkin { get; set; } - public Scalings DefaultChartYScaling { get; set; } - public IconSize IconSizeTreeView { get; set; } - public IconSize IconSizeTab { get; set; } - public IconSize IconSizeContextMenu { get; set; } - public Color ChartBackColor { get; set; } - public Color ChartDiagramBackColor { get; set; } - public bool ColorGroupObservedDataFromSameFolder { get; set; } - public DisplayUnitsManager DisplayUnits { get; set; } - public IList ProjectFiles { get; set; } - public uint MRUListItemCount { get; set; } - public ComparerSettings ComparerSettings { get; set; } - public IDiagramOptions DiagramOptions { get; set; } - public string ChartEditorLayout { get; set; } - public JournalPageEditorSettings JournalPageEditorSettings { get; set; } - public ParameterIdentificationFeedbackEditorSettings ParameterIdentificationFeedbackEditorSettings { get; set; } - public SensitivityAnalysisFeedbackEditorSettings SensitivityAnalysisFeedbackEditorSettings { get; set; } - } -} \ No newline at end of file diff --git a/src/PKSim.UI/PKSim.UI.csproj b/src/PKSim.UI/PKSim.UI.csproj index fcf4a1e82..5a835b53b 100644 --- a/src/PKSim.UI/PKSim.UI.csproj +++ b/src/PKSim.UI/PKSim.UI.csproj @@ -60,14 +60,14 @@ - + - - - + + + diff --git a/src/PKSim.UI/ToolTipCreator.cs b/src/PKSim.UI/ToolTipCreator.cs index 9b8fa5de0..580925145 100644 --- a/src/PKSim.UI/ToolTipCreator.cs +++ b/src/PKSim.UI/ToolTipCreator.cs @@ -225,7 +225,7 @@ private void addFormulaToolTipTo(SuperToolTip toolTip, IParameterDTO parameterDT toolTip.WithText(sb.ToString()); } - private string displayObjectPathFrom(IFormulaUsablePath objectPath) + private string displayObjectPathFrom(FormulaUsablePath objectPath) { var display = objectPath.PathAsString; display = display.Replace($"{Constants.ROOT}|", string.Empty); diff --git a/src/PKSim.UI/UserInterfaceRegister.cs b/src/PKSim.UI/UserInterfaceRegister.cs index fcf24955d..2b373997f 100644 --- a/src/PKSim.UI/UserInterfaceRegister.cs +++ b/src/PKSim.UI/UserInterfaceRegister.cs @@ -7,6 +7,7 @@ using OSPSuite.Core; using OSPSuite.Presentation; using OSPSuite.Presentation.Views; +using OSPSuite.UI.Views; using OSPSuite.Utility.Container; using OSPSuite.Utility.Extensions; using PKSim.Presentation.Views.Individuals; @@ -28,7 +29,9 @@ public static void InitializeForStartup(IContainer container) var shell = container.Resolve().DowncastTo(); container.RegisterImplementationOf(shell); + container.RegisterImplementationOf((IShell) shell); + container.RegisterImplementationOf((BaseShell) shell); container.RegisterImplementationOf((IMainView) shell); var exceptionView = container.Resolve(); @@ -49,7 +52,7 @@ public override void RegisterInContainer(IContainer container) container.Register(typeof(ISimulationCompoundProcessView<,>), typeof(SimulationCompoundProcessView<,>)); container.Register(typeof(IExpressionParametersView<>), typeof(ExpressionParametersView<>)); - container.Register(LifeStyle.Singleton); + container.Register(LifeStyle.Singleton); } } } \ No newline at end of file diff --git a/src/PKSim.UI/UserSettings.cs b/src/PKSim.UI/UserSettings.cs index 16cd478a1..d0dab5afe 100644 --- a/src/PKSim.UI/UserSettings.cs +++ b/src/PKSim.UI/UserSettings.cs @@ -99,7 +99,6 @@ public void ResetToDefault() AllowsScientificNotation = true; ShouldRestoreWorkspaceLayout = false; MRUListItemCount = CoreConstants.DEFAULT_MRU_LIST_ITEM_COUNT; - ActiveSkin = CoreConstants.DEFAULT_SKIN; NumberOfBins = CoreConstants.DEFAULT_NUMBER_OF_BINS; NumberOfIndividualsPerBin = CoreConstants.DEFAULT_NUMBER_OF_INDIVIDUALS_PER_BIN; DefaultSpecies = CoreConstants.Species.HUMAN; diff --git a/src/PKSim.UI/Views/Core/BuildingBlockWizardView.cs b/src/PKSim.UI/Views/Core/BuildingBlockWizardView.cs index 385977270..6a877f61d 100644 --- a/src/PKSim.UI/Views/Core/BuildingBlockWizardView.cs +++ b/src/PKSim.UI/Views/Core/BuildingBlockWizardView.cs @@ -18,7 +18,7 @@ public BuildingBlockWizardView() { } - public BuildingBlockWizardView(Shell shell) : base(shell) + public BuildingBlockWizardView(BaseShell shell) : base(shell) { InitializeComponent(); } diff --git a/src/PKSim.UI/Views/Individuals/CreateIndividualView.cs b/src/PKSim.UI/Views/Individuals/CreateIndividualView.cs index f9787aefb..b8c029b83 100644 --- a/src/PKSim.UI/Views/Individuals/CreateIndividualView.cs +++ b/src/PKSim.UI/Views/Individuals/CreateIndividualView.cs @@ -1,7 +1,7 @@ using System.Drawing; -using PKSim.Assets; using OSPSuite.Assets; -using PKSim.Core; +using OSPSuite.UI.Views; +using PKSim.Assets; using PKSim.Presentation.Presenters.Individuals; using PKSim.Presentation.Views.Individuals; using PKSim.UI.Views.Core; @@ -10,7 +10,7 @@ namespace PKSim.UI.Views.Individuals { public partial class CreateIndividualView : BuildingBlockWizardView, ICreateIndividualView { - public CreateIndividualView(Shell shell) : base(shell) + public CreateIndividualView(BaseShell shell) : base(shell) { InitializeComponent(); ClientSize = new Size(UIConstants.Size.INDIVIDUAL_VIEW_WIDTH, UIConstants.Size.INDIVIDUAL_VIEW_HEIGHT); diff --git a/src/PKSim/PKSim.csproj b/src/PKSim/PKSim.csproj index d4eeb92fd..5be12dbb7 100644 --- a/src/PKSim/PKSim.csproj +++ b/src/PKSim/PKSim.csproj @@ -76,14 +76,14 @@ - - + + - + diff --git a/tests/PKSim.Matlab.Tests/PKSim.Matlab.Tests.csproj b/tests/PKSim.Matlab.Tests/PKSim.Matlab.Tests.csproj index b08894b30..f6dab44b5 100644 --- a/tests/PKSim.Matlab.Tests/PKSim.Matlab.Tests.csproj +++ b/tests/PKSim.Matlab.Tests/PKSim.Matlab.Tests.csproj @@ -22,9 +22,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/tests/PKSim.R.Tests/PKSim.R.Tests.csproj b/tests/PKSim.R.Tests/PKSim.R.Tests.csproj index 6b27e2aed..0b8291816 100644 --- a/tests/PKSim.R.Tests/PKSim.R.Tests.csproj +++ b/tests/PKSim.R.Tests/PKSim.R.Tests.csproj @@ -22,9 +22,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/tests/PKSim.Tests/Core/FormulaFactorySpecs.cs b/tests/PKSim.Tests/Core/FormulaFactorySpecs.cs index b58250da6..d256c4a81 100644 --- a/tests/PKSim.Tests/Core/FormulaFactorySpecs.cs +++ b/tests/PKSim.Tests/Core/FormulaFactorySpecs.cs @@ -24,7 +24,7 @@ public abstract class concern_for_FormulaFactory : ContextSpecification _rateObjectPathsRepository.ObjectPathsFor(_dynamicSumFormulaRateKey)).Returns(new List()); + A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(_dynamicSumFormulaRateKey)).Returns(new List()); } protected override void Because() @@ -104,7 +104,7 @@ protected override void Context() _rateDefinition2 = new ParameterRateMetaData {Rate = "toto", CalculationMethod = "tutu"}; _formulaCache = new FormulaCache(); - A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(new RateKey(_rateDefinition1.CalculationMethod, _rateDefinition1.Rate))).Returns(new List()); + A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(new RateKey(_rateDefinition1.CalculationMethod, _rateDefinition1.Rate))).Returns(new List()); A.CallTo(() => _rateFormulaRepository.FormulaFor(new RateKey(_rateDefinition1.CalculationMethod, _rateDefinition1.Rate))).Returns("0"); } @@ -131,7 +131,7 @@ protected override void Context() { base.Context(); _rateDefinition = new ParameterRateMetaData {Rate = "toto", CalculationMethod = "tutu"}; - A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(new RateKey(_rateDefinition.CalculationMethod, _rateDefinition.Rate))).Returns(new List()); + A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(new RateKey(_rateDefinition.CalculationMethod, _rateDefinition.Rate))).Returns(new List()); A.CallTo(() => _rateFormulaRepository.FormulaFor(new RateKey(_rateDefinition.CalculationMethod, _rateDefinition.Rate))).Returns("0"); A.CallTo(() => _idGenerator.NewId()).Returns("newId"); } @@ -178,15 +178,15 @@ public class When_creating_a_formula_for_a_rate_definition_that_was_never_create { private ParameterRateMetaData _rateDefinition; private IFormula _formula; - private IFormulaUsablePath _objectPath1; - private IFormulaUsablePath _objectPath2; + private FormulaUsablePath _objectPath1; + private FormulaUsablePath _objectPath2; private string _formulaString; protected override void Context() { base.Context(); - _objectPath1 = A.Fake(); - _objectPath2 = A.Fake(); + _objectPath1 = A.Fake(); + _objectPath2 = A.Fake(); _rateDefinition = new ParameterRateMetaData {Rate = "toto", CalculationMethod = "tutu"}; var rateKey = new RateKey(_rateDefinition.CalculationMethod, _rateDefinition.Rate); A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(rateKey)).Returns(new[] {_objectPath1, _objectPath2}); @@ -223,7 +223,7 @@ protected override void Context() base.Context(); _rateDefinition = new ParameterRateMetaData {Rate = "toto", CalculationMethod = "tutu"}; var rateKey = new RateKey(_rateDefinition.CalculationMethod, _rateDefinition.Rate); - A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(rateKey)).Returns(Enumerable.Empty()); + A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(rateKey)).Returns(Enumerable.Empty()); _formulaString = "10"; A.CallTo(() => _rateFormulaRepository.FormulaFor(rateKey)).Returns(_formulaString); } @@ -304,7 +304,7 @@ protected override void Context() A.CallTo(() => _rateFormulaRepository.FormulaFor(_rateKey)).Returns("x+y"); A.CallTo(() => _objectBaseFactory.Create()).Returns(new ExplicitFormula()); A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(_rateKey)).Returns( - new List {new FormulaUsablePath(new[] {"x"})}); + new List {new FormulaUsablePath(new[] {"x"})}); } protected override void Because() @@ -335,7 +335,7 @@ protected override void Context() A.CallTo(() => _rateFormulaRepository.FormulaFor(_rateKey)).Returns("Time * 2"); A.CallTo(() => _objectBaseFactory.Create()).Returns(new ExplicitFormula()); A.CallTo(() => _rateObjectPathsRepository.ObjectPathsFor(_rateKey)).Returns( - new List()); + new List()); } } diff --git a/tests/PKSim.Tests/Core/FormulaToFormulaTypeMapperSpecs.cs b/tests/PKSim.Tests/Core/FormulaToFormulaTypeMapperSpecs.cs index 586b65595..06993ca0f 100644 --- a/tests/PKSim.Tests/Core/FormulaToFormulaTypeMapperSpecs.cs +++ b/tests/PKSim.Tests/Core/FormulaToFormulaTypeMapperSpecs.cs @@ -61,7 +61,7 @@ protected override void Context() { base.Context(); _formula = A.Fake(); - A.CallTo(() => _formula.ObjectPaths).Returns(new List {A.Fake()}); + A.CallTo(() => _formula.ObjectPaths).Returns(new List {A.Fake()}); } protected override void Because() diff --git a/tests/PKSim.Tests/Core/IndividualPathWithRootExpanderSpecs.cs b/tests/PKSim.Tests/Core/IndividualPathWithRootExpanderSpecs.cs index f57207723..f170f5f50 100644 --- a/tests/PKSim.Tests/Core/IndividualPathWithRootExpanderSpecs.cs +++ b/tests/PKSim.Tests/Core/IndividualPathWithRootExpanderSpecs.cs @@ -21,8 +21,8 @@ public class When_expanding_the_path_defined_in_the_formula_used_in_an_individua private PKSim.Core.Model.Individual _individual; private IContainer _container; private IParameter _parameter; - private IFormulaUsablePath _oneRelativeObjectPath; - private IFormulaUsablePath _oneOrganismAbsoluteObjectPath; + private FormulaUsablePath _oneRelativeObjectPath; + private FormulaUsablePath _oneOrganismAbsoluteObjectPath; private string _oneRelativeObjectPathAsString; private string _oneOrganismAbsoluteObjectPathAsString; diff --git a/tests/PKSim.Tests/Core/IrreversibleInhibitionKineticUpdaterSpecificationSpecs.cs b/tests/PKSim.Tests/Core/IrreversibleInhibitionKineticUpdaterSpecificationSpecs.cs index 2946a542e..b2f187aeb 100644 --- a/tests/PKSim.Tests/Core/IrreversibleInhibitionKineticUpdaterSpecificationSpecs.cs +++ b/tests/PKSim.Tests/Core/IrreversibleInhibitionKineticUpdaterSpecificationSpecs.cs @@ -24,7 +24,7 @@ public abstract class concern_for_IrreversibleInhibitionKineticUpdaterSpecificat protected InteractionProcess _irreversibleInhibition2; protected InhibitionProcess _uncompetitiveInhibition; - protected IObjectPathFactory _objectPathFactory; + protected ObjectPathFactory _objectPathFactory; protected IDimensionRepository _dimensionRepository; private IInteractionTask _interactionTask; diff --git a/tests/PKSim.Tests/Core/PKSimDistributedParameterSpecs.cs b/tests/PKSim.Tests/Core/PKSimDistributedParameterSpecs.cs index a6b7be791..10852abbb 100644 --- a/tests/PKSim.Tests/Core/PKSimDistributedParameterSpecs.cs +++ b/tests/PKSim.Tests/Core/PKSimDistributedParameterSpecs.cs @@ -87,7 +87,7 @@ public abstract class concern_for_PKSimDistributedParameterUniformDistributed : protected IParameter _minimumParameter; protected IParameter _maximumParameter; protected IParameter _defaultPercentileParameter; - protected IObjectPathFactory _pathFactory; + protected ObjectPathFactory _pathFactory; private PKSimParameter _percentileParameter; protected IDistributionFormula _distributedFormula; protected RandomGenerator _randomGenerator; diff --git a/tests/PKSim.Tests/Core/QuantityPathToQuantityDisplayPathMapperSpecs.cs b/tests/PKSim.Tests/Core/QuantityPathToQuantityDisplayPathMapperSpecs.cs index 25f374c65..ce8c04379 100644 --- a/tests/PKSim.Tests/Core/QuantityPathToQuantityDisplayPathMapperSpecs.cs +++ b/tests/PKSim.Tests/Core/QuantityPathToQuantityDisplayPathMapperSpecs.cs @@ -16,7 +16,7 @@ public abstract class concern_for_QuantityPathToQuantityDisplayPathMapper : Cont protected IndividualSimulation _individualSimulation; protected IContainer _bone; protected IContainer _intracellular; - private IObjectPathFactory _objectPathFactory; + private ObjectPathFactory _objectPathFactory; protected IList _displayPath; protected IObserver _observer; protected string _intracellularDisplay; diff --git a/tests/PKSim.Tests/Core/SetSpeciesInCompoundProcessCommandSpecs.cs b/tests/PKSim.Tests/Core/SetSpeciesInCompoundProcessCommandSpecs.cs index 273f8c01e..439982098 100644 --- a/tests/PKSim.Tests/Core/SetSpeciesInCompoundProcessCommandSpecs.cs +++ b/tests/PKSim.Tests/Core/SetSpeciesInCompoundProcessCommandSpecs.cs @@ -22,7 +22,7 @@ public abstract class concern_for_SetSpeciesInCompoundProcessCommand : ContextSp protected IParameter _nonMatchingIndividualParameter; protected Organism _organism; protected IParameter _individualParameter; - protected IObjectPath _objectPath; + protected ObjectPath _objectPath; protected override void Context() { diff --git a/tests/PKSim.Tests/Core/UncompetitiveInhibitionKineticUpdaterSpecificationSpecs.cs b/tests/PKSim.Tests/Core/UncompetitiveInhibitionKineticUpdaterSpecificationSpecs.cs index a8ad0db74..399cba819 100644 --- a/tests/PKSim.Tests/Core/UncompetitiveInhibitionKineticUpdaterSpecificationSpecs.cs +++ b/tests/PKSim.Tests/Core/UncompetitiveInhibitionKineticUpdaterSpecificationSpecs.cs @@ -13,7 +13,7 @@ namespace PKSim.Core public abstract class concern_for_UncompetitiveInhibitionKineticUpdaterSpecification : ContextSpecification { private IDimensionRepository _dimensionRepository; - private IObjectPathFactory _objectPathFactory; + private ObjectPathFactory _objectPathFactory; private InhibitionProcess _competitiveInhibition; protected InhibitionProcess _uncompetitiveInhibition2; protected InhibitionProcess _uncompetitiveInhibition1; diff --git a/tests/PKSim.Tests/Infrastructure/NeighborhoodFinalizerSpecs.cs b/tests/PKSim.Tests/Infrastructure/NeighborhoodFinalizerSpecs.cs index 2b519aa59..ad8e8f014 100644 --- a/tests/PKSim.Tests/Infrastructure/NeighborhoodFinalizerSpecs.cs +++ b/tests/PKSim.Tests/Infrastructure/NeighborhoodFinalizerSpecs.cs @@ -44,8 +44,8 @@ protected override void Context() _neighborhoods = new List { _neighborhood}; var flatNeighborhood = new FlatNeighborhood {FirstNeighborId = 1, SecondNeighborId = 2}; A.CallTo(() => _flatNeighborhoodRepository.NeighborhoodFrom(_neighborhood.Name)).Returns(flatNeighborhood); - var containerPath1 = A.Fake(); - var containerPath2 = A.Fake(); + var containerPath1 = A.Fake(); + var containerPath2 = A.Fake(); A.CallTo(() => _flatContainerRepository.ContainerPathFrom(flatNeighborhood.FirstNeighborId)).Returns(containerPath1); A.CallTo(() => _flatContainerRepository.ContainerPathFrom(flatNeighborhood.SecondNeighborId)).Returns(containerPath2); A.CallTo(() => containerPath1.Resolve(_organism)).Returns(_firstNeighbor); diff --git a/tests/PKSim.Tests/Infrastructure/ObjectPathXmlAttributeMapperSpecs.cs b/tests/PKSim.Tests/Infrastructure/ObjectPathXmlAttributeMapperSpecs.cs index f2210a248..6b35eb9b6 100644 --- a/tests/PKSim.Tests/Infrastructure/ObjectPathXmlAttributeMapperSpecs.cs +++ b/tests/PKSim.Tests/Infrastructure/ObjectPathXmlAttributeMapperSpecs.cs @@ -26,7 +26,7 @@ protected override void Context() public class When_mapping_an_entity_path_to_a_string : concern_for_ObjectPathXmlAttributeMapper { - private IObjectPath _containerPath; + private ObjectPath _containerPath; private object _result; protected override void Context() @@ -49,7 +49,7 @@ public void should_return_a_string_that_can_be_used_to_create_an_identical_entit public class When_mapping_an_empty_entity_path_ : concern_for_ObjectPathXmlAttributeMapper { - private IObjectPath _entityPath; + private ObjectPath _entityPath; private object _result; protected override void Context() @@ -75,7 +75,7 @@ public class When_the_entity_path_xml_attribute_mapper_is_asked_if_a_type_is_a_m [Observation] public void should_return_true_for_any_implementation_of_container_path() { - sut.IsMatch(typeof(IObjectPath)).ShouldBeTrue(); + sut.IsMatch(typeof(ObjectPath)).ShouldBeTrue(); } [Observation] diff --git a/tests/PKSim.Tests/IntegrationTests/PKSimParameterStartValuesCreatorSpecs.cs b/tests/PKSim.Tests/IntegrationTests/PKSimParameterStartValuesCreatorSpecs.cs index c9ba58340..709ba2546 100644 --- a/tests/PKSim.Tests/IntegrationTests/PKSimParameterStartValuesCreatorSpecs.cs +++ b/tests/PKSim.Tests/IntegrationTests/PKSimParameterStartValuesCreatorSpecs.cs @@ -22,7 +22,7 @@ public class When_creating_a_parameter_start_value_building_block_for_a_simulati { private IBuildConfigurationTask _buildConfigurationTask; private IEntityPathResolver _entityPathResolver; - private IObjectPath _parameterPath; + private ObjectPath _parameterPath; private IParameterStartValuesBuildingBlock _psv; private Individual _individual; private Compound _compound; @@ -92,7 +92,7 @@ public class When_creating_a_parameter_start_value_for_an_individual_and_simulat { private IBuildConfigurationTask _buildConfigurationTask; private IEntityPathResolver _entityPathResolver; - private IObjectPath _parameterPath; + private ObjectPath _parameterPath; private IParameterStartValuesBuildingBlock _psv; private Individual _individual; private Compound _compound; diff --git a/tests/PKSim.Tests/IntegrationTests/RateObjectPathsRepositorySpecs.cs b/tests/PKSim.Tests/IntegrationTests/RateObjectPathsRepositorySpecs.cs index 6595b9bcc..65ca2b2ff 100644 --- a/tests/PKSim.Tests/IntegrationTests/RateObjectPathsRepositorySpecs.cs +++ b/tests/PKSim.Tests/IntegrationTests/RateObjectPathsRepositorySpecs.cs @@ -16,8 +16,8 @@ public abstract class concern_for_RateObjectPathsRepository : ContextForIntegrat public class When_getting_rate_paths : concern_for_RateObjectPathsRepository { - private IEnumerable _rateObjectPaths1; - private IEnumerable _rateObjectPaths2; + private IEnumerable _rateObjectPaths1; + private IEnumerable _rateObjectPaths2; private IEnumerable _allRateObjectPaths; protected override void Because() diff --git a/tests/PKSim.Tests/PKSim.Tests.csproj b/tests/PKSim.Tests/PKSim.Tests.csproj index 0c9ac1b23..38837c9a2 100644 --- a/tests/PKSim.Tests/PKSim.Tests.csproj +++ b/tests/PKSim.Tests/PKSim.Tests.csproj @@ -20,9 +20,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/tests/PKSim.Tests/Presentation/MultipleUsedBuildingBlockNodeContextMenuFactorySpecs.cs b/tests/PKSim.Tests/Presentation/MultipleUsedBuildingBlockNodeContextMenuFactorySpecs.cs index a173c99e4..9a8dc14d5 100644 --- a/tests/PKSim.Tests/Presentation/MultipleUsedBuildingBlockNodeContextMenuFactorySpecs.cs +++ b/tests/PKSim.Tests/Presentation/MultipleUsedBuildingBlockNodeContextMenuFactorySpecs.cs @@ -11,6 +11,7 @@ using OSPSuite.Core.Domain; using OSPSuite.Presentation.Presenters; using OSPSuite.Presentation.UICommands; +using IContainer = OSPSuite.Utility.Container.IContainer; namespace PKSim.Presentation { @@ -34,7 +35,8 @@ protected override void Context() _executionContext = A.Fake(); _simulationBuildingBlockUpdater= A.Fake(); _buildingBlockInProjectManager = A.Fake(); - sut = new MultipleUsedBuildingBlockNodeContextMenuFactory(_buildingBlockInProjectManager, _executionContext); + _container = A.Fake(); + sut = new MultipleUsedBuildingBlockNodeContextMenuFactory(_buildingBlockInProjectManager, _executionContext, _container); _usedBuildingBlocksTreeNode = new List(); _presenter = A.Fake>>(); diff --git a/tests/PKSim.Tests/Presentation/RenameBuildingBlockTaskSpecs.cs b/tests/PKSim.Tests/Presentation/RenameBuildingBlockTaskSpecs.cs index 826eed8ea..fe854ec97 100644 --- a/tests/PKSim.Tests/Presentation/RenameBuildingBlockTaskSpecs.cs +++ b/tests/PKSim.Tests/Presentation/RenameBuildingBlockTaskSpecs.cs @@ -30,7 +30,7 @@ public abstract class concern_for_RenameBuildingBlockTask : ContextSpecification private IBuildingBlockInProjectManager _buildingBlockInProjectManager; private ILazyLoadTask _lazyloadTask; private IHeavyWorkManager _heavyWorkManager; - protected IObjectPathFactory _objectPathFactory; + protected ObjectPathFactory _objectPathFactory; protected IndividualSimulation _individualSimulation; protected Simulation _simulation; protected IContainer _root; @@ -173,24 +173,24 @@ public void should_load_the_simulation() } [Observation] - public void should_have_renamed_the_absolute_object_path_in_the_simultion() + public void should_have_renamed_the_absolute_object_path_in_the_simulation() { - _f1.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "Liver", "Cell")); - _f3.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "Liver", "Cell")); - _f3.ObjectPaths.ElementAt(1).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "LogP")); - _f4.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "SolubilityTable")); + _f1.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "Liver", "Cell").ToArray()); + _f3.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "Liver", "Cell").ToArray()); + _f3.ObjectPaths.ElementAt(1).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "LogP").ToArray()); + _f4.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom(_newName, "SolubilityTable").ToArray()); } [Observation] public void should_not_have_change_the_relative_paths() { - _f1.ObjectPaths.ElementAt(1).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom("Drug", "LogP")); - _f2.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom("SU", "Liver", "Cell")); - _f2.ObjectPaths.ElementAt(1).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom("Drug", "LogP")); + _f1.ObjectPaths.ElementAt(1).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom("Drug", "LogP").ToArray()); + _f2.ObjectPaths.ElementAt(0).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom("SU", "Liver", "Cell").ToArray()); + _f2.ObjectPaths.ElementAt(1).ShouldOnlyContain(_objectPathFactory.CreateFormulaUsablePathFrom("Drug", "LogP").ToArray()); } [Observation] - public void should_have_change_the_abolute_path_of_quantity_info_that_were_calculated_in_the_simulation() + public void should_have_change_the_absolute_path_of_quantity_info_that_were_calculated_in_the_simulation() { _individualResults.HasValuesFor("Liver|Cell|Drug").ShouldBeTrue(); _individualResults.HasValuesFor("Liver|Cell|Meta").ShouldBeTrue(); diff --git a/tests/PKSim.Tests/Presentation/SimulationComparisonTreeNodeContextMenuFactorySpecs.cs b/tests/PKSim.Tests/Presentation/SimulationComparisonTreeNodeContextMenuFactorySpecs.cs index b9ce5eaf9..c6d16a4b8 100644 --- a/tests/PKSim.Tests/Presentation/SimulationComparisonTreeNodeContextMenuFactorySpecs.cs +++ b/tests/PKSim.Tests/Presentation/SimulationComparisonTreeNodeContextMenuFactorySpecs.cs @@ -6,14 +6,18 @@ using PKSim.Presentation.Presenters.ContextMenus; using OSPSuite.Presentation.Nodes; using OSPSuite.Presentation.Presenters; +using OSPSuite.Utility.Container; namespace PKSim.Presentation { public abstract class concern_for_SimulationComparisonTreeNodeContextMenuFactory : ContextSpecification { + private IContainer _container; + protected override void Context() { - sut = new SimulationComparisonTreeNodeContextMenuFactory(); + _container = A.Fake(); + sut = new SimulationComparisonTreeNodeContextMenuFactory(_container); } } diff --git a/tests/PKSim.UI.Tests/PKSim.UI.Tests.csproj b/tests/PKSim.UI.Tests/PKSim.UI.Tests.csproj index 8c0e4b2f8..76a7537c7 100644 --- a/tests/PKSim.UI.Tests/PKSim.UI.Tests.csproj +++ b/tests/PKSim.UI.Tests/PKSim.UI.Tests.csproj @@ -29,10 +29,10 @@ - + - - + + diff --git a/tests/PKSim.UI.Tests/UI.StarterTests/ApplicationStartupTests.cs b/tests/PKSim.UI.Tests/UI.StarterTests/ApplicationStartupTests.cs index 74595ffea..cc7804eef 100644 --- a/tests/PKSim.UI.Tests/UI.StarterTests/ApplicationStartupTests.cs +++ b/tests/PKSim.UI.Tests/UI.StarterTests/ApplicationStartupTests.cs @@ -1,12 +1,18 @@ -using FakeItEasy; +using System.Threading; +using FakeItEasy; using OSPSuite.BDDHelper; using OSPSuite.BDDHelper.Extensions; +using OSPSuite.Infrastructure.Container.Castle; +using OSPSuite.Presentation.Presenters.Journal; +using OSPSuite.Presentation.Presenters.Main; using OSPSuite.Presentation.Views; +using OSPSuite.UI.Views; using OSPSuite.Utility.Container; +using PKSim.Core.Mappers; +using PKSim.Presentation.Mappers; using PKSim.Presentation.Presenters.ExpressionProfiles; +using PKSim.Presentation.Presenters.Individuals; using PKSim.UI.Starter; -using System.Threading; -using PKSim.Core.Mappers; namespace PKSim.UI.UI.StarterTests { @@ -16,12 +22,21 @@ public class concern_for_ApplicationStartup : StaticContextSpecification protected override void Context() { - SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext()); - _container = ApplicationStartup.Initialize(A.Fake()); + SynchronizationContext.SetSynchronizationContext(new When_resolving_the_individual_presenter.TestSynchronizationContext()); + IoC.InitializeWith(new CastleWindsorContainer()); + + // To initialize the local container, the application starter will take some components from the + // static container + IoC.Container.RegisterImplementationOf(A.Fake()); + IoC.Container.RegisterImplementationOf(A.Fake()); + IoC.Container.RegisterImplementationOf(A.Fake()); + IoC.Container.RegisterImplementationOf(new BaseShell() as IShell); + + _container = ApplicationStartup.Initialize(); } } - public class When_resolving_the_presenter: concern_for_ApplicationStartup + public class When_resolving_the_expression_profile_presenter : concern_for_ApplicationStartup { private ICreateExpressionProfilePresenter _presenter; @@ -37,23 +52,55 @@ public void the_presenter_should_be_resolved() } } - public class When_resolving_the_building_block_mapper : concern_for_ApplicationStartup + public class When_resolving_the_individual_presenter : concern_for_ApplicationStartup { - private IExpressionProfileToExpressionProfileBuildingBlockMapper _mapper; + private ICreateIndividualPresenter _presenter; protected override void Because() { - _mapper = _container.Resolve(); + _presenter = _container.Resolve(); } [Observation] - public void the_mapper_should_be_resolved() + public void the_presenter_should_be_resolved() { - _mapper.ShouldBeAnInstanceOf(); + _presenter.ShouldBeAnInstanceOf(); } - } - public class TestSynchronizationContext : SynchronizationContext - { + public class When_resolving_the_individual_mapper : concern_for_ApplicationStartup + { + private IIndividualToIndividualBuildingBlockMapper _mapper; + + protected override void Because() + { + _mapper = _container.Resolve(); + } + + [Observation] + public void the_mapper_should_be_resolved() + { + _mapper.ShouldBeAnInstanceOf(); + } + } + + public class When_resolving_the_building_block_mapper : concern_for_ApplicationStartup + { + private IExpressionProfileToExpressionProfileBuildingBlockMapper _mapper; + + protected override void Because() + { + _mapper = _container.Resolve(); + } + + [Observation] + public void the_mapper_should_be_resolved() + { + _mapper.ShouldBeAnInstanceOf(); + } + } + + public class TestSynchronizationContext : SynchronizationContext + { + } } -} +} \ No newline at end of file