<commit_before>package org.shopkeeper.gui.fx.controller;

import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import org.shopkeeper.gui.fx.completeviews.CompleteViewModuleFX;
import org.shopkeeper.gui.fx.controller.handler.CompleteViewActionHandler;

/**
 * Inspired by: http://stackoverflow.com/questions/12830402/javafx-2-buttons-size-fill-width-and-are-each-same-width
 * Answered by: jewelsea
 * Found: 29-12-2015
 */
public class SubjectsCompleteViewControllerFX extends HBox {

    public static Button ITEM_BUTTON = new Button("Items");
    public static Button CAT_BUTTON = new Button("Categories");
    public static Button CUS_BUTTON = new Button("Customers");
    public static Button HOME_BUTTON = new Button("Home");

    // Listeners:
    static {
        CompleteViewActionHandler handler = new CompleteViewActionHandler();
        ITEM_BUTTON.setOnAction(handler);
        CUS_BUTTON.setOnAction(handler);
        CAT_BUTTON.setOnAction(handler);
        HOME_BUTTON.setOnAction(handler);
    }

    public SubjectsCompleteViewControllerFX() {
        super(10);
        Button[] buttons = {HOME_BUTTON,ITEM_BUTTON, CAT_BUTTON, CUS_BUTTON};
        getChildren().addAll(buttons);
        for (Button b : buttons) {
            HBox.setHgrow(b, Priority.ALWAYS);
            b.setMaxWidth(Double.MAX_VALUE);
        }
    }


    @Override
    protected void layoutChildren() {
        double minPrefWidth = calculatePrefChildWidth();
        for (Node n : getChildren()) {
            if (n instanceof Button) {
                ((Button) n).setMinWidth(minPrefWidth);
            }
        }
        super.layoutChildren();
    }

    private double calculatePrefChildWidth() {
        double minPrefWidth = 0;
        for (Node n : getChildren()) {
            minPrefWidth = Math.max(minPrefWidth, n.prefWidth(-1));
        }
        return minPrefWidth;
    }
}

<commit_msg>Refactoring and removed unused imports<commit_after>package org.shopkeeper.gui.fx.controller;

import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import org.shopkeeper.gui.fx.controller.handler.CompleteViewActionHandler;

/**
 * Inspired by: http://stackoverflow.com/questions/12830402/javafx-2-buttons-size-fill-width-and-are-each-same-width
 * Answered by: jewelsea
 * Found: 29-12-2015
 */
public class SubjectsCompleteViewControllerFX extends HBox {

    public static Button ITEM_BUTTON = new Button("Items");
    public static Button CAT_BUTTON = new Button("Categories");
    public static Button CUS_BUTTON = new Button("Customers");
    public static Button HOME_BUTTON = new Button("Home");

    // Listeners:
    static {
        CompleteViewActionHandler handler = new CompleteViewActionHandler();
        ITEM_BUTTON.setOnAction(handler);
        CUS_BUTTON.setOnAction(handler);
        CAT_BUTTON.setOnAction(handler);
        HOME_BUTTON.setOnAction(handler);
    }

    public SubjectsCompleteViewControllerFX() {
        super(10);
        Button[] buttons = {HOME_BUTTON, ITEM_BUTTON, CAT_BUTTON, CUS_BUTTON};
        getChildren().addAll(buttons);
        for (Button b : buttons) {
            HBox.setHgrow(b, Priority.ALWAYS);
            b.setMaxWidth(Double.MAX_VALUE);
        }
    }


    @Override
    protected void layoutChildren() {
        double minPrefWidth = calculatePrefChildWidth();
        getChildren().stream().filter(n -> n instanceof Button).forEach(n -> ((Button) n).setMinWidth(minPrefWidth));
        super.layoutChildren();
    }

    private double calculatePrefChildWidth() {
        double minPrefWidth = 0;
        for (Node n : getChildren()) {
            minPrefWidth = Math.max(minPrefWidth, n.prefWidth(-1));
        }
        return minPrefWidth;
    }
}


{'fraction_non_alphanumeric': 0.10815648171823063, 'fraction_numerical': 0.010738941447200204, 'mean_word_length': 3.1309398099260823, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2408846', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1116, 'n_words': 221}