コード例 #1
0
        public Presenter(
            ILogSourcesManager logSources,
            IView view,
            ILogSourcesPreprocessingManager logSourcesPreprocessings,
            SourcePropertiesWindow.IPresenter propertiesWindowPresenter,
            LogViewer.IPresenter logViewerPresenter,
            IPresentersFacade navHandler,
            IAlertPopup alerts,
            IFileDialogs fileDialogs,
            IClipboardAccess clipboard,
            IShellOpen shellOpen,
            SaveJointLogInteractionPresenter.IPresenter saveJointLogInteractionPresenter
            )
        {
            this.logSources = logSources;
            this.view       = view;
            this.propertiesWindowPresenter = propertiesWindowPresenter;
            this.logViewerPresenter        = logViewerPresenter;
            this.logSourcesPreprocessings  = logSourcesPreprocessings;
            this.alerts      = alerts;
            this.fileDialogs = fileDialogs;
            this.clipboard   = clipboard;
            this.shellOpen   = shellOpen;
            this.saveJointLogInteractionPresenter = saveJointLogInteractionPresenter;

            logViewerPresenter.FocusedMessageChanged += (sender, args) =>
            {
                view.InvalidateFocusedMessageArea();
            };

            view.SetPresenter(this);
        }
コード例 #2
0
        async void IPresenter.ReceiveInputFocusByShortcut(bool forceSearchAllOccurencesMode)
        {
            LogViewer.IPresenter focusedPresenter =
                loadedMessagesPresenter.LogViewerPresenter.HasInputFocus ? loadedMessagesPresenter.LogViewerPresenter :
                searchResultPresenter.LogViewerPresenter.HasInputFocus ? searchResultPresenter.LogViewerPresenter : null;

            string searchText = null;

            if (forceSearchAllOccurencesMode)
            {
                view.SetCheckableControlsState(ViewCheckableControl.SearchAllOccurences, ViewCheckableControl.SearchAllOccurences);
            }

            if (focusedPresenter != null && focusedPresenter.IsSinglelineNonEmptySelection)
            {
                var selectedText = await focusedPresenter.GetSelectedText();

                if (!string.IsNullOrEmpty(selectedText))
                {
                    searchText = selectedText;
                }
            }

            quickSearchPresenter.Focus(searchText);
            quickSearchPresenter.SelectAll();
        }
コード例 #3
0
        public Presenter(
            IBookmarks bookmarks,
            IFiltersList hlFilters,
            IView view,
            LogViewer.IPresenter viewerPresenter,
            IPresentersFacade navHandler)
        {
            this.hlFilters       = hlFilters;
            this.bookmarks       = bookmarks;
            this.view            = view;
            this.viewerPresenter = viewerPresenter;
            this.navHandler      = navHandler;

            viewerPresenter.FocusedMessageChanged += delegate(object sender, EventArgs args)
            {
                if (GetPropertiesForm() != null)
                {
                    GetPropertiesForm().UpdateView(viewerPresenter.FocusedMessage);
                }
            };
            bookmarks.OnBookmarksChanged += (sender, args) =>
            {
                var focused = viewerPresenter.FocusedMessage;
                if (GetPropertiesForm() != null && focused != null)
                {
                    if (args.AffectedBookmarks.Any(b => b.Position == focused.Position))
                    {
                        GetPropertiesForm().UpdateView(focused);
                    }
                }
            };
        }
コード例 #4
0
        public Presenter(
            IBookmarks bookmarks,
            IView view,
            LogViewer.IPresenter viewerPresenter,
            SearchResult.IPresenter searchResultPresenter,
            BookmarksList.IPresenter listPresenter,
            StatusReports.IPresenter statusReportFactory,
            IPresentersFacade navHandler,
            IAlertPopup alerts,
            ITraceSourceFactory traceSourceFactory
            )
        {
            this.bookmarks             = bookmarks;
            this.view                  = view;
            this.viewerPresenter       = viewerPresenter;
            this.tracer                = traceSourceFactory.CreateTraceSource("UI", "ui.bmkm");
            this.statusReportFactory   = statusReportFactory;
            this.searchResultPresenter = searchResultPresenter;
            this.navHandler            = navHandler;
            this.listPresenter         = listPresenter;
            this.alerts                = alerts;

            listPresenter.Click += (s, bmk) =>
            {
                IPresenter myPublicIntf = this;
                myPublicIntf.NavigateToBookmark(bmk, BookmarkNavigationOptions.EnablePopups | BookmarkNavigationOptions.BookmarksStringsSet);
            };

            view.SetPresenter(this);
        }
