Ejemplo n.º 1
0
 public DummyModel(IModelThreads threads = null, Settings.IGlobalSettingsAccessor settings = null)
 {
     this.threads               = threads ?? new ModelThreads();
     this.dummySource           = new DummySource();
     this.hlFilters             = new FiltersList(FilterAction.Exclude, FiltersListPurpose.Highlighting);
     hlFilters.FilteringEnabled = false;
 }
Ejemplo n.º 2
0
        public LogSource(ILogSourcesManagerInternal owner, int id,
                         ILogProviderFactory providerFactory, IConnectionParams connectionParams,
                         IModelThreads threads, ITempFilesManager tempFilesManager, Persistence.IStorageManager storageManager,
                         IInvokeSynchronization invoker, Settings.IGlobalSettingsAccessor globalSettingsAccess, IBookmarks bookmarks)
        {
            this.owner                = owner;
            this.tracer               = new LJTraceSource("LogSource", string.Format("ls{0:D2}", id));
            this.tempFilesManager     = tempFilesManager;
            this.invoker              = invoker;
            this.globalSettingsAccess = globalSettingsAccess;
            this.bookmarks            = bookmarks;

            try
            {
                this.logSourceThreads              = new LogSourceThreads(this.tracer, threads, this);
                this.timeGaps                      = new TimeGapsDetector(tracer, invoker, new LogSourceGapsSource(this));
                this.timeGaps.OnTimeGapsChanged   += timeGaps_OnTimeGapsChanged;
                this.logSourceSpecificStorageEntry = CreateLogSourceSpecificStorageEntry(providerFactory, connectionParams, storageManager);

                var extendedConnectionParams = connectionParams.Clone(true);
                this.LoadPersistedSettings(extendedConnectionParams);
                this.provider = providerFactory.CreateFromConnectionParams(this, extendedConnectionParams);
            }
            catch (Exception e)
            {
                tracer.Error(e, "Failed to initialize log source");
                ((ILogSource)this).Dispose();
                throw;
            }

            this.owner.Container.Add(this);
            this.owner.FireOnLogSourceAdded(this);

            this.LoadBookmarks();
        }
        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.º 4
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.º 5
0
 public SearchCommand(
     SearchAllOccurencesParams searchParams,
     Func <SearchResultMessage, bool> callback,
     Progress.IProgressEventsSink progress,
     IModelThreads modelThreads
     )
 {
     this.searchParams = searchParams;
     this.callback     = callback;
     this.progress     = progress;
     this.modelThreads = modelThreads;
 }
Ejemplo n.º 6
0
        public StateInspectorPresenter(
            IView view,
            IStateInspectorVisualizerModel model,
            IUserNamesProvider shortNames,
            ILogSourcesManager logSources,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IBookmarks bookmarks,
            IModelThreads threads,
            IPresentersFacade presentersFacade,
            IClipboardAccess clipboardAccess,
            SourcesManager.IPresenter sourcesManagerPresenter,
            IColorTheme theme
            )
        {
            this.view                    = view;
            this.model                   = model;
            this.shortNames              = shortNames;
            this.threads                 = threads;
            this.presentersFacade        = presentersFacade;
            this.bookmarks               = bookmarks;
            this.clipboardAccess         = clipboardAccess;
            this.sourcesManagerPresenter = sourcesManagerPresenter;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.theme                   = theme;

            view.SetEventsHandler(this);

            logSources.OnLogSourceAnnotationChanged += (sender, e) =>
            {
                InvalidateTree();
            };

            loadedMessagesPresenter.LogViewerPresenter.FocusedMessageChanged += (sender, args) =>
            {
                HandleFocusedMessageChange();
            };

            bookmarks.OnBookmarksChanged += (sender, args) =>
            {
                view.BeginUpdateStateHistoryList(false, false);
                view.EndUpdateStateHistoryList(null, false, redrawFocusedMessageMark: true);
            };

            model.Changed += (sender, args) =>
            {
                InvalidateTree();
                HandleFocusedMessageChange();
                RemoveMissingGroupsFromCache();
            };

            InvalidateTree();
            HandleFocusedMessageChange();
        }
