Ejemplo n.º 1
0
        public PostprocessorsManager(
            ILogSourcesManager logSources,
            Telemetry.ITelemetryCollector telemetry,
            ISynchronizationContext modelSyncContext,
            ISynchronizationContext threadPoolSyncContext,
            IHeartBeatTimer heartbeat,
            Progress.IProgressAggregator progressAggregator,
            Settings.IGlobalSettingsAccessor settingsAccessor,
            IOutputDataDeserializer outputDataDeserializer,
            ITraceSourceFactory traceSourceFactory
            )
        {
            this.logSources             = logSources;
            this.telemetry              = telemetry;
            this.progressAggregator     = progressAggregator;
            this.settingsAccessor       = settingsAccessor;
            this.modelSyncContext       = modelSyncContext;
            this.threadPoolSyncContext  = threadPoolSyncContext;
            this.heartbeat              = heartbeat;
            this.outputDataDeserializer = outputDataDeserializer;
            this.tracer  = traceSourceFactory.CreateTraceSource("App", "ppm");
            this.updater = new AsyncInvokeHelper(modelSyncContext, Refresh);

            logSources.OnLogSourceAdded             += (sender, args) => updater.Invoke();
            logSources.OnLogSourceRemoved           += (sender, args) => updater.Invoke();
            logSources.OnLogSourceAnnotationChanged += (sender, args) => updater.Invoke();
            logSources.OnLogSourceStatsChanged      += (object sender, LogSourceStatsEventArgs e) =>
            {
                if ((e.Flags & LogProviderStatsFlag.ContentsEtag) != 0)
                {
                    updater.Invoke();
                }
            };
            Refresh();
        }
Ejemplo n.º 2
0
        public Presenter(IView view, IHeartBeatTimer heartbeatTimer)
        {
            this.view = view;
            this.view.SetViewEvents(this);

            heartbeatTimer.OnTimer += (s, e) => Timeslice();
        }
Ejemplo n.º 3
0
        public Presenter(
            IBookmarks bookmarks,
            ILogSourcesManager sourcesManager,
            IView view,
            IHeartBeatTimer heartbeat,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess)
        {
            this.bookmarks = bookmarks;
            this.view      = view;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.clipboardAccess         = clipboardAccess;
            this.trace = new LJTraceSource("UI", "bmks");

            bookmarks.OnBookmarksChanged += (sender, evt) => updateTracker.Invalidate();
            heartbeat.OnTimer            += (sender, evt) =>
            {
                if (evt.IsNormalUpdate && updateTracker.Validate())
                {
                    UpdateViewInternal(null, ViewUpdateFlags.None);
                }
            };
            sourcesManager.OnLogSourceVisiblityChanged += (sender, evt) => updateTracker.Invalidate();
            loadedMessagesPresenter.LogViewerPresenter.ColoringModeChanged += (sender, evt) => view.Invalidate();

            view.SetPresenter(this);
        }
Ejemplo n.º 4
0
        public Presenter(
            IBookmarks bookmarks,
            ILogSourcesManager sourcesManager,
            IView view,
            IHeartBeatTimer heartbeat,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess,
            IColorTheme colorTheme,
            IChangeNotification changeNotification,
            ITraceSourceFactory traceSourceFactory
            )
        {
            this.bookmarks = bookmarks;
            this.view      = view;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.clipboardAccess         = clipboardAccess;
            this.colorTheme         = colorTheme;
            this.changeNotification = changeNotification;
            this.trace = traceSourceFactory.CreateTraceSource("UI", "bmks");

            itemsSelector = Selectors.Create(
                () => bookmarks.Items,
                () => selectedBookmarks,
                () => colorTheme.ThreadColors,
                () => loadedMessagesPresenter.LogViewerPresenter.Coloring,
                CreateViewItems
                );
            focusedMessagePositionSelector = Selectors.Create(
                () => loadedMessagesPresenter.LogViewerPresenter.FocusedMessageBookmark,
                () => bookmarks.Items,
                FindFocusedMessagePosition
                );

            view.SetViewModel(this);
        }
        public PresenterFactory(
            IHeartBeatTimer heartbeat,
            IPresentersFacade presentationFacade,
            IClipboardAccess clipboard,
            IBookmarksFactory bookmarksFactory,
            Telemetry.ITelemetryCollector telemetry,
            ILogSourcesManager logSources,
            IInvokeSynchronization modelInvoke,
            IModelThreads modelThreads,
            IFiltersList hlFilters,
            IBookmarks bookmarks,
            Settings.IGlobalSettingsAccessor settings,
            ISearchManager searchManager,
            IFiltersFactory filtersFactory
            )
        {
            this.heartbeat          = heartbeat;
            this.presentationFacade = presentationFacade;
            this.clipboard          = clipboard;
            this.bookmarksFactory   = bookmarksFactory;
            this.telemetry          = telemetry;

            this.logSources     = logSources;
            this.modelInvoke    = modelInvoke;
            this.modelThreads   = modelThreads;
            this.hlFilters      = hlFilters;
            this.bookmarks      = bookmarks;
            this.settings       = settings;
            this.searchManager  = searchManager;
            this.filtersFactory = filtersFactory;
        }