コード例 #5
0
        public Presenter(
            IBookmarks bookmarks,
            IView view,
            LogViewer.IPresenter viewerPresenter,
            SearchResult.IPresenter searchResultPresenter,
            BookmarksList.IPresenter listPresenter,
            StatusReports.IPresenter statusReportFactory,
            IPresentersFacade navHandler,
            IViewUpdates viewUpdates,
            IAlertPopup alerts)
        {
            this.bookmarks             = bookmarks;
            this.view                  = view;
            this.viewerPresenter       = viewerPresenter;
            this.tracer                = new LJTraceSource("UI", "ui.bmkm");
            this.statusReportFactory   = statusReportFactory;
            this.searchResultPresenter = searchResultPresenter;
            this.viewUpdates           = viewUpdates;
            this.navHandler            = navHandler;
            this.listPresenter         = listPresenter;
            this.alerts                = alerts;

            viewerPresenter.FocusedMessageBookmarkChanged += delegate(object sender, EventArgs args)
            {
                listPresenter.SetMasterFocusedMessage(viewerPresenter.GetFocusedMessageBookmark());
            };
            listPresenter.Click += (s, bmk) =>
            {
                IPresenter myPublicIntf = this;
                myPublicIntf.NavigateToBookmark(bmk, BookmarkNavigationOptions.EnablePopups | BookmarkNavigationOptions.BookmarksStringsSet);
            };

            view.SetPresenter(this);
        }
コード例 #6
0
        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");
            });
コード例 #7
0
        public Presenter(
            IFiltersList filtersList,
            IView view,
            FiltersListBox.IPresenter filtersListPresenter,
            FilterDialog.IPresenter filtersDialogPresenter,
            LogViewer.IPresenter logViewerPresenter,
            IViewUpdates viewUpdates,
            IHeartBeatTimer heartbeat,
            IFiltersFactory filtersFactory,
            IAlertPopup alerts
            )
        {
            this.filtersList            = filtersList;
            this.view                   = view;
            this.heartbeat              = heartbeat;
            this.filtersListPresenter   = filtersListPresenter;
            this.filtersDialogPresenter = filtersDialogPresenter;
            this.logViewerPresenter     = logViewerPresenter;
            this.viewUpdates            = viewUpdates;
            this.filtersFactory         = filtersFactory;
            this.alerts                 = alerts;

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

            UpdateControls();

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

            view.SetPresenter(this);

            updateTracker.Invalidate();
        }
コード例 #8
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;
        }
コード例 #9
0
ファイル: TestDialogPresenter.cs プロジェクト: cxsun/logjoint
        public Presenter(
            IView view,
            ITempFilesManager tempFilesManager,
            ITraceSourceFactory traceSourceFactory,
            LogViewer.IPresenterFactory logViewerPresenterFactory,
            ISynchronizationContext synchronizationContext
            )
        {
            this.view = view;
            this.view.SetEventsHandler(this);
            this.tempFilesManager       = tempFilesManager;
            this.traceSourceFactory     = traceSourceFactory;
            this.synchronizationContext = synchronizationContext;

            this.threads          = new ModelThreads();
            this.logSourceThreads = new LogSourceThreads(
                LJTraceSource.EmptyTracer, threads, null);
            this.model            = new Presenters.LogViewer.DummyModel();
            this.logPresenter     = logViewerPresenterFactory.CreateIsolatedPresenter(model, view.LogViewer);
            logPresenter.ShowTime = true;
        }
