public StudioViewsEditorViewModel(EditorController editorController,
                                          FilterItemService filterItemService, ProjectService projectService, ProjectFileService projectFileService,
                                          SdlxliffMerger sdlxliffMerger, SdlxliffExporter sdlxliffExporter, SdlxliffReader sdlxliffReader)
        {
            _filterItemService  = filterItemService;
            _projectService     = projectService;
            _projectFileService = projectFileService;
            _sdlxliffMerger     = sdlxliffMerger;
            _sdlxliffExporter   = sdlxliffExporter;
            _sdlxliffReader     = sdlxliffReader;

            _editorController = editorController;
            _editorController.ActiveDocumentChanged += EditorController_ActiveDocumentChanged;

            ActivateDocument(_editorController.ActiveDocument);

            // Default values
            ExportSelectedSegments     = true;
            FilterItems                = new List <FilterItem>(_filterItemService.GetFilterItems());
            SelectedExcludeFilterItems = new ObservableCollection <FilterItem>(
                _filterItemService.GetFilterItems(FilterItems, new List <string> {
                "Locked"
            }));
            SelectedTabItem = 0;
        }
Exemple #2
0
        protected override void Initialize()
        {
            _editorController     = SdlTradosStudio.Application.GetController <EditorController>();
            _projectsController   = SdlTradosStudio.Application.GetController <ProjectsController>();
            _studioVersionService = new StudioVersionService();

            var commonService         = new ProjectFileService();
            var projectHelper         = new ProjectService(_projectsController, _studioVersionService);
            var analysisBands         = projectHelper.GetAnalysisBands(_projectsController.CurrentProject ?? _projectsController.SelectedProjects.FirstOrDefault());
            var filterItemService     = new FilterItemService(analysisBands);
            var sdlxliffMerger        = new SdlxliffMerger();
            var segmentBuilder        = new SegmentBuilder();
            var segmentVisitor        = new SegmentVisitor();
            var paragraphUnitProvider = new ParagraphUnitProvider(segmentVisitor, filterItemService);
            var sdlxliffExporter      = new SdlxliffExporter(segmentBuilder);
            var sdlXliffReader        = new SdlxliffReader();
            var displayFilter         = new DisplayFilter();

            var model = new StudioViewsEditorViewModel(_editorController, filterItemService,
                                                       commonService, sdlxliffMerger, sdlxliffExporter, sdlXliffReader, paragraphUnitProvider, displayFilter);

            _control = new StudioViewsEditorView {
                DataContext = model
            };
        }
Exemple #3
0
        public StudioViewsFilesSplitViewModel(Window window, List <ProjectFile> selectedFiles, ProjectFileService projectFileService,
                                              SdlxliffMerger sdlxliffMerger, SdlxliffExporter sdlxliffExporter, SdlxliffReader sdlxliffReader)
        {
            _window             = window;
            _selectedFiles      = selectedFiles;
            _projectFileService = projectFileService;
            _sdlxliffMerger     = sdlxliffMerger;
            _sdlxliffExporter   = sdlxliffExporter;
            _sdlxliffReader     = sdlxliffReader;

            WindowTitle = PluginResources.StudioViews_SplitSelectedFiles_Name;

            DialogResult = DialogResult.None;
            Reset(null);
        }
Exemple #4
0
        protected override void Execute()
        {
            var selectedFiles = _filesController.SelectedFiles.Where(projectFile => projectFile.Role == FileRole.Translatable).ToList();

            if (selectedFiles.Count == 0)
            {
                MessageBox.Show(PluginResources.Message_No_files_selected, PluginResources.Plugin_Name, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var missingFiles = selectedFiles.Any(file => file.LocalFileState == LocalFileState.Missing);

            if (missingFiles)
            {
                MessageBox.Show(PluginResources.Message_Missing_Project_Files_Download_From_Server, PluginResources.Plugin_Name, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var project            = _projectsController.CurrentProject ?? _projectsController.SelectedProjects.FirstOrDefault();
            var projectFileService = new ProjectFileService();
            var sdlxliffMerger     = new SdlxliffMerger();
            var segmentBuilder     = new SegmentBuilder();
            var sdlxliffExporter   = new SdlxliffExporter(segmentBuilder);
            var sdlXliffReader     = new SdlxliffReader();


            var projectHelper     = new ProjectService(_projectsController, _studioVersionService);
            var analysisBands     = projectHelper.GetAnalysisBands(_projectsController.CurrentProject ?? _projectsController.SelectedProjects.FirstOrDefault());
            var filterItemService = new FilterItemService(analysisBands);

            _window = new StudioViewsFilesSplitView();
            var model = new StudioViewsFilesSplitViewModel(_window, project, selectedFiles, projectFileService, filterItemService,
                                                           sdlxliffMerger, sdlxliffExporter, sdlXliffReader);

            _window.DataContext = model;
            _window.ShowDialog();

            if (model.DialogResult != DialogResult.OK)
            {
                return;
            }


            OpenMessageWindow(model);
        }
Exemple #5
0
        protected override void Initialize()
        {
            _editorController   = SdlTradosStudio.Application.GetController <EditorController>();
            _projectsController = SdlTradosStudio.Application.GetController <ProjectsController>();

            var commonService    = new ProjectFileService();
            var filterItemHelper = new FilterItemService();
            var projectHelper    = new ProjectService(_projectsController);
            var sdlxliffMerger   = new SdlxliffMerger();
            var sdlxliffExporter = new SdlxliffExporter();
            var sdlXliffReader   = new SdlxliffReader();

            var model = new StudioViewsEditorViewModel(_editorController, filterItemHelper, projectHelper,
                                                       commonService, sdlxliffMerger, sdlxliffExporter, sdlXliffReader);

            _control = new StudioViewsEditorView {
                DataContext = model
            };
        }
Exemple #6
0
        protected override void Execute()
        {
            var selectedFiles = _filesController.SelectedFiles.Where(projectFile => projectFile.Role == FileRole.Translatable).ToList();

            if (selectedFiles.Count == 0)
            {
                MessageBox.Show(PluginResources.Message_No_files_selected, PluginResources.Plugin_Name, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var missingFiles = selectedFiles.Any(file => file.LocalFileState == LocalFileState.Missing);

            if (missingFiles)
            {
                MessageBox.Show(PluginResources.Message_Missing_Project_Files_Download_From_Server, PluginResources.Plugin_Name, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var commonService    = new ProjectFileService();
            var sdlxliffMerger   = new SdlxliffMerger();
            var segmentBuilder   = new SegmentBuilder();
            var sdlxliffExporter = new SdlxliffExporter(segmentBuilder);
            var sdlXliffReader   = new SdlxliffReader();

            _window = new StudioViewsFilesSplitView();
            var model = new StudioViewsFilesSplitViewModel(_window, selectedFiles, commonService,
                                                           sdlxliffMerger, sdlxliffExporter, sdlXliffReader);

            _window.DataContext = model;
            _window.ShowDialog();

            if (model.DialogResult != DialogResult.OK)
            {
                return;
            }


            OpenMessageWindow(model);
        }