Ejemplo n.º 6
0
 public PostprocessorOutputRecord(
     ILogSourcePostprocessor metadata,
     LogSourceRecord logSourceRecord,
     Action scheduleRefresh,
     Action fireChangeNotification,
     LJTraceSource trace,
     IHeartBeatTimer heartbeat,
     ISynchronizationContext modelSyncContext,
     ISynchronizationContext threadPoolSyncContext,
     Telemetry.ITelemetryCollector telemetry,
     IOutputDataDeserializer outputDataDeserializer)
 {
     this.metadata        = metadata;
     this.logSourceRecord = logSourceRecord;
     state = new LoadingState(new PostprocessorOutputRecordState.Context()
     {
         owner                  = this,
         scheduleRefresh        = scheduleRefresh,
         fireChangeNotification = fireChangeNotification,
         tracer                 = trace,
         telemetry              = telemetry,
         heartbeat              = heartbeat,
         modelSyncContext       = modelSyncContext,
         threadPoolSyncContext  = threadPoolSyncContext,
         outputDataDeserializer = outputDataDeserializer
     }, null, null);
 }
Ejemplo n.º 7
0
        public void BeforeEach()
        {
            logSources         = Substitute.For <ILogSourcesManager>();
            telemetry          = Substitute.For <Telemetry.ITelemetryCollector>();
            mockedSyncContext  = new ManualSynchronizationContext();
            heartbeat          = Substitute.For <IHeartBeatTimer>();
            progressAggregator = Substitute.For <Progress.IProgressAggregator>();
            settingsAccessor   = Substitute.For <Settings.IGlobalSettingsAccessor>();
            logSource1         = Substitute.For <ILogSource>();
            logProviderFac1    = Substitute.For <ILogProviderFactory>();
            logSource1.Provider.Factory.Returns(logProviderFac1);
            logSource1.Provider.ConnectionParams.Returns(new ConnectionParams($"{ConnectionParamsKeys.PathConnectionParam}=/log.txt"));
            logSource1.Provider.Stats.Returns(new LogProviderStats()
            {
                ContentsEtag = null
            });
            logSourcePP1 = Substitute.For <ILogSourcePostprocessor>();
            logSourcePP1.Kind.Returns(PostprocessorKind.SequenceDiagram);
            pp1outputXmlSection = Substitute.For <Persistence.ISaxXMLStorageSection>();
            logSource1.LogSourceSpecificStorageEntry.OpenSaxXMLSection("postproc-sequencediagram.xml", Persistence.StorageSectionOpenFlag.ReadOnly).Returns(pp1outputXmlSection);
            pp1outputXmlSection.Reader.Returns(Substitute.For <XmlReader>());
            pp1PostprocessorOutput = Substitute.For <IPostprocessorOutputETag>();
            outputDataDeserializer = Substitute.For <IOutputDataDeserializer>();
            outputDataDeserializer.Deserialize(PostprocessorKind.SequenceDiagram, Arg.Any <LogSourcePostprocessorDeserializationParams>()).Returns(pp1PostprocessorOutput);
            pp1RunSummary = Substitute.For <IPostprocessorRunSummary>();
            logSourcePP1.Run(null).ReturnsForAnyArgs(Task.FromResult(pp1RunSummary));
            pp1RunSummary.GetLogSpecificSummary(null).ReturnsForAnyArgs((IPostprocessorRunSummary)null);

            manager = new LogJoint.Postprocessing.PostprocessorsManager(
                logSources, telemetry, mockedSyncContext, mockedSyncContext, heartbeat, progressAggregator, settingsAccessor, outputDataDeserializer, new TraceSourceFactory());

            manager.RegisterLogType(new LogSourceMetadata(logProviderFac1, logSourcePP1));
        }
Ejemplo n.º 8
0
        internal LogSourcesManager(
            IHeartBeatTimer heartbeat,
            MRU.IRecentlyUsedEntities recentlyUsedEntities,
            IShutdown shutdown,
            ITraceSourceFactory traceSourceFactory,
            IChangeNotification changeNotification,
            ILogSourceFactory logSourceFactory
            )
        {
            this.tracer               = traceSourceFactory.CreateTraceSource("LogSourcesManager", "lsm");
            this.logSourceFactory     = logSourceFactory;
            this.recentlyUsedEntities = recentlyUsedEntities;
            this.changeNotification   = changeNotification;

            this.visibleItems = Selectors.Create(
                () => logSources,
                () => visibilityRevision,
                (items, _) => ImmutableArray.CreateRange(items.Where(i => i.Visible))
                );

            heartbeat.OnTimer += (s, e) =>
            {
                if (e.IsRareUpdate)
                {
                    PeriodicUpdate();
                }
            };

            shutdown.Cleanup += (sender, e) =>
            {
                shutdown.AddCleanupTask(this.DeleteAllLogs());
            };
        }
