Exemple #1
0
        public StateInspectorVisualizerModel(
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            IChangeNotification changeNotification,
            IUserNamesProvider shortNamesManager)
        {
            this.postprocessorsManager = postprocessorsManager;
            this.shortNamesManager     = shortNamesManager;

            int postprocessorsVersion = 0;

            postprocessorsManager.Changed += (sender, args) =>
            {
                postprocessorsVersion++;
                changeNotification.Post();
            };
            var updateGroups = Updaters.Create(
                () => logSourcesManager.VisibleItems,
                () => postprocessorsVersion,
                (visibleSources, _) =>
            {
                UpdateOutputs();
                UpdateOutputGroups();
            }
                );

            this.getGroupsList = Selectors.Create(
                () =>
            {
                updateGroups();
                return(groups);
            },
                dict => (IReadOnlyList <IStateInspectorOutputsGroup>)dict.Values.ToImmutableArray()
                );
        }
Exemple #2
0
 public PropertyChangeView(IInspectedObject obj, StateInspectorEvent change, DisplayMode mode, IUserNamesProvider shortNames) : base(obj)
 {
     this.Change     = change;
     this.Object     = obj;
     this.Mode       = mode;
     this.shortNames = shortNames;
 }
Exemple #3
0
        public static string AddShortNameToUserHash(this IUserNamesProvider shortNames, string hash)
        {
            var resolvedName = shortNames.ResolveObfuscatedUserName(hash);

            if (resolvedName != null)
            {
                return(string.Format("{0} ({1})", resolvedName, hash));
            }
            return(hash);
        }
Exemple #4
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();
        }
 public void Init()
 {
     view = Substitute.For <IView>();
     presentationObjectsFactory = Substitute.For <Postprocessing.Common.IPresentationObjectsFactory>();
     bookmarks               = Substitute.For <IBookmarks>();
     storageManager          = Substitute.For <Persistence.IStorageManager>();
     loadedMessagesPresenter = Substitute.For <LoadedMessages.IPresenter>();
     userNamesProvider       = Substitute.For <IUserNamesProvider>();
     view.When(v => v.SetViewModel(Arg.Any <IViewModel>())).Do(x => viewModel = x.Arg <IViewModel>());
     quickSearchTextBoxPresenter = Substitute.For <QuickSearchTextBox.IPresenter>();
     changeNotification          = Substitute.For <IChangeNotification>();
     theme = Substitute.For <IColorTheme>();
     theme.ThreadColors.Returns(ImmutableArray.Create(new Color(1), new Color(2)));
     presentationObjectsFactory.CreateQuickSearch(Arg.Any <QuickSearchTextBox.IView>()).Returns(quickSearchTextBoxPresenter);
 }
Exemple #6
0
        public TimelineVisualizerModel(
            IPostprocessorsManager postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            IUserNamesProvider shortNames,
            ILogSourceNamesProvider logSourceNamesProvider)
        {
            this.postprocessorsManager  = postprocessorsManager;
            this.shortNames             = shortNames;
            this.logSourceNamesProvider = logSourceNamesProvider;

            postprocessorsManager.Changed += (sender, args) => UpdateOutputs();
            logSourcesManager.OnLogSourceTimeOffsetChanged += (logSource, args) => UpdateAll();
            logSourcesManager.OnLogSourceVisiblityChanged  += (logSource, args) => UpdateOutputs();

            UpdateOutputs();
        }
        public TimelineVisualizerModel(
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            IUserNamesProvider shortNames,
            ILogSourceNamesProvider logSourceNamesProvider)
        {
            this.postprocessorsManager  = postprocessorsManager;
            this.entitiesComparer       = TimelineEntitiesComparer.Instance;
            this.shortNames             = shortNames;
            this.logSourceNamesProvider = logSourceNamesProvider;

            postprocessorsManager.Changed += (sender, args) => UpdateOutputs(invalidateGroupContents: true);
            logSourcesManager.OnLogSourceTimeOffsetChanged += (logSource, args) => UpdateAll();
            logSourcesManager.OnLogSourceAnnotationChanged += (logSource, args) => UpdateOutputsSequenceDiagramNames(true);
            logSourcesManager.OnLogSourceVisiblityChanged  += (logSource, args) => UpdateOutputs(invalidateGroupContents: false);

            UpdateOutputs(invalidateGroupContents: false);
        }
Exemple #8
0
        public SequenceDiagramVisualizerModel(
            IPostprocessorsManager postprocessorsManager,
            ILogSourcesManager logSourceManager,
            IUserNamesProvider shortNames,
            ILogSourceNamesProvider logSourceNamesProvider)
        {
            this.postprocessorsManager  = postprocessorsManager;
            this.shortNames             = shortNames;
            this.logSourceNamesProvider = logSourceNamesProvider;

            postprocessorsManager.Changed += (sender, args) => UpdateOutputs();
            logSourceManager.OnLogSourceTimeOffsetChanged += (s, e) => UpdateCachedContent();
            logSourceManager.OnLogSourceAnnotationChanged += (sender, args) => UpdateCachedContent();
            logSourceManager.OnLogSourceVisiblityChanged  += (sender, args) => UpdateOutputs();


            UpdateOutputs();
        }
Exemple #9
0
 public static string ResolveShortNamesMurkup(this IUserNamesProvider shortNames, string str)
 {
     if (str == null)
     {
         return(null);
     }
     for (; ;)
     {
         var m = re.Match(str);
         if (!m.Success)
         {
             break;
         }
         str =
             str.Substring(0, m.Index)
             + shortNames.GetShortNameForUserHash(m.Groups[1].Value)
             + str.Substring(m.Index + m.Length, str.Length - m.Index - m.Length);
     }
     return(str);
 }
        public StateInspectorVisualizerModel(
            IManager postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            ISynchronizationContext invokeSync,
            IUserNamesProvider shortNamesManager)
        {
            this.postprocessorsManager   = postprocessorsManager;
            this.outputsUpdateInvocation = new AsyncInvokeHelper(invokeSync, UpdateOutputs);
            this.shortNamesManager       = shortNamesManager;

            postprocessorsManager.Changed += (sender, args) =>
            {
                outputsUpdateInvocation.Invoke();
            };
            logSourcesManager.OnLogSourceVisiblityChanged += (sender, args) =>
            {
                outputsUpdateInvocation.Invoke();
            };

            UpdateOutputs();
        }
Exemple #11
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;
 }
        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);
        }
Exemple #13
0
 public TreeBuilder(IStateInspectorOutputsGroup owner, IUserNamesProvider shortNames)
 {
     this.owner      = owner;
     this.shortNames = shortNames;
 }
Exemple #14
0
 public InspectedObject(IStateInspectorOutputsGroup owner, string id, IUserNamesProvider shortNames)
 {
     this.owner      = owner;
     this.id         = id;
     this.shortNames = shortNames;
 }
Exemple #15
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
                           ));
            });
        }
Exemple #16
0
 public static string GetShortNameForUserHash(this IUserNamesProvider shortNames, string hash)
 {
     return(shortNames.ResolveObfuscatedUserName(hash) ?? hash);
 }
 public TimelineBuilder(IEntitiesComparer entitiesComparer, IUserNamesProvider shortNames)
 {
     this.entitiesComparer = entitiesComparer;
     this.shortNames       = shortNames;
 }