KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > notes > gui > comment > CommentFrame


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2003 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

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 JavaDoc txt)
74     {
75         title.setTitle(txt);
76     }
77     
78     public String JavaDoc getCommentTitle()
79     {
80         return title.getTitle();
81     }
82     
83     public void setContent(String JavaDoc txt)
84     {
85         content.setContent(txt);
86     }
87     
88     public String JavaDoc 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