Example #1
0
        public WidgetViewModelProxy(IWidgetPlugin plugin, IWidgetTemplate widgetTemplate, IDataSourceAnalyser analyser)
        {
            _plugin         = plugin;
            _widgetTemplate = widgetTemplate;
            _analyser       = analyser;
            _deleteCommand  = new DelegateCommand(Delete);

            try
            {
                InnerViewModel = plugin.CreateViewModel(widgetTemplate, analyser);
            }
            catch (Exception e)
            {
                var type = plugin.GetType();
                Log.ErrorFormat("{0}.CreateViewModel() threw exception:\r\n{1}", type.FullName, e);
            }

            if (InnerViewModel != null)
            {
                InnerViewModel.PropertyChanged  += ViewModelOnPropertyChanged;
                InnerViewModel.TemplateModified += ViewModelOnTemplateModified;

                try
                {
                    Content = plugin.CreateContentPresenterFor(InnerViewModel);
                }
                catch (Exception e)
                {
                    var type = plugin.GetType();
                    Log.ErrorFormat("{0}.CreateContentPresenterFor() threw exception:\r\n{1}", type.FullName, e);
                }
            }
        }
 private void Add(IDataSourceAnalyser analyser)
 {
     lock (_syncRoot)
     {
         _dataSourceAnalysers.Add(analyser);
     }
 }
Example #3
0
 public bool TryGetAnalyser(AnalyserId analyserId, out IDataSourceAnalyser analyser)
 {
     lock (_syncRoot)
     {
         analyser = _analysers.Keys.FirstOrDefault(x => x.Id == analyserId);
         return(analyser != null);
     }
 }
 public EntryCountWidgetViewModel(IWidgetTemplate template, IDataSourceAnalyser dataSourceAnalyser)
     : base(template, dataSourceAnalyser)
 {
     _configuration = AnalyserConfiguration as LogEntryCountAnalyserConfiguration;
     Title          = "Line Count";
     Caption        = "Line(s)";
     _quickFilters  = new FiltersViewModel(_configuration?.QuickFilters);
 }
 public void RemoveAnalyser(IDataSourceAnalyser analyser)
 {
     lock (_syncRoot)
     {
         _dataSourceAnalysers.Remove(analyser);
         analyser.Dispose();
     }
 }
Example #6
0
        public DataSourcesWidgetViewModel(IWidgetTemplate template, IDataSourceAnalyser dataSourceAnalyser)
            : base(template, dataSourceAnalyser)
        {
            _dataSources     = new ObservableCollection <DataSourceViewModel>();
            _dataSourcesById = new Dictionary <DataSourceId, DataSourceViewModel>();
            CanBeEdited      = true;

            Configuration.PropertyChanged += ConfigurationOnPropertyChanged;
        }
Example #7
0
 private ILogAnalyserConfiguration CloneConfiguration(IDataSourceAnalyser dataSourceAnalyser)
 {
     try
     {
         return((ILogAnalyserConfiguration)dataSourceAnalyser.Configuration?.Clone());
     }
     catch (Exception e)
     {
         Log.ErrorFormat("Caught unexpected exception while cloning configuration: {0}", e);
         return(null);
     }
 }
Example #8
0
        private DataSourceAnalyserSnapshot CreateSnapshot(IDataSourceAnalyser analyser)
        {
            var configuration = analyser.Configuration?.Clone() as ILogAnalyserConfiguration;
            var result        = analyser.Result?.Clone() as ILogAnalysisResult;
            var progress      = Progress;

            return(new DataSourceAnalyserSnapshot(analyser.Id,
                                                  analyser.AnalyserPluginId,
                                                  configuration,
                                                  result,
                                                  progress));
        }
Example #9
0
        public DataSourceAnalyserProxy(IDataSourceAnalyserPlugin plugin,
                                       AnalyserId id,
                                       ITaskScheduler scheduler,
                                       ILogFile logFile,
                                       ILogAnalyserConfiguration configuration)
        {
            _plugin        = plugin;
            _id            = id;
            _logFile       = logFile;
            _configuration = configuration;

            _analyser = TryCreateAnalyser(scheduler);
        }
        public QuickInfoWidgetViewModel(IWidgetTemplate template,
                                        IDataSourceAnalyser dataSourceAnalyser)
            : base(template, dataSourceAnalyser)
        {
            _viewConfiguration     = template.Configuration as QuickInfoWidgetConfiguration;
            _analyserConfiguration = AnalyserConfiguration as QuickInfoAnalyserConfiguration;

            _quickInfosById      = new Dictionary <Guid, QuickInfoViewModel>();
            _quickInfos          = new ObservableCollection <QuickInfoViewModel>();
            _addQuickInfoCommand = new DelegateCommand2(AddQuickInfo);

            PropertyChanged += OnPropertyChanged;
        }
        /// <summary>
        /// </summary>
        protected AbstractWidgetViewModel(IWidgetTemplate template,
                                          IDataSourceAnalyser dataSourceAnalyser)
        {
            if (dataSourceAnalyser == null)
            {
                throw new ArgumentNullException(nameof(dataSourceAnalyser));
            }

            _dataSourceAnalyser   = dataSourceAnalyser;
            AnalyserConfiguration = CloneConfiguration(dataSourceAnalyser);
            Template    = template;
            CanBeEdited = AnalyserConfiguration != null && !dataSourceAnalyser.IsFrozen;
        }
