// Path: src/net/bitpot/railways/models/RoutesFilter.java
// public class RoutesFilter {
//     private final RouteTableModel tableModel;
//     private String filterText = "";
//     @NotNull private Pattern filterPattern = Pattern.compile("");
//     private boolean mountedRoutesVisible = true;
// 
//     private static Pattern buildPattern(String filterText) {
//         // Escape regex special chars except "*"
//         filterText = filterText.replaceAll("[\\\\.\\[\\]{}()+\\-?^$|]", "\\\\$0");
//         String regex = filterText.replace("*", ".*?");
//         return Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
//     }
// 
//     public RoutesFilter(@NotNull RouteTableModel tableModel) {
//         this.tableModel = tableModel;
//     }
// 
//     public void setFilterText(String filterText) {
//         filterText = filterText.toLowerCase();
//         if (!this.filterText.equals(filterText)) {
//             this.filterText = filterText;
//             filterPattern = buildPattern(filterText);
//             tableModel.filterChanged();
//         }
//     }
// 
//     public boolean isMountedRoutesVisible() {
//         return mountedRoutesVisible;
//     }
// 
//     public void setMountedRoutesVisible(boolean value) {
//         if (mountedRoutesVisible != value) {
//             mountedRoutesVisible = value;
//             tableModel.filterChanged();
//         }
//     }
// 
//     /**
//      * Returns true if any filter is set and should be applied.
//      * Actually checks if filter values are set to defaults or not.
//      *
//      * @return True when any filter is active, false otherwise.
//      */
//     boolean isFilterActive() {
//         return !filterText.equals("") || !mountedRoutesVisible;
//     }
// 
//     /**
//      * Checks whether specified route matches current filter.
//      *
//      * @param route Route to be matched against current filter.
//      * @return True if route matches filter, false otherwise.
//      */
//     boolean match(Route route) {
//         if (!mountedRoutesVisible && route.getParentEngine() != null)
//             return false;
// 
//         return filterPattern.matcher(route.getPath()).find() ||
//                 filterPattern.matcher(route.getActionTitle()).find() ||
//                 filterPattern.matcher(route.getRouteName()).find();
//     }
// 
//     public String findMatchedString(String text) {
//         Matcher matcher = filterPattern.matcher(text);
//         return matcher.find() ? matcher.group() : "";
//     }
// 
// }


import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.ui.UIUtil;
import net.bitpot.railways.models.RoutesFilter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
package net.bitpot.railways.gui;



public class FilterHighlightRenderer extends ColoredTableCellRenderer {

    // Contains formatted text.
    private final RoutesFilter filter;


    FilterHighlightRenderer(@NotNull RoutesFilter filter) {
        this.filter = filter;
    }


// Path: src/net/bitpot/railways/models/RoutesFilter.java
// public class RoutesFilter {
//     private final RouteTableModel tableModel;
//     private String filterText = "";
//     @NotNull private Pattern filterPattern = Pattern.compile("");
//     private boolean mountedRoutesVisible = true;
// 
//     private static Pattern buildPattern(String filterText) {
//         // Escape regex special chars except "*"
//         filterText = filterText.replaceAll("[\\\\.\\[\\]{}()+\\-?^$|]", "\\\\$0");
//         String regex = filterText.replace("*", ".*?");
//         return Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
//     }
// 
//     public RoutesFilter(@NotNull RouteTableModel tableModel) {
//         this.tableModel = tableModel;
//     }
// 
//     public void setFilterText(String filterText) {
//         filterText = filterText.toLowerCase();
//         if (!this.filterText.equals(filterText)) {
//             this.filterText = filterText;
//             filterPattern = buildPattern(filterText);
//             tableModel.filterChanged();
//         }
//     }
// 
//     public boolean isMountedRoutesVisible() {
//         return mountedRoutesVisible;
//     }
// 
//     public void setMountedRoutesVisible(boolean value) {
//         if (mountedRoutesVisible != value) {
//             mountedRoutesVisible = value;
//             tableModel.filterChanged();
//         }
//     }
// 
//     /**
//      * Returns true if any filter is set and should be applied.
//      * Actually checks if filter values are set to defaults or not.
//      *
//      * @return True when any filter is active, false otherwise.
//      */
//     boolean isFilterActive() {
//         return !filterText.equals("") || !mountedRoutesVisible;
//     }
// 
//     /**
//      * Checks whether specified route matches current filter.
//      *
//      * @param route Route to be matched against current filter.
//      * @return True if route matches filter, false otherwise.
//      */
//     boolean match(Route route) {
//         if (!mountedRoutesVisible && route.getParentEngine() != null)
//             return false;
// 
//         return filterPattern.matcher(route.getPath()).find() ||
//                 filterPattern.matcher(route.getActionTitle()).find() ||
//                 filterPattern.matcher(route.getRouteName()).find();
//     }
// 
//     public String findMatchedString(String text) {
//         Matcher matcher = filterPattern.matcher(text);
//         return matcher.find() ? matcher.group() : "";
//     }
// 
// }


// Path: src/net/bitpot/railways/gui/FilterHighlightRenderer.java
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.ui.UIUtil;
import net.bitpot.railways.models.RoutesFilter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;

package net.bitpot.railways.gui;



public class FilterHighlightRenderer extends ColoredTableCellRenderer {

    // Contains formatted text.
    private final RoutesFilter filter;


    FilterHighlightRenderer(@NotNull RoutesFilter filter) {
        this.filter = filter;
    }


    RoutesFilter getFilter() {