<commit_before>package SW9.presentations;

import SW9.utility.colors.Color;
import SW9.utility.colors.EnabledColor;
import com.jfoenix.controls.JFXPopup;
import com.jfoenix.controls.JFXRippler;
import javafx.animation.ScaleTransition;
import javafx.beans.binding.When;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableBooleanValue;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.util.Duration;
import org.kordamp.ikonli.javafx.FontIcon;

import javax.swing.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import static SW9.utility.colors.EnabledColor.enabledColors;
import static javafx.scene.paint.Color.TRANSPARENT;
import static javafx.scene.paint.Color.WHITE;

public class DropDownMenu {

    public static double x = 0;
    public static double y = 0;
    private final int width;
    private final StackPane content;
    private final VBox list;
    private final JFXPopup popup;
    private final SimpleBooleanProperty isHoveringSubMenu = new SimpleBooleanProperty(false);
    private final SimpleBooleanProperty isHoveringMenu = new SimpleBooleanProperty(false);
    private final SimpleBooleanProperty showSubMenu = new SimpleBooleanProperty(false);
    private final SimpleBooleanProperty canIShowSubMenu = new SimpleBooleanProperty(false);
    private StackPane subMenuContent;

    public DropDownMenu(final Pane container, final Node source, final int width, final boolean closeOnMouseExit) {
        this.width = width;

        popup = new JFXPopup();

        list = new VBox();
        list.setStyle("-fx-background-color: white; -fx-padding: 8 0 8 0;");
        list.setMaxHeight(1);
        StackPane.setAlignment(list, Pos.TOP_CENTER);

        content = new StackPane(list);
        content.setMinWidth(width);
        content.setMaxWidth(width);

        if (closeOnMouseExit) {
            final Runnable checkIfWeShouldClose = () -> {
                if (!isHoveringMenu.get() && !isHoveringSubMenu.get()) {
                    final Timer timer = new Timer(20, arg0 -> {
                        if (!isHoveringMenu.get() && !isHoveringSubMenu.get()) {
                            close();
                        }
                    });
                    timer.setRepeats(false); // Only execute once
                    timer.start(); // Go go go!
                }
            };
            isHoveringMenu.addListener(observable -> checkIfWeShouldClose.run());
            isHoveringSubMenu.addListener(observable -> checkIfWeShouldClose.run());
        }


        list.setOnMouseExited(event -> isHoveringMenu.set(false));
        list.setOnMouseEntered(event -> isHoveringMenu.set(true));

    }

    public void close() {

    }

    public void show(final JFXPopup.PopupVPosition vAlign, final JFXPopup.PopupHPosition hAlign, final double initOffsetX, final double initOffsetY) {

    }

    public void addListElement(final String s) {
        final Label label = new Label(s);

        label.setStyle("-fx-padding: 8 16 8 16;");
        label.getStyleClass().add("body2");
        label.setMinWidth(width);

        list.getChildren().add(label);

        label.setOnMouseEntered(event -> canIShowSubMenu.set(false));
    }

    public void addClickableListElement(final String s, final Consumer<MouseEvent> mouseEventConsumer) {
        final Label label = new Label(s);

        label.setStyle("-fx-padding: 8 16 8 16;");
        label.getStyleClass().add("body2");
        label.setMinWidth(width);

        final JFXRippler rippler = new JFXRippler(label);<commit_msg>Comment out code not wokring due to api changed<commit_after>package SW9.presentations;

import SW9.utility.colors.Color;
import SW9.utility.colors.EnabledColor;
import com.jfoenix.controls.JFXPopup;
import com.jfoenix.controls.JFXRippler;
import javafx.animation.ScaleTransition;
import javafx.beans.binding.When;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableBooleanValue;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.util.Duration;
import org.kordamp.ikonli.javafx.FontIcon;

import javax.swing.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import static SW9.utility.colors.EnabledColor.enabledColors;
import static javafx.scene.paint.Color.TRANSPARENT;
import static javafx.scene.paint.Color.WHITE;

public class DropDownMenu {

    public static double x = 0;
    public static double y = 0;
    private final int width;
    private final StackPane content;
    private final VBox list;
    private final JFXPopup popup;
    private final SimpleBooleanProperty isHoveringSubMenu = new SimpleBooleanProperty(false);
    private final SimpleBooleanProperty isHoveringMenu = new SimpleBooleanProperty(false);
    private final SimpleBooleanProperty showSubMenu = new SimpleBooleanProperty(false);
    private final SimpleBooleanProperty canIShowSubMenu = new SimpleBooleanProperty(false);
    private StackPane subMenuContent;

    public DropDownMenu(final Pane container, final Node source, final int width, final boolean closeOnMouseExit) {
        this.width = width;

        popup = new JFXPopup();

        list = new VBox();
        list.setStyle("-fx-background-color: white; -fx-padding: 8 0 8 0;");
        list.setMaxHeight(1);
        StackPane.setAlignment(list, Pos.TOP_CENTER);

        content = new StackPane(list);
        content.setMinWidth(width);
        content.setMaxWidth(width);

        if (closeOnMouseExit) {
            final Runnable checkIfWeShouldClose = () -> {
                if (!isHoveringMenu.get() && !isHoveringSubMenu.get()) {
                    final Timer timer = new Timer(20, arg0 -> {
                        if (!isHoveringMenu.get() && !isHoveringSubMenu.get()) {
                            close();
                        }
                    });
                    timer.setRepeats(false); // Only execute once
                    timer.start(); // Go go go!
                }
            };
            isHoveringMenu.addListener(observable -> checkIfWeShouldClose.run());
            isHoveringSubMenu.addListener(observable -> checkIfWeShouldClose.run());
        }


        list.setOnMouseExited(event -> isHoveringMenu.set(false));
        list.setOnMouseEntered(event -> isHoveringMenu.set(true));

        //XXX: removed due to api changed
        /*
        popup.setContent(content);
        popup.setPopupContainer(container);
        popup.setSource(source);
        */
    }

    public void close() {
        //XXX: removed due to api changed
        //popup.close();
    }

    public void show(final JFXPopup.PopupVPosition vAlign, final JFXPopup.PopupHPosition hAlign, final double initOffsetX, final double initOffsetY) {
        //XXX: removed due to api changed
        popup.show(vAlign, hAlign, initOffsetX, initOffsetY);
    }

    public void addListElement(final String s) {
        final Label label = new Label(s);

        label.setStyle("-fx-padding: 8 16 8 16;");
        label.getStyleClass().add("body2");
        label.setMinWidth(width);

        list.getChildren().add(label);

        label.setOnMouseEntered(event -> canIShowSubMenu.set(false));
    }

    public void addClickableListElement(final String s, final Consumer<MouseEvent> mouseEventConsumer) {
        final Label label = new Label(s);

        label.setStyle("-fx-padding: 8 16 8 16;");
        label.getStyleClass().add("body2");
        label.setMinWidth(width);

        final JFXRippler rippler = new JFXRippler(label);
{'fraction_non_alphanumeric': 0.0998389694041868, 'fraction_numerical': 0.006936702588876502, 'mean_word_length': 2.9773399014778326, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5894081', 'n_tokens_mistral': 2373, 'n_tokens_neox': 2280, 'n_words': 519}