Ejemplo n.º 9
0
        public PostprocessorsManager(
            ILogSourcesManager logSources,
            Telemetry.ITelemetryCollector telemetry,
            IInvokeSynchronization modelInvoke,
            IHeartBeatTimer heartbeat,
            Progress.IProgressAggregator progressAggregator,
            IPostprocessorsManagerUserInteractions userInteractions,
            Settings.IGlobalSettingsAccessor settingsAccessor
            )
        {
            this.userInteractions   = userInteractions;
            this.logSources         = logSources;
            this.telemetry          = telemetry;
            this.progressAggregator = progressAggregator;
            this.settingsAccessor   = settingsAccessor;

            logSources.OnLogSourceAdded             += (sender, args) => { lazyUpdateTracker.Invalidate(); };
            logSources.OnLogSourceRemoved           += (sender, args) => { lazyUpdateTracker.Invalidate(); };
            logSources.OnLogSourceAnnotationChanged += (sender, args) => { lazyUpdateTracker.Invalidate(); };
            logSources.OnLogSourceStatsChanged      += (object sender, LogSourceStatsEventArgs e) =>
            {
                if ((e.Flags & LogProviderStatsFlag.ContentsEtag) != 0)
                {
                    modelInvoke.Invoke(() => RefreshInternal(assumeSourceChanged: sender as ILogSource));
                }
            };
            heartbeat.OnTimer += (sender, args) =>
            {
                if (lazyUpdateTracker.Validate())
                {
                    RefreshInternal();
                }
            };
            RefreshInternal();
        }
        public Presenter(
            ILogSourcesManager sourcesManager,
            Preprocessing.ILogSourcesPreprocessingManager preprocessingManager,
            IInvokeSynchronization invoker,
            IHeartBeatTimer heartbeat,
            IPresentersFacade presentersFacade,
            StatusReports.IPresenter statusReports
            )
        {
            this.preprocessingManager = preprocessingManager;
            this.presentersFacade     = presentersFacade;
            this.statusReports        = statusReports;

            this.updateInvokeHelper = new AsyncInvokeHelper(invoker, Update)
            {
                ForceAsyncInvocation = true
            };

            sourcesManager.OnLogSourceStatsChanged += (sender, e) =>
            {
                bool?logSourceNeedsFixing = null;
                if ((e.Flags & LogProviderStatsFlag.FirstMessageWithTimeConstraintViolation) != 0 ||
                    (e.Flags & LogProviderStatsFlag.Error) != 0)
                {
                    var badMsg = ((ILogSource)sender).Provider.Stats.FirstMessageWithTimeConstraintViolation;
                    var failedWithBoundaryDates = ((ILogSource)sender).Provider.Stats.Error is BadBoundaryDatesException;

                    logSourceNeedsFixing = badMsg != null || failedWithBoundaryDates;
                }
                if (logSourceNeedsFixing != null)
                {
                    bool updated;
                    if (logSourceNeedsFixing.Value)
                    {
                        updated = logSourcesRequiringReordering.Add((ILogSource)sender);
                    }
                    else
                    {
                        updated = logSourcesRequiringReordering.Remove((ILogSource)sender);
                    }
                    if (updated)
                    {
                        updateFlag.Invalidate();
                    }
                }
            };
            sourcesManager.OnLogSourceRemoved += (sender, e) =>
            {
                updateFlag.Invalidate();
            };
            heartbeat.OnTimer += (sender, e) =>
            {
                if (e.IsNormalUpdate && updateFlag.Validate())
                {
                    Update();
                }
            };
        }
Ejemplo n.º 11
0
 public Model(
     IInvokeSynchronization threadSync,
     Telemetry.ITelemetryCollector telemetryCollector,
     Persistence.IWebContentCache webCache,
     Persistence.IContentCache contentCache,
     Persistence.IStorageManager storageManager,
     IBookmarks bookmarks,
     ILogSourcesManager sourcesManager,
     IModelThreads threads,
     ITempFilesManager tempFilesManager,
     Preprocessing.IPreprocessingManagerExtensionsRegistry preprocessingManagerExtentionsRegistry,
     Preprocessing.ILogSourcesPreprocessingManager logSourcesPreprocessingManager,
     Preprocessing.IPreprocessingStepsFactory preprocessingStepsFactory,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     MRU.IRecentlyUsedEntities mru,
     Progress.IProgressAggregatorFactory progressAggregatorsFactory,
     IHeartBeatTimer heartbeat,
     ILogSourcesController logSourcesController,
     IShutdown shutdown,
     WebBrowserDownloader.IDownloader webBrowserDownloader,
     AppLaunch.ICommandLineHandler commandLineHandler,
     Postprocessing.IPostprocessorsManager postprocessorsManager,
     Postprocessing.IUserNamesProvider analyticsShortNames,
     Analytics.TimeSeries.ITimeSeriesTypesAccess timeSeriesTypes,
     Postprocessing.IAggregatingLogSourceNamesProvider logSourceNamesProvider
     )
 {
     this.ModelThreadSynchronization = threadSync;
     this.Telemetry        = telemetryCollector;
     this.WebContentCache  = webCache;
     this.ContentCache     = contentCache;
     this.StorageManager   = storageManager;
     this.Bookmarks        = bookmarks;
     this.SourcesManager   = sourcesManager;
     this.Threads          = threads;
     this.TempFilesManager = tempFilesManager;
     this.PreprocessingManagerExtensionsRegistry = preprocessingManagerExtentionsRegistry;
     this.PreprocessingStepsFactory      = preprocessingStepsFactory;
     this.LogSourcesPreprocessingManager = logSourcesPreprocessingManager;
     this.ProgressAggregator             = progressAggregator;
     this.LogProviderFactoryRegistry     = logProviderFactoryRegistry;
     this.UserDefinedFormatsManager      = userDefinedFormatsManager;
     this.ProgressAggregatorsFactory     = progressAggregatorsFactory;
     this.MRU                    = mru;
     this.Heartbeat              = heartbeat;
     this.LogSourcesController   = logSourcesController;
     this.Shutdown               = shutdown;
     this.WebBrowserDownloader   = webBrowserDownloader;
     this.CommandLineHandler     = commandLineHandler;
     this.PostprocessorsManager  = postprocessorsManager;
     this.ShortNames             = analyticsShortNames;
     this.TimeSeriesTypes        = timeSeriesTypes;
     this.LogSourceNamesProvider = logSourceNamesProvider;
 }