コード例 #10
0
        public Presenter(
            ILogSourcesManager logSources,
            IBookmarks bookmarks,
            IView view,
            IHeartBeatTimer heartbeat,
            LogViewer.IPresenterFactory logViewerPresenterFactory
            )
        {
            this.logSources        = logSources;
            this.bookmarks         = bookmarks;
            this.view              = view;
            this.messagesPresenter = logViewerPresenterFactory.Create(
                logViewerPresenterFactory.CreateLoadedMessagesModel(),
                view.MessagesView,
                createIsolatedPresenter: false
                );
            this.messagesPresenter.DblClickAction = Presenters.LogViewer.PreferredDblClickAction.SelectWord;
            this.UpdateRawViewButton();
            this.UpdateColoringControls();
            this.messagesPresenter.RawViewModeChanged            += (s, e) => UpdateRawViewButton();
            this.messagesPresenter.NavigationIsInProgressChanged += (s, e) =>
            { view.SetNavigationProgressIndicatorVisibility(messagesPresenter.NavigationIsInProgress); };
            this.messagesPresenter.ViewTailModeChanged += (s, e) => UpdateViewTailButton();

            heartbeat.OnTimer += (sender, args) =>
            {
                if (args.IsNormalUpdate && rawViewUpdateFlag.Validate())
                {
                    UpdateRawViewAvailability();
                    UpdateRawViewMode();
                    UpdateRawViewButton();
                }
                if (args.IsNormalUpdate && tailUpdateFlag.Validate())
                {
                    UpdateViewTailButton();
                }
            };
            logSources.OnLogSourceRemoved += (sender, evt) =>
            {
                if (logSources.Items.Count(s => !s.IsDisposed) == 0)
                {
                    automaticRawView = true;                     // reset automatic mode when last source is gone
                }
                rawViewUpdateFlag.Invalidate();
                tailUpdateFlag.Invalidate();
            };
            logSources.OnLogSourceAdded += (sender, evt) =>
            {
                rawViewUpdateFlag.Invalidate();
                tailUpdateFlag.Invalidate();
            };
            logSources.OnLogSourceVisiblityChanged += (sender, evt) =>
            {
                rawViewUpdateFlag.Invalidate();
                tailUpdateFlag.Invalidate();
            };


            this.view.SetEventsHandler(this);

            tailUpdateFlag.Invalidate();
            rawViewUpdateFlag.Invalidate();
        }
