View Javadoc
1 // re/mind - Remote Reminder Software 2 // Copyright (C) 2002 Moritz Petersen 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation; either version 2 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 // 18 // $Id: Model.java,v 1.2 2002/09/29 19:33:23 powerpete Exp $ 19 package de.jface.remind; 20 21 import de.jface.remind.core.Note; 22 import de.jface.remind.core.NoteText; 23 import de.jface.remind.core.NoteMetaData; 24 import de.jface.remind.core.NoteMetaData.Visibility; 25 import de.jface.remind.io.Storage; 26 import de.jface.remind.io.StorageException; 27 28 import java.util.ArrayList; 29 import java.util.Collection; 30 import java.util.Iterator; 31 32 /*** 33 * Class <code>Model</code> 34 * of project RemotePostIt. 35 * 36 * @author Moritz Petersen 37 * @version $Revision: 1.2 $ 38 */ 39 public class Model 40 { 41 private Collection notes = new ArrayList(); 42 43 public void open() throws StorageException 44 { 45 notes = Storage.getInstance().readNotes(); 46 } 47 48 public void close() throws StorageException 49 { 50 Storage.getInstance().writeNotes(notes); 51 } 52 53 public Note newNote() 54 { 55 Note note = new Note(); 56 57 notes.add(note); 58 59 return note; 60 } 61 62 public Iterator notes() 63 { 64 return notes.iterator(); 65 } 66 67 public int size() 68 { 69 return notes.size(); 70 } 71 72 public void textValueChanged(Note note, String text) 73 { 74 NoteText noteText = note.getText(); 75 76 noteText.setBody(text); 77 } 78 79 public void removeNote(Note note) 80 { 81 notes.remove(note); 82 } 83 84 /*** 85 * Returns true, if visible notes exist in this mode. Hidden or minimized 86 * notes are not considered visible. 87 */ 88 public boolean hasVisibleNotes() 89 { 90 for (Iterator i = notes.iterator(); i.hasNext();) 91 { 92 Note note = (Note) i.next(); 93 Visibility visibility = note.getMetaData().getVisibility(); 94 if (visibility == Visibility.VISIBLE || visibility == Visibility.MINIMIZED) 95 { 96 return true; 97 } 98 } 99 return false; 100 } 101 } 102 103 // ------1---------2---------3---------4---------5---------6---------7---------8

This page was automatically generated by Maven