// Path: src/main/java/com/github/kindrat/cassandra/client/ui/DataObject.java
// @ToString
// @EqualsAndHashCode
// @RequiredArgsConstructor
// public class DataObject {
//     @Getter
//     private final int position;
//     private final Map<String, Object> data = new HashMap<>();
// 
//     public void set(String name, Object value) {
//         data.put(name, value);
//     }
// 
//     public Object get(String name) {
//         if ("#".equals(name)) {
//             return position;
//         }
//         return data.get(name);
//     }
// }
// 
// Path: src/main/java/com/github/kindrat/cassandra/client/ui/eventhandler/FilterBtnHandler.java
// @RequiredArgsConstructor
// public class FilterBtnHandler implements EventHandler<ActionEvent> {
//     private final TextField filterTb;
//     private final TableView<DataObject> dataTable;
//     private final ObservableList<DataObject> originalData;
// 
//     @Override
//     public void handle(ActionEvent event) {
//         if (filterTb.getText().isEmpty()) {
//             if (dataTable.getItems().size() != originalData.size()) {
//                 dataTable.setItems(originalData);
//             }
//         } else {
//             Predicate<DataObject> rowPredicate = DataFilter.parsePredicate(filterTb.getText());
//             List<DataObject> filtered = originalData.stream().filter(rowPredicate).collect(Collectors.toList());
//             dataTable.setItems(FXCollections.observableArrayList(filtered));
//         }
//     }
// }
// 
// Path: src/main/java/com/github/kindrat/cassandra/client/ui/window/editor/main/table/DataTableView.java
// public class DataTableView extends TableView<DataObject> {
//     public DataTableView() {
//         setEditable(true);
//         setPrefSize(200, 200);
//         GridPane.setHalignment(this, HPos.CENTER);
//         GridPane.setValignment(this, VPos.CENTER);
//         GridPane.setRowIndex(this, 1);
//         setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);
// 
//         TableViewSelectionModel<DataObject> selectionModel = getSelectionModel();
//         selectionModel.setSelectionMode(SelectionMode.SINGLE);
//         selectionModel.setCellSelectionEnabled(true);
//     }
// 
//     public void setDataColumns(List<TableColumn<DataObject, Object>> columns) {
//         getColumns().clear();
//         getItems().clear();
//         setEditable(true);
//         getColumns().addAll(columns);
//     }
// 
//     public void onTableSelected(TableMetadata tableMetadata) {
//         setOnMouseClicked(new TableClickEventHandler<>(this));
//     }
// 
//     public TableCellCopyHandler buildCopyHandler() {
//         return new TableCellCopyHandler(this);
//     }
// }