Ejemplo n.º 12
0
        public PostprocessorsManager(
            ILogSourcesManager logSources,
            Telemetry.ITelemetryCollector telemetry,
            ISynchronizationContext modelSyncContext,
            ISynchronizationContext threadPoolSyncContext,
            IHeartBeatTimer heartbeat,
            Progress.IProgressAggregator progressAggregator,
            Settings.IGlobalSettingsAccessor settingsAccessor,
            IOutputDataDeserializer outputDataDeserializer,
            ITraceSourceFactory traceSourceFactory,
            ILogPartTokenFactories logPartTokenFactories,
            Correlation.ISameNodeDetectionTokenFactories sameNodeDetectionTokenFactories,
            IChangeNotification changeNotification,
            LogMedia.IFileSystem logFileSystem
            )
        {
            this.logSources                      = logSources;
            this.telemetry                       = telemetry;
            this.progressAggregator              = progressAggregator;
            this.settingsAccessor                = settingsAccessor;
            this.modelSyncContext                = modelSyncContext;
            this.threadPoolSyncContext           = threadPoolSyncContext;
            this.heartbeat                       = heartbeat;
            this.outputDataDeserializer          = outputDataDeserializer;
            this.logPartTokenFactories           = logPartTokenFactories;
            this.sameNodeDetectionTokenFactories = sameNodeDetectionTokenFactories;
            this.changeNotification              = changeNotification;
            this.logFileSystem                   = logFileSystem;
            this.tracer  = traceSourceFactory.CreateTraceSource("App", "ppm");
            this.updater = new AsyncInvokeHelper(modelSyncContext, Refresh);

            logSources.OnLogSourceAdded             += (sender, args) => updater.Invoke();
            logSources.OnLogSourceRemoved           += (sender, args) => updater.Invoke();
            logSources.OnLogSourceAnnotationChanged += (sender, args) => updater.Invoke();
            logSources.OnLogSourceStatsChanged      += (object sender, LogSourceStatsEventArgs e) =>
            {
                if ((e.Flags & LogProviderStatsFlag.ContentsEtag) != 0)
                {
                    updater.Invoke();
                }
            };

            this.visiblePostprocessorsOutputs = Selectors.Create(
                () => postprocessorsOutputs,
                () => logSources.Items,
                (outputs, sources) => {
                var sourcesMap = sources.ToLookup(s => s);
                return(ImmutableArray.CreateRange(outputs.Where(output => sourcesMap.Contains(output.LogSource))));
            }
                );

            Refresh();
        }
Ejemplo n.º 13
0
 public void Init()
 {
     timer  = Substitute.For <IHeartBeatTimer>();
     invoke = Substitute.For <ISynchronizationContext>();
     invoke.When(x => x.Post(Arg.Any <Action>())).Do(callInfo =>
     {
         Assert.IsNull(lastInvokedAction);
         lastInvokedAction = callInfo.Arg <Action>();
     });
     agg       = ((IProgressAggregatorFactory) new ProgressAggregator.Factory(timer, invoke)).CreateProgressAggregator();
     outEvents = MakeOutEventsMock(agg);
 }
Ejemplo n.º 14
0
 public LogSourcesManager(
     IHeartBeatTimer heartbeat,
     IInvokeSynchronization invoker,
     IModelThreads threads,
     ITempFilesManager tempFilesManager,
     Persistence.IStorageManager storageManager,
     IBookmarks bookmarks,
     Settings.IGlobalSettingsAccessor globalSettingsAccess
     ) : this(heartbeat,
              new LogSourceFactory(threads, bookmarks, invoker, storageManager, tempFilesManager, globalSettingsAccess))
 {
 }
