Ejemplo n.º 1
0
        public InspectionResultsViewModel(
            RubberduckParserState state,
            IInspector inspector,
            IQuickFixProvider quickFixProvider,
            INavigateCommand navigateCommand,
            ReparseCommand reparseCommand,
            IClipboardWriter clipboard,
            IGeneralConfigService configService,
            ISettingsFormFactory settingsFormFactory,
            IUiDispatcher uiDispatcher)
        {
            _state               = state;
            _inspector           = inspector;
            _quickFixProvider    = quickFixProvider;
            NavigateCommand      = navigateCommand;
            _clipboard           = clipboard;
            _configService       = configService;
            _settingsFormFactory = settingsFormFactory;
            _uiDispatcher        = uiDispatcher;

            RefreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(),
                                                 o =>
            {
                IsRefreshing = true;
                IsBusy       = true;
                reparseCommand.Execute(o);
            },
                                                 o => !IsBusy && reparseCommand.CanExecute(o));

            DisableInspectionCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteDisableInspectionCommand);
            QuickFixCommand              = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixCommand, CanExecuteQuickFixCommand);
            QuickFixInProcedureCommand   = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProcedureCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            QuickFixInModuleCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInModuleCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            QuickFixInProjectCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProjectCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            QuickFixInAllProjectsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInAllProjectsCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            CopyResultsCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand, CanExecuteCopyResultsCommand);
            OpenInspectionSettings       = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);

            _configService.SettingsChanged += _configService_SettingsChanged;

            // todo: remove I/O work in constructor
            _runInspectionsOnReparse = _configService.LoadConfiguration().UserSettings.CodeInspectionSettings.RunInspectionsOnSuccessfulParse;

            SetInspectionTypeGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByInspectionType = (bool)param;
                GroupByLocation       = !(bool)param;
            });

            SetLocationGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByLocation       = (bool)param;
                GroupByInspectionType = !(bool)param;
            });

            _state.StateChanged += HandleStateChanged;

            BindingOperations.CollectionRegistering += BindingOperations_CollectionRegistering;
        }
Ejemplo n.º 2
0
        public InspectionResultsViewModel(
            RubberduckParserState state,
            IInspector inspector,
            IQuickFixProvider quickFixProvider,
            INavigateCommand navigateCommand,
            ReparseCommand reparseCommand,
            IClipboardWriter clipboard,
            IWebNavigator web,
            IConfigurationService <Configuration> configService,
            ISettingsFormFactory settingsFormFactory,
            IUiDispatcher uiDispatcher)
        {
            _web                 = web;
            _state               = state;
            _inspector           = inspector;
            _quickFixProvider    = quickFixProvider;
            NavigateCommand      = navigateCommand;
            _clipboard           = clipboard;
            _configService       = configService;
            _settingsFormFactory = settingsFormFactory;
            _uiDispatcher        = uiDispatcher;

            RefreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(),
                                                 o =>
            {
                IsBusy = true;
                _forceRefreshResults = true;
                var cancellation     = new ReparseCancellationFlag();
                reparseCommand.Execute(cancellation);
                if (cancellation.Canceled)
                {
                    IsBusy = false;
                }
            },
                                                 o => !IsBusy && reparseCommand.CanExecute(o));

            DisableInspectionCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteDisableInspectionCommand);
            QuickFixCommand              = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixCommand, CanExecuteQuickFixCommand);
            QuickFixSelectedItemsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixForSelection, CanExecuteQuickFixForSelection);
            QuickFixInProcedureCommand   = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProcedureCommand, CanExecuteQuickFixInProcedure);
            QuickFixInModuleCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInModuleCommand, CanExecuteQuickFixInModule);
            QuickFixInProjectCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProjectCommand, CanExecuteQuickFixInProject);
            QuickFixInAllProjectsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInAllProjectsCommand, CanExecuteQuickFixAll);
            CopyResultsCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand, CanExecuteCopyResultsCommand);
            OpenInspectionSettings       = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);
            CollapseAllCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAll);
            ExpandAllCommand             = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAll);

            OpenInspectionDetailsPageCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteOpenInspectionDetailsPageCommand);

            QuickFixCommands = new List <(ICommand command, string key, Func <IQuickFix, bool> visibility)>
            {
                (QuickFixCommand, "QuickFix_Instance", quickFix => true),
                (QuickFixSelectedItemsCommand, "QuickFix_Selection", quickFix => quickFix.CanFixMultiple),
                (QuickFixInProcedureCommand, "QuickFix_ThisProcedure", quickFix => quickFix.CanFixInProcedure),
                (QuickFixInModuleCommand, "QuickFix_ThisModule", quickFix => quickFix.CanFixInModule),
                (QuickFixInProjectCommand, "QuickFix_ThisProject", quickFix => quickFix.CanFixInProject),
                (QuickFixInAllProjectsCommand, "QuickFix_All", quickFix => quickFix.CanFixAll)
            };

            _configService.SettingsChanged += _configService_SettingsChanged;

            // todo: remove I/O work in constructor
            _runInspectionsOnReparse = _configService.Read().UserSettings.CodeInspectionSettings.RunInspectionsOnSuccessfulParse;

            if (CollectionViewSource.GetDefaultView(_results) is ListCollectionView results)
            {
                results.Filter     = inspection => InspectionFilter((IInspectionResult)inspection);
                results.CustomSort = this;
                Results            = results;
            }

            OnPropertyChanged(nameof(Results));
            Grouping = InspectionResultGrouping.Type;

            _state.StateChanged += HandleStateChanged;
        }
