public LoadedMessagesViewModeStrategy(
            ILogSourcesManager logSourcesManager,
            IChangeNotification changeNotification
            )
        {
            this.logSourcesManager  = logSourcesManager;
            this.changeNotification = changeNotification;
            this.rawModeAllowed     = Selectors.Create(
                () => logSourcesManager.VisibleItems,
                sources => sources.Any(s => s.Provider.Factory.ViewOptions.RawViewAllowed)
                );
            this.isRawMode = Selectors.Create(
                rawModeAllowed,
                () => manuallySetRawMode,
                () => logSourcesManager.VisibleItems,
                (allowed, set, sources) =>
            {
                return
                (!allowed ? false :
                 set != null ? set.Value :
                 sources.All(s => s.Provider.Factory.ViewOptions.PreferredView == PreferredViewMode.Raw));
            }
                );

            logSourceRemovedHandler = (s, e) =>
            {
                if (logSourcesManager.Items.Count == 0 && manuallySetRawMode.HasValue)
                {
                    manuallySetRawMode = null;                     // reset automatic mode when last source is gone
                    changeNotification.Post();
                }
            };

            logSourcesManager.OnLogSourceRemoved += logSourceRemovedHandler;
        }
Exemple #2
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);
        }
Exemple #3
0
 private void UnHookChangeNotification(IChangeNotification element)
 {
     if (element != null)
     {
         element.Changed -= ChildChanged;
     }
 }
        public PresenterPersistentState(
            Persistence.IStorageManager storageManager,
            string globalStateStorageEntryName,
            string logSourceSpecificStateSectionName,
            IChangeNotification changeNotification,
            Func <ImmutableHashSet <string> > availableTagsSelector,
            Func <IEnumerable <ILogSource> > sourcesSelector
            )
        {
            this.changeNotification        = changeNotification;
            this.stateEntry                = storageManager.GetEntry(globalStateStorageEntryName);
            this.logSourceStateSectionName = logSourceSpecificStateSectionName;
            this.availableTagsSelector     = CreateAvailableTagsSelectorAdapter(availableTagsSelector);
            this.sourcesSelector           = sourcesSelector;

            this.getDefaultPredicate = Selectors.Create(
                this.availableTagsSelector,
                availableTags => TagsPredicate.MakeMatchAnyPredicate(availableTags)
                );

            this.getTagsPredicate = Selectors.Create(
                getDefaultPredicate,
                sourcesSelector,
                () => savedTagsRevision,
                (defaultPredicate, sources, _revision) => LoadPredicate(sources, defaultPredicate, logSourceStateSectionName)
                );
        }
        public Presenter(
            IBookmarks bookmarks,
            IFiltersList hlFilters,
            IView view,
            LogViewer.IPresenter viewerPresenter,
            IPresentersFacade navHandler,
            IColorTheme theme,
            IChangeNotification parentChangeNotification,
            Telemetry.ITelemetryCollector telemetryCollector
            )
        {
            this.hlFilters          = hlFilters;
            this.bookmarks          = bookmarks;
            this.view               = view;
            this.viewerPresenter    = viewerPresenter;
            this.navHandler         = navHandler;
            this.changeNotification = parentChangeNotification.CreateChainedChangeNotification(false);

            this.getFocusedMessage = Selectors.Create(() => viewerPresenter.FocusedMessage,
                                                      message => message?.GetLogSource() == null ? null : message);
            var getBookmarkData = bookmarks == null ? () => (null, null) :
                                  Selectors.Create(getFocusedMessage, () => bookmarks.Items, (focused, bmks) =>
            {
                if (focused == null)
                {
                    return(noSelection, null);
                }
                var isBookmarked = IsMessageBookmarked(focused);
                return(isBookmarked ? "yes" : "no", isBookmarked ? "clear bookmark" : "set bookmark");
            });
Exemple #6
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());
            };
        }
Exemple #7
0
 public Presenter(IChangeNotification changeNotification)
 {
     this.changeNotification = changeNotification;
     this.availableToolsInfo = Selectors.Create(
         () => availableTools,
         kinds => ImmutableList.CreateRange(kinds.Select(ToToolInfo))
         );
 }