Ejemplo n.º 15
0
 ProgressAggregator(IHeartBeatTimer timer, IInvokeSynchronization invoker)
 {
     this.invoker   = invoker;
     this.root      = this;
     timer.OnTimer += (s, e) =>
     {
         if (e.IsNormalUpdate)
         {
             RootUpdate();
         }
     };
 }
Ejemplo n.º 16
0
 public void Init()
 {
     timer  = Substitute.For <IHeartBeatTimer>();
     invoke = Substitute.For <IInvokeSynchronization>();
     invoke.Invoke(null).ReturnsForAnyArgs(callInfo =>
     {
         Assert.IsNull(lastInvokedAction);
         lastInvokedAction    = callInfo.Arg <Action>();
         lastActionCompletion = new TaskCompletionSource <int>();
         return(lastActionCompletion.Task);
     });
     agg       = ((IProgressAggregatorFactory) new ProgressAggregator.Factory(timer, invoke)).CreateProgressAggregator();
     outEvents = MakeOutEventsMock(agg);
 }
Ejemplo n.º 17
0
        internal SearchManager(
            ILogSourcesManager sources,
            ISynchronizationContext modelSynchronization,
            IHeartBeatTimer heartBeat,
            ISearchObjectsFactory factory,
            IChangeNotification changeNotification
            )
        {
            this.sources            = sources;
            this.factory            = factory;
            this.changeNotification = changeNotification;

            this.combinedSearchResult        = factory.CreateCombinedSearchResult(this);
            this.combinedResultUpdateInvoker = new AsyncInvokeHelper(
                modelSynchronization, UpdateCombinedResult);
            this.combinedResultNeedsLazyUpdateFlag = new LazyUpdateFlag();

            sources.OnLogSourceAdded += (s, e) =>
            {
                results.ForEach(r => r.FireChangeEventIfContainsSourceResults(s as ILogSource));
            };
            sources.OnLogSourceRemoved += (s, e) =>
            {
                results.ForEach(r => r.FireChangeEventIfContainsSourceResults(s as ILogSource));

                // Search result is fully disposed if it contains messages
                // only from disposed log sources.
                // Fully disposed results are automatically dropped.
                var toBeDropped = results.Where(
                    r => r.Results.All(sr => sr.Source.IsDisposed)).ToHashSet();
                var nrOfFullyDisposedResults = DisposeResults(toBeDropped);
                if (nrOfFullyDisposedResults > 0 && SearchResultsChanged != null)
                {
                    SearchResultsChanged(this, EventArgs.Empty);
                }
                if (nrOfFullyDisposedResults > 0)
                {
                    changeNotification.Post();
                    combinedResultNeedsLazyUpdateFlag.Invalidate();
                }
            };
            heartBeat.OnTimer += (s, e) =>
            {
                if (e.IsNormalUpdate && combinedResultNeedsLazyUpdateFlag.Validate())
                {
                    combinedResultUpdateInvoker.Invoke();
                }
            };
        }
Ejemplo n.º 18
0
 public SearchManager(
     ILogSourcesManager sources,
     Progress.IProgressAggregatorFactory progressAggregatorFactory,
     IInvokeSynchronization modelSynchronization,
     Settings.IGlobalSettingsAccessor settings,
     Telemetry.ITelemetryCollector telemetryCollector,
     IHeartBeatTimer heartBeat
     ) : this(
         sources,
         modelSynchronization,
         heartBeat,
         new SearchObjectsFactory(progressAggregatorFactory, modelSynchronization, settings, telemetryCollector)
         )
 {
 }
Ejemplo n.º 19
0
        internal LogSourcesManager(
            IHeartBeatTimer heartbeat,
            ILogSourceFactory logSourceFactory
            )
        {
            this.tracer           = new LJTraceSource("LogSourcesManager", "lsm");
            this.logSourceFactory = logSourceFactory;

            heartbeat.OnTimer += (s, e) =>
            {
                if (e.IsRareUpdate)
                {
                    PeriodicUpdate();
                }
            };
        }
