protected override void Context() { _view = A.Fake <IMoleculesView>(); A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>()); _moleculeExpressionTask = A.Fake <IMoleculeExpressionTask <Individual> >(); _treeNodeFactory = A.Fake <ITreeNodeFactory>(); _contextMenyFactory = A.Fake <ITreeNodeContextMenuFactory>(); _dialogCreator = A.Fake <IDialogCreator>(); _entityTask = A.Fake <IEntityTask>(); _commandRegister = A.Fake <ICommandCollector>(); _expressionsPresenterMapper = A.Fake <IRootNodeToIndividualExpressionsPresenterMapper <Individual> >(); _noitemInSelectionPresenter = A.Fake <INoItemInSelectionPresenter>(); _enzymeList = new List <IndividualEnzyme>(); _moleculeList = new List <IndividualMolecule>(); _otherProteinList = new List <IndividualOtherProtein>(); _transporterList = new List <IndividualTransporter>(); _individual = A.Fake <Individual>(); _enzymeFolderNode = new RootNode(PKSimRootNodeTypes.IndividualMetabolizingEnzymes); _otherProteinsFolderNode = new RootNode(PKSimRootNodeTypes.IndividualProteinBindingPartners); _transporterFolderNode = new RootNode(PKSimRootNodeTypes.IndividualTransportProteins); A.CallTo(() => _individual.AllMolecules <IndividualEnzyme>()).Returns(_enzymeList); A.CallTo(() => _individual.AllMolecules <IndividualOtherProtein>()).Returns(_otherProteinList); A.CallTo(() => _individual.AllMolecules <IndividualTransporter>()).Returns(_transporterList); A.CallTo(() => _individual.AllMolecules()).Returns(_moleculeList); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualMetabolizingEnzymes)).Returns(_enzymeFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualProteinBindingPartners)).Returns(_otherProteinsFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualTransportProteins)).Returns(_transporterFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.IndividualMetabolizingEnzymes.Id)).Returns(_enzymeFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.IndividualProteinBindingPartners.Id)).Returns(_otherProteinsFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.IndividualTransportProteins.Id)).Returns(_transporterFolderNode); sut = new IndividualMoleculesPresenter(_view, _moleculeExpressionTask, _treeNodeFactory, _contextMenyFactory, _dialogCreator, _entityTask, _expressionsPresenterMapper, _noitemInSelectionPresenter); sut.InitializeWith(_commandRegister); }
public IReadOnlyList <T> LoadFromTemplate <T>(TemplateType templateType) { _buildingBlockTypeString = _objectTypeResolver.TypeFor <T>(); _view.Caption = PKSimConstants.UI.LoadBuildingBlockFromTemplate(_buildingBlockTypeString); _shouldAddItemIcons = !_templateTaskQuery.IsPrimitiveType(templateType); updateIcon(templateType); _availableBuildingBlocks = _templateTaskQuery.AllTemplatesFor(templateType); if (!_availableBuildingBlocks.Any()) { throw new NoBuildingBlockTemplateAvailableException(_buildingBlockTypeString); } var userTemplateNode = _treeNodeFactory.CreateFor(PKSimRootNodeTypes.UserTemplates); var systemTemplateNode = _treeNodeFactory.CreateFor(PKSimRootNodeTypes.SystemTemplates); addTemplatesTo(userTemplateNode, TemplateDatabaseType.User); addTemplatesTo(systemTemplateNode, TemplateDatabaseType.System); updateView(); _view.Display(); if (_view.Canceled) { return(new List <T>()); } return(shouldLoadTemplateWithReferences() ? loadMultipleTemplate <T>() : loadSingleTemplate <T>()); }
public ITreeNode MapFrom(PartialProcess partialProcess) { //protein id should be created using the process type as well since the same protein might be used for e.g transporter and metabolism var moleculeNode = _treeNodeFactory.CreateFor(partialProcess, partialProcess.MoleculeName); moleculeNode.AddChild(_treeNodeFactory.CreateFor(partialProcess).WithIcon(ApplicationIcons.IconByName(partialProcess.Icon))); return(moleculeNode); }
public virtual void Edit(TSimulationSubject simulationSubject) { _simulationSubject = simulationSubject; _view.DestroyNodes(); _expressionsPresenterCache.Clear(); //add root nodes _view.AddNode(_treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualMetabolizingEnzymes)); _view.AddNode(_treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualTransportProteins)); _view.AddNode(_treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualProteinBindingPartners)); addIndividualProteins <IndividualEnzyme>(PKSimRootNodeTypes.IndividualMetabolizingEnzymes, ApplicationIcons.EmptyIcon); addIndividualProteins <IndividualOtherProtein>(PKSimRootNodeTypes.IndividualProteinBindingPartners, ApplicationIcons.EmptyIcon); addIndividualProteins <IndividualTransporter>(PKSimRootNodeTypes.IndividualTransportProteins, ApplicationIcons.EmptyIcon); _view.ExpandAllNodes(); //select first node _view.SelectNode(_view.NodeByType(PKSimRootNodeTypes.IndividualMetabolizingEnzymes)); }
public IReadOnlyList <T> LoadFromTemplate <T>(TemplateType templateType) { var allTemplates = new List <T>(); string buildingBlockTypeString = _objectTypeResolver.TypeFor <T>(); _view.Caption = PKSimConstants.UI.LoadBuildingBlockFromTemplate(buildingBlockTypeString); _shouldAddItemIcons = !_templateTaskQuery.IsPrimitiveType(templateType); updateIcon(templateType); _availableBuildingBlocks = _templateTaskQuery.AllTemplatesFor(templateType); if (!_availableBuildingBlocks.Any()) { throw new NoBuildingBlockTemplateAvailableException(buildingBlockTypeString); } var userTemplateNode = _treeNodeFactory.CreateFor(PKSimRootNodeTypes.UserTemplates); var systemTemplateNode = _treeNodeFactory.CreateFor(PKSimRootNodeTypes.SystemTemplates); addTemplatesTo(userTemplateNode, TemplateDatabaseType.User); addTemplatesTo(systemTemplateNode, TemplateDatabaseType.System); updateView(); _view.Display(); if (_view.Canceled) { return(allTemplates); } if (_selectedTemplate.HasReferences) { if (_dialogCreator.MessageBoxYesNo(PKSimConstants.UI.DoYouWantToLoadReferencedTemplateAsWell) == ViewResult.Yes) { return(loadMultipleTemplate <T>()); } } allTemplates.Add(loadSingleTemplate <T>()); return(allTemplates); }
private ITreeNode createNodeForContainer(IContainer container) { var representationInfo = _representationInfoRepository.InfoFor(container); var node = _treeNodeFactory.CreateFor(container, representationInfo); var moleculeAmount = container as IMoleculeAmount; if (moleculeAmount != null) { node.Icon = ApplicationIcons.IconByName(moleculeAmount.QuantityType.ToString()); } var reaction = container as IReaction; if (reaction != null) { node.Icon = ApplicationIcons.Reaction; } return(node); }
protected override void Context() { _buildingBlockIconRetriever = A.Fake <IBuildingBlockIconRetriever>(); _view = A.Fake <ISimulationExplorerView>(); A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>()); _treeNodeFactory = A.Fake <ITreeNodeFactory>(); _contextMenuFactory = A.Fake <ITreeNodeContextMenuFactory>(); _regionResolver = A.Fake <IRegionResolver>(); _buildingBlockInSimulationManager = A.Fake <IBuildingBlockInSimulationManager>(); _buildingBlockTask = A.Fake <IBuildingBlockTask>(); _toolTipNodeCreator = A.Fake <IToolTipPartCreator>(); _projectRetriever = A.Fake <IProjectRetriever>(); _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>(); _parameterAnalysablesInExplorerPresenter = A.Fake <IParameterAnalysablesInExplorerPresenter>(); _simulationComparisonTask = A.Fake <ISimulationComparisonTask>(); _simulationFolderNode = new RootNode(RootNodeTypes.SimulationFolder); _comparisonFolderNode = new RootNode(RootNodeTypes.ComparisonFolder); _project = new PKSimProject(); _usedObservedData = new UsedObservedData { Id = "UsedData" }; _simulation = new IndividualSimulation().WithName("individualSimulation").WithId("individualSimulation"); _populationSimulation = new PopulationSimulation().WithName("populationSimulation").WithId("populationSimulation"); _importedSimulaton = A.Fake <Simulation>().WithName("ImportedSimulation").WithId("ImportedSimulation"); A.CallTo(() => _importedSimulaton.IsImported).Returns(true); _simulation.Properties = new SimulationProperties(); _simulation.ModelProperties = new ModelProperties(); _simulation.ModelConfiguration = A.Fake <ModelConfiguration>(); _populationSimulation.Properties = new SimulationProperties(); _populationSimulation.ModelProperties = new ModelProperties(); _populationSimulation.ModelConfiguration = A.Fake <ModelConfiguration>(); _classificationPresenter = A.Fake <IClassificationPresenter>(); _project.AddBuildingBlock(_simulation); _project.AddBuildingBlock(_populationSimulation); var classifiableIndividualSimulation = new ClassifiableSimulation { Subject = _simulation }; var classfiablePopulationSimulation = new ClassifiableSimulation { Subject = _populationSimulation }; var classifiableImportSimulation = new ClassifiableSimulation { Subject = _importedSimulaton }; _project.AddClassifiable(classifiableIndividualSimulation); _project.AddClassifiable(classfiablePopulationSimulation); _individualSimulationNode = new SimulationNode(classifiableIndividualSimulation); _populationSimulationNode = new SimulationNode(classfiablePopulationSimulation); _importedSimulationNode = new SimulationNode(classifiableImportSimulation); _usedObservedDataNode = A.Fake <ITreeNode>(); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableIndividualSimulation)).Returns(_individualSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(classfiablePopulationSimulation)).Returns(_populationSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableImportSimulation)).Returns(_importedSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(_usedObservedData)).Returns(_usedObservedDataNode); _project.AddBuildingBlock(_importedSimulaton); var simulationComparison = A.Fake <ISimulationComparison>().WithId("SimComp_Id"); var classifiableComparison = new ClassifiableComparison { Subject = simulationComparison }; _comparisonNode = new ComparisonNode(classifiableComparison); _project.AddSimulationComparison(simulationComparison); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableComparison)).Returns(_comparisonNode); _usedCompoundBuildingBlock = new UsedBuildingBlock("toto", PKSimBuildingBlockType.Compound) { Id = "usedBB" }; _simulation.AddUsedBuildingBlock(_usedCompoundBuildingBlock); _simulation.AddUsedObservedData(_usedObservedData); _project.AddClassifiable(classifiableComparison); _templageCompoundBuildingBlock = A.Fake <IPKSimBuildingBlock>(); _usedBuildingBlockNode = new UsedBuildingBlockInSimulationNode(_simulation, _usedCompoundBuildingBlock, _templageCompoundBuildingBlock); A.CallTo(() => _treeNodeFactory.CreateFor(_simulation, _usedCompoundBuildingBlock)).Returns(_usedBuildingBlockNode); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_simulation)).Returns(ApplicationIcons.SimulationGreen); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_populationSimulation)).Returns(ApplicationIcons.SimulationGreen); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_usedCompoundBuildingBlock)).Returns(ApplicationIcons.CompoundRed); A.CallTo(() => _view.TreeView.NodeById(_simulation.Id)).Returns(_individualSimulationNode); A.CallTo(() => _view.TreeView.NodeById(_usedCompoundBuildingBlock.Id)).Returns(_usedBuildingBlockNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.SimulationFolder.Id)).Returns(_simulationFolderNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ComparisonFolder.Id)).Returns(_comparisonFolderNode); _observedDataInSimulationManager = A.Fake <IObservedDataInSimulationManager>(); sut = new SimulationExplorerPresenter( _view, _treeNodeFactory, _contextMenuFactory, _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever, _regionResolver, _buildingBlockTask, _buildingBlockInSimulationManager, _toolTipNodeCreator, _projectRetriever, _classificationPresenter, _parameterAnalysablesInExplorerPresenter, _observedDataInSimulationManager, _simulationComparisonTask); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); }
protected override void Context() { _view = A.Fake <IBuildingBlockExplorerView>(); A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>()); _regionResolver = A.Fake <IRegionResolver>(); _region = A.Fake <IRegion>(); A.CallTo(() => _regionResolver.RegionWithName(RegionNames.BuildingBlockExplorer)).Returns(_region); _project = new PKSimProject(); var compound = new Compound().WithName("compound"); _individual = new Individual().WithName("individual"); _individual.OriginData = new OriginData { Species = new Species() }; _project.AddBuildingBlock(_individual); _project.AddBuildingBlock(compound); _observedDataInExplorerPresenter = A.Fake <IObservedDataInExplorerPresenter>(); _buildingBlockIconRetriever = A.Fake <IBuildingBlockIconRetriever>(); _treeNodeFactory = A.Fake <ITreeNodeFactory>(); _contextMenuFactory = A.Fake <ITreeNodeContextMenuFactory>(); _buildingBlockTask = A.Fake <IBuildingBlockTask>(); _toolTipCreator = A.Fake <IToolTipPartCreator>(); _projectRetriever = A.Fake <IProjectRetriever>(); _classificationPresenter = A.Fake <IClassificationPresenter>(); _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>(); sut = new BuildingBlockExplorerPresenter(_view, _treeNodeFactory, _contextMenuFactory, _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever, _regionResolver, _buildingBlockTask, _toolTipCreator, _projectRetriever, _classificationPresenter, _observedDataInExplorerPresenter); _compoundFolderNode = new RootNode(PKSimRootNodeTypes.CompoundFolder); _individualFolderNode = new RootNode(PKSimRootNodeTypes.IndividualFolder); _formulationFolderNode = new RootNode(PKSimRootNodeTypes.FormulationFolder); _protocolFolderNode = new RootNode(PKSimRootNodeTypes.ProtocolFolder); _observersFolderNode = new RootNode(PKSimRootNodeTypes.ObserverSetFolder); _populationFolderNode = new RootNode(PKSimRootNodeTypes.PopulationFolder); _eventRootNode = new RootNode(PKSimRootNodeTypes.EventFolder); _simulationNode = new SimulationNode(new ClassifiableSimulation { Subject = new IndividualSimulation { Id = "1" } }); _compoundNode = new ObjectWithIdAndNameNode <Compound>(compound); _individualNode = new ObjectWithIdAndNameNode <Individual>(_individual); _observationRootNode = new RootNode(RootNodeTypes.ObservedDataFolder); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.CompoundFolder)).Returns(_compoundFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualFolder)).Returns(_individualFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.ProtocolFolder)).Returns(_protocolFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.ObserverSetFolder)).Returns(_observersFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.FormulationFolder)).Returns(_formulationFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.PopulationFolder)).Returns(_populationFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(RootNodeTypes.ObservedDataFolder)).Returns(_observationRootNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.EventFolder)).Returns(_eventRootNode); A.CallTo(() => _treeNodeFactory.CreateFor(_individual)).Returns(_individualNode); A.CallTo(() => _treeNodeFactory.CreateFor(compound)).Returns(_compoundNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.CompoundFolder.Id)).Returns(_compoundFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.IndividualFolder.Id)).Returns(_individualFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.ProtocolFolder.Id)).Returns(_protocolFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.ObserverSetFolder.Id)).Returns(_observersFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.FormulationFolder.Id)).Returns(_formulationFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.PopulationFolder.Id)).Returns(_populationFolderNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ObservedDataFolder.Id)).Returns(_observationRootNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.EventFolder.Id)).Returns(_eventRootNode); A.CallTo(() => _view.AddNode(A <ITreeNode> ._)).ReturnsLazily(s => s.Arguments[0].DowncastTo <ITreeNode>()); }
private ITreeNode <RootNodeType> createInhibitionSubtree() { return(_treeNodeFactory.CreateFor(PKSimRootNodeTypes.InhibitionProcess)); }