Exemple #8
0
 public Presenter(
     IView view,
     IChangeNotification changeNotification
     )
 {
     this.view = view;
     this.changeNotification = changeNotification;
     view.SetEventsHandler(this);
 }
        public Presenter(IChangeNotification changeNotification)
        {
            this.changeNotification = changeNotification;
            this.searchBox          = new QuickSearchTextBox.Presenter(null, changeNotification);
            searchBox.HideClearButton();

            searchBox.OnCancelled += (s, e) => DoHide();
            searchBox.OnSearchNow += (s, e) => DoSearch(e.ReverseSearchModifier);
        }
Exemple #10
0
 public Subscription(IChangeNotification changeNotification, Action sideEffect, bool initiallyActive)
 {
     this.changeNotification = changeNotification;
     this.SideEffect         = sideEffect;
     this.changeHandler      = (sender, evt) => SideEffect?.Invoke();
     if (initiallyActive)
     {
         Active = true;
     }
 }
Exemple #11
0
 private void HookChangeNotification(IChangeNotification element)
 {
     if (element != null)
     {
         // Unhook first to avoid double-hooking if the same
         // element is passed twice.
         element.Changed -= ChildChanged;
         element.Changed += ChildChanged;
     }
 }
Exemple #12
0
 public NavigationManager(
     LJTraceSource tracer,
     Telemetry.ITelemetryCollector telemetry,
     IChangeNotification changeNotification
     )
 {
     this.tracer             = tracer;
     this.telemetry          = telemetry;
     this.changeNotification = changeNotification;
 }
        public Presenter(
            ILogSourcesManager logSourcesManager,
            IChangeNotification changeNotification,
            IView view,
            Preprocessing.IManager sourcesPreprocessingManager,
            Preprocessing.IStepsFactory preprocessingStepsFactory,
            MRU.IRecentlyUsedEntities mru,
            QuickSearchTextBox.IPresenter searchBoxPresenter,
            IAlertPopup alerts,
            ITraceSourceFactory traceSourceFactory
            )
        {
            this.view = view;
            this.changeNotification          = changeNotification;
            this.logSourcesManager           = logSourcesManager;
            this.sourcesPreprocessingManager = sourcesPreprocessingManager;
            this.preprocessingStepsFactory   = preprocessingStepsFactory;
            this.mru = mru;
            this.searchBoxPresenter = searchBoxPresenter;
            this.trace  = traceSourceFactory.CreateTraceSource("UI", "hist-dlg");
            this.alerts = alerts;

            items            = Selectors.Create(() => visible, () => acceptedFilter, MakeItems);
            actuallySelected = Selectors.Create(() => items().displayItems, () => selected,
                                                (items, selected) => items.SelectMany(i => i.Flatten()).Where(i => selected.Contains(i.key)).ToImmutableList());
            openButtonEnabled = Selectors.Create(actuallySelected, selected => selected.Any(IsOpenable));
            rootViewItem      = Selectors.Create(() => items().displayItems, () => selected, () => expanded, MakeRootItem);

            searchBoxPresenter.OnSearchNow += (s, e) =>
            {
                acceptedFilter = searchBoxPresenter.Text;
                FocusItemsListAndSelectFirstItem();
                changeNotification.Post();
            };
            searchBoxPresenter.OnRealtimeSearch += (s, e) =>
            {
                acceptedFilter = searchBoxPresenter.Text;
                changeNotification.Post();
            };
            searchBoxPresenter.OnCancelled += (s, e) =>
            {
                if (acceptedFilter != "")
                {
                    acceptedFilter = "";
                    searchBoxPresenter.Focus(null);
                }
                else
                {
                    visible = false;
                }
                changeNotification.Post();
            };

            view.SetViewModel(this);
        }
