comparison jface/Librarian.d @ 143:42c3056512ba

redirect the jface examples to the new collection wrappers
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 22:21:50 +0200
parents 9ff9b8f7284b
children
comparison
equal deleted inserted replaced
142:7dca96709d29 143:42c3056512ba
44 44
45 import dwt.dwthelper.utils; 45 import dwt.dwthelper.utils;
46 import dwt.dwthelper.ByteArrayInputStream; 46 import dwt.dwthelper.ByteArrayInputStream;
47 47
48 import tango.text.convert.Format; 48 import tango.text.convert.Format;
49 import tango.util.collection.LinkSeq;
50 import tango.io.FilePath; 49 import tango.io.FilePath;
51 import tango.io.File; 50 import tango.io.File;
52 import tango.io.Print; 51 import tango.io.Print;
53 import tango.io.stream.FileStream; 52 import tango.io.stream.FileStream;
54 import tango.text.Util; 53 import tango.text.Util;
55 import tango.text.stream.LineIterator; 54 import tango.text.stream.LineIterator;
56 import tango.util.log.Trace; 55 import tango.util.log.Trace;
56 import dwtx.dwtxhelper.Collection;
57 57
58 version(JIVE) import jive.stacktrace; 58 version(JIVE) import jive.stacktrace;
59 59
60 /** 60 /**
61 * The application entry point 61 * The application entry point
952 952
953 // The filename 953 // The filename
954 private String filename; 954 private String filename;
955 955
956 // The books 956 // The books
957 private LinkSeq!(Book) books; 957 private LinkedList books;
958 958
959 // The dirty flag 959 // The dirty flag
960 private bool dirty; 960 private bool dirty;
961 961
962 /** 962 /**
963 * Library constructor Note the signature :-) 963 * Library constructor Note the signature :-)
964 */ 964 */
965 public this() { 965 public this() {
966 books = new LinkSeq!(Book); 966 books = new LinkedList();
967 } 967 }
968 968
969 /** 969 /**
970 * Loads the library from a file 970 * Loads the library from a file
971 * 971 *
995 * @throws IOException 995 * @throws IOException
996 */ 996 */
997 public void save(String filename) { 997 public void save(String filename) {
998 scope ostr = (new FileOutput(filename)).output; 998 scope ostr = (new FileOutput(filename)).output;
999 scope printer = new Print!(char)( Format, ostr ); 999 scope printer = new Print!(char)( Format, ostr );
1000 foreach ( book; books ) { 1000 foreach ( o; books ) {
1001 Book book = cast(Book)o;
1001 printer.formatln( "{}|{}",book.getTitle(), (book.getCheckedOutTo() is null ? "" : book.getCheckedOutTo())); 1002 printer.formatln( "{}|{}",book.getTitle(), (book.getCheckedOutTo() is null ? "" : book.getCheckedOutTo()));
1002 } 1003 }
1003 ostr.close(); 1004 ostr.close();
1004 this.filename = filename; 1005 this.filename = filename;
1005 dirty = false; 1006 dirty = false;
1010 * 1011 *
1011 * @param book the book to add 1012 * @param book the book to add
1012 * @return bool 1013 * @return bool
1013 */ 1014 */
1014 public bool add(Book book) { 1015 public bool add(Book book) {
1015 books.append(book); 1016 books.add(book);
1016 setDirty(); 1017 setDirty();
1017 return true; 1018 return true;
1018 } 1019 }
1019 1020
1020 /** 1021 /**
1030 /** 1031 /**
1031 * Gets the books 1032 * Gets the books
1032 * 1033 *
1033 * @return Collection 1034 * @return Collection
1034 */ 1035 */
1035 public LinkSeq!(Book) getBooks() { 1036 public LinkedList getBooks() {
1036 return books; 1037 return books;
1037 } 1038 }
1038 1039
1039 /** 1040 /**
1040 * Gets the file name 1041 * Gets the file name