Ejemplo n.º 3
0
        public InspectionResultsViewModel(
            RubberduckParserState state,
            IInspector inspector,
            IQuickFixProvider quickFixProvider,
            INavigateCommand navigateCommand,
            ReparseCommand reparseCommand,
            IClipboardWriter clipboard,
            IGeneralConfigService configService,
            ISettingsFormFactory settingsFormFactory,
            IUiDispatcher uiDispatcher)
        {
            _state               = state;
            _inspector           = inspector;
            _quickFixProvider    = quickFixProvider;
            NavigateCommand      = navigateCommand;
            _clipboard           = clipboard;
            _configService       = configService;
            _settingsFormFactory = settingsFormFactory;
            _uiDispatcher        = uiDispatcher;

            RefreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(),
                                                 o =>
            {
                IsRefreshing     = true;
                IsBusy           = true;
                var cancellation = new ReparseCancellationFlag();
                reparseCommand.Execute(cancellation);
                if (cancellation.Canceled)
                {
                    IsBusy = false;
                }
            },
                                                 o => !IsBusy && reparseCommand.CanExecute(o));

            DisableInspectionCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteDisableInspectionCommand);
            QuickFixCommand              = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixCommand, CanExecuteQuickFixCommand);
            QuickFixInProcedureCommand   = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProcedureCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            QuickFixInModuleCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInModuleCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            QuickFixInProjectCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInProjectCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            QuickFixInAllProjectsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInAllProjectsCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
            CopyResultsCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand, CanExecuteCopyResultsCommand);
            OpenInspectionSettings       = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);
            CollapseAllCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAll);
            ExpandAllCommand             = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAll);

            _configService.SettingsChanged += _configService_SettingsChanged;

            // todo: remove I/O work in constructor
            _runInspectionsOnReparse = _configService.LoadConfiguration().UserSettings.CodeInspectionSettings.RunInspectionsOnSuccessfulParse;

            if (CollectionViewSource.GetDefaultView(_results) is ListCollectionView results)
            {
                results.Filter     = inspection => InspectionFilter((IInspectionResult)inspection);
                results.CustomSort = this;
                Results            = results;
            }

            OnPropertyChanged(nameof(Results));
            Grouping = InspectionResultGrouping.Type;

            _state.StateChanged += HandleStateChanged;
        }