Ejemplo n.º 7
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.º 8
0
 public LogSourceFactory(
     IModelThreads threads,
     IBookmarks bookmarks,
     IInvokeSynchronization invoker,
     Persistence.IStorageManager storageManager,
     ITempFilesManager tempFilesManager,
     Settings.IGlobalSettingsAccessor globalSettingsAccess
     )
 {
     this.threads              = threads;
     this.bookmarks            = bookmarks;
     this.invoker              = invoker;
     this.storageManager       = storageManager;
     this.tempFilesManager     = tempFilesManager;
     this.globalSettingsAccess = globalSettingsAccess;
 }
Ejemplo n.º 9
0
        public PresentationModel(
            ILogSourcesManager logSources,
            IInvokeSynchronization modelInvoke,
            IModelThreads modelThreads,
            IFiltersList hlFilters,
            IBookmarks bookmarks,
            Settings.IGlobalSettingsAccessor settings
            )
        {
            this.logSources   = logSources;
            this.modelThreads = modelThreads;
            this.hlFilters    = hlFilters;
            this.bookmarks    = bookmarks;
            this.settings     = settings;

            updateSourcesInvoker = new AsyncInvokeHelper(modelInvoke, UpdateSources);

            logSources.OnLogSourceColorChanged += (s, e) =>
            {
                if (OnLogSourceColorChanged != null)
                {
                    OnLogSourceColorChanged(s, e);
                }
            };
            logSources.OnLogSourceAdded += (s, e) =>
            {
                updateSourcesInvoker.Invoke();
            };
            logSources.OnLogSourceRemoved += (s, e) =>
            {
                updateSourcesInvoker.Invoke();
            };
            logSources.OnLogSourceStatsChanged += (s, e) =>
            {
                if ((e.Flags & LogProviderStatsFlag.PositionsRange) != 0)
                {
                    if ((e.Flags & LogProviderStatsFlag.AvailableTimeUpdatedIncrementallyFlag) == 0)
                    {
                        updateSourcesInvoker.Invoke();
                    }
                    else if (OnSourceMessagesChanged != null)
                    {
                        OnSourceMessagesChanged(this, EventArgs.Empty);
                    }
                }
            };
        }
        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);
        }
