<commit_before>package seedu.todo.ui.components;

import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import seedu.todo.commons.util.FxViewUtil;
import seedu.todo.ui.InputHandler;
import seedu.todo.ui.UiPartLoader;

public class ConsoleInput extends Component {

    private static final String FXML_PATH = "components/ConsoleInput.fxml";
    private static final String INVALID_COMMAND_RESPONSE = "Invalid command!";
    private static final String INVALID_COMMAND_STYLECLASS = "invalid";

    // Props
    public String consoleOutput;
    private String lastCommandEntered;
    
    // Input handler
    private InputHandler inputHandler = new InputHandler();
    
    // Components
    Console console;
    
    // FXML
    @FXML
    private TextField consoleInputTextField;
    @FXML
    private Pane consolePlaceholder;

    public static ConsoleInput load(Stage primaryStage, Pane placeholderPane) {
        return UiPartLoader.loadUiPart(primaryStage, placeholderPane, new ConsoleInput());
    }

    @Override
    public String getFxmlPath() {
        return FXML_PATH;
    }

    @Override
    public void componentDidMount() {
        // Makes ConsoleInput full width wrt parent container.
        FxViewUtil.makeFullWidth(this.mainNode);
        
        // Load Console.
        loadConsole();
    }
    
    private void loadConsole() {
        console = Console.load(primaryStage, consolePlaceholder);
        console.consoleOutput = consoleOutput;
        console.render();
    }

    /** ================ ACTION HANDLERS ================== **/
    @FXML
    public void handleConsoleInputChanged() {
        lastCommandEntered = consoleInputTextField.getText();
        boolean isValidCommand = inputHandler.processInput(lastCommandEntered);
        
        if (!isValidCommand) {
            // Show invalid response in Console
            console.consoleOutput = INVALID_COMMAND_RESPONSE;
            console.render();
            
            // Set CSS
            consoleInputTextField.getStyleClass().add(INVALID_COMMAND_STYLECLASS);
        } else {
            // Remove console output
            console.consoleOutput = "";
            console.render();
            
            // Remove CSS
            consoleInputTextField.getStyleClass().remove(INVALID_COMMAND_STYLECLASS);
            
            // Clear input text
            consoleInputTextField.clear();
        }
    }
}<commit_msg>Don't show invalid command when consoleInput is empty<commit_after>package seedu.todo.ui.components;

import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import seedu.todo.commons.util.FxViewUtil;
import seedu.todo.ui.InputHandler;
import seedu.todo.ui.UiPartLoader;

public class ConsoleInput extends Component {

    private static final String FXML_PATH = "components/ConsoleInput.fxml";
    private static final String INVALID_COMMAND_RESPONSE = "Invalid command!";
    private static final String INVALID_COMMAND_STYLECLASS = "invalid";

    // Props
    public String consoleOutput;
    private String lastCommandEntered;
    
    // Input handler
    private InputHandler inputHandler = new InputHandler();
    
    // Components
    Console console;
    
    // FXML
    @FXML
    private TextField consoleInputTextField;
    @FXML
    private Pane consolePlaceholder;

    public static ConsoleInput load(Stage primaryStage, Pane placeholderPane) {
        return UiPartLoader.loadUiPart(primaryStage, placeholderPane, new ConsoleInput());
    }

    @Override
    public String getFxmlPath() {
        return FXML_PATH;
    }

    @Override
    public void componentDidMount() {
        // Makes ConsoleInput full width wrt parent container.
        FxViewUtil.makeFullWidth(this.mainNode);
        
        // Load Console.
        loadConsole();
    }
    
    private void loadConsole() {
        console = Console.load(primaryStage, consolePlaceholder);
        console.consoleOutput = consoleOutput;
        console.render();
    }

    /** ================ ACTION HANDLERS ================== **/
    @FXML
    public void handleConsoleInputChanged() {
        lastCommandEntered = consoleInputTextField.getText();
        
        // Don't change anything if our command is empty.
        if (lastCommandEntered.length() <= 0) {
            return;
        }
        
        assert lastCommandEntered.length() > 0;
        
        boolean isValidCommand = inputHandler.processInput(lastCommandEntered);
        
        if (!isValidCommand) {
            // Show invalid response in Console
            console.consoleOutput = INVALID_COMMAND_RESPONSE;
            console.render();
            
            // Set CSS
            consoleInputTextField.getStyleClass().add(INVALID_COMMAND_STYLECLASS);
        } else {
            // Remove console output
            console.consoleOutput = "";
            console.render();
            
            // Remove CSS
            consoleInputTextField.getStyleClass().remove(INVALID_COMMAND_STYLECLASS);
            
            // Clear input text
            consoleInputTextField.clear();
        }
    }
}
{'fraction_non_alphanumeric': 0.09196718183552757, 'fraction_numerical': 0.00038160656363289447, 'mean_word_length': 2.435124508519004, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '253309', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1340, 'n_words': 312}