コード例 #11
0
ファイル: MainFormPresenter.cs プロジェクト: cxsun/logjoint
        public Presenter(
            ILogSourcesManager logSources,
            Preprocessing.IManager preprocessingsManager,
            IView view,
            LogViewer.IPresenter viewerPresenter,
            SearchResult.IPresenter searchResultPresenter,
            SearchPanel.IPresenter searchPanelPresenter,
            SourcesManager.IPresenter sourcesManagerPresenter,
            MessagePropertiesDialog.IPresenter messagePropertiesDialogPresenter,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            BookmarksManager.IPresenter bookmarksManagerPresenter,
            IHeartBeatTimer heartBeatTimer,
            ITabUsageTracker tabUsageTracker,
            StatusReports.IPresenter statusReportFactory,
            IDragDropHandler dragDropHandler,
            IPresentersFacade presentersFacade,
            IAutoUpdater autoUpdater,
            Progress.IProgressAggregator progressAggregator,
            IAlertPopup alerts,
            SharingDialog.IPresenter sharingDialogPresenter,
            IssueReportDialogPresenter.IPresenter issueReportDialogPresenter,
            IShutdownSource shutdown,
            IColorTheme theme,
            IChangeNotification changeNotification,
            ITraceSourceFactory traceSourceFactory
            )
        {
            this.tracer                = traceSourceFactory.CreateTraceSource("UI", "ui.main");
            this.logSources            = logSources;
            this.preprocessingsManager = preprocessingsManager;
            this.view                       = view;
            this.tabUsageTracker            = tabUsageTracker;
            this.searchPanelPresenter       = searchPanelPresenter;
            this.searchResultPresenter      = searchResultPresenter;
            this.bookmarksManagerPresenter  = bookmarksManagerPresenter;
            this.viewerPresenter            = viewerPresenter;
            this.presentersFacade           = presentersFacade;
            this.dragDropHandler            = dragDropHandler;
            this.heartBeatTimer             = heartBeatTimer;
            this.autoUpdater                = autoUpdater;
            this.progressAggregator         = progressAggregator;
            this.alerts                     = alerts;
            this.sharingDialogPresenter     = sharingDialogPresenter;
            this.issueReportDialogPresenter = issueReportDialogPresenter;
            this.shutdown                   = shutdown;
            this.statusRepors               = statusReportFactory;
            this.theme                      = theme;
            this.changeNotification         = changeNotification;

            view.SetPresenter(this);

            viewerPresenter.ManualRefresh += delegate(object sender, EventArgs args)
            {
                using (tracer.NewFrame)
                {
                    tracer.Info("----> User Command: Refresh");
                    logSources.Refresh();
                }
            };
            viewerPresenter.FocusedMessageBookmarkChanged += delegate(object sender, EventArgs args)
            {
                if (searchResultPresenter != null)
                {
                    searchResultPresenter.MasterFocusedMessage = viewerPresenter.FocusedMessageBookmark;
                }
            };
            if (messagePropertiesDialogPresenter != null)
            {
                viewerPresenter.DefaultFocusedMessageActionCaption = "Show properties...";
                viewerPresenter.DefaultFocusedMessageAction       += (s, e) =>
                {
                    messagePropertiesDialogPresenter.ShowDialog();
                };
            }

            if (searchResultPresenter != null)
            {
                searchResultPresenter.OnClose           += (sender, args) => searchPanelPresenter.CollapseSearchResultPanel();
                searchResultPresenter.OnResizingStarted += (sender, args) => view.BeginSplittingSearchResults();
            }

            sourcesManagerPresenter.OnBusyState += (_, evt) => SetWaitState(evt.BusyStateRequired);

            searchPanelPresenter.InputFocusAbandoned += delegate(object sender, EventArgs args)
            {
                loadedMessagesPresenter.LogViewerPresenter.ReceiveInputFocus();
            };
            loadedMessagesPresenter.OnResizingStarted += (s, e) => view.BeginSplittingTabsPanel();

            this.heartBeatTimer.OnTimer += (sender, e) =>
            {
                if (e.IsRareUpdate)
                {
                    SetAnalyzingIndication(logSources.Items.Any(s => s.TimeGaps.IsWorking));
                }
            };

            logSources.OnLogSourceAdded += (sender, evt) =>
            {
                UpdateFormCaption();
            };
            logSources.OnLogSourceRemoved += (sender, evt) =>
            {
                UpdateFormCaption();
            };

            if (autoUpdater != null)
            {
                autoUpdater.Changed += (sender, args) =>
                {
                    UpdateAutoUpdateIcon();
                };
            }

            progressAggregator.ProgressStarted += (sender, args) =>
            {
                view.SetTaskbarState(TaskbarState.Progress);
                UpdateFormCaption();
            };

            progressAggregator.ProgressEnded += (sender, args) =>
            {
                view.SetTaskbarState(TaskbarState.Idle);
                UpdateFormCaption();
            };

            progressAggregator.ProgressChanged += (sender, args) =>
            {
                view.UpdateTaskbarProgress(args.ProgressPercentage);
                UpdateFormCaption();
            };

            if (sharingDialogPresenter != null)
            {
                sharingDialogPresenter.AvailabilityChanged += (sender, args) =>
                {
                    UpdateShareButton();
                };
                sharingDialogPresenter.IsBusyChanged += (sender, args) =>
                {
                    UpdateShareButton();
                };
            }
            ;

            UpdateFormCaption();
            UpdateShareButton();

            view.SetIssueReportingMenuAvailablity(issueReportDialogPresenter.IsAvailable);
        }
コード例 #12
0
        public Presenter(
            ILogSourcesManager logSources,
            IView view,
            IManager logSourcesPreprocessings,
            SourcePropertiesWindow.IPresenter propertiesWindowPresenter,
            LogViewer.IPresenter logViewerPresenter,
            IAlertPopup alerts,
            IFileDialogs fileDialogs,
            IClipboardAccess clipboard,
            IShellOpen shellOpen,
            SaveJointLogInteractionPresenter.IPresenter saveJointLogInteractionPresenter,
            IColorTheme theme,
            IChangeNotification changeNotification,
            IHeartBeatTimer heartbeat
            )
        {
            this.logSources = logSources;
            this.view       = view;
            this.propertiesWindowPresenter = propertiesWindowPresenter;
            this.logSourcesPreprocessings  = logSourcesPreprocessings;
            this.alerts      = alerts;
            this.fileDialogs = fileDialogs;
            this.clipboard   = clipboard;
            this.shellOpen   = shellOpen;
            this.saveJointLogInteractionPresenter = saveJointLogInteractionPresenter;
            this.changeNotification = changeNotification;

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

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

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

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

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

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

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

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

            view.SetViewModel(this);
        }