Ejemplo n.º 20
0
 public LogSourcesManager(
     IHeartBeatTimer heartbeat,
     ISynchronizationContext invoker,
     IModelThreadsInternal threads,
     ITempFilesManager tempFilesManager,
     Persistence.IStorageManager storageManager,
     IBookmarks bookmarks,
     Settings.IGlobalSettingsAccessor globalSettingsAccess,
     MRU.IRecentlyUsedEntities recentlyUsedEntities,
     IShutdown shutdown,
     ITraceSourceFactory traceSourceFactory,
     IChangeNotification changeNotification
     ) : this(heartbeat, recentlyUsedEntities, shutdown, traceSourceFactory, changeNotification,
              new LogSourceFactory(threads, bookmarks, invoker, storageManager, tempFilesManager, globalSettingsAccess, traceSourceFactory))
 {
 }
        public Presenter(
            IView view,
            ILogSourcesManager logSources,
            Preprocessing.IManager preprocessings,
            IModelThreads threads,
            IPresentersFacade navHandler,
            IAlertPopup alerts,
            IClipboardAccess clipboard,
            IShellOpen shellOpen,
            IColorTheme theme,
            IHeartBeatTimer heartBeat,
            IChangeNotification changeNotification
            )
        {
            this.view               = view;
            this.presentersFacade   = navHandler;
            this.alerts             = alerts;
            this.preprocessings     = preprocessings;
            this.clipboard          = clipboard;
            this.shellOpen          = shellOpen;
            this.theme              = theme;
            this.changeNotification = changeNotification.CreateChainedChangeNotification(initiallyActive: false);

            logSources.OnLogSourceStatsChanged += (s, e) =>
            {
                if (s == logSources)
                {
                    pendingUpdateFlag.Invalidate();
                }
            };

            threads.OnThreadListChanged       += (s, e) => pendingUpdateFlag.Invalidate();
            threads.OnThreadPropertiesChanged += (s, e) => pendingUpdateFlag.Invalidate();

            heartBeat.OnTimer += (s, e) =>
            {
                if (pendingUpdateFlag.Validate())
                {
                    ++forceUpdateRevision;
                    changeNotification.Post();
                }
            };

            this.getViewState = () => emptyViewState;

            view.SetViewModel(this);
        }
        public Presenter(
            ILogSourcesManager logSources,
            IBookmarks bookmarks,
            IView view,
            Presenters.Timeline.IPresenter timelinePresenter,
            IHeartBeatTimer heartbeat)
        {
            this.logSources        = logSources;
            this.bookmarks         = bookmarks;
            this.view              = view;
            this.timelinePresenter = timelinePresenter;

            this.logSources.OnLogSourceStatsChanged += (sender, args) =>
            {
                if ((args.Flags & (LogProviderStatsFlag.CachedTime | LogProviderStatsFlag.AvailableTime)) != 0)
                {
                    lazyUpdateFlag.Invalidate();
                }
            };
            this.logSources.OnLogTimeGapsChanged += (sender, args) =>
            {
                lazyUpdateFlag.Invalidate();
            };
            this.logSources.OnLogSourceVisiblityChanged += (sender, args) =>
            {
                lazyUpdateFlag.Invalidate();
            };
            this.logSources.OnLogSourceRemoved += (sender, args) =>
            {
                lazyUpdateFlag.Invalidate();
            };
            this.bookmarks.OnBookmarksChanged += (sender, args) =>
            {
                lazyUpdateFlag.Invalidate();
            };

            heartbeat.OnTimer += (sender, args) =>
            {
                if (args.IsNormalUpdate && lazyUpdateFlag.Validate())
                {
                    UpdateView();
                }
            };

            view.SetPresenter(this);
            view.SetEnabled(false);
        }
Ejemplo n.º 23
0
        public Presenter(
            IModelThreads threads,
            ILogSourcesManager logSources,
            IView view,
            Presenters.LogViewer.IPresenter viewerPresenter,
            IPresentersFacade navHandler,
            IViewUpdates viewUpdates,
            IHeartBeatTimer heartbeat)
        {
            this.threads         = threads;
            this.view            = view;
            this.viewerPresenter = viewerPresenter;
            this.navHandler      = navHandler;
            this.viewUpdates     = viewUpdates;

            viewerPresenter.FocusedMessageChanged += delegate(object sender, EventArgs args)
            {
                view.UpdateFocusedThreadView();
            };
            threads.OnThreadListChanged += (sender, args) =>
            {
                updateTracker.Invalidate();
            };
            threads.OnThreadVisibilityChanged += (sender, args) =>
            {
                updateTracker.Invalidate();
            };
            threads.OnPropertiesChanged += (sender, args) =>
            {
                updateTracker.Invalidate();
            };
            logSources.OnLogSourceVisiblityChanged += (sender, args) =>
            {
                updateTracker.Invalidate();
            };
            heartbeat.OnTimer += (sender, args) =>
            {
                if (args.IsNormalUpdate && updateTracker.Validate())
                {
                    UpdateView();
                }
            };

            view.SetPresenter(this);
        }
        public Presenter(
            IFiltersList filtersList,
            IView view,
            FiltersListBox.IPresenter filtersListPresenter,
            FilterDialog.IPresenter filtersDialogPresenter,
            LogViewer.IPresenter logViewerPresenter,
            IViewUpdates viewUpdates,
            IHeartBeatTimer heartbeat,
            IFiltersFactory filtersFactory,
            IAlertPopup alerts
            )
        {
            this.filtersList            = filtersList;
            this.view                   = view;
            this.heartbeat              = heartbeat;
            this.filtersListPresenter   = filtersListPresenter;
            this.filtersDialogPresenter = filtersDialogPresenter;
            this.logViewerPresenter     = logViewerPresenter;
            this.viewUpdates            = viewUpdates;
            this.filtersFactory         = filtersFactory;
            this.alerts                 = alerts;

            view.SetFiltertingEnabledCheckBoxLabel(
                filtersList.Purpose == FiltersListPurpose.Highlighting ? "Enabled highlighting" : "Enable filtering");

            UpdateControls();

            filtersListPresenter.SelectionChanged += delegate(object sender, EventArgs args) {
                UpdateControls();
            };
            filtersListPresenter.FilterChecked += delegate(object sender, EventArgs args) {
                NotifyAboutFilteringResultChange();
            };
            filtersListPresenter.DeleteRequested += (s, a) => {
                DoRemoveSelected();
            };
            filtersList.OnPropertiesChanged       += HandleFiltersListChange;
            filtersList.OnFilteringEnabledChanged += HandleFiltersListChange;
            filtersList.OnFiltersListChanged      += HandleFiltersListChange;
            heartbeat.OnTimer += PeriodicUpdate;

            view.SetPresenter(this);

            updateTracker.Invalidate();
        }
