1 19 20 package org.lucane.applications.notes.gui.comment; 21 22 import java.awt.*; 23 import javax.swing.*; 24 25 import org.lucane.client.Client; 26 import org.lucane.client.widgets.ManagedWindow; 27 import org.lucane.applications.notes.*; 28 29 public class CommentFrame extends ManagedWindow 30 { 31 private Note note; 32 private TitlePanel title; 33 private ContentPanel content; 34 private ButtonPanel buttons; 35 36 public CommentFrame(NotesPlugin plugin, Note note) 37 { 38 super(plugin, plugin.tr("comment.frame.title.add")); 39 init(plugin, note); 40 } 41 42 public CommentFrame(NotesPlugin plugin, Note note, Comment comment) 43 { 44 super(plugin, plugin.tr("comment.frame.title.view")); 45 init(plugin, note); 46 setCommentTitle(comment.getTitle()); 47 setContent(comment.getContent()); 48 buttons.hideSave(); 49 content.setEditable(false); 50 title.setEditable(false); 51 } 52 53 private void init(NotesPlugin plugin, Note note) 54 { 55 this.setPreferredSize(new Dimension(600, 400)); 56 this.getContentPane().setLayout(new BorderLayout(5, 0)); 57 58 MyActionListener listener = new MyActionListener(plugin, this); 59 this.note = note; 60 61 this.title = new TitlePanel(plugin); 62 this.content = new ContentPanel(plugin); 63 this.buttons = new ButtonPanel(plugin, listener); 64 65 JPanel main = new JPanel(new BorderLayout(0, 5)); 66 main.add(title, BorderLayout.NORTH); 67 main.add(content, BorderLayout.CENTER); 68 69 this.getContentPane().add(main, BorderLayout.CENTER); 70 this.getContentPane().add(buttons, BorderLayout.EAST); 71 } 72 73 public void setCommentTitle(String txt) 74 { 75 title.setTitle(txt); 76 } 77 78 public String getCommentTitle() 79 { 80 return title.getTitle(); 81 } 82 83 public void setContent(String txt) 84 { 85 content.setContent(txt); 86 } 87 88 public String getContent() 89 { 90 return content.getContent(); 91 } 92 93 public Comment getComment() 94 { 95 return new Comment(note, Client.getInstance().getMyInfos().getName(), 96 getCommentTitle(), getContent()); 97 } 98 } | Popular Tags |