Exemplo n.º 1
0
 public TimeSpreadCalculator(LogWindow logWindow)
 {
     _logWindow  = logWindow;
     _callback   = new ColumnizerCallback(_logWindow);
     _calcThread = new Thread(new ThreadStart(WorkerFx));
     _calcThread.IsBackground = true;
     _calcThread.Name         = "TimeSpreadCalculator Worker";
     _calcThread.Priority     = ThreadPriority.BelowNormal;
     _calcThread.Start();
 }
Exemplo n.º 2
0
        public LogWindow(LogTabWindow parent, string fileName, bool isTempFile,
                         bool forcePersistenceLoading)
        {
            SuspendLayout();

            InitializeComponent();

            columnNamesLabel.Text = ""; // no filtering on columns by default

            parentLogTabWin = parent;
            IsTempFile      = isTempFile;
            //Thread.CurrentThread.Name = "LogWindowThread";
            ColumnizerCallbackObject = new ColumnizerCallback(this);

            FileName = fileName;
            ForcePersistenceLoading = forcePersistenceLoading;

            dataGridView.CellValueNeeded += dataGridView_CellValueNeeded;
            dataGridView.CellPainting    += dataGridView_CellPainting;

            filterGridView.CellValueNeeded += filterGridView_CellValueNeeded;
            filterGridView.CellPainting    += filterGridView_CellPainting;

            Closing  += LogWindow_Closing;
            Disposed += LogWindow_Disposed;

            timeSpreadCalc = new TimeSpreadCalculator(this);
            timeSpreadingControl1.TimeSpreadCalc       = timeSpreadCalc;
            timeSpreadingControl1.LineSelected        += timeSpreadingControl1_LineSelected;
            tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute;
            tableLayoutPanel1.ColumnStyles[1].Width    = 20;
            tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent;
            tableLayoutPanel1.ColumnStyles[0].Width    = 100;

            parentLogTabWin.HighlightSettingsChanged += parent_HighlightSettingsChanged;

            SetColumnizer(PluginRegistry.GetInstance().RegisteredColumnizers[0]);

            patternArgs.maxMisses      = 5;
            patternArgs.minWeight      = 1;
            patternArgs.maxDiffInBlock = 5;
            patternArgs.fuzzy          = 5;

            //InitPatternWindow();

            //this.toolwinTabControl.TabPages.Add(this.patternWindow);
            //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow);

            filterParams = new FilterParams();
            foreach (string item in ConfigManager.Settings.filterHistoryList)
            {
                filterComboBox.Items.Add(item);
            }

            filterComboBox.DropDownHeight = filterComboBox.ItemHeight * ConfigManager.Settings.preferences.maximumFilterEntriesDisplayed;

            filterRegexCheckBox.Checked         = filterParams.isRegex;
            filterCaseSensitiveCheckBox.Checked = filterParams.isCaseSensitive;
            filterTailCheckBox.Checked          = filterParams.isFilterTail;

            splitContainer1.Panel2Collapsed = true;
            advancedFilterSplitContainer.SplitterDistance = FILTER_ADCANCED_SPLITTER_DISTANCE;

            timeshiftSyncThread = new Thread(SyncTimestampDisplayWorker);
            timeshiftSyncThread.IsBackground = true;
            timeshiftSyncThread.Start();

            logEventHandlerThread = new Thread(LogEventWorker);
            logEventHandlerThread.IsBackground = true;
            logEventHandlerThread.Start();

            //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker));
            //this.filterUpdateThread.Start();

            advancedButtonImage      = advancedButton.Image;
            searchButtonImage        = filterSearchButton.Image;
            filterSearchButton.Image = null;

            dataGridView.EditModeMenuStrip        = editModeContextMenuStrip;
            markEditModeToolStripMenuItem.Enabled = true;

            panelOpenButtonImage  = new Bitmap(GetType(), "Resources.PanelOpen.gif");
            panelCloseButtonImage = new Bitmap(GetType(), "Resources.PanelClose.gif");

            Settings settings = ConfigManager.Settings;

            if (settings.appBounds != null && settings.appBounds.Right > 0)
            {
                Bounds = settings.appBounds;
            }

            waitingForClose      = false;
            dataGridView.Enabled = false;
            dataGridView.ColumnDividerDoubleClick += dataGridView_ColumnDividerDoubleClick;
            ShowAdvancedFilterPanel(false);
            filterKnobControl1.MinValue      = 0;
            filterKnobControl1.MaxValue      = SPREAD_MAX;
            filterKnobControl1.ValueChanged += filterKnobControl1_ValueChanged;
            filterKnobControl2.MinValue      = 0;
            filterKnobControl2.MaxValue      = SPREAD_MAX;
            filterKnobControl2.ValueChanged += filterKnobControl1_ValueChanged;
            fuzzyKnobControl.MinValue        = 0;
            fuzzyKnobControl.MaxValue        = 10;
            //PreferencesChanged(settings.preferences, true);
            AdjustHighlightSplitterWidth();
            ToggleHighlightPanel(false); // hidden

            bookmarkProvider.BookmarkAdded       += bookmarkProvider_BookmarkAdded;
            bookmarkProvider.BookmarkRemoved     += bookmarkProvider_BookmarkRemoved;
            bookmarkProvider.AllBookmarksRemoved += bookmarkProvider_AllBookmarksRemoved;

            ResumeLayout();

            statusLineTrigger.Signal       += statusLineTrigger_Signal;
            selectionChangedTrigger.Signal += selectionChangedTrigger_Signal;

            PreferencesChanged(parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors);
        }
