public void SelectDatabasePathFor(SpeciesDatabaseMapDTO speciesDatabaseMapDTO) { var dataBaseFile = _dialogCreator.AskForFileToOpen(PKSimConstants.UI.SelectDatabasePathFor(speciesDatabaseMapDTO.SpeciesDisplayName), CoreConstants.Filter.EXPRESSION_DATABASE_FILE_FILTER, CoreConstants.DirectoryKey.DATABASE); if (string.IsNullOrEmpty(dataBaseFile)) { return; } speciesDatabaseMapDTO.DatabaseFullPath = dataBaseFile; }
public void SelectSimulationFile() { var pkml = _dialogCreator.AskForFileToOpen(PKSimConstants.UI.SelectSimulationPKMLFile, Constants.Filter.PKML_FILE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(pkml)) { return; } _importPopulationSimulationDTO.FilePath = pkml; }
private void StartImporterExcelView(IReadOnlyList <MetaDataCategory> categories, IReadOnlyList <ColumnInfo> columns, DataImporterSettings settings) { settings.NameOfMetaDataHoldingMoleculeInformation = "Molecule"; settings.NameOfMetaDataHoldingMolecularWeightInformation = "Molecular Weight"; _dialogCreator.MessageBoxInfo(_dataImporter.ImportDataSets ( categories, columns, settings, _dialogCreator.AskForFileToOpen(Captions.Importer.OpenFile, Captions.Importer.ImportFileFilter, Constants.DirectoryKey.OBSERVED_DATA) ).DataRepositories?.Count() + " data sets successfully imported"); }
public ImporterConfiguration OpenXmlConfiguration() { using (var serializationContext = SerializationTransaction.Create(_container)) { var serializer = _modelingXmlSerializerRepository.SerializerFor <ImporterConfiguration>(); var fileName = _dialogCreator.AskForFileToOpen("Open configuration", "xml files (*.xml)|*.xml|All files (*.*)|*.*", //move to constants and use filter Constants.DirectoryKey.PROJECT); if (fileName.IsNullOrEmpty()) { return(null); } var xel = XElement.Load(fileName); // We have to correctly handle the case of cancellation return(serializer.Deserialize <ImporterConfiguration>(xel, serializationContext)); } }
public void SelectPKSimPath() { var pkSimPath = _dialogCreator.AskForFileToOpen(AppConstants.Captions.SelectPKSimExecutablePath, AppConstants.Filter.PKSIM_FILE_FILTER, Constants.DirectoryKey.PROJECT); if (string.IsNullOrEmpty(pkSimPath)) { return; } _applicationSettingsDTO.PKSimPath = pkSimPath; }
public bool OpenSimulationAsProject() { bool readyForOpen = CloseProject(); if (!readyForOpen) { return(false); } string fileName = _dialogCreator.AskForFileToOpen(AppConstants.Dialog.LoadProject, Constants.Filter.PKML_FILE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(fileName)) { return(false); } StartWithSimulation(fileName); return(true); }
public void LoadMergeConfiguration() { var pkmlFile = _dialogCreator.AskForFileToOpen(AppConstants.Captions.SourceSimulationFileForMerge, Constants.Filter.PKML_FILE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(pkmlFile)) { return; } LoadMergeConfigurationFromFile(pkmlFile); }
public void SelectFile() { var file = _dialogCreator.AskForFileToOpen(AppConstants.BrowseForFile, Constants.Filter.EXCEL_OPEN_FILE_FILTER, Constants.DirectoryKey.XLS_IMPORT); if (string.IsNullOrEmpty(file)) { return; } updateDTOFromSelectedFile(file); }
public void SelectFile() { var file = _dialogCreator.AskForFileToOpen(PKSimConstants.UI.SelectPKAnalysesFileToImport, Constants.Filter.CSV_FILE_FILTER, Constants.DirectoryKey.POPULATION); if (string.IsNullOrEmpty(file)) { return; } _importDTO.FilePath = file; udpateButtonState(); }
public void StartSingleMerge(Action <IBuildingBlockMergePresenter, TObjectToMerge> configuration) { _buildingBlockMergePresenter.SetMergeConfiguration(configuration); var pkmlFile = _dialogCreator.AskForFileToOpen(AppConstants.Captions.SourceBuildingBlockFileForMerge(_objectTypeResolver.TypeFor <TObjectToMerge>()), Constants.Filter.PKML_FILE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(pkmlFile)) { return; } _buildingBlockMergePresenter.LoadMergeConfigurationFromFile(pkmlFile); _buildingBlockMergePresenter.PerformMerge(); }
private Core.Journal.Journal openExistingJournal(string journalFullPath = null, string defaultFileName = null, string defaultDirectory = null) { if (!FileHelper.FileExists(journalFullPath)) { journalFullPath = _dialogCreator.AskForFileToOpen(Captions.Journal.OpenJournal, Constants.Filter.JOURNAL_FILE_FILTER, Constants.DirectoryKey.PROJECT, defaultFileName: defaultFileName, defaultDirectory: defaultDirectory); if (string.IsNullOrEmpty(journalFullPath)) { return(null); } } return(_journalLoader.Load(journalFullPath)); }
private bool selectSourceFile() { var initDir = Path.GetDirectoryName(txtExcelFile.Text); var newFile = _dialogCreator.AskForFileToOpen(Captions.Importer.PleaseSelectDataFile, Captions.Importer.ImportFileFilter, OSPSuite.Core.Domain.Constants.DirectoryKey.OBSERVED_DATA, initDir); if (string.IsNullOrEmpty(newFile)) { return(false); } txtExcelFile.Text = newFile; return(true); }
public void SelectTemplateDatabase() { var dataBaseFile = _dialogCreator.AskForFileToOpen(PKSimConstants.UI.SelectTemplateDatabasePath, CoreConstants.Filter.TEMPLATE_DATABASE_FILE_FILTER, CoreConstants.DirectoryKey.DATABASE); if (string.IsNullOrEmpty(dataBaseFile)) { return; } if (string.Equals(_userSettings.TemplateDatabasePath, dataBaseFile)) { return; } _userSettings.TemplateDatabasePath = dataBaseFile; }
public void ImportFolderList() { var file = _dialogCreator.AskForFileToOpen("Open Folder List File", OSPSuite.Core.Domain.Constants.Filter.JSON_FILE_FILTER, CoreConstants.DirectoryKey.BATCH_INPUT); if (string.IsNullOrEmpty(file)) { return; } ClearFolderList(); var settings = new PKSimJsonSerializerSetings(); var folders = JsonConvert.DeserializeObject <IEnumerable <string> >(File.ReadAllText(file), settings); _snapshotFolderListDTO.AddFolders(folders); }
public void OpenProject() { if (!shouldCloseProject()) { return; } var fileName = _dialogCreator.AskForFileToOpen(PKSimConstants.UI.OpenProjectTitle, CoreConstants.Filter.LOAD_PROJECT_FILTER, Constants.DirectoryKey.PROJECT); if (string.IsNullOrEmpty(fileName)) { return; } openProjectFromFile(fileName); }
public void LoadUnitsFromFile() { var filename = _dialogCreator.AskForFileToOpen(Captions.LoadUnitsFromFile, Constants.Filter.UNITS_FILE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(filename)) { return; } var displayUnitsFromFile = _serializationTask.Load <DisplayUnitsManager>(filename); if (displayUnitsFromFile == null) { return; } _unitsManager.UpdatePropertiesFrom(displayUnitsFromFile, _cloneManager); bindToView(); }
public void LoadFromFile() { var filename = _dialogCreator.AskForFileToOpen(Captions.LoadFavoritesFromFile, Constants.Filter.FAVORITES_FILE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(filename)) { return; } var favoritesFromFiles = _serializationTask.Load <Favorites>(filename); if (favoritesFromFiles == null) { return; } _favoriteRepository.Clear(); _favoriteRepository.AddFavorites(favoritesFromFiles); _eventPublisher.PublishEvent(new FavoritesLoadedEvent()); }
public void LoadTemplateFromFile() { var file = _dialogCreator.AskForFileToOpen(Captions.LoadChartTemplateFromFile, Constants.Filter.CHART_TEMPLATE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(file)) { return; } var template = _chartTemplatingTask.LoadTemplateFromFile(file, _chartTemplatesToEdit); if (template == null) { return; } addTemplate(template); }
public void OpenFileDialog(string initFileName) { if (!CheckBeforeSelectFile()) { return; } string initDirectoryName = null; if (!initFileName.IsNullOrEmpty()) { initDirectoryName = Path.GetDirectoryName(initFileName); } OnSourceFileChanged.Invoke(this, new SourceFileChangedEventArgs() { FileName = _dialogCreator.AskForFileToOpen(Title, Filter, DirectoryKey, null, initDirectoryName) }); }
public void Execute() { var pkml = _dialogCreator.AskForFileToOpen(PKSimConstants.UI.SelectSimulationPKMLFile, Constants.Filter.PKML_FILE_FILTER, Constants.DirectoryKey.MODEL_PART); if (string.IsNullOrEmpty(pkml)) { return; } var importedSimulation = _importSimulationTask.ImportIndividualSimulation(pkml); if (importedSimulation == null) { return; } _simulationTask.AddToProject(importedSimulation, editBuildingBlock: true); }
public TableFormula ImportSolubilityTableFormula() { var dataImporterSettings = new DataImporterSettings { Caption = $"{CoreConstants.ProductDisplayName} - {PKSimConstants.UI.ImportSolubilityTable}", IconName = ApplicationIcons.Compound.IconName }; dataImporterSettings.AddNamingPatternMetaData(Constants.FILE); var importedFormula = _dataImporter.ImportDataSets( new List <MetaDataCategory>(), getColumnInfos(), dataImporterSettings, _dialogCreator.AskForFileToOpen(Captions.Importer.OpenFile, Captions.Importer.ImportFileFilter, Constants.DirectoryKey.OBSERVED_DATA) ).DataRepositories.FirstOrDefault(); return(importedFormula == null ? null : formulaFrom(importedFormula)); }
public IEnumerable <DataRepository> ImportDataSets(IReadOnlyList <MetaDataCategory> metaDataCategories, IReadOnlyList <ColumnInfo> columnInfos, DataImporterSettings dataImporterSettings, Mode mode) { var sourceFile = _dialogCreator.AskForFileToOpen(Captions.Importer.PleaseSelectDataFile, Captions.Importer.ImportFileFilter, Constants.DirectoryKey.OBSERVED_DATA); if (string.IsNullOrEmpty(sourceFile)) { return(new List <DataRepository>()); } _namingPatternPresenter.WithToken(dataImporterSettings.Token); _namingTask.CreateNamingPatternsBasedOn(metaDataCategories, dataImporterSettings).Each((_namingPatternPresenter.AddPresetNamingPatterns)); _view.Caption = dataImporterSettings.Caption; _view.SetIcon(dataImporterSettings.Icon); _view.StartImport(sourceFile, new ImportTableConfiguration { MetaDataCategories = metaDataCategories, ColumnInfos = columnInfos }, mode); _view.ShowDialog(); if (_view.Canceled) { return(Enumerable.Empty <DataRepository>()); } bool errorNaN; var dataRepositoriesToImport = ConvertImportDataTableList(_view.Imports, columnInfos, out errorNaN); dataRepositoriesToImport.Each(dataRepository => { dataRepository.RenameColumnsToSource(); dataRepository.CutUnitFromColumnNames(); }); if (errorNaN) { _dialogCreator.MessageBoxInfo(Error.MESSAGE_ERROR_NAN); } _namingPatternToRepositoryNameMapper.RenameRepositories(dataRepositoriesToImport, _namingPatternPresenter.Pattern, dataImporterSettings); return(dataRepositoriesToImport); }
public void LoadConfigurationWithoutImporting() { if (confirmDroppingOfLoadedSheets()) { return; } ResetMappingBasedOnCurrentSheet(); var fileName = _dialogCreator.AskForFileToOpen(Captions.Importer.ApplyConfiguration, Constants.Filter.XML_FILE_FILTER, Constants.DirectoryKey.OBSERVED_DATA); if (fileName.IsNullOrEmpty()) { return; } var configuration = _pkmlPersistor.Load <ImporterConfiguration>(fileName); applyConfiguration(configuration); }
public ICommand LoadOntogenyForMolecule(IndividualMolecule molecule, ISimulationSubject simulationSubject) { var dataImporterSettings = new DataImporterSettings { Caption = $"{CoreConstants.ProductDisplayName} - {PKSimConstants.UI.ImportOntogeny}", IconName = ApplicationIcons.Excel.IconName }; dataImporterSettings.AddNamingPatternMetaData(Constants.FILE); var data = _dataImporter.ImportDataSets( new List <MetaDataCategory>(), getColumnInfos(), dataImporterSettings, _dialogCreator.AskForFileToOpen(Captions.Importer.OpenFile, Captions.Importer.ImportFileFilter, Constants.DirectoryKey.OBSERVED_DATA) ).DataRepositories.FirstOrDefault(); if (data == null) { return(null); } var ontogeny = new UserDefinedOntogeny { Table = formulaFrom(data), Name = data.Name }; //only first ontogeny will be imported if (_ontogenyRepository.AllNames().Contains(ontogeny.Name)) { var name = _entityTask.NewNameFor(ontogeny, _ontogenyRepository.AllNames()); if (string.IsNullOrEmpty(name)) { return(null); } ontogeny.Name = name; } return(SetOntogenyForMolecule(molecule, ontogeny, simulationSubject)); }
public void AddRelatedItemFromFile(JournalPage journalPage) { var allFilesFilter = Constants.Filter.FileFilter(Captions.Journal.RelatedItemFile, Constants.Filter.ANY_EXTENSION); var fileName = _dialogCreator.AskForFileToOpen(Captions.Journal.SelectedFileToLoadAsRelatedItem, allFilesFilter, Constants.DirectoryKey.PROJECT); if (string.IsNullOrEmpty(fileName)) { return; } if (!fileIsTooLargeAndCannotBeAddedToJournal(fileName)) { return; } var relatedItem = _relatedItemFactory.CreateFromFile(fileName); AddRelatedItemTo(journalPage, relatedItem); //unload data to ensure that we do no keep the reference in memory relatedItem.Content = null; }
private string selectSnapshotFile() { var message = PKSimConstants.UI.LoadObjectFromSnapshot(typeToLoad); return(_dialogCreator.AskForFileToOpen(message, Constants.Filter.JSON_FILE_FILTER, Constants.DirectoryKey.REPORT)); }
private string getNewFile() { return(_dialogCreator.AskForFileToOpen(PKSimConstants.UI.SelectPopulationFileToImport, Constants.Filter.CSV_FILE_FILTER, Constants.DirectoryKey.POPULATION)); }
public string AskForFileToOpen(string title, string filter, string directoryKey) { return(_dialogCreator.AskForFileToOpen(title, filter, directoryKey)); }
private string fileNameForSnapshotImport <T>() { var message = PKSimConstants.UI.LoadObjectFromSnapshot(_objectTypeResolver.TypeFor <T>()); return(_dialogCreator.AskForFileToOpen(message, Constants.Filter.JSON_FILE_FILTER, Constants.DirectoryKey.REPORT)); }