<commit_before>package linenux.view;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import linenux.control.ControlUnit;

/**
 * Created by yihangho on 10/30/16.
 */
public class ExpandableResultBoxController {
    @FXML
    Button button;
    @FXML
    TextArea textArea;

    private BooleanProperty expanded = new SimpleBooleanProperty(false);
    private ControlUnit controlUnit;

    public void setControlUnit(ControlUnit controlUnit) {
        this.controlUnit = controlUnit;
        this.controlUnit.getLastCommandResultProperty().addListener((change) -> {
            this.textArea.setText(this.controlUnit.getLastCommandResultProperty().get().getFeedback());
        });
    }

    @FXML
    private void initialize() {
        this.expanded.addListener(change -> {
            this.render();
        });
    }

    @FXML
    private void toggleExpandedState() {
        this.expanded.set(!this.expanded.get());
    }

    private void render() {
        if (this.expanded.get()) {
            this.button.setText("Hide");
            this.textArea.setPrefHeight(200);
        } else {
            this.button.setText("Show");
            this.textArea.setPrefHeight(0);
        }
    }
}<commit_msg>Show only long command results in expandable result box<commit_after>package linenux.view;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import linenux.control.ControlUnit;

/**
 * Created by yihangho on 10/30/16.
 */
public class ExpandableResultBoxController {
    @FXML
    Button button;
    @FXML
    TextArea textArea;

    private BooleanProperty expanded = new SimpleBooleanProperty(false);
    private ControlUnit controlUnit;

    public void setControlUnit(ControlUnit controlUnit) {
        this.controlUnit = controlUnit;
        this.controlUnit.getLastCommandResultProperty().addListener((change) -> {
            this.setText(this.controlUnit.getLastCommandResultProperty().get().getFeedback());
        });
    }

    @FXML
    private void initialize() {
        this.expanded.addListener(change -> {
            this.render();
        });
    }

    @FXML
    private void toggleExpandedState() {
        this.expanded.set(!this.expanded.get());
    }

    private void render() {
        if (this.expanded.get()) {
            this.button.setText("Hide");
            this.textArea.setPrefHeight(200);
        } else {
            this.button.setText("Show");
            this.textArea.setPrefHeight(0);
        }
    }

    private void setText(String text) {
        if (text.trim().contains("\n")) {
            this.textArea.setText(text.trim());
        } else {
            // TODO show the reminders instead.
            this.textArea.setText("");
        }
    }
}
{'fraction_non_alphanumeric': 0.11451398135818908, 'fraction_numerical': 0.006657789613848202, 'mean_word_length': 2.651275820170109, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '676801', 'n_tokens_mistral': 869, 'n_tokens_neox': 839, 'n_words': 152}