Exemple #14
0
 public PresentationObjectsFactory(
     IManager ppm,
     ILogSourcesManager lsm,
     IChangeNotification changeNotification,
     IAlertPopup alerts
     )
 {
     this.ppm    = ppm;
     this.lsm    = lsm;
     this.alerts = alerts;
 }
        public MessagePropertiesDialogAdapter(IDialogViewModel viewModel)
            : base("MessagePropertiesDialog")
        {
            this.changeNotification = viewModel.ChangeNotification;
            this.viewModel          = viewModel;

            NSColor resolveColor(Color?cl) =>
            cl.HasValue ? cl.Value.ToNSColor() : null;

            var update = Updaters.Create(() => viewModel.Data, (viewData, prevData) =>
            {
                this.Window.EnsureCreated();

                timestampLabel.StringValue  = viewData.TimeValue;
                threadLabel.StringValue     = viewData.ThreadLinkValue;
                threadLabel.BackgroundColor =
                    viewData.ThreadLinkEnabled ? resolveColor(viewData.ThreadLinkBkColor) : null;
                threadLabel.IsEnabled           = viewData.ThreadLinkEnabled;
                sourceLabel.StringValue         = viewData.SourceLinkValue;
                sourceLabel.IsEnabled           = viewData.SourceLinkEnabled;
                sourceLabel.BackgroundColor     = resolveColor(viewData.SourceLinkBkColor);
                bookmarkStatusLabel.StringValue = viewData.BookmarkedStatusText;
                bookmarkActionLabel.StringValue = viewData.BookmarkActionLinkText;
                bookmarkActionLabel.IsEnabled   = viewData.BookmarkActionLinkEnabled;
                severityLabel.StringValue       = viewData.SeverityValue;
                var prevCustomView = prevData?.CustomView as NSView;
                if (viewData.CustomView is NSView customView)
                {
                    textContentScrollView.Hidden = true;
                    if (prevCustomView != customView)
                    {
                        prevCustomView?.RemoveFromSuperview();
                        customView.MoveToPlaceholder(messageContentContainerView);
                        customView.Hidden = false;
                    }
                }
                else
                {
                    textContentScrollView.Hidden = false;
                    textView.Value = viewData.TextValue ?? "";
                    prevCustomView?.RemoveFromSuperview();
                }
                hlCheckbox.Enabled = viewData.HighlightedCheckboxEnabled;
                contentModeSegmentedControl.SegmentCount = viewData.ContentViewModes.Count;
                foreach (var i in viewData.ContentViewModes.Select((lbl, idx) => (lbl, idx)))
                {
                    contentModeSegmentedControl.SetLabel(i.lbl, i.idx);
                }
                if (viewData.ContentViewModeIndex != null)
                {
                    contentModeSegmentedControl.SelectedSegment = viewData.ContentViewModeIndex.Value;
                }
            });
 public void Init()
 {
     view = Substitute.For <IView>();
     view.When(v => v.SetViewModel(Arg.Any <IViewModel>())).Do(
         x => viewModel                    = x.Arg <IViewModel>());
     changeNotification                    = Substitute.For <IChangeNotification>();
     presenter                             = new Presenter(view, changeNotification);
     onSearchNowRaised                     = 0;
     presenter.OnSearchNow                += (sender, e) => ++ onSearchNowRaised;
     onCurrentSuggestionChanged            = 0;
     presenter.OnCurrentSuggestionChanged += (sender, e) => ++ onCurrentSuggestionChanged;
 }
        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();
        }
