<commit_before>package codeOrchestra.colt.core.ui.components.popupmenu

import codeOrchestra.util.SystemInfo
import javafx.event.ActionEvent
import javafx.event.EventHandler
import javafx.geometry.Point2D
import javafx.geometry.Side
import javafx.scene.control.ContextMenu
import javafx.stage.Popup

/**
 * @author <NAME>
 */
class PopupMenu extends Popup {
    PopupMenuContent menuContent
    ContextMenu contextMenu = new ContextMenu()

    PopupMenu() {
        menuContent = new PopupMenuContent()
        content.add(menuContent)

        setAutoHide(true)
        addEventFilter(ActionEvent.ACTION, {
            hide()
        } as EventHandler)
    }

    void show(javafx.scene.Node node) {
        if (SystemInfo.isMac) {
            Point2D point = node.parent.localToScreen(node.layoutX, node.layoutY)
            super.show(node, point.x - 17, point.y - menuContent.height - 5)
        } else {
            contextMenu.show(node, Side.TOP, 0, 0)
            //hac for correct position
            contextMenu.hide()
            contextMenu.show(node, Side.TOP, 0, 0)
        }
    }
}
<commit_msg>fix context menu for windows<commit_after>package codeOrchestra.colt.core.ui.components.popupmenu

import codeOrchestra.util.SystemInfo
import javafx.application.Platform
import javafx.event.ActionEvent
import javafx.event.EventHandler
import javafx.geometry.Point2D
import javafx.geometry.Side
import javafx.scene.control.ContextMenu
import javafx.stage.Popup

/**
 * @author <NAME>
 */
class PopupMenu extends Popup {
    PopupMenuContent menuContent
    ContextMenu contextMenu = new ContextMenu()

    PopupMenu() {
        menuContent = new PopupMenuContent()
        content.add(menuContent)

        setAutoHide(true)
        addEventFilter(ActionEvent.ACTION, {
            hide()
        } as EventHandler)
    }

    void show(javafx.scene.Node node) {
        if (SystemInfo.isMac) {
            Point2D point = node.parent.localToScreen(node.layoutX, node.layoutY)
            super.show(node, point.x - 17, point.y - menuContent.height - 5)
        } else {
            contextMenu.show(node, Side.TOP, 0, 0)
            if (contextMenu.height == -1) {
                Platform.runLater({
                    contextMenu.hide()
                    contextMenu.show(node, Side.TOP, 0, 0)
                })
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.09695173581710415, 'fraction_numerical': 0.008044030482641828, 'mean_word_length': 2.3853868194842405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6721243', 'n_tokens_mistral': 712, 'n_tokens_neox': 694, 'n_words': 140}