@FXML private void initialize() { // Request focus for text field input, and select all default text Platform.runLater( new Runnable() { @Override public void run() { textInput.requestFocus(); textInput.setText(DEFAULT_INPUT_COMMAND); textInput.selectAll(); } }); // Construct the TaskieCommandHistory to keep track of commands typed in by user cmdHistory = new TaskieCommandHistory(); upPressed = false; obeservableMainList = FXCollections.observableArrayList(); createTree(new ArrayList<String>()); setupListCell(); setupTreeCell(); try { logicOut = TaskieLogic.getInstance().execute(VIEW_COMMAND); populate(logicOut.getMain(), logicOut.getAll()); } catch (UnrecognisedCommandException e) { // catch the exception thrown by logic // displays the warning message to feedbackLabel. logger.log(Level.SEVERE, "invalid command at UI initialization", e); feedbackLabel.setText(INVALID_COMMAND_MESSAGE); } }
/** Handle the KeyEvent when ENTER is pressed in TextInput */ private void handleInput() { upPressed = false; String input; String response; input = textInput.getText(); cmdHistory.addCommand(input); try { if (input.equals(COMMAND_HELP)) { mainApp.switchToHelp(); textInput.clear(); return; } logicOut = TaskieLogic.getInstance().execute(input); // logicOut can never be null as returned by Logic assert !(logicOut == null); // main list can never be empty as the first element is always a description of the content in // the list assert !(logicOut.getMain().isEmpty()); populate(logicOut.getMain(), logicOut.getAll()); response = logicOut.getFeedback(); feedbackLabel.setText(response); textInput.clear(); } catch (UnrecognisedCommandException e) { logger.log(Level.FINE, "invalid command at input", e); feedbackLabel.setText(INVALID_COMMAND_MESSAGE); } }