Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2251 also load metabolites #2266

Merged
merged 3 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/PKSim.Assets/PKSimConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,7 @@ public static class UI
public static readonly string DefaultSolubilityName = "Solubility";
public static readonly string DefaultPopulationAnalysisType = "Population analysis";
public static readonly string PreferredViewLayout = "Preferred View Layout";
public static readonly string TemplateReferenceBehavior = "Load metabolites when loading compound";
public static readonly string Defaults = "Defaults";
public static readonly string Default = "Default";
public static readonly string Add = "Add";
Expand Down
4 changes: 3 additions & 1 deletion src/PKSim.BatchTool/BatchUserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using OSPSuite.Presentation.Services;
using OSPSuite.Presentation.Settings;
using PKSim.CLI.Core.MinimalImplementations;
using PKSim.Core.Model;
using PKSim.Presentation;

namespace PKSim.BatchTool
Expand All @@ -24,7 +25,7 @@ public class BatchUserSettings : CLIUserSettings, IUserSettings
public IconSize IconSizeTab { get; set; }
public IconSize IconSizeContextMenu { get; set; }
public uint DecimalPlace { get; set; }
public bool AllowsScientifcNotation { get; set; }
public bool AllowsScientificNotation { get; set; }
public uint MRUListItemCount { get; set; }
public ComparerSettings ComparerSettings { get; set; }
public string MainViewLayout { get; set; }
Expand Down Expand Up @@ -69,5 +70,6 @@ public void ResetLayout()
}

public ViewLayout PreferredViewLayout { get; set; } = ViewLayouts.TabbedView;
public LoadTemplateWithReference LoadTemplateWithReference { get; set; } = LoadTemplateWithReference.Load;
}
}
10 changes: 10 additions & 0 deletions src/PKSim.Core/Model/Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public RemoteTemplate()
}
}

public enum LoadTemplateWithReference
{
//Always load (default)
Load,
//never load
DoNotLoad,
//Always ask
Ask
}

public class RemoteTemplates
{
public string Version { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected override void AddInitialSerializer()
AttributeMapperRepository.AddAttributeMapper(new EnumAttributeMapper<AxisCountMode, SerializationContext>());
AttributeMapperRepository.AddAttributeMapper(new EnumAttributeMapper<PopulationAnalysisType, SerializationContext>());
AttributeMapperRepository.AddAttributeMapper(new EnumAttributeMapper<InteractionType, SerializationContext>());
AttributeMapperRepository.AddAttributeMapper(new EnumAttributeMapper<LoadTemplateWithReference, SerializationContext>());

//PKSim Serializers
this.AddSerializers(x =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public UserSettingsXmlSerializer()
public override void PerformMapping()
{
Map(x => x.DecimalPlace);
Map(x => x.AllowsScientifcNotation);
Map(x => x.AllowsScientificNotation);
Map(x => x.ActiveSkin);
Map(x => x.IconSizeTab);
Map(x => x.IconSizeTreeView);
Expand Down Expand Up @@ -56,6 +56,7 @@ public override void PerformMapping()
Map(x => x.ChartEditorLayout);
Map(x => x.JournalPageEditorSettings);
Map(x => x.ParameterIdentificationFeedbackEditorSettings);
Map(x => x.LoadTemplateWithReference);
MapEnumerable(x => x.UsedDirectories, x => x.DirectoryMapSettings.AddUsedDirectory);
MapEnumerable(x => x.ProjectFiles, x => x.ProjectFiles.Add).WithChildMappingName(CoreConstants.Serialization.ProjectFile);
}
Expand Down
8 changes: 7 additions & 1 deletion src/PKSim.Presentation/IUserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using OSPSuite.Presentation.Services;
using OSPSuite.Utility.Reflection;
using OSPSuite.Utility.Validation;
using PKSim.Core.Model;

namespace PKSim.Presentation
{
Expand All @@ -19,7 +20,7 @@ public interface IUserSettings : ICoreUserSettings, IPresentationUserSettings, I
/// <summary>
/// Scientific notation allows (1e-2 for instance)
/// </summary>
bool AllowsScientifcNotation { get; set; }
bool AllowsScientificNotation { get; set; }

/// <summary>
/// String representing the serialization of the main view
Expand Down Expand Up @@ -101,6 +102,11 @@ public interface IUserSettings : ICoreUserSettings, IPresentationUserSettings, I
/// </summary>
ViewLayout PreferredViewLayout { get; set; }

/// <summary>
/// 3 states flag: Load, do not load, ask
/// </summary>
LoadTemplateWithReference LoadTemplateWithReference { get; set; }

void ResetToDefault();
}
}
20 changes: 17 additions & 3 deletions src/PKSim.Presentation/Presenters/TemplatePresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class TemplatePresenter : AbstractDisposablePresenter<ITemplateView, ITem
private bool _shouldAddItemIcons;
private readonly IStartOptions _startOptions;
private readonly IApplicationConfiguration _configuration;
private readonly IUserSettings _userSettings;
private string _templateTypeDisplay = string.Empty;
private readonly List<Template> _selectedTemplates = new List<Template>();

Expand All @@ -81,14 +82,16 @@ public TemplatePresenter(
IApplicationController applicationController,
IDialogCreator dialogCreator,
IStartOptions startOptions,
IApplicationConfiguration configuration)
IApplicationConfiguration configuration,
IUserSettings userSettings)
: base(view)
{
_templateTaskQuery = templateTaskQuery;
_applicationController = applicationController;
_dialogCreator = dialogCreator;
_startOptions = startOptions;
_configuration = configuration;
_userSettings = userSettings;
}

public Task<IReadOnlyList<T>> LoadFromTemplateAsync<T>(TemplateType templateType)
Expand Down Expand Up @@ -124,8 +127,19 @@ private bool shouldLoadTemplateWithReferences(TemplateType templateType)
if (templateType.Is(TemplateType.SimulationSubject))
return true;

var message = getMessageForLoadWithReference(templateType);
return _dialogCreator.MessageBoxYesNo(message) == ViewResult.Yes;
switch (_userSettings.LoadTemplateWithReference)
{
case LoadTemplateWithReference.Load:
return true;
case LoadTemplateWithReference.DoNotLoad:
return false;
case LoadTemplateWithReference.Ask:
var message = getMessageForLoadWithReference(templateType);
return _dialogCreator.MessageBoxYesNo(message) == ViewResult.Yes;
default:
throw new ArgumentOutOfRangeException();
}

}

