Exemplo n.º 1
0
        public bool SetSourceFile(string path)
        {
            _dataSourceFile = _importerDataPresenter.SetDataSource(path);

            if (_dataSourceFile == null)
            {
                return(false);
            }

            _sourceFilePresenter.SetFilePath(path);
            _columnMappingPresenter.ValidateMapping();
            _configuration.FileName = path;

            return(true);
        }
Exemplo n.º 2
0
        public ImporterPresenter(
            IImporterView view,
            IDataSetToDataRepositoryMapper dataRepositoryMapper,
            IImporter importer,
            INanPresenter nanPresenter,
            IImporterDataPresenter importerDataPresenter,
            IImportConfirmationPresenter confirmationPresenter,
            IColumnMappingPresenter columnMappingPresenter,
            ISourceFilePresenter sourceFilePresenter,
            IDialogCreator dialogCreator,
            IPKMLPersistor pkmlPersistor) : base(view)
        {
            _importerDataPresenter  = importerDataPresenter;
            _confirmationPresenter  = confirmationPresenter;
            _columnMappingPresenter = columnMappingPresenter;
            _nanPresenter           = nanPresenter;
            _sourceFilePresenter    = sourceFilePresenter;
            _dataRepositoryMapper   = dataRepositoryMapper;
            _dataSource             = new DataSource(importer);
            _pkmlPersistor          = pkmlPersistor;
            _importer      = importer;
            _dialogCreator = dialogCreator;

            _sourceFilePresenter.Title                 = Captions.Importer.PleaseSelectDataFile;
            _sourceFilePresenter.Filter                = Captions.Importer.ImportFileFilter;
            _sourceFilePresenter.DirectoryKey          = Constants.DirectoryKey.OBSERVED_DATA;
            _sourceFilePresenter.OnSourceFileChanged  += (s, e) => SetDataSource(e.FileName);
            _sourceFilePresenter.CheckBeforeSelectFile = () =>
                                                         !_dataSource.DataSets.Any() || dialogCreator.MessageBoxYesNo(Captions.Importer.OpenFileConfirmation) == ViewResult.Yes;

            _view.AddColumnMappingControl(columnMappingPresenter.View);
            _view.AddSourceFileControl(sourceFilePresenter.View);
            _view.AddNanView(nanPresenter.View);
            _confirmationPresenter.OnImportData              += ImportData;
            _confirmationPresenter.OnDataSetSelected         += plotDataSet;
            _confirmationPresenter.OnNamingConventionChanged += (s, a) =>
            {
                _dataSource.SetNamingConvention(a.NamingConvention);
                _confirmationPresenter.SetDataSetNames(_dataSource.NamesFromConvention());
                _configuration.NamingConventions = a.NamingConvention;
            };
            _importerDataPresenter.OnImportSheets += loadSheetsFromDataPresenter;
            _nanPresenter.OnNaNSettingsChanged    += (s, a) =>
            {
                _columnMappingPresenter.ValidateMapping();
                _configuration.NanSettings = _nanPresenter.Settings;
            };
            _view.AddConfirmationView(_confirmationPresenter.View);
            _view.AddImporterView(_importerDataPresenter.View);
            AddSubPresenters(_importerDataPresenter, _confirmationPresenter, _columnMappingPresenter, _sourceFilePresenter);
            _importerDataPresenter.OnFormatChanged     += onFormatChanged;
            _importerDataPresenter.OnTabChanged        += onTabChanged;
            _importerDataPresenter.OnDataChanged       += onImporterDataChanged;
            _columnMappingPresenter.OnMissingMapping   += onMissingMapping;
            _columnMappingPresenter.OnMappingCompleted += onCompletedMapping;
            View.DisableConfirmationView();
        }