package edu.chl.proton.model;


import javafx.scene.text.Text;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

/**
 * @author Mickaela
 * Created by Mickaela on 2017-05-01.
 */
public abstract class Document {

    private Cursor cursor;;
    private File file;
    private List<String> lines = new ArrayList<String>();
    private List<Parts> parts = new ArrayList<Parts>();

    protected Cursor getCursor(){
        return this.cursor;
    }

    protected void setCursor(Cursor cursor){
        this.cursor = cursor;
    }

    protected File getFile(){
        return this.file;
    }

    protected void setFile(File file){
        this.file = file;
    }

    protected void addFile(String path){
        // file.setPath(path);
        // setFile(rootFolder.getFileFromPath(path)); ???
    }

    protected void addParts(Parts parts){
        this.parts.add(parts);
    }

    protected void removeParts(int index){
        parts.remove(index);
    }

    protected void removeAllParts(){
        parts.clear();
    }

    protected void addLines(String lines){
        this.lines.add(lines);
    }

    protected void removeLines(int index){
        lines.remove(index);
    }

    protected void removeAllLines(){
        lines.clear();
    }

    protected void setText(List<String> text){
        for(String str : text){
            lines.add(str);
        }
    }

    // Returns a formated List, where every lsit item is a row in the document
    protected List<javafx.scene.text.Text> getText(){

        List<javafx.scene.text.Text> text = new ArrayList<javafx.scene.text.Text>();

        for(String str : lines){
            javafx.scene.text.Text newText = new javafx.scene.text.Text(str);
            text.add(newText);
        }
        return text;
    }

    protected void save(){
        file.save();
    }

    // Aqcuires the text from the file we opened.
    protected void aqcuireText(){

        // This will reference one line at a time
        String line = null;

        try {
            // FileReader reads text files in the default encoding.
            FileReader fileReader =
                    new FileReader(file.getName());

            // Always wrap FileReader in BufferedReader.
            BufferedReader bufferedReader =
                    new BufferedReader(fileReader);

            while((line = bufferedReader.readLine()) != null) {
                lines.add(line);
            }

            // Close file.
            bufferedReader.close();
        }
        catch(FileNotFoundException ex) {
            System.out.println(
                    "Unable to open file '" +
                            file.getName() + "'");
        }
        catch(IOException ex) {
            System.out.println(
                    "Error reading file '"
                            + file.getName() + "'");
        }


    }

}

@@ -1638,34 +1638,16 @@
 ed List%3C
-javafx.scene.text.
 Text%3E ge
@@ -1671,34 +1671,16 @@
    List%3C
-javafx.scene.text.
 Text%3E te
@@ -1698,34 +1698,16 @@
 rayList%3C
-javafx.scene.text.
 Text%3E();
@@ -1756,34 +1756,16 @@
         
-javafx.scene.text.
 Text new
@@ -1775,34 +1775,16 @@
 t = new 
-javafx.scene.text.
 Text(str

Update Document.java