private string getMessageForLoadWithReference(TemplateType templateType)
Expand Down
6 changes: 4 additions & 2 deletions src/PKSim.UI/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class UserSettings : ValidatableDTO, IUserSettings
public int MaximumNumberOfCoresToUse { get; set; }
public PopulationAnalysisType DefaultPopulationAnalysis { get; set; }
public ViewLayout PreferredViewLayout { get; set; }
public LoadTemplateWithReference LoadTemplateWithReference { get; set; }
public int NumberOfIndividualsPerBin { get; set; }
public string DefaultSpecies { get; set; }
public string DefaultPopulation { get; set; }
Expand Down Expand Up @@ -87,14 +88,15 @@ public UserSettings(DockManager dockManager, RibbonBarManager ribbonManager, INu
JournalPageEditorSettings = new JournalPageEditorSettings();
ParameterIdentificationFeedbackEditorSettings = new ParameterIdentificationFeedbackEditorSettings();
SensitivityAnalysisFeedbackEditorSettings = new SensitivityAnalysisFeedbackEditorSettings();
LoadTemplateWithReference = LoadTemplateWithReference.Load;
ResetToDefault();
_layoutWasExplicitlyReset = false;
}

public void ResetToDefault()
{
DecimalPlace = CoreConstants.DEFAULT_DECIMAL_PLACE;
AllowsScientifcNotation = true;
AllowsScientificNotation = true;
ShouldRestoreWorkspaceLayout = false;
MRUListItemCount = CoreConstants.DEFAULT_MRU_LIST_ITEM_COUNT;
ActiveSkin = CoreConstants.DEFAULT_SKIN;
Expand Down Expand Up @@ -177,7 +179,7 @@ public uint DecimalPlace
set => _numericFormatterOptions.DecimalPlace = value;
}

public bool AllowsScientifcNotation
public bool AllowsScientificNotation
{
get => _numericFormatterOptions.AllowsScientificNotation;
set => _numericFormatterOptions.AllowsScientificNotation = value;
Expand Down
2 changes: 1 addition & 1 deletion src/PKSim.UI/Views/SettingsView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading