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;
 }
        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);
                    }
                }
            };
        }
        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
        bool IPresenter.Open(IUserDefinedSearch search)
        {
            IFiltersList tempList  = search.Filters.Clone();
            bool         confirmed = false;

            using (dialogView = view.CreateDialog(this))
                using (var filtersManagerPresenter = filtersManagerFactory(tempList, dialogView))
                {
                    dialogView.SetData(new DialogData()
                    {
                        Name = search.Name
                    });
                    confirm = () =>
                    {
                        string name = dialogView.GetData().Name;
                        if (string.IsNullOrWhiteSpace(name))
                        {
                            alerts.ShowPopup(
                                alertsCaption,
                                "Bad filter name.",
                                AlertFlags.Ok
                                );
                            return(false);
                        }
                        if (name != search.Name && userDefinedSearches.ContainsItem(name))
                        {
                            alerts.ShowPopup(
                                alertsCaption,
                                string.Format("Name '{0}' is already used by another filter. Enter another name.", name),
                                AlertFlags.Ok
                                );
                            return(false);
                        }
                        if (tempList.Items.Count == 0)
                        {
                            alerts.ShowPopup(
                                alertsCaption,
                                "Can not save: filter must have at least one rule.",
                                AlertFlags.Ok
                                );
                            return(false);
                        }
                        confirmed = true;
                        return(confirmed);
                    };
                    dialogView.OpenModal();
                    confirm = null;
                    if (confirmed)
                    {
                        search.Name    = dialogView.GetData().Name;
                        search.Filters = tempList;
                    }
                    else
                    {
                        tempList.Dispose();
                    }
                }
            dialogView = null;
            return(confirmed);
        }
Ejemplo n.º 5
0
        public FiltersManager(
            IFiltersFactory filtersFactory,
            Settings.IGlobalSettingsAccessor globalSettingsAccessor,
            ILogSourcesManager logSourcesManager,
            IAdjustingColorsGenerator threadColors,
            IShutdown shutdown
            )
        {
            this.globalSettings = globalSettingsAccessor;
            this.logSources     = logSourcesManager;

            this.highlightFilters = filtersFactory.CreateFiltersList(FilterAction.Exclude, FiltersListPurpose.Highlighting);

            this.globalSettings.Changed += (sender, args) =>
            {
                if ((args.ChangedPieces & Settings.SettingsPiece.Appearance) != 0)
                {
                    threadColors.Brightness = globalSettings.Appearance.ColoringBrightness;
                }
            };

            this.logSources.OnLogSourceRemoved += (s, e) =>
            {
                highlightFilters.PurgeDisposedFiltersAndFiltersHavingDisposedThreads();
            };

            shutdown.Cleanup += (sender, args) =>
            {
                highlightFilters.Dispose();
            };
        }
Ejemplo n.º 6
0
        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.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");
            });
Ejemplo n.º 7
0
 void IFilter.SetOwner(IFiltersList newOwner)
 {
     CheckDisposed();
     if (newOwner != null && owner != null)
     {
         throw new InvalidOperationException("Filter can not be attached to FiltersList: already attached to another list");
     }
     owner = newOwner;
 }
Ejemplo n.º 8
0
		public UserDefinedSearch(
			IUserDefinedSearchesInternal owner,
			string name,
			IFiltersList filtersList
		)
		{
			this.owner = owner;
			this.name = name;
			this.filters = filtersList;
		}
Ejemplo n.º 9
0
 public HighlightFiltersHandler(IFiltersList filters, bool matchRawMessages)
 {
     this.filters = filters
                    .Items
                    .Where(f => f.Enabled)
                    .Select(f => new KeyValuePair <IFilterBulkProcessing, IFilter>(
                                f.StartBulkProcessing(matchRawMessages, false), f
                                ))
                    .ToArray();
 }
Ejemplo n.º 10
0
 public HighlightingManager(
     ISearchResultModel searchResultModel,
     IPresentationDataAccess presentationDataAccess,
     IFiltersList highlightFilters
     )
 {
     this.searchResultModel      = searchResultModel;
     this.presentationDataAccess = presentationDataAccess;
     this.highlightFilters       = highlightFilters;
 }
Ejemplo n.º 11
0
        public static List <IFilter> GetPositiveFilters(this IFiltersList filters)
        {
            var positiveFilters = filters.Items.Where(f => f.Enabled && f.Action != FilterAction.Exclude).ToList();

            if (filters.GetDefaultAction() != FilterAction.Exclude)
            {
                positiveFilters.Add(null);
            }
            return(positiveFilters);
        }
Ejemplo n.º 12
0
 public Presenter(
     IFiltersList filtersList,
     IView view,
     FilterDialog.IPresenter filtersDialogPresenter
     )
 {
     this.filtersList            = filtersList;
     this.view                   = view;
     this.filtersDialogPresenter = filtersDialogPresenter;
     view.SetPresenter(this);
 }
Ejemplo n.º 13
0
 public Presenter(
     ILogSourcesManager logSources,
     IFiltersList filtersList,
     IView view
     )
 {
     this.logSources     = logSources;
     this.view           = view;
     this.actionsOptions = MakeActionsOptions(filtersList.Purpose);
     this.scopeSupported = filtersList.Purpose == FiltersListPurpose.Highlighting;
     view.SetEventsHandler(this);
 }
Ejemplo n.º 14
0
 public Presenter(
     IFiltersList filtersList,
     IView view,
     FilterDialog.IPresenter filtersDialogPresenter,
     IColorTable highlightColorsTable
     )
 {
     this.filtersList            = filtersList;
     this.view                   = view;
     this.filtersDialogPresenter = filtersDialogPresenter;
     this.highlightColorsTable   = highlightColorsTable;
     view.SetPresenter(this);
 }
Ejemplo n.º 15
0
        public void BeforeEach()
        {
            searchResultModel = Substitute.For <ISearchResultModel>();
            highlightFilters  = Substitute.For <IFiltersList>();
            selectionManager  = Substitute.For <ISelectionManager>();
            messagesSource    = Substitute.For <IMessagesSource>();
            colorTheme        = Substitute.For <IColorTheme>();
            wordSelection     = new WordSelection(RegularExpressions.FCLRegexFactory.Instance);
            isRawMessagesMode = false;
            viewSize          = 3;
            highlightFilters.FilteringEnabled.Returns(true);
            colorTheme.HighlightingColors.Returns(ImmutableArray.CreateRange(Enumerable.Range(
                                                                                 (int)FilterAction.IncludeAndColorizeFirst, FilterAction.IncludeAndColorizeLast - FilterAction.IncludeAndColorizeFirst + 1)
                                                                             .Select(i => MakeHightlightingColor((FilterAction)i))
                                                                             ));
            msg1 = new Message(0, 1, null, new MessageTimestamp(), new StringSlice("test message 1"), SeverityFlag.Info);
            msg2 = new Message(0, 1, null, new MessageTimestamp(), new StringSlice("test message 2"), SeverityFlag.Info);
            msgWithMultilineText = new Message(0, 1, null, new MessageTimestamp(), new StringSlice(
                                                   @"2019/03/27 06:27:52.143 T#1 I app: model creation finished
import { imock, instance, when, anything, verify, resetCalls, MockPropertyPolicy, deepEqual } from 'ts-mockito';
import * as expect from 'expect';
import { Map, OrderedSet } from 'immutable';
import { ChangeNotification } from '../../../../client/model/utils';
import { PodStore, Pod } from '../../../../client/model/pod/store';
import { MeetingSession } from '../../../../client/model/meeting/impl/meeting/meetingSession';
import { Meeting, MeetingParticipant, LocalMeetingParticipant } from '../../../../client/model/meeting';
import { Conversation, ConversationStore, StreamId } from '../../../../client/model/conversation/store';
import { MeetingStartupOptions, Meeting as MeetingBase, MediaDevices, ParticipantTracks, ScreenTrack } from '../../../../client/model/meeting';
import { Protocol } from '../../../../client/model/meeting/protocol';
import { MeetingImpl } from '../../../../client/model/meeting/impl/meeting/impl/meetingImpl';
import { RtcManager, RtcManagerConfig } from '../../../../client/model/rtcManager';
import { MeetingAnalytics, LeaveSources } from '../../../../client/model/analytics';
import { MeetingParticipants } from '../../../../client/model/meeting/impl/meeting/meetingParticipants';
import { UncaughtExceptionsTrap } from '../../../utils/uncaughtExceptionsTrap';
import { AutoResetEvent, waiter } from '../../../utils/promise-utils';
import { MeetingLocalMedia } from '../../../../client/model/meeting/impl/media/meetingLocalMedia';
import { MeetingRemoteMedia } from '../../../../client/model/meeting/impl/media/meetingRemoteMedia';
import { LolexClock, install } from 'lolex';
import { RtcTokenProvider } from '../../../../client/model/meeting/impl/protocol/impl/rtcTokenProviderImpl';
import { User, UserStore, CurrentUser, UserId } from '../../../../client/model/users/store';
import { fireAndForget } from '../../../utils/promise-utils';
import { RtcSettingsStore, RtcSettings } from '../../../../client/model/settings/store';
import { GeoRouter } from '../../../../client/model/georouting/geoRouter';
import { UserBackend } from '../../../../client/model/users/backend';

describe('MeetingV2', () => {
    let meeting: Meeting;"
                                                   ), SeverityFlag.Info);
        }
Ejemplo n.º 16
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(
            IFiltersList filtersList,
            IView view,
            FiltersListBox.IPresenter filtersListPresenter,
            FilterDialog.IPresenter filtersDialogPresenter,
            LogViewer.IPresenter logViewerPresenter,
            IViewUpdates viewUpdates,
            IHeartBeatTimer heartbeat,
            IFiltersFactory filtersFactory,
            IAlertPopup alerts
            )
        {
            this.filtersList            = filtersList;
            this.view                   = view;
            this.heartbeat              = heartbeat;
            this.filtersListPresenter   = filtersListPresenter;
            this.filtersDialogPresenter = filtersDialogPresenter;
            this.logViewerPresenter     = logViewerPresenter;
            this.viewUpdates            = viewUpdates;
            this.filtersFactory         = filtersFactory;
            this.alerts                 = alerts;

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

            UpdateControls();

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

            view.SetPresenter(this);

            updateTracker.Invalidate();
        }
Ejemplo n.º 18
0
        public HighlightingManager(
            ISearchResultModel searchResultModel,
            Func <MessageTextGetter> displayTextGetterSelector,
            Func <int> viewSizeSelector,
            IFiltersList highlightFilters,
            ISelectionManager selectionManager,
            IWordSelection wordSelection,
            IColorTheme theme,
            RegularExpressions.IRegexFactory regexFactory
            )
        {
            var viewSizeQuantizedSelector = Selectors.Create(
                viewSizeSelector,
                viewSize => (1 + (viewSize / 16)) * 16
                );

            this.getHighlightingHandler = Selectors.Create(
                () => (highlightFilters?.FilteringEnabled, highlightFilters?.Items, highlightFilters?.FiltersVersion),
                displayTextGetterSelector,
                viewSizeQuantizedSelector,
                () => theme.HighlightingColors,
                (filtersData, displayTextGetter, viewSize, hlColors) => filtersData.FilteringEnabled == true ?
                new CachingHighlightingHandler(msg => GetHlHighlightingRanges(msg, filtersData.Items, displayTextGetter, hlColors), ViewSizeToCacheSize(viewSize))
                                        : (IHighlightingHandler) new DummyHandler()
                );
            this.getSearchResultHandler = Selectors.Create(
                () => searchResultModel?.SearchFiltersList,
                displayTextGetterSelector,
                viewSizeQuantizedSelector,
                (filters, displayTextGetter, viewSize) => filters != null ?
                new CachingHighlightingHandler(msg => GetSearchResultsHighlightingRanges(msg, filters, displayTextGetter), ViewSizeToCacheSize(viewSize))
                                        : null
                );
            this.getSelectionHandler = Selectors.Create(
                () => selectionManager.Selection,
                displayTextGetterSelector,
                viewSizeQuantizedSelector,
                (selection, displayTextGetter, viewSize) =>
                MakeSelectionInplaceHighlightingHander(selection, displayTextGetter, wordSelection, ViewSizeToCacheSize(viewSize), regexFactory)
                );
        }
Ejemplo n.º 19
0
        public FiltersManager(
            IFiltersFactory filtersFactory,
            Settings.IGlobalSettingsAccessor globalSettingsAccessor,
            ILogSourcesManager logSourcesManager,
            IShutdown shutdown
            )
        {
            this.globalSettings = globalSettingsAccessor;
            this.logSources     = logSourcesManager;

            this.highlightFilters = filtersFactory.CreateFiltersList(FilterAction.Exclude, FiltersListPurpose.Highlighting);

            this.logSources.OnLogSourceRemoved += (s, e) =>
            {
                highlightFilters.PurgeDisposedFiltersAndFiltersHavingDisposedThreads();
            };

            shutdown.Cleanup += (sender, args) =>
            {
                highlightFilters.Dispose();
            };
        }
Ejemplo n.º 20
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.º 21
0
        private static IEnumerable <(int b, int e, Color a)> FindSearchMatches(
            IMessage msg, MessageTextGetter textGetter, IFiltersList filters,
            bool skipWholeLines)
        {
            IFiltersListBulkProcessing processing;

            try
            {
                processing = filters.StartBulkProcessing(textGetter, reverseMatchDirection: false);
            }
            catch (Search.TemplateException)
            {
                yield break;
            }
            using (processing)
            {
                for (int?startPos = null; ;)
                {
                    var rslt = processing.ProcessMessage(msg, startPos);
                    if (rslt.Action == FilterAction.Exclude || rslt.MatchedRange == null)
                    {
                        yield break;
                    }
                    var r = rslt.MatchedRange.Value;
                    if (skipWholeLines && r.WholeTextMatched)
                    {
                        yield break;
                    }
                    if (r.MatchBegin == r.MatchEnd)
                    {
                        yield break;
                    }
                    yield return(r.MatchBegin, r.MatchEnd, new Color());

                    startPos = r.MatchEnd;
                }
            }
        }
Ejemplo n.º 22
0
 private static IEnumerable <(int, int, Color)> GetSearchResultsHighlightingRanges(
     IMessage msg, IFiltersList filters, MessageTextGetter displayTextGetter)
 {
     return(FindSearchMatches(msg, displayTextGetter, filters, skipWholeLines: true));
 }
Ejemplo n.º 23
0
 public SearchResultHandler(IFiltersList filters, bool matchRawMessages)
 {
     this.filter     = filters;
     this.processing = filters.StartBulkProcessing(matchRawMessages, reverseMatchDirection: false);
 }
Ejemplo n.º 24
0
        void IPresenter.UpdateView()
        {
            updateLock++;
            view.BeginUpdate();
            try
            {
                IFiltersList filters       = filtersList;
                IViewItem    defActionItem = null;
                for (int i = view.Count - 1; i >= 0; --i)
                {
                    IFilter ls = view.GetItem(i).Filter;
                    if (ls == null)
                    {
                        defActionItem = view.GetItem(i);
                    }
                    else if (ls.Owner == null)
                    {
                        view.RemoveAt(i);
                    }
                }
                int filterIdx = 0;
                foreach (var f in filters.Items)
                {
                    IViewItem lvi;
                    int       existingItemIdx = view.GetItemIndexByKey(f.GetHashCode().ToString());
                    if (existingItemIdx < 0)
                    {
                        lvi = view.CreateItem(f, f.GetHashCode().ToString());
                        view.Insert(filterIdx, lvi);
                    }
                    else
                    {
                        lvi = view.GetItem(existingItemIdx);
                        if (existingItemIdx != filterIdx)
                        {
                            view.RemoveAt(existingItemIdx);
                            view.Insert(filterIdx, lvi);
                        }
                    }
                    ++filterIdx;

                    if (!f.IsDisposed)
                    {
                        lvi.Text    = f.Name;
                        lvi.Color   = f.Action.ToColor(highlightColorsTable.Items);
                        lvi.Checked = f.Enabled;
                        if (f.Enabled)
                        {
                            lvi.CheckboxTooltip = "Uncheck to disable rule without deleting it";
                        }
                        else
                        {
                            lvi.CheckboxTooltip = "Check to enable rule";
                        }
                        lvi.SetImageType(f.Action == FilterAction.Exclude ? ViewItemImageType.Exclude : ViewItemImageType.Include);
                        if (filtersList.Purpose == FiltersListPurpose.Highlighting)
                        {
                            if (f.Action == FilterAction.Exclude)
                            {
                                lvi.ActionTooltip = "Rule excludes matched messages from highlighting";
                            }
                            else
                            {
                                lvi.ActionTooltip = string.Format(
                                    "Rule highlights matched messages with color #{0}",
                                    f.Action - FilterAction.IncludeAndColorizeFirst + 1);
                            }
                        }
                        else if (filtersList.Purpose == FiltersListPurpose.Search)
                        {
                            if (f.Action == FilterAction.Exclude)
                            {
                                lvi.ActionTooltip = "Rule excludes matched messages from search results";
                            }
                            else
                            {
                                lvi.ActionTooltip = string.Format(
                                    "Rule includes matched messages to search results" +
                                    (f.Action == FilterAction.Include
                                                                         ? "" : " and highlights them with color #{0}"),
                                    f.Action - FilterAction.IncludeAndColorizeFirst + 1);
                            }
                        }
                    }
                    else
                    {
                        lvi.Text            = "-";
                        lvi.Checked         = null;
                        lvi.CheckboxTooltip = "";
                        lvi.Color           = null;
                        lvi.SetImageType(ViewItemImageType.None);
                    }
                }

                if (filters.Items.Count == 0)
                {
                    if (defActionItem != null)
                    {
                        view.Remove(defActionItem);
                    }
                }
                else
                {
                    if (defActionItem == null)
                    {
                        defActionItem = view.CreateItem(null, "");
                        view.Insert(filterIdx, defActionItem);
                        defActionItem.Checked = null;
                    }
                    if (filters.GetDefaultAction() == FilterAction.Exclude)
                    {
                        if (filtersList.Purpose == FiltersListPurpose.Highlighting)
                        {
                            defActionItem.Text = "Don't hightlight by-default";
                        }
                        else if (filtersList.Purpose == FiltersListPurpose.Search)
                        {
                            defActionItem.Text = "Exclude from search results by-default";
                        }
                        else
                        {
                            defActionItem.Text = "Exclude all by-default";
                        }
                        defActionItem.SetImageType(ViewItemImageType.Exclude);
                    }
                    else
                    {
                        if (filtersList.Purpose == FiltersListPurpose.Highlighting)
                        {
                            defActionItem.Text = "Highlight all by-default";
                        }
                        else if (filtersList.Purpose == FiltersListPurpose.Search)
                        {
                            defActionItem.Text = "Include all to search results by-default";
                        }
                        else
                        {
                            defActionItem.Text = "Include all by-default";
                        }
                        defActionItem.SetImageType(ViewItemImageType.Include);
                    }
                }

                view.SetEnabled(filters.FilteringEnabled);
            }
            finally
            {
                updateLock--;
                view.EndUpdate();
            }
        }
Ejemplo n.º 25
0
        public Presenter(
            ISearchManager searchManager,
            IBookmarks bookmarks,
            IFiltersList hlFilters,
            IView view,
            IPresentersFacade navHandler,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IHeartBeatTimer heartbeat,
            ISynchronizationContext uiThreadSynchronization,
            StatusReports.IPresenter statusReports,
            LogViewer.IPresenterFactory logViewerPresenterFactory,
            IColorTheme theme,
            IChangeNotification changeNotification
            )
        {
            this.searchManager                    = searchManager;
            this.bookmarks                        = bookmarks;
            this.hlFilters                        = hlFilters;
            this.view                             = view;
            this.loadedMessagesPresenter          = loadedMessagesPresenter;
            this.statusReports                    = statusReports;
            this.theme                            = theme;
            this.changeNotification               = changeNotification;
            var(messagesPresenter, messagesModel) = logViewerPresenterFactory.CreateSearchResultsPresenter(
                view.MessagesView, loadedMessagesPresenter.LogViewerPresenter);
            this.messagesPresenter = messagesPresenter;
            this.messagesPresenter.FocusedMessageDisplayMode          = LogViewer.FocusedMessageDisplayModes.Slave;
            this.messagesPresenter.DblClickAction                     = Presenters.LogViewer.PreferredDblClickAction.DoDefaultAction;
            this.messagesPresenter.DefaultFocusedMessageActionCaption = "Go to message";
            this.messagesPresenter.DisabledUserInteractions           = LogViewer.UserInteraction.RawViewSwitching;
            this.messagesPresenter.DefaultFocusedMessageAction       += async(s, e) =>
            {
                if (messagesPresenter.FocusedMessage != null)
                {
                    if (await navHandler.ShowMessage(messagesPresenter.FocusedMessageBookmark,
                                                     BookmarkNavigationOptions.EnablePopups | BookmarkNavigationOptions.SearchResultStringsSet
                                                     ).IgnoreCancellation())
                    {
                        loadedMessagesPresenter.LogViewerPresenter.ReceiveInputFocus();
                    }
                }
            };
            this.hlFilters.OnPropertiesChanged += (sender, args) =>
            {
                if (args.ChangeAffectsFilterResult)
                {
                    lazyUpdateFlag.Invalidate();
                }
            };
            this.hlFilters.OnFiltersListChanged += (sender, args) =>
            {
                lazyUpdateFlag.Invalidate();
            };
            this.hlFilters.OnFilteringEnabledChanged += (sender, args) =>
            {
                lazyUpdateFlag.Invalidate();
            };
            this.searchManager.SearchResultChanged += (sender, e) =>
            {
                if ((e.Flags & SearchResultChangeFlag.HitCountChanged) != 0 ||
                    (e.Flags & SearchResultChangeFlag.ProgressChanged) != 0 ||
                    (e.Flags & SearchResultChangeFlag.PinnedChanged) != 0 ||
                    (e.Flags & SearchResultChangeFlag.VisibleChanged) != 0)
                {
                    lazyUpdateFlag.Invalidate();
                }
                if ((e.Flags & SearchResultChangeFlag.StatusChanged) != 0)
                {
                    lazyUpdateFlag.Invalidate();
                    uiThreadSynchronization.Post(ValidateView);
                    uiThreadSynchronization.Post(PostSearchActions);
                }
            };
            this.searchManager.CombinedSearchResultChanged += (sender, e) =>
            {
                uiThreadSynchronization.Post(() => messagesModel.RaiseSourcesChanged());
            };
            this.searchManager.SearchResultsChanged += (sender, e) =>
            {
                lazyUpdateFlag.Invalidate();
                messagesModel.RaiseSourcesChanged();
                uiThreadSynchronization.Post(ValidateView);
                uiThreadSynchronization.Post(PreSearchActions);
            };

            heartbeat.OnTimer += (sender, args) =>
            {
                if (args.IsNormalUpdate)
                {
                    ValidateView();
                }
            };

            view.SetViewModel(this);
            UpdateExpandedState();
        }
Ejemplo n.º 26
0
 public SearchAllOccurencesParams(IFiltersList filters, bool searchInRawText, long?fromPosition)
 {
     this.Filters         = filters;
     this.SearchInRawText = searchInRawText;
     this.FromPosition    = fromPosition;
 }
Ejemplo n.º 27
0
        MessageDisplayTextInfo IHighlightingManager.GetSearchResultMessageText(IMessage msg, MessageTextGetter originalTextGetter, IFiltersList filters)
        {
            var originalText        = originalTextGetter(msg);
            var retLines            = new List <StringSlice>();
            var retLinesMap         = new List <int>();
            int originalTextLineIdx = 0;

            foreach (var m in FindSearchMatches(msg, originalTextGetter, filters, skipWholeLines: false))
            {
                for (int stage = 0; originalTextLineIdx < originalText.GetLinesCount() && stage != 2; ++originalTextLineIdx)
                {
                    var line           = originalText.GetNthTextLine(originalTextLineIdx);
                    var lineBeginIndex = line.StartIndex - originalText.Text.StartIndex;
                    var lineEndIndex   = line.EndIndex - originalText.Text.StartIndex;
                    if (lineBeginIndex >= m.e)
                    {
                        break;
                    }
                    if (stage == 0 && lineEndIndex >= m.b)
                    {
                        stage = 1;
                    }
                    if (stage == 1 && lineEndIndex >= m.e)
                    {
                        stage = 2;
                    }
                    if (stage != 0)
                    {
                        retLines.Add(line);
                        retLinesMap.Add(originalTextLineIdx);
                    }
                }
            }
            if (originalTextLineIdx == 0)
            {
                retLines.Add(originalText.GetNthTextLine(0));
                retLinesMap.Add(originalTextLineIdx);
            }
            return(new MessageDisplayTextInfo()
            {
                DisplayText = new MultilineText(new StringSlice(string.Join("\n", retLines))),
                LinesMapper = i => retLinesMap.ElementAtOrDefault(i),
                ReverseLinesMapper = i =>
                {
                    int result = 0;
                    while (result < retLinesMap.Count && retLinesMap[result] < i)
                    {
                        ++result;
                    }
                    return result;
                }
            });
        }