private async void OpenCommandExecute(object obj) { if (EnsureConfigurationsAreAvailable()) { IAppConfig appConfig; var chooseConfigWindow = new ChooseConfigurationWindow(appConfigMapper); if (chooseConfigWindow.ShowDialog().GetValueOrDefault()) { var configFilePath = chooseConfigWindow.SelectedConfigFile.FilePath; appConfig = await appConfigMapper.Map(configFilePath); } else { return; } var documentFilePath = openFileDialogService.GetFileLocation(FileFilters.XmlAndConllxFilesOnlyFilter); eventAggregator.GetEvent<StatusNotificationEvent>() .Publish(string.Format("Loading document: {0}. Please wait...", documentFilePath)); if (string.IsNullOrWhiteSpace(documentFilePath)) { return; } DocumentLoadExceptions.Clear(); var documentModel = await MapDocumentModel(documentFilePath, appConfig); if (documentModel == null) { return; } var documentWrapper = new DocumentWrapper(documentModel); documentsWrappers[documentFilePath] = documentWrapper; RefreshDocumentsExplorerList(); InvalidateCommands(); eventAggregator.GetEvent<StatusNotificationEvent>() .Publish(string.Format("Document loaded: {0}", documentFilePath)); } }
private void NewTreeBankCommandExecute(object obj) { if (EnsureConfigurationsAreAvailable()) { IAppConfig appConfig; var chooseConfigWindow = new ChooseConfigurationWindow(appConfigMapper); if (chooseConfigWindow.ShowDialog().GetValueOrDefault()) { var configFilePath = chooseConfigWindow.SelectedConfigFile.FilePath; appConfig = appConfigMapper.Map(configFilePath).GetAwaiter().GetResult(); } else { return; } var documentPrototype = DataStructure.Elements.OfType<Document>().Single(); var document = ObjectCopier.Clone(documentPrototype); document.SetAttributeByName("id", "Treebank" + Documents.Count); var filenameToPathMapping = AppConfig.GetConfigFileNameToFilePathMapping(); document.Attributes.Add( new Attribute { AllowedValuesSet = filenameToPathMapping.Values, Value = appConfig.Name, Name = "configuration", DisplayName = "Configuration", Entity = "attribute", IsEditable = true, IsOptional = false }); if (Documents == null) { Documents = new ChangeTrackingCollection<DocumentWrapper>( new List<DocumentWrapper> {new DocumentWrapper(document)}); } else { Documents.Add(new DocumentWrapper(document)); } InvalidateCommands(); eventAggregator.GetEvent<StatusNotificationEvent>().Publish("Treebank created"); } }