Exemplo n.º 3
0
 void MarkCurrentFilterRange()
 {
     _filterParams.rangeSearchText = filterRangeComboBox.Text;
     ColumnizerCallback callback = new ColumnizerCallback(this);
     RangeFinder rangeFinder = new RangeFinder(_filterParams, callback);
     Range range = rangeFinder.FindRange(dataGridView.CurrentCellAddress.Y);
     if (range != null)
     {
         SetCellSelectionMode(false);
         _noSelectionUpdates = true;
         for (int i = range.StartLine; i <= range.EndLine; ++i)
         {
             dataGridView.Rows[i].Selected = true;
         }
         _noSelectionUpdates = false;
         UpdateSelectionDisplay();
     }
 }
Exemplo n.º 4
0
        void ProcessFilterPipes(int lineNum)
        {
            string searchLine = CurrentLogFileReader.GetLogLine(lineNum);
            if (searchLine == null)
            {
                return;
            }

            ColumnizerCallback callback = new ColumnizerCallback(this);
            callback.LineNum = lineNum;
            IList<FilterPipe> deleteList = new List<FilterPipe>();
            lock (_filterPipeList)
            {
                foreach (FilterPipe pipe in _filterPipeList)
                {
                    if (pipe.IsStopped)
                    {
                        continue;
                    }
                    if (Classes.DamerauLevenshtein.TestFilterCondition(pipe.FilterParams, searchLine, callback))
                    {
                        IList<int> filterResult = GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList);
                        pipe.OpenFile();
                        foreach (int line in filterResult)
                        {
                            pipe.LastLinesHistoryList.Add(line);
                            if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2)
                            {
                                pipe.LastLinesHistoryList.RemoveAt(0);
                            }

                            string textLine = CurrentLogFileReader.GetLogLine(line);
                            bool fileOk = pipe.WriteToPipe(textLine, line);
                            if (!fileOk)
                            {
                                deleteList.Add(pipe);
                            }
                        }
                        pipe.CloseFile();
                    }
                }
            }
            foreach (FilterPipe pipe in deleteList)
            {
                _filterPipeList.Remove(pipe);
            }
        }
