/// <summary> /// This method implemented the "auto columnizer" feature. /// This method should be called after each columnizer is changed to update the columizer. /// </summary> /// <param name="fileName"></param> /// <param name="logFileReader"></param> /// <param name="logLineColumnizer"></param> /// <returns></returns> public static ILogLineColumnizer FindReplacementForAutoColumnizer(string fileName, IAutoLogLineColumnizerCallback logFileReader, ILogLineColumnizer logLineColumnizer) { if (logLineColumnizer == null || logLineColumnizer.GetName() == "Auto Columnizer") { return(FindColumnizer(fileName, logFileReader)); } return(logLineColumnizer); }
private void FillColumnizerList() { columnizerDataGridView.Rows.Clear(); DataGridViewComboBoxColumn comboColumn = (DataGridViewComboBoxColumn)columnizerDataGridView.Columns[1]; comboColumn.Items.Clear(); DataGridViewTextBoxColumn textColumn = (DataGridViewTextBoxColumn)columnizerDataGridView.Columns[0]; IList <ILogLineColumnizer> columnizers = PluginRegistry.GetInstance().RegisteredColumnizers; foreach (ILogLineColumnizer columnizer in columnizers) { int index = comboColumn.Items.Add(columnizer.GetName()); } //comboColumn.DisplayMember = "Name"; //comboColumn.ValueMember = "Columnizer"; foreach (ColumnizerMaskEntry maskEntry in Preferences.columnizerMaskList) { DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell()); DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); foreach (ILogLineColumnizer logColumnizer in columnizers) { int index = cell.Items.Add(logColumnizer.GetName()); } row.Cells.Add(cell); row.Cells[0].Value = maskEntry.mask; ILogLineColumnizer columnizer = Util.FindColumnizerByName(maskEntry.columnizerName, PluginRegistry.GetInstance().RegisteredColumnizers); if (columnizer == null) { columnizer = PluginRegistry.GetInstance().RegisteredColumnizers[0]; } row.Cells[1].Value = columnizer.GetName(); columnizerDataGridView.Rows.Add(row); } int count = columnizerDataGridView.RowCount; if (count > 0 && !columnizerDataGridView.Rows[count - 1].IsNewRow) { DataGridViewComboBoxCell comboCell = (DataGridViewComboBoxCell)columnizerDataGridView.Rows[count - 1].Cells[1]; comboCell.Value = comboCell.Items[0]; } }
void SetColumnizerInternal(ILogLineColumnizer columnizer) { Logger.logInfo("SetColumnizerInternal(): " + columnizer.GetName()); ILogLineColumnizer oldColumnizer = CurrentColumnizer; bool oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer; bool oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer; bool mustReload = false; // Check if the filtered columns disappeared, if so must refresh the UI if (_filterParams.columnRestrict) { string[] newColumns = columnizer != null ? columnizer.GetColumnNames() : new string[0]; bool colChanged = false; if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number' { for (int i = 0; i < newColumns.Length; i++) { if (dataGridView.Columns[i].HeaderText != newColumns[i]) { colChanged = true; break; // one change is sufficient } } } else { colChanged = true; } if (colChanged) { // Update UI columnNamesLabel.Text = CalculateColumnNames(_filterParams); } } Type oldColType = _filterParams.currentColumnizer != null ? _filterParams.currentColumnizer.GetType() : null; Type newColType = columnizer != null ? columnizer.GetType() : null; if (oldColType != newColType && _filterParams.columnRestrict && _filterParams.isFilterTail) { _filterParams.columnList.Clear(); } if (CurrentColumnizer == null || !CurrentColumnizer.GetType().Equals(columnizer.GetType())) { CurrentColumnizer = columnizer; _freezeStateMap.Clear(); if (CurrentLogFileReader != null) { IPreProcessColumnizer preprocessColumnizer = CurrentColumnizer as IPreProcessColumnizer; if (preprocessColumnizer != null) { CurrentLogFileReader.PreProcessColumnizer = preprocessColumnizer; } else { CurrentLogFileReader.PreProcessColumnizer = null; } } // always reload when choosing XML columnizers if (CurrentLogFileReader != null && CurrentColumnizer is ILogLineXmlColumnizer) { //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() mustReload = true; } // Reload when choosing no XML columnizer but previous columnizer was XML if (CurrentLogFileReader != null && !(CurrentColumnizer is ILogLineXmlColumnizer) && oldColumnizerIsXmlType) { CurrentLogFileReader.IsXmlMode = false; //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() mustReload = true; } // Reload when previous columnizer was PreProcess and current is not, and vice versa. // When the current columnizer is a preProcess columnizer, reload in every case. bool isCurrentColumnizerIPreProcessColumnizer = CurrentColumnizer is IPreProcessColumnizer; if ((isCurrentColumnizerIPreProcessColumnizer != oldColumnizerIsPreProcess) || isCurrentColumnizerIPreProcessColumnizer) { //forcedColumnizer = currentColumnizer; // prevent Columnizer selection on SetGuiAfterReload() mustReload = true; } } else { CurrentColumnizer = columnizer; } IInitColumnizer initColumnizer = oldColumnizer as IInitColumnizer; if (initColumnizer != null) { initColumnizer.DeSelected(new ColumnizerCallback(this)); } initColumnizer = columnizer as IInitColumnizer; if (initColumnizer != null) { initColumnizer.Selected(new ColumnizerCallback(this)); } SetColumnizer(columnizer, dataGridView); SetColumnizer(columnizer, filterGridView); if (_patternWindow != null) { _patternWindow.SetColumnizer(columnizer); } _guiStateArgs.TimeshiftPossible = columnizer.IsTimeshiftImplemented(); SendGuiStateUpdate(); if (CurrentLogFileReader != null) { dataGridView.RowCount = CurrentLogFileReader.LineCount; } if (_filterResultList != null) { filterGridView.RowCount = _filterResultList.Count; } if (mustReload) { Reload(); } else { if (CurrentColumnizer.IsTimeshiftImplemented()) { SetTimestampLimits(); SyncTimestampDisplay(); } Settings settings = ConfigManager.Settings; ShowLineColumn(!settings.hideLineColumn); ShowTimeSpread(Preferences.showTimeSpread && columnizer.IsTimeshiftImplemented()); } if (!columnizer.IsTimeshiftImplemented() && IsTimeSynced) { FreeFromTimeSync(); } columnComboBox.Items.Clear(); foreach (String columnName in columnizer.GetColumnNames()) { columnComboBox.Items.Add(columnName); } columnComboBox.SelectedIndex = 0; OnColumnizerChanged(CurrentColumnizer); }
private void setColumnizerHistoryEntry(string fileName, ILogLineColumnizer columnizer) { ColumnizerHistoryEntry entry = findColumnizerHistoryEntry(fileName); if (entry != null) { ConfigManager.Settings.columnizerHistoryList.Remove(entry); } ConfigManager.Settings.columnizerHistoryList.Add(new ColumnizerHistoryEntry(fileName, columnizer.GetName())); if (ConfigManager.Settings.columnizerHistoryList.Count > MAX_COLUMNIZER_HISTORY) { ConfigManager.Settings.columnizerHistoryList.RemoveAt(0); } }