Exemplo n.º 1
0
        public FilterSelectorForm(IList <ILogLineColumnizer> existingColumnizerList, ILogLineColumnizer currentColumnizer, ILogLineColumnizerCallback callback)
        {
            SelectedColumnizer = currentColumnizer;
            _callback          = callback;
            InitializeComponent();
            filterComboBox.SelectedIndexChanged += OnFilterComboBoxSelectedIndexChanged;

            // for the currently selected columnizer use the current instance and not the template instance from
            // columnizer registry. This ensures that changes made in columnizer config dialogs
            // will apply to the current instance
            _columnizerList = new List <ILogLineColumnizer>();
            foreach (ILogLineColumnizer col in existingColumnizerList)
            {
                _columnizerList.Add(col.GetType() == SelectedColumnizer.GetType() ? SelectedColumnizer : col);
            }

            foreach (ILogLineColumnizer col in _columnizerList)
            {
                filterComboBox.Items.Add(col);
            }

            foreach (ILogLineColumnizer columnizer in _columnizerList)
            {
                if (columnizer.GetType() == SelectedColumnizer.GetType())
                {
                    filterComboBox.SelectedItem = columnizer;
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static ILogLineColumnizer FindBetterColumnizer(string fileName,
                                                              IAutoLogLineColumnizerCallback logFileReader,
                                                              ILogLineColumnizer logLineColumnizer)
        {
            var newColumnizer = FindColumnizer(fileName, logFileReader);

            if (newColumnizer.GetType().Equals(logLineColumnizer.GetType()))
            {
                return(null);
            }
            return(newColumnizer);
        }
Exemplo n.º 3
0
		public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer)
		{
			if (columnizer == null)
			{
				return null;
			}
			ConstructorInfo cti = columnizer.GetType().GetConstructor(Type.EmptyTypes);
			if (cti != null)
			{
				object o = cti.Invoke(new object[] { });
				if (o is IColumnizerConfigurator)
				{
					((IColumnizerConfigurator)o).LoadConfig(ConfigManager.ConfigDir);
				}
				return (ILogLineColumnizer)o;
			}
			return null;
		}
Exemplo n.º 4
0
        public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer)
        {
            if (columnizer == null)
            {
                return(null);
            }
            ConstructorInfo cti = columnizer.GetType().GetConstructor(Type.EmptyTypes);

            if (cti != null)
            {
                object o = cti.Invoke(new object[] { });
                if (o is IColumnizerConfigurator)
                {
                    ((IColumnizerConfigurator)o).LoadConfig(ConfigManager.ConfigDir);
                }
                return((ILogLineColumnizer)o);
            }
            return(null);
        }
Exemplo n.º 5
0
        public static ILogLineColumnizer CloneColumnizer(ILogLineColumnizer columnizer)
        {
            if (columnizer == null)
            {
                return(null);
            }
            ConstructorInfo cti = columnizer.GetType().GetConstructor(Type.EmptyTypes);

            if (cti != null)
            {
                object o = cti.Invoke(new object[] { });
                if (o is IColumnizerConfigurator configurator)
                {
                    configurator.LoadConfig(ConfigManager.Settings.preferences.PortableMode ? ConfigManager.PortableModeDir : ConfigManager.ConfigDir);
                }
                return((ILogLineColumnizer)o);
            }
            return(null);
        }
Exemplo n.º 6
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);
        }