Exemplo n.º 5
0
        void Filter(FilterParams filterParams, List<int> filterResultLines, List<int> lastFilterLinesList, List<int> filterHitList)
        {
            long startTime = Environment.TickCount;
            try
            {
                filterParams.Reset();
                int lineNum = 0;
                ColumnizerCallback callback = new ColumnizerCallback(this);
                while (true)
                {
                    string line = CurrentLogFileReader.GetLogLine(lineNum);
                    if (line == null)
                    {
                        break;
                    }
                    callback.LineNum = lineNum;
                    if (Classes.DamerauLevenshtein.TestFilterCondition(filterParams, line, callback))
                    {
                        AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, filterHitList);
                    }
                    lineNum++;
                    if (lineNum % PROGRESS_BAR_MODULO == 0)
                    {
                        UpdateProgressBar(lineNum);
                    }
                    if (_shouldCancel)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.logError("Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace);
                MessageBox.Show(null, "Exception while filtering. Please report to developer: \n\n" + ex + "\n\n" + ex.StackTrace, "LogExpert");
            }
            long endTime = Environment.TickCount;
#if DEBUG
            Logger.logInfo("Single threaded filter duration: " + ((endTime - startTime)) + " ms.");
#endif
            StatusLineText("Filter duration: " + ((endTime - startTime)) + " ms.");
        }
Exemplo n.º 6
0
        void MultiThreadedFilter(FilterParams filterParams, List<int> filterResultLines, List<int> lastFilterLinesList, List<int> filterHitList)
        {
            ColumnizerCallback callback = new ColumnizerCallback(this);
            FilterStarter fs = new FilterStarter(callback, Environment.ProcessorCount + 2);
            fs.FilterHitList = _filterHitList;
            fs.FilterResultLines = _filterResultList;
            fs.LastFilterLinesList = _lastFilterLinesList;
            BackgroundProcessCancelHandler cancelHandler = new FilterCancelHandler(fs);
            RegisterCancelHandler(cancelHandler);
            long startTime = Environment.TickCount;

            fs.DoFilter(filterParams, 0, CurrentLogFileReader.LineCount, FilterProgressCallback);

            long endTime = Environment.TickCount;
#if DEBUG
            Logger.logInfo("Multi threaded filter duration: " + ((endTime - startTime)) + " ms.");
#endif
            DeRegisterCancelHandler(cancelHandler);
            StatusLineText("Filter duration: " + ((endTime - startTime)) + " ms.");
        }
Exemplo n.º 7
0
        protected void CheckFilterAndHighlight(LogEventArgs e)
        {
            bool noLed = true;
            bool suppressLed = false;
            bool setBookmark = false;
            bool stopTail = false;
            string bookmarkComment = null;
            if (filterTailCheckBox.Checked || _filterPipeList.Count > 0)
            {
                int filterStart = e.PrevLineCount;
                if (e.IsRollover)
                {
                    ShiftFilterLines(e.RolloverOffset);
                    filterStart -= e.RolloverOffset;
                }
                bool firstStopTail = true;
                ColumnizerCallback callback = new ColumnizerCallback(this);
                bool filterLineAdded = false;
                for (int i = filterStart; i < e.LineCount; ++i)
                {
                    string line = CurrentLogFileReader.GetLogLine(i);
                    if (line == null)
                    {
                        return;
                    }
                    if (filterTailCheckBox.Checked)
                    {
                        callback.LineNum = i;
                        if (Classes.DamerauLevenshtein.TestFilterCondition(_filterParams, line, callback))
                        {
                            filterLineAdded = true;
                            AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, _filterHitList);
                        }
                    }
                    ProcessFilterPipes(i);

                    IList<HilightEntry> matchingList = FindMatchingHilightEntries(line);
                    LaunchHighlightPlugins(matchingList, i);
                    GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment);
                    if (setBookmark)
                    {
                        Action<int, string> fx = new Action<int, string>(SetBookmarkFromTrigger);
                        fx.BeginInvoke(i, bookmarkComment, null, null);
                    }
                    if (stopTail && _guiStateArgs.FollowTail)
                    {
                        bool wasFollow = _guiStateArgs.FollowTail;
                        FollowTailChanged(false, true);
                        if (firstStopTail && wasFollow)
                        {
                            Invoke(new Action<int, bool>(SelectAndEnsureVisible), new object[] { i, false });
                            firstStopTail = false;
                        }
                    }
                    if (!suppressLed)
                    {
                        noLed = false;
                    }
                }
                if (filterLineAdded)
                {
                    TriggerFilterLineGuiUpdate();
                }
            }
            else
            {
                bool firstStopTail = true;
                int startLine = e.PrevLineCount;
                if (e.IsRollover)
                {
                    ShiftFilterLines(e.RolloverOffset);
                    startLine -= e.RolloverOffset;
                }
                for (int i = startLine; i < e.LineCount; ++i)
                {
                    string line = CurrentLogFileReader.GetLogLine(i);
                    if (line != null)
                    {
                        IList<HilightEntry> matchingList = FindMatchingHilightEntries(line);
                        LaunchHighlightPlugins(matchingList, i);
                        GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment);
                        if (setBookmark)
                        {
                            Action<int, string> fx = new Action<int, string>(SetBookmarkFromTrigger);
                            fx.BeginInvoke(i, bookmarkComment, null, null);
                        }
                        if (stopTail && _guiStateArgs.FollowTail)
                        {
                            bool wasFollow = _guiStateArgs.FollowTail;
                            FollowTailChanged(false, true);
                            if (firstStopTail && wasFollow)
                            {
                                Invoke(new Action<int, bool>(SelectAndEnsureVisible), new object[] { i, false });
                                firstStopTail = false;
                            }
                        }
                        if (!suppressLed)
                        {
                            noLed = false;
                        }
                    }
                }
            }
            if (!noLed)
            {
                OnFileSizeChanged(e);
            }
        }