import com.datastax.driver.core.TableMetadata;
import com.github.kindrat.cassandra.client.ui.DataObject;
import com.github.kindrat.cassandra.client.ui.eventhandler.FilterBtnHandler;
import com.github.kindrat.cassandra.client.ui.window.editor.main.table.DataTableView;
import javafx.collections.ObservableList;
import javafx.geometry.HPos;
import javafx.scene.control.Button;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;
        column2.setMinWidth(100);
        column2.setMaxWidth(100);
        column2.setHalignment(HPos.CENTER);
        column2.setHgrow(Priority.SOMETIMES);

        getColumnConstraints().clear();
        getColumnConstraints().addAll(column1, column2);

        RowConstraints row = new RowConstraints(10, 30, 30);
        row.setVgrow(Priority.SOMETIMES);

        getRowConstraints().clear();
        getRowConstraints().add(row);

        add(textField, 0, 0);
        add(filterButton, 1, 0);
    }

    public void setTableMetadata(TableMetadata tableMetadata) {
        textField.setTableMetadata(tableMetadata);
    }

    public void suggestCompletion() {
        if (textField.isFocused()) {
            textField.suggestCompletion();
        }
    }

    public void onDataUpdated(ObservableList<DataObject> data) {
        filterButton.setOnAction(new FilterBtnHandler(textField, dataTableView, data));
// Path: src/main/java/com/github/kindrat/cassandra/client/ui/DataObject.java
// @ToString
// @EqualsAndHashCode
// @RequiredArgsConstructor
// public class DataObject {
//     @Getter
//     private final int position;
//     private final Map<String, Object> data = new HashMap<>();
// 
//     public void set(String name, Object value) {
//         data.put(name, value);
//     }
// 
//     public Object get(String name) {
//         if ("#".equals(name)) {
//             return position;
//         }
//         return data.get(name);
//     }
// }
// 
// Path: src/main/java/com/github/kindrat/cassandra/client/ui/eventhandler/FilterBtnHandler.java
// @RequiredArgsConstructor
// public class FilterBtnHandler implements EventHandler<ActionEvent> {
//     private final TextField filterTb;
//     private final TableView<DataObject> dataTable;
//     private final ObservableList<DataObject> originalData;
// 
//     @Override
//     public void handle(ActionEvent event) {
//         if (filterTb.getText().isEmpty()) {
//             if (dataTable.getItems().size() != originalData.size()) {
//                 dataTable.setItems(originalData);
//             }
//         } else {
//             Predicate<DataObject> rowPredicate = DataFilter.parsePredicate(filterTb.getText());
//             List<DataObject> filtered = originalData.stream().filter(rowPredicate).collect(Collectors.toList());
//             dataTable.setItems(FXCollections.observableArrayList(filtered));
//         }
//     }
// }
// 
// Path: src/main/java/com/github/kindrat/cassandra/client/ui/window/editor/main/table/DataTableView.java
// public class DataTableView extends TableView<DataObject> {
//     public DataTableView() {
//         setEditable(true);
//         setPrefSize(200, 200);
//         GridPane.setHalignment(this, HPos.CENTER);
//         GridPane.setValignment(this, VPos.CENTER);
//         GridPane.setRowIndex(this, 1);
//         setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);
// 
//         TableViewSelectionModel<DataObject> selectionModel = getSelectionModel();
//         selectionModel.setSelectionMode(SelectionMode.SINGLE);
//         selectionModel.setCellSelectionEnabled(true);
//     }
// 
//     public void setDataColumns(List<TableColumn<DataObject, Object>> columns) {
//         getColumns().clear();
//         getItems().clear();
//         setEditable(true);
//         getColumns().addAll(columns);
//     }
// 
//     public void onTableSelected(TableMetadata tableMetadata) {
//         setOnMouseClicked(new TableClickEventHandler<>(this));
//     }
// 
//     public TableCellCopyHandler buildCopyHandler() {
//         return new TableCellCopyHandler(this);
//     }
// }


// Path: src/main/java/com/github/kindrat/cassandra/client/ui/window/editor/main/filter/FilterGrid.java
import com.datastax.driver.core.TableMetadata;
import com.github.kindrat.cassandra.client.ui.DataObject;
import com.github.kindrat.cassandra.client.ui.eventhandler.FilterBtnHandler;
import com.github.kindrat.cassandra.client.ui.window.editor.main.table.DataTableView;
import javafx.collections.ObservableList;
import javafx.geometry.HPos;
import javafx.scene.control.Button;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;

        column2.setMinWidth(100);
        column2.setMaxWidth(100);
        column2.setHalignment(HPos.CENTER);
        column2.setHgrow(Priority.SOMETIMES);

        getColumnConstraints().clear();
        getColumnConstraints().addAll(column1, column2);

        RowConstraints row = new RowConstraints(10, 30, 30);
        row.setVgrow(Priority.SOMETIMES);

        getRowConstraints().clear();
        getRowConstraints().add(row);

        add(textField, 0, 0);
        add(filterButton, 1, 0);
    }

    public void setTableMetadata(TableMetadata tableMetadata) {
        textField.setTableMetadata(tableMetadata);
    }

    public void suggestCompletion() {
        if (textField.isFocused()) {
            textField.suggestCompletion();
        }
    }

    public void onDataUpdated(ObservableList<DataObject> data) {
        filterButton.setOnAction(new FilterBtnHandler(textField, dataTableView, data));
        textField.setOnAction(new FilterBtnHandler(textField, dataTableView, data));