Example #12
0
        /// <summary>
        /// </summary>
        /// <param name="analyser"></param>
        public void Remove(IDataSourceAnalyser analyser)
        {
            lock (_syncRoot)
            {
                AnalyserTemplate template;
                if (analyser != null && _analysers.TryGetValue(analyser, out template))
                {
                    _template.Remove(template);
                    _analysers.Remove(analyser);

                    analyser.Dispose();
                }
            }
        }
Example #13
0
        private bool TryGetAnalyser(AnalyserId id, out IDataSourceAnalyser analyser)
        {
            if (id == AnalyserId.Empty)
            {
                analyser = new NoAnalyser();
                return(true);
            }

            if (_analysis.TryGetAnalyser(id, out analyser))
            {
                return(true);
            }

            return(false);
        }
Example #14
0
        /// <summary>
        /// </summary>
        protected AbstractWidgetViewModel(IWidgetTemplate template,
                                          IDataSourceAnalyser dataSourceAnalyser)
        {
            if (dataSourceAnalyser == null)
            {
                throw new ArgumentNullException(nameof(dataSourceAnalyser));
            }

            _dataSourceAnalyser    = dataSourceAnalyser;
            _analyserConfiguration = dataSourceAnalyser.Configuration?.Clone() as ILogAnalyserConfiguration;
            _isAnalysisFinished    = false;
            _template     = template;
            CanBeEdited   = AnalyserConfiguration != null && !dataSourceAnalyser.IsFrozen;
            DeleteCommand = new DelegateCommand(Delete);
        }
Example #15
0
        /// <summary>
        /// </summary>
        /// <param name="analyser"></param>
        public void Remove(IDataSourceAnalyser analyser)
        {
            var tmp = analyser as DataSourceAnalyser;

            lock (_syncRoot)
            {
                AnalyserTemplate template;
                if (tmp != null && _analysers.TryGetValue(tmp, out template))
                {
                    _template.Remove(template);
                    _analysers.Remove(tmp);

                    tmp?.Dispose();
                }
            }
        }
        public QuickInfoWidgetViewModel(IWidgetTemplate template,
                                        IDataSourceAnalyser dataSourceAnalyser)
            : base(template, dataSourceAnalyser)
        {
            _viewConfiguration     = template.Configuration as QuickInfoWidgetConfiguration ?? new QuickInfoWidgetConfiguration();
            _analyserConfiguration = AnalyserConfiguration as QuickInfoAnalyserConfiguration ?? new QuickInfoAnalyserConfiguration();

            _quickInfosById      = new Dictionary <Guid, QuickInfoViewModel>();
            _quickInfos          = new ObservableCollection <QuickInfoViewModel>();
            _addQuickInfoCommand = new DelegateCommand2(AddQuickInfo);

            foreach (var quickInfo in _viewConfiguration.Titles)
            {
                var analysis = _analyserConfiguration.QuickInfos.FirstOrDefault(x => x.Id == quickInfo.Id);
                if (analysis != null)
                {
                    AddQuickInfo(quickInfo.Id, quickInfo, analysis);
                }
            }

            PropertyChanged += OnPropertyChanged;
        }
Example #17
0
 public IWidgetViewModel CreateViewModel(IWidgetTemplate template, IDataSourceAnalyser dataSourceAnalyser)
 {
     return(new DataSourcesWidgetViewModel(template, dataSourceAnalyser));
 }
Example #18
0
 public HelpWidgetViewModel(IWidgetTemplate template, IDataSourceAnalyser dataSourceAnalyser)
     : base(template, dataSourceAnalyser)
 {
     Title = "Help";
 }
Example #19
0
 public void Remove(IDataSourceAnalyser analyser)
 {
     throw new InvalidOperationException("Removing analysers from a snapshot is not allowed");
 }
Example #20
0
 public bool TryGetAnalyser(AnalyserId analyserId, out IDataSourceAnalyser analyser)
 {
     throw new NotImplementedException();
 }