Exemplo n.º 8
0
        public LogWindow(LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading)
        {
            _logEventHandlerThread = new Thread(new ThreadStart(LogEventWorker));
            _logEventHandlerThread.IsBackground = true;
            _logEventHandlerThread.Start();

            BookmarkProvider = new BookmarkDataProvider();

            BookmarkColor = Color.FromArgb(165, 200, 225);
            TempTitleName = "";
            SuspendLayout();

            InitializeComponent();

            columnNamesLabel.Text = ""; // no filtering on columns by default

            _parentLogTabWin = parent;
            IsTempFile = isTempFile;
            ColumnizerCallbackObject = new ColumnizerCallback(this);

            FileName = fileName;
            ForcePersistenceLoading = forcePersistenceLoading;

            selectedDataGridView.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            selectedDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
            selectedDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

            selectedDataGridView.SelectionChanged += selectedDataGridView_SelectionChanged;

            dataGridView.CellValueNeeded += DataGridView_CellValueNeeded;
            dataGridView.CellPainting += DataGridView_CellPainting;
            dataGridView.SelectionChanged += DataGridView_NewSelectionChanged;
            dataGridView.DoubleClick += DataGridView_DoubleClick;

            filterGridView.CellValueNeeded += FilterGridView_CellValueNeeded;
            filterGridView.CellPainting += FilterGridView_CellPainting;

            Closing += LogWindow_Closing;
            Disposed += LogWindow_Disposed;

            _timeSpreadCalc = new TimeSpreadCalculator(this);
            timeSpreadingControl1.TimeSpreadCalc = _timeSpreadCalc;
            timeSpreadingControl1.LineSelected += TimeSpreadingControl1_LineSelected;
            tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute;
            tableLayoutPanel1.ColumnStyles[1].Width = 20;
            tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent;
            tableLayoutPanel1.ColumnStyles[0].Width = 100;

            _parentLogTabWin.HighlightSettingsChanged += Parent_HighlightSettingsChanged;

            SetColumnizer(PluginRegistry.GetInstance().RegisteredColumnizers[0]);

            _patternArgs.maxMisses = 5;
            _patternArgs.minWeight = 1;
            _patternArgs.maxDiffInBlock = 5;
            _patternArgs.fuzzy = 5;

            _filterParams = new FilterParams();
            foreach (string item in ConfigManager.Settings.filterHistoryList)
            {
                filterComboBox.Items.Add(item);
            }
            filterRegexCheckBox.Checked = _filterParams.isRegex;
            filterCaseSensitiveCheckBox.Checked = _filterParams.isCaseSensitive;
            filterTailCheckBox.Checked = _filterParams.isFilterTail;

            splitContainer1.Panel2Collapsed = true;
            advancedFilterSplitContainer.SplitterDistance = FILTER_ADCANCED_SPLITTER_DISTANCE;

            _timeshiftSyncThread = new Thread(SyncTimestampDisplayWorker);
            _timeshiftSyncThread.IsBackground = true;
            _timeshiftSyncThread.Start();

            _advancedButtonImage = advancedButton.Image;
            _searchButtonImage = filterSearchButton.Image;
            filterSearchButton.Image = null;

            dataGridView.EditModeMenuStrip = editModeContextMenuStrip;
            markEditModeToolStripMenuItem.Enabled = true;


            _panelOpenButtonImage = new Bitmap(GetType(), "Resources.PanelOpen.gif");
            _panelCloseButtonImage = new Bitmap(GetType(), "Resources.PanelClose.gif");

            Settings settings = ConfigManager.Settings;
            if (settings.appBounds != null && settings.appBounds.Right > 0)
            {
                Bounds = settings.appBounds;
            }

            _waitingForClose = false;
            dataGridView.Enabled = false;
            dataGridView.ColumnDividerDoubleClick += DataGridView_ColumnDividerDoubleClick;
            ShowAdvancedFilterPanel(false);
            filterKnobControl1.MinValue = 0;
            filterKnobControl1.MaxValue = SPREAD_MAX;
            filterKnobControl1.ValueChanged += FilterKnobControl1_CheckForFilterDirty;
            filterKnobControl2.MinValue = 0;
            filterKnobControl2.MaxValue = SPREAD_MAX;
            filterKnobControl2.ValueChanged += FilterKnobControl1_CheckForFilterDirty;
            fuzzyKnobControl.MinValue = 0;
            fuzzyKnobControl.MaxValue = 10;
            ToggleHighlightPanel(false); // hidden

            BookmarkProvider.BookmarkAdded += BookmarkProvider_BookmarkAdded;
            BookmarkProvider.BookmarkRemoved += BookmarkProvider_BookmarkRemoved;

            ResumeLayout();

            _statusLineTrigger.Signal += StatusLineTrigger_Signal;
            _selectionChangedTrigger.Signal += SelectionChangedTrigger_Signal;

            PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors);
        }
Exemplo n.º 9
0
 private ColumnizerCallback(ColumnizerCallback original)
 {
     this.logWindow = original.logWindow;
     this.LineNum   = original.LineNum;
 }
Exemplo n.º 10
0
 private ColumnizerCallback(ColumnizerCallback original)
 {
     _logWindow = original._logWindow;
     LineNum    = original.LineNum;
 }
Exemplo n.º 11
0
		public TimeSpreadCalculator(LogWindow logWindow)
		{
			_logWindow = logWindow;
			_callback = new ColumnizerCallback(_logWindow);
			_calcThread = new Thread(new ThreadStart(WorkerFx));
			_calcThread.IsBackground = true;
			_calcThread.Name = "TimeSpreadCalculator Worker";
			_calcThread.Priority = ThreadPriority.BelowNormal;
			_calcThread.Start();
		}
Exemplo n.º 12
0
		private ColumnizerCallback(ColumnizerCallback original)
		{
			_logWindow = original._logWindow;
			LineNum = original.LineNum;
		}