Exemple #18
0
        void IView.SetViewModel(IViewModel viewModel)
        {
            this.viewModel = viewModel;

            res = new GraphicsResources(
                viewModel,
                Font.FontFamily.Name,
                Font.Size,
                8f,
                6f,
                new LJD.Image(TimelineVisualizerControlResources.UserAction),
                new LJD.Image(TimelineVisualizerControlResources.APICall),
                new LJD.Image(TimelineVisualizerControlResources.TimelineBookmark),
                new LJD.Image(TimelineVisualizerControlResources.FocusedMsgSlaveVert),
                UIUtils.Dpi.ScaleUp(1, 120),
                new LJD.Brush(System.Drawing.SystemColors.Control.ToColor())
                );
            drawing = new ControlDrawing(res);
            var vm = GetUpToDateViewMetrics();

            var rulersPanelHeight = vm.RulersPanelHeight;

            activitiesScrollBar.SmallChange = vm.LineHeight;
            activitiesScrollBar.Top         = rulersPanelHeight;
            quickSearchEditBox.Top          = rulersPanelHeight - quickSearchEditBox.Height;
            panel5.Height = rulersPanelHeight;

            this.changeNotification = viewModel.ChangeNotification;
            var updateNotificationsButton = Updaters.Create(() => viewModel.NotificationsIconVisibile, v => notificationsButton.Visible = v);
            var updateNoContentMessage    = Updaters.Create(() => viewModel.NoContentMessageVisibile, SetNoContentMessageVisibility);
            var updateVertScroller        = Updaters.Create(
                Selectors.Create(() => viewModel.ActivitiesCount, () => activitiesViewPanelSize, (activitiesCount, sz) => new { activitiesCount, sz }),
                key => UpdateActivitiesScroller(key.activitiesCount, key.sz.Value));
            var updateCurrentActivityInfo = Updaters.Create(() => viewModel.CurrentActivity, UpdateCurrentActivityControls);

            this.changeNotificationSubscription = changeNotification.CreateSubscription(() => {
                updateNotificationsButton();
                updateNoContentMessage();
                updateVertScroller();
                updateCurrentActivityInfo();
            });
            this.ParentForm.VisibleChanged += (s, e) =>
            {
                if (this.ParentForm.Visible)
                {
                    viewModel.OnWindowShown();
                }
                else
                {
                    viewModel.OnWindowHidden();
                }
            };
        }
        public Presenter(
            ILogSourcesManager logSourcesManager,
            Workspaces.IWorkspacesManager workspacesManager,
            Preprocessing.IManager preprocessingsManager,
            IAlertPopup alertPopup,
            IClipboardAccess clipboard,
            IView view,
            IChangeNotification changeNotification
            )
        {
            this.logSourcesManager = logSourcesManager;
            this.workspacesManager = workspacesManager;
            this.view = view;
            this.preprocessingsManager = preprocessingsManager;
            this.alertPopup            = alertPopup;
            this.clipboard             = clipboard;
            this.changeNotification    = changeNotification;

            view.SetEventsHandler(this);

            logSourcesManager.OnLogSourceAdded += (sender, args) =>
            {
                UpdateAvaialibility();
            };

            logSourcesManager.OnLogSourceRemoved += (sender, args) =>
            {
                UpdateAvaialibility();
            };

            workspacesManager.CurrentWorkspaceChanged += (sender, args) =>
            {
                UpdateWorkspaceUrlEditBox();
                UpdateWorkspaceEditCotrols();
            };

            workspacesManager.StatusChanged += (sender, args) =>
            {
                UpdateWorkspaceUrlEditBox();
                UpdateDescription();
                UpdateDialogButtons();
                UpdateProgressIndicator();
                UpdateWorkspaceEditCotrols(triggeredByStatusChange: true);
                UpdateIsBusy();
            };

            UpdateAvaialibility();
            UpdateDescription();
            UpdateWorkspaceUrlEditBox();
            UpdateDialogButtons();
            UpdateWorkspaceEditCotrols();
        }
Exemple #20
0
 public PresentationObjectsFactory(
     IManagerInternal ppm,
     ILogSourcesManager lsm,
     IChangeNotification changeNotification,
     IAlertPopup alerts,
     ICorrelationManager correlationManager
     )
 {
     this.ppm                = ppm;
     this.lsm                = lsm;
     this.alerts             = alerts;
     this.correlationManager = correlationManager;
 }
Exemple #21
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();
                }
            };
        }
 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 #23
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))
 {
 }
Exemple #24
0
 public SearchManager(
     ILogSourcesManager sources,
     Progress.IProgressAggregatorFactory progressAggregatorFactory,
     ISynchronizationContext modelSynchronization,
     Settings.IGlobalSettingsAccessor settings,
     Telemetry.ITelemetryCollector telemetryCollector,
     IChangeNotification changeNotification,
     ITraceSourceFactory traceSourceFactory
     ) : this(
         sources,
         modelSynchronization,
         new SearchObjectsFactory(progressAggregatorFactory, modelSynchronization, settings, telemetryCollector, traceSourceFactory),
         changeNotification
         )
 {
 }
        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);
        }
