package ryhma57.gui;

import java.util.EnumMap;
import ryhma57.backend.BibtexReferenceField;

/**
 * This is the main class currently.
 */
public class Application {
    public static void main(String[] args) {
        Application app = new Application();
        Window window;
        window = new Window(app);

        window.setVisible(true);
        System.out.println("test");
    }

    public void generateBibTex() {
        //XXX do something here
        System.out.println("Generate the bibtext file in the backend");
    }

    public void createNewBookReference(EnumMap<BibtexReferenceField, String> fields) {
        //XXX do something here
        System.out.println("Create the book reference in the backend");

        /* Push the changes into backend */
        //Reference ref = new Reference();
        //ref = this.referenceList.addReference(ref);
        //
        //for (BibtexReferenceField field : fields.keySet()) {
        //    ref.setField(field, fields.get(field));
        //}
    }
}

@@ -31,65 +31,304 @@
 ava.
-util.EnumMap;%0Aimport ryhma57.backend.BibtexReferenceField
+io.FileNotFoundException;%0Aimport java.io.PrintWriter;%0Aimport java.io.UnsupportedEncodingException;%0Aimport java.util.EnumMap;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0Aimport ryhma57.backend.BibtexReferenceField;%0Aimport ryhma57.backend.Book;%0Aimport ryhma57.backend.Reference
 ;%0A%0A/
@@ -665,39 +665,35 @@
         
-//XXX do something here
+PrintWriter writer;
 %0A       
@@ -756,16 +756,369 @@
 ckend%22);
+%0A%0A        try %7B%0A            writer = new PrintWriter(%22database.bib%22, %22UTF-8%22);%0A            writer.print(%22Implement%22 /*this.referenceList.toBibTex()*/);%0A            writer.close();%0A%0A        %7D catch (FileNotFoundException %7C UnsupportedEncodingException ex) %7B%0A            Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);%0A        %7D
 %0A    %7D%0A%0A
@@ -1208,40 +1208,8 @@
 ) %7B%0A
-        //XXX do something here%0A
     
@@ -1289,12 +1289,468 @@
     
-/* P
+String id = fields.get(BibtexReferenceField.ID);%0A        String author = fields.get(BibtexReferenceField.AUTHOR);%0A        String title = fields.get(BibtexReferenceField.TITLE);%0A        String year = fields.get(BibtexReferenceField.YEAR);%0A        String publisher = fields.get(BibtexReferenceField.PUBLISHER);%0A%0A        Reference ref = new Book(id, author, title, year, publisher);%0A        //this.referenceList.addReference(ref);%0A%0A        /* Alternative way to p
 ush 
@@ -1830,22 +1830,16 @@
       //
-ref = 
 this.ref

Implement most of the initial window contoller code.