KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > notes > gui > note > NoteFrame


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.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 JavaDoc txt)
74     {
75         content.setTitle(txt);
76     }
77     
78     public String JavaDoc 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 JavaDoc txt)
104     {
105         content.setCreationDate(txt);
106     }
107     
108     public void setEditionDate(String JavaDoc txt)
109     {
110         content.setEditionDate(txt);
111     }
112     
113     public void setContent(String JavaDoc txt)
114     {
115         content.setContent(txt);
116     }
117     
118     public String JavaDoc 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