Exemple #26
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;
 }
        public Presenter(
            IBookmarks bookmarks,
            IFiltersList hlFilters,
            IView view,
            LogViewer.IPresenterInternal viewerPresenter,
            IPresentersFacade navHandler,
            IColorTheme theme,
            IChangeNotification parentChangeNotification,
            Telemetry.ITelemetryCollector telemetryCollector
            )
        {
            this.hlFilters          = hlFilters;
            this.bookmarks          = bookmarks;
            this.view               = view;
            this.viewerPresenter    = viewerPresenter;
            this.navHandler         = navHandler;
            this.changeNotification = parentChangeNotification.CreateChainedChangeNotification(false);
            this.inlineSearch       = new InlineSearch.Presenter(changeNotification);

            inlineSearch.OnSearch += (s, e) =>
            {
                inlineSearchText = e.Query;
                if (e.Reverse)
                {
                    inlineSearchIndex--;
                }
                else
                {
                    inlineSearchIndex++;
                }
                changeNotification.Post();
            };

            this.getFocusedMessage = Selectors.Create(() => viewerPresenter.FocusedMessage,
                                                      message => message?.GetLogSource() == null ? null : message);
            var getBookmarkData = bookmarks == null ? () => (null, null) :
                                  Selectors.Create(getFocusedMessage, () => bookmarks.Items, (focused, bmks) =>
            {
                if (focused == null)
                {
                    return(noSelection, null);
                }
                var isBookmarked = IsMessageBookmarked(focused);
                return(isBookmarked ? "yes" : "no", isBookmarked ? "clear bookmark" : "set bookmark");
            });
Exemple #28
0
        public Presenter(
            IView view,
            IPluginsManagerInternal pluginsManager,
            IChangeNotification changeNotification,
            AutoUpdate.IAutoUpdater autoUpdater
            )
        {
            this.pluginsManager = pluginsManager;
            this.view           = view;
            this.autoUpdater    = autoUpdater;

            this.changeNotification = changeNotification.CreateChainedChangeNotification();
            this.fetchCancellation  = new CancellationTokenSource();

            this.pluginInstallationRequestsBuilder = pluginsManager.CreatePluginInstallationRequestsBuilder();

            this.listItemsSelector = Selectors.Create(
                () => pluginInstallationRequestsBuilder.InstallationRequests,
                () => pluginsInfo,
                () => selectedPlugin,
                (requests, all, selected) =>
            {
                return(ImmutableArray.CreateRange(all.Select(p => new ListItem(p, requests, selected?.Id))));
            }
                );

            this.selectedPluginDataSelector = Selectors.Create(
                listItemsSelector,
                list =>
            {
                var itemData = list.Select(i => i.MakeSelectedPluginData()).FirstOrDefault(i => i != null);
                return(itemData ?? new SelectedPluginData
                {
                    actionCaption = "Install",
                    actionEnabled = false,
                    caption = "",
                    description = ""
                });
            }
                );

            view.SetViewModel(this);

            this.FetchPlugins();
        }
Exemple #29
0
 public void BeforeEach()
 {
     model      = Substitute.For <IPostprocessorTags>();
     view       = Substitute.For <IView>();
     dialogView = Substitute.For <IDialogView>();
     alerts     = Substitute.For <IAlertPopup>();
     view.When(v => v.SetViewModel(Arg.Any <IViewModel>())).Do(x => viewModel = x.Arg <IViewModel>());
     view.CreateDialog(Arg.Do <IDialogViewModel>(x => dialogViewModel         = x), Arg.Any <IEnumerable <string> >(), Arg.Any <string>()).Returns(dialogView);
     changeNotification = Substitute.For <IChangeNotification>();
     model.AvailableTags.Returns(ImmutableHashSet.Create(new[] { "foo", "bar", "item-1", "item-2", "abd", "abc" }));
     model.TagsPredicate.Returns(TagsPredicate.Parse("bar OR item-1 AND NOT abc"));
     presenter = new TagsListPresenter(
         model,
         view,
         changeNotification,
         alerts
         );
 }
        public Presenter(IView view, IChangeNotification changeNotification)
        {
            this.view = view;
            this.changeNotification = changeNotification;

            this.viewListItems = Selectors.Create(
                () => suggestions,
                () => selectedSuggestion,
                () => suggestionsListVisible,
                (presentationObjects, selected, visible) =>
            {
                return(visible ?
                       (IReadOnlyList <ISuggestionsListItem>)presentationObjects.Select((obj, idx) => new SuggestionsViewListItem(obj, idx == selected)).ToImmutableArray()
                                                : ImmutableList <ISuggestionsListItem> .Empty);
            }
                );

            view?.SetViewModel(this);
        }
Exemple #31
0
 public RoomHotspot(IChangeNotification changeNotifier)
 {
     _notifyOfModification = changeNotifier;
 }
 private void HookChangeNotification(IChangeNotification element)
 {
     if (element != null)
     {
         // Unhook first to avoid double-hooking if the same
         // element is passed twice.
         element.Changed -= ChildChanged;
         element.Changed += ChildChanged;
     }
 }
 private void UnHookChangeNotification(IChangeNotification element)
 {
     if (element != null)
     {
         element.Changed -= ChildChanged;
     }
 }