Ejemplo n.º 25
0
 public SearchManager(
     ILogSourcesManager sources,
     Progress.IProgressAggregatorFactory progressAggregatorFactory,
     ISynchronizationContext modelSynchronization,
     Settings.IGlobalSettingsAccessor settings,
     Telemetry.ITelemetryCollector telemetryCollector,
     IHeartBeatTimer heartBeat,
     IChangeNotification changeNotification,
     ITraceSourceFactory traceSourceFactory
     ) : this(
         sources,
         modelSynchronization,
         heartBeat,
         new SearchObjectsFactory(progressAggregatorFactory, modelSynchronization, settings, telemetryCollector, traceSourceFactory),
         changeNotification
         )
 {
 }
Ejemplo n.º 26
0
 public BookmarkController(
     IBookmarks bookmarks,
     IModelThreads threads,
     IHeartBeatTimer heartbeat
     )
 {
     tracer = LJTraceSource.EmptyTracer;
     threads.OnThreadListChanged += (s, e) =>
     {
         bookmarksNeedPurgeFlag.Invalidate();
     };
     heartbeat.OnTimer += (sender, args) =>
     {
         if (args.IsNormalUpdate && bookmarksNeedPurgeFlag.Validate())
         {
             bookmarks.PurgeBookmarksForDisposedThreads();
         }
     };
     bookmarks.OnBookmarksChanged += (sender, e) =>
     {
         if (e.Type == BookmarksChangedEventArgs.ChangeType.Added || e.Type == BookmarksChangedEventArgs.ChangeType.Removed ||
             e.Type == BookmarksChangedEventArgs.ChangeType.RemovedAll || e.Type == BookmarksChangedEventArgs.ChangeType.Purged)
         {
             foreach (var affectedSource in
                      e.AffectedBookmarks
                      .Select(b => b.GetLogSource())
                      .Where(s => s.LogSourceStateIsOkToChangePersistentState())
                      .Distinct())
             {
                 try
                 {
                     affectedSource.StoreBookmarks();
                 }
                 catch (Persistence.StorageException storageException)
                 {
                     tracer.Error(storageException, "Failed to store bookmarks for log {0}",
                                  affectedSource.GetSafeConnectionId());
                 }
             }
         }
     };
 }
Ejemplo n.º 27
0
 public PresenterFactory(
     IChangeNotification changeNotification,
     IHeartBeatTimer heartbeat,
     IPresentersFacade presentationFacade,
     IClipboardAccess clipboard,
     IBookmarksFactory bookmarksFactory,
     Telemetry.ITelemetryCollector telemetry,
     ILogSourcesManager logSources,
     ISynchronizationContext modelInvoke,
     IModelThreads modelThreads,
     IFiltersList hlFilters,
     IBookmarks bookmarks,
     Settings.IGlobalSettingsAccessor settings,
     ISearchManager searchManager,
     IFiltersFactory filtersFactory,
     IColorTheme theme,
     ITraceSourceFactory traceSourceFactory,
     RegularExpressions.IRegexFactory regexFactory
     )
 {
     this.changeNotification = changeNotification;
     this.heartbeat          = heartbeat;
     this.presentationFacade = presentationFacade;
     this.clipboard          = clipboard;
     this.bookmarksFactory   = bookmarksFactory;
     this.telemetry          = telemetry;
     this.logSources         = logSources;
     this.modelInvoke        = modelInvoke;
     this.modelThreads       = modelThreads;
     this.hlFilters          = hlFilters;
     this.bookmarks          = bookmarks;
     this.settings           = settings;
     this.searchManager      = searchManager;
     this.filtersFactory     = filtersFactory;
     this.theme = theme;
     this.traceSourceFactory = traceSourceFactory;
     this.regexFactory       = regexFactory;
 }
