<commit_before>/*
 * The Command to create a new file.
 */
package htmleditor.commands;

import htmleditor.CloseListener;
import htmleditor.HTMLEditor;
import htmleditor.MyEventHandler;
import htmleditor.TabData;
import javafx.event.Event;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;

/**
 *
 * @author aac6012
 */
public class NewFileCommand implements Command {
    HTMLEditor editor ;
    
    public NewFileCommand(HTMLEditor editor){
        this.editor = editor;
    }
    
    public void execute(Event t){
        Tab tab = new Tab();
        tab.setOnClosed(new CloseListener(this.editor));
        tab.setText("Untitled");
        tab.setId("Untitled");
        tab.setUserData(new TabData(this.editor));
        
        BorderPane tabBorderContent = new BorderPane();
        
        // line numbers
        /*
        TextArea lineNumbers = new TextArea("1");
        lineNumbers.setDisable(true);
        lineNumbers.setWrapText(true);
        lineNumbers.setPrefWidth(20);
        tabBorderContent.setLeft(lineNumbers);
        */
        GridPane lineNumbers = new GridPane();
        Label lineno = new Label(" 1 ");
        GridPane.setConstraints(lineno, 3, 1); // column=3 row=1

        lineNumbers.getChildren().addAll(lineno);
        tabBorderContent.setLeft(lineNumbers);
        
        
        // text area
        TextArea ta = new TextArea();
        ta.setOnKeyReleased(new MyEventHandler(new TextAnalysisCommand(this.editor)));
        ta.setWrapText(true);
        ta.prefHeightProperty().bind(this.editor.getScene().heightProperty());
        ta.prefWidthProperty().bind(this.editor.getScene().widthProperty());
        ta.setStyle("-fx-font: \"Segoe UI Semibold\"; ");
        tabBorderContent.setRight(ta);
        
        
        tab.setContent(tabBorderContent);
        this.editor.getTabPane().getTabs().add(tab);
        this.editor.getTabPane().getSelectionModel().select(tab);
        
        /*
        if (tab.isSelected()){
            tab.getContent().requestFocus();
        }
        */
    }
}<commit_msg>Minor change to fix undo/redo.<commit_after>/*
 * The Command to create a new file.
 */
package htmleditor.commands;

import htmleditor.CloseListener;
import htmleditor.HTMLEditor;
import htmleditor.MyEventHandler;
import htmleditor.TabData;
import javafx.event.Event;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;

/**
 *
 * @author aac6012
 */
public class NewFileCommand implements Command {
    HTMLEditor editor ;
    
    public NewFileCommand(HTMLEditor editor){
        this.editor = editor;
    }
    
    public void execute(Event t){
        Tab tab = new Tab();
        tab.setOnClosed(new CloseListener(this.editor));
        tab.setText("Untitled");
        tab.setId("Untitled");
        tab.setUserData(new TabData(this.editor));
        
        BorderPane tabBorderContent = new BorderPane();
        
        // line numbers
        /*
        TextArea lineNumbers = new TextArea("1");
        lineNumbers.setDisable(true);
        lineNumbers.setWrapText(true);
        lineNumbers.setPrefWidth(20);
        tabBorderContent.setLeft(lineNumbers);
        */
        GridPane lineNumbers = new GridPane();
        Label lineno = new Label(" 1 ");
        GridPane.setConstraints(lineno, 3, 1); // column=3 row=1

        lineNumbers.getChildren().addAll(lineno);
        tabBorderContent.setLeft(lineNumbers);
        
        
        // text area
        TextArea ta = new TextArea();
        ta.setOnKeyReleased(new MyEventHandler(new TextAnalysisCommand(this.editor)));
        ta.setWrapText(true);
        ta.prefHeightProperty().bind(this.editor.getScene().heightProperty());
        ta.prefWidthProperty().bind(this.editor.getScene().widthProperty());
        ta.setStyle("-fx-font: \"Segoe UI Semibold\"; ");
        tabBorderContent.setRight(ta);
        
        
        tab.setContent(tabBorderContent);
        this.editor.getTabPane().getTabs().add(tab);
        this.editor.getTabPane().getSelectionModel().select(tab);
        
        /*
        if (tab.isSelected()){
            tab.getContent().requestFocus();
        }
        */
        
        //This saves the initial state to the newly created tab's undoManager.
        ((TabData)tab.getUserData()).getUndoManager().save(this.editor.createMemento());
        
    }
}
{'fraction_non_alphanumeric': 0.12089584692324418, 'fraction_numerical': 0.005218525766470972, 'mean_word_length': 2.5686578743211794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '931767', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1338, 'n_words': 238}