Ejemplo n.º 11
0
 public Model(
     ISynchronizationContext threadSync,
     IChangeNotification changeNotification,
     Persistence.IWebContentCache webCache,
     Persistence.IContentCache contentCache,
     Persistence.IStorageManager storageManager,
     IBookmarks bookmarks,
     ILogSourcesManager sourcesManager,
     IModelThreads threads,
     ITempFilesManager tempFilesManager,
     Preprocessing.IModel preprocessingModel,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IUserDefinedFormatsManager userDefinedFormatsManager,
     MRU.IRecentlyUsedEntities mru,
     Progress.IProgressAggregatorFactory progressAggregatorsFactory,
     IShutdown shutdown,
     WebViewTools.IWebViewTools webViewTools,
     Postprocessing.IModel postprocessingModel,
     IPluginsManager pluginsManager,
     ITraceSourceFactory traceSourceFactory,
     LogMedia.IFileSystem fileSystem
     )
 {
     this.SynchronizationContext = threadSync;
     this.ChangeNotification     = changeNotification;
     this.WebContentCache        = webCache;
     this.ContentCache           = contentCache;
     this.StorageManager         = storageManager;
     this.Bookmarks                  = bookmarks;
     this.SourcesManager             = sourcesManager;
     this.Threads                    = threads;
     this.TempFilesManager           = tempFilesManager;
     this.Preprocessing              = preprocessingModel;
     this.ProgressAggregator         = progressAggregator;
     this.LogProviderFactoryRegistry = logProviderFactoryRegistry;
     this.UserDefinedFormatsManager  = userDefinedFormatsManager;
     this.ProgressAggregatorsFactory = progressAggregatorsFactory;
     this.MRU                = mru;
     this.Shutdown           = shutdown;
     this.WebViewTools       = webViewTools;
     this.Postprocessing     = postprocessingModel;
     this.PluginsManager     = pluginsManager;
     this.TraceSourceFactory = traceSourceFactory;
     this.FileSystem         = fileSystem;
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public Presenter(
            IView view,
            ITempFilesManager tempFilesManager,
            LogViewer.IPresenterFactory logViewerPresenterFactory
            )
        {
            this.view = view;
            this.view.SetEventsHandler(this);
            this.tempFilesManager = tempFilesManager;

            this.threads          = new ModelThreads();
            this.logSourceThreads = new LogSourceThreads(
                LJTraceSource.EmptyTracer, threads, null);
            this.model        = new Presenters.LogViewer.DummyModel(threads);
            this.logPresenter = logViewerPresenterFactory.Create(
                model, view.LogViewer, createIsolatedPresenter: true);
            logPresenter.ShowTime = true;
        }
Ejemplo n.º 14
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.º 15
0
 public SearchResultMessagesModel(
     ILogSourcesManager logSources,
     ISearchManager searchManager,
     IFiltersFactory filtersFactory,
     IModelThreads threads,
     IBookmarks bookmarks,
     Settings.IGlobalSettingsAccessor settings
     )
 {
     this.logSources     = logSources;
     this.searchManager  = searchManager;
     this.threads        = threads;
     this.bookmarks      = bookmarks;
     this.settings       = settings;
     this.filtersFactory = filtersFactory;
     logSources.OnLogSourceColorChanged += (s, e) =>
     {
         OnLogSourceColorChanged?.Invoke(s, e);
     };
 }
Ejemplo n.º 16
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.º 17
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.º 18
0
 public Factory(
     IViewsFactory postprocessingViewsFactory,
     IManager postprocessorsManager,
     ILogSourcesManager logSourcesManager,
     ISynchronizationContext synchronizationContext,
     IChangeNotification changeNotification,
     IBookmarks bookmarks,
     IModelThreads threads,
     Persistence.IStorageManager storageManager,
     ILogSourceNamesProvider logSourceNamesProvider,
     IUserNamesProvider shortNames,
     SourcesManager.IPresenter sourcesManagerPresenter,
     LoadedMessages.IPresenter loadedMessagesPresenter,
     IClipboardAccess clipboardAccess,
     IPresentersFacade presentersFacade,
     IAlertPopup alerts,
     IColorTheme colorTheme
     )
 {
     this.postprocessingViewsFactory = postprocessingViewsFactory;
     this.postprocessorsManager      = postprocessorsManager;
     this.logSourcesManager          = logSourcesManager;
     this.synchronizationContext     = synchronizationContext;
     this.changeNotification         = changeNotification;
     this.bookmarks               = bookmarks;
     this.threads                 = threads;
     this.storageManager          = storageManager;
     this.logSourceNamesProvider  = logSourceNamesProvider;
     this.shortNames              = shortNames;
     this.sourcesManagerPresenter = sourcesManagerPresenter;
     this.loadedMessagesPresenter = loadedMessagesPresenter;
     this.clipboardAccess         = clipboardAccess;
     this.presentersFacade        = presentersFacade;
     this.alerts     = alerts;
     this.colorTheme = colorTheme;
 }
Ejemplo n.º 19
0
        public StateInspectorPresenter(
            IView view,
            IStateInspectorVisualizerModel model,
            IUserNamesProvider shortNames,
            ILogSourcesManager logSources,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IBookmarks bookmarks,
            IModelThreads threads,
            IPresentersFacade presentersFacade,
            IClipboardAccess clipboardAccess,
            SourcesManager.IPresenter sourcesManagerPresenter,
            IColorTheme theme,
            IChangeNotification changeNotification
            )
        {
            this.view                    = view;
            this.model                   = model;
            this.shortNames              = shortNames;
            this.threads                 = threads;
            this.presentersFacade        = presentersFacade;
            this.bookmarks               = bookmarks;
            this.clipboardAccess         = clipboardAccess;
            this.sourcesManagerPresenter = sourcesManagerPresenter;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.theme                   = theme;
            this.changeNotification      = changeNotification.CreateChainedChangeNotification(initiallyActive: false);

            var annotationsVersion = 0;

            logSources.OnLogSourceAnnotationChanged += (sender, e) =>
            {
                annotationsVersion++;
                changeNotification.Post();
            };

            var getAnnotationsMap = Selectors.Create(
                () => logSources.Items,
                () => annotationsVersion,
                (sources, _) =>
                sources
                .Where(s => !s.IsDisposed && !string.IsNullOrEmpty(s.Annotation))
                .ToImmutableDictionary(s => s, s => s.Annotation)
                );

            VisualizerNode rootNode   = new VisualizerNode(null, ImmutableList <VisualizerNode> .Empty, true, false, 0, ImmutableDictionary <ILogSource, string> .Empty);
            var            updateRoot = Updaters.Create(
                () => model.Groups,
                getAnnotationsMap,
                (groups, annotationsMap) => rootNode = MakeRootNode(groups, OnNodeCreated, annotationsMap, rootNode)
                );

            this.getRootNode = () =>
            {
                updateRoot();
                return(rootNode);
            };
            this.updateRootNode = reducer =>
            {
                var oldRoot = getRootNode();
                var newRoot = reducer(oldRoot);
                if (oldRoot != newRoot)
                {
                    rootNode = newRoot;
                    changeNotification.Post();
                }
            };

            this.getSelectedNodes = Selectors.Create(
                getRootNode,
                (root) =>
            {
                var result = ImmutableArray.CreateBuilder <VisualizerNode>();

                void traverse(VisualizerNode n)
                {
                    if (!n.HasSelectedNodes)
                    {
                        return;
                    }
                    if (n.IsSelected)
                    {
                        result.Add(n);
                    }
                    foreach (var c in n.Children)
                    {
                        traverse(c);
                    }
                }

                traverse(root);

                return(result.ToImmutable());
            }
                );

            this.getSelectedInspectedObjects = Selectors.Create(
                getSelectedNodes,
                nodes => ImmutableArray.CreateRange(nodes.Select(n => n.InspectedObject))
                );

            this.getStateHistoryItems = Selectors.Create(
                getSelectedInspectedObjects,
                () => selectedHistoryEvents,
                MakeSelectedObjectHistory
                );

            this.getIsHistoryItemBookmarked = Selectors.Create(
                () => bookmarks.Items,
                boormarksItems =>
            {
                Predicate <IStateHistoryItem> result = (item) =>
                {
                    var change = (item as StateHistoryItem)?.Event;
                    if (change == null || change.Output.LogSource.IsDisposed)
                    {
                        return(false);
                    }
                    var bmk = bookmarks.Factory.CreateBookmark(
                        change.Trigger.Timestamp.Adjust(change.Output.LogSource.TimeOffsets),
                        change.Output.LogSource.GetSafeConnectionId(), change.Trigger.StreamPosition, 0);
                    var pos = boormarksItems.FindBookmark(bmk);
                    return(pos.Item2 > pos.Item1);
                };
                return(result);
            }
                );

            this.getFocusedMessageInfo = () => loadedMessagesPresenter.LogViewerPresenter.FocusedMessage;

            this.getFocusedMessageEqualRange = Selectors.Create(
                getFocusedMessageInfo,
                focusedMessageInfo =>
            {
                var cache = new Dictionary <IStateInspectorOutputsGroup, FocusedMessageEventsRange>();
                Func <IStateInspectorOutputsGroup, FocusedMessageEventsRange> result = forGroup =>
                {
                    if (!cache.TryGetValue(forGroup, out FocusedMessageEventsRange eventsRange))
                    {
                        eventsRange = new FocusedMessageEventsRange(focusedMessageInfo,
                                                                    forGroup.Events.CalcFocusedMessageEqualRange(focusedMessageInfo));
                        cache.Add(forGroup, eventsRange);
                    }
                    return(eventsRange);
                };
                return(result);
            }
                );

            this.getPaintNode = Selectors.Create(
                getFocusedMessageEqualRange,
                MakePaintNodeDelegate
                );

            this.getFocusedMessagePositionInHistory = Selectors.Create(
                getStateHistoryItems,
                getFocusedMessageInfo,
                (changes, focusedMessage) =>
            {
                return
                (focusedMessage == null ? null :
                 new ListUtils.VirtualList <StateInspectorEvent>(changes.Length,
                                                                 i => changes[i].Event).CalcFocusedMessageEqualRange(focusedMessage));
            }
                );

            this.getCurrentTimeLabelText = Selectors.Create(
                getFocusedMessageInfo,
                focusedMsg => focusedMsg != null ? $"at {focusedMsg.Time}" : ""
                );

            this.getCurrentProperties = Selectors.Create(
                getSelectedInspectedObjects,
                getFocusedMessageEqualRange,
                () => selectedProperty,
                MakeCurrentProperties
                );

            this.getPropertyItems = Selectors.Create(
                getCurrentProperties,
                props => (IReadOnlyList <IPropertyListItem>)props.Cast <IPropertyListItem>().ToImmutableArray()
                );

            this.getObjectsProperties = Selectors.Create(
                getCurrentProperties,
                props => (IReadOnlyList <KeyValuePair <string, object> >)props.Select(p => p.ToDataSourceItem()).ToImmutableArray()
                );

            view.SetViewModel(this);
        }
Ejemplo n.º 20
0
 public LogSourceThreads(LJTraceSource tracer, IModelThreads modelThreads, ILogSource threadsSource)
 {
     this.tracer       = tracer;
     this.modelThreads = modelThreads;
     this.logSource    = threadsSource;
 }
Ejemplo n.º 21
0
        public Factory(
            IViewsFactory postprocessingViewsFactory,
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            ISynchronizationContext synchronizationContext,
            IChangeNotification changeNotification,
            IBookmarks bookmarks,
            IModelThreads threads,
            Persistence.IStorageManager storageManager,
            ILogSourceNamesProvider logSourceNamesProvider,
            IUserNamesProvider shortNames,
            SourcesManager.IPresenter sourcesManagerPresenter,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess,
            IPresentersFacade presentersFacade,
            IAlertPopup alerts,
            IColorTheme colorTheme,
            Drawing.IMatrixFactory matrixFactory,
            ICorrelationManager correlationManager
            )
        {
            stateInspectorVisualizer = new Lazy <StateInspectorVisualizer.IPresenterInternal>(() =>
            {
                var view  = postprocessingViewsFactory.CreateStateInspectorView();
                var model = new LogJoint.Postprocessing.StateInspector.StateInspectorVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    synchronizationContext,
                    shortNames
                    );
                return(new StateInspectorVisualizer.StateInspectorPresenter(
                           view,
                           model,
                           shortNames,
                           logSourcesManager,
                           loadedMessagesPresenter,
                           bookmarks,
                           threads,
                           presentersFacade,
                           clipboardAccess,
                           sourcesManagerPresenter,
                           colorTheme
                           ));
            });

            timelineVisualizer = new Lazy <TimelineVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimelineView();
                var model = new LogJoint.Postprocessing.Timeline.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimelineVisualizer.TimelineVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme
                           ));
            });

            sequenceDiagramVisualizer = new Lazy <SequenceDiagramVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateSequenceDiagramView();
                var model = new LogJoint.Postprocessing.SequenceDiagram.SequenceDiagramVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider,
                    changeNotification
                    );
                return(new SequenceDiagramVisualizer.SequenceDiagramVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme,
                           matrixFactory
                           ));
            });

            timeSeriesVisualizer = new Lazy <TimeSeriesVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimeSeriesView();
                var model = new LogJoint.Postprocessing.TimeSeries.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimeSeriesVisualizer.TimeSeriesVisualizerPresenter(
                           model,
                           view,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter.LogViewerPresenter,
                           bookmarks,
                           presentersFacade,
                           changeNotification
                           ));
            });
        }