1 19 20 package org.lucane.applications.notes.gui.note; 21 22 import java.awt.*; 23 24 import org.lucane.client.Client; 25 import org.lucane.client.widgets.ManagedWindow; 26 import org.lucane.applications.notes.Note; 27 import org.lucane.applications.notes.NotesPlugin; 28 29 public class NoteFrame extends ManagedWindow 30 { 31 private MainPanel content; 32 private ButtonPanel buttons; 33 private Note note = null; 34 35 public NoteFrame(NotesPlugin plugin) 36 { 37 super(plugin, plugin.tr("note.frame.title.add")); 38 init(plugin); 39 } 40 41 public NoteFrame(NotesPlugin plugin, Note note) 42 { 43 super(plugin, plugin.tr("note.frame.title.edit")); 44 init(plugin); 45 this.note = note; 46 47 setNoteTitle(note.getTitle()); 48 setCommentable(note.isCommentable()); 49 setPublic(note.isPublic()); 50 setCreationDate(note.getCreationDate().toString()); 51 if(note.getEditionDate() != null) 52 setEditionDate(note.getEditionDate().toString()); 53 else 54 setEditionDate(""); 55 56 setContent(note.getContent()); 57 } 58 59 private void init(NotesPlugin plugin) 60 { 61 this.setPreferredSize(new Dimension(600, 400)); 62 this.getContentPane().setLayout(new BorderLayout(5, 0)); 63 64 MyActionListener listener = new MyActionListener(plugin, this); 65 66 this.content = new MainPanel(plugin); 67 this.buttons = new ButtonPanel(plugin, listener); 68 69 this.getContentPane().add(content, BorderLayout.CENTER); 70 this.getContentPane().add(buttons, BorderLayout.EAST); 71 } 72 73 public void setNoteTitle(String txt) 74 { 75 content.setTitle(txt); 76 } 77 78 public String getNoteTitle() 79 { 80 return content.getTitle(); 81 } 82 83 public void setCommentable(boolean state) 84 { 85 content.setCommentable(state); 86 } 87 88 public void setPublic(boolean state) 89 { 90 content.setPublic(state); 91 } 92 93 public boolean isCommentable() 94 { 95 return content.isCommentable(); 96 } 97 98 public boolean isPublic() 99 { 100 return content.isPublic(); 101 } 102 103 public void setCreationDate(String txt) 104 { 105 content.setCreationDate(txt); 106 } 107 108 public void setEditionDate(String txt) 109 { 110 content.setEditionDate(txt); 111 } 112 113 public void setContent(String txt) 114 { 115 content.setContent(txt); 116 } 117 118 public String getContent() 119 { 120 return content.getContent(); 121 } 122 123 124 public Note getNote() 125 { 126 if(note != null) 127 note.editContent(getNoteTitle(), getContent(), isPublic(), isCommentable()); 128 else 129 { 130 note = new Note(Client.getInstance().getMyInfos().getName(), 131 getNoteTitle(), getContent(), isPublic(), 132 isCommentable()); 133 } 134 return note; 135 } 136 } | Popular Tags |