KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > notes > gui > main > MyListSelectionListener


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.main;
21
22 import org.lucane.applications.notes.*;
23
24 import javax.swing.*;
25 import javax.swing.event.*;
26
27 class MyListSelectionListener implements ListSelectionListener
28 {
29     private NotesPlugin plugin;
30     private MainFrame parent;
31
32     public MyListSelectionListener(NotesPlugin plugin, MainFrame parent)
33     {
34         this.plugin = plugin;
35         this.parent = parent;
36     }
37
38     public void valueChanged(ListSelectionEvent lse)
39     {
40         JList source = (JList)lse.getSource();
41         String JavaDoc sourceName = source.getName();
42
43         if (sourceName.equals("authors"))
44         {
45             Object JavaDoc author = source.getSelectedValue();
46             if(author != null)
47             {
48                 if(author instanceof SpecialElement)
49                 {
50                     SpecialElement elem = (SpecialElement)author;
51                     if(elem.getName().equals("recentNotes"))
52                         parent.setNotes(plugin.getRecentPublishedNotes());
53                     else if(elem.getName().equals("myNotes"))
54                         parent.setNotes(plugin.getPersonnalNotes());
55                 }
56                 else
57                     parent.setNotes(plugin.getPublishedNotesByAuthor((String JavaDoc)author));
58             }
59             else
60                 parent.setNotes(plugin.getRecentPublishedNotes());
61         }
62         else if (sourceName.equals("notes"))
63         {
64             Note note = (Note)source.getSelectedValue();
65             if(note != null)
66             {
67                 parent.setNoteContent(note.getContent());
68                 parent.setComments(plugin.getCommentsForNote(note.getId()));
69             }
70             else
71             {
72                 parent.setNoteContent(null);
73                 parent.setComments(new Object JavaDoc[0]);
74             }
75         }
76     }
77 }
78
Popular Tags