Ejemplo n.º 28
0
 public BookmarkController(
     IBookmarks bookmarks,
     IModelThreads threads,
     IHeartBeatTimer heartbeat,
     ISynchronizationContext synchronization
     )
 {
     tracer         = LJTraceSource.EmptyTracer;
     bookmarksPurge = new AsyncInvokeHelper(synchronization, bookmarks.PurgeBookmarksForDisposedThreads);
     threads.OnThreadListChanged += (s, e) =>
     {
         bookmarksPurge.Invoke();
     };
     bookmarks.OnBookmarksChanged += (sender, e) =>
     {
         if (e.Type == BookmarksChangedEventArgs.ChangeType.Added || e.Type == BookmarksChangedEventArgs.ChangeType.Removed ||
             e.Type == BookmarksChangedEventArgs.ChangeType.RemovedAll || e.Type == BookmarksChangedEventArgs.ChangeType.Purged)
         {
             foreach (var affectedSource in
                      e.AffectedBookmarks
                      .Select(b => b.GetLogSource())
                      .Where(s => s.LogSourceStateIsOkToChangePersistentState())
                      .Distinct())
             {
                 try
                 {
                     affectedSource.StoreBookmarks();
                 }
                 catch (Persistence.StorageException storageException)
                 {
                     tracer.Error(storageException, "Failed to store bookmarks for log {0}",
                                  affectedSource.GetSafeConnectionId());
                 }
             }
         }
     };
 }
Ejemplo n.º 29
0
 public Factory(IHeartBeatTimer timer, IInvokeSynchronization invoker)
 {
     this.timer   = timer;
     this.invoker = invoker;
 }
Ejemplo n.º 30
0
        public Presenter(
            ILogSourcesManager logSources,
            IView view,
            IManager logSourcesPreprocessings,
            SourcePropertiesWindow.IPresenter propertiesWindowPresenter,
            LogViewer.IPresenterInternal logViewerPresenter,
            IAlertPopup alerts,
            IFileDialogs fileDialogs,
            IClipboardAccess clipboard,
            IShellOpen shellOpen,
            SaveJointLogInteractionPresenter.IPresenter saveJointLogInteractionPresenter,
            IColorTheme theme,
            IChangeNotification changeNotification,
            IHeartBeatTimer heartbeat
            )
        {
            this.logSources = logSources;
            this.view       = view;
            this.propertiesWindowPresenter = propertiesWindowPresenter;
            this.logSourcesPreprocessings  = logSourcesPreprocessings;
            this.alerts      = alerts;
            this.fileDialogs = fileDialogs;
            this.clipboard   = clipboard;
            this.shellOpen   = shellOpen;
            this.saveJointLogInteractionPresenter = saveJointLogInteractionPresenter;
            this.changeNotification = changeNotification;

            void updateItems()
            {
                itemsRevision++;
                changeNotification.Post();
            }

            logSources.OnLogSourceVisiblityChanged  += (s, e) => updateItems();
            logSources.OnLogSourceAnnotationChanged += (s, e) => updateItems();
            logSources.OnLogSourceColorChanged      += (s, e) => updateItems();

            logSourcesPreprocessings.PreprocessingChangedAsync += (s, e) => pendingUpdateFlag.Invalidate();
            logSources.OnLogSourceStatsChanged += (s, e) =>
            {
                if ((e.Flags & (LogProviderStatsFlag.Error | LogProviderStatsFlag.CachedMessagesCount | LogProviderStatsFlag.State | LogProviderStatsFlag.BytesCount | LogProviderStatsFlag.BackgroundAcivityStatus)) != 0)
                {
                    pendingUpdateFlag.Invalidate();
                }
            };

            heartbeat.OnTimer += (s, e) =>
            {
                if (pendingUpdateFlag.Validate())
                {
                    updateItems();
                }
            };

            this.getRoot = Selectors.Create(
                () => logSources.Items,
                () => logSourcesPreprocessings.Items,
                () => theme.ThreadColors,
                () => expandedKeys,
                () => selectedKeys,
                () => itemsRevision,
                (sources, preprocessings, themeColors, expanded, selected, rev) => new RootViewItem
            {
                Items = ImmutableArray.CreateRange(
                    EnumItemsData(sources, preprocessings, themeColors, expanded, selected, logSourcesPreprocessings))
            }
                );

            this.getSelectedSources = Selectors.Create(
                getRoot,
                root => ImmutableArray.CreateRange(
                    ViewItem.Flatten(root).Where(i => i.IsSelected).SelectMany(i =>
            {
                if (i is LogSourceViewItem singleSource)
                {
                    return new[] { singleSource.LogSource }
                }
                ;
                if (i is SourcesContainerViewItem container)
                {
                    return(container.LogSources.Select(x => x.LogSource));
                }
                return(Enumerable.Empty <ILogSource>());
            })
                    .Distinct()
                    )
                );

            this.getSelectedPreprocessings = Selectors.Create(
                getRoot,
                root => ImmutableArray.CreateRange(
                    ViewItem.Flatten(root).OfType <PreprocessingViewItem>().Select(p => p.Preprocessing)
                    )
                );

            this.getFocusedMessageItem = Selectors.Create(
                () => logViewerPresenter.FocusedMessage,
                getRoot,
                (msg, root) =>
            {
                var ls = msg?.GetLogSource();
                return((IViewItem)ViewItem.Flatten(root).FirstOrDefault(
                           i => (i as LogSourceViewItem)?.LogSource == ls
                           ));
            }
                );

            view.SetViewModel(this);
        }