1 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 sourceName = source.getName(); 42 43 if (sourceName.equals("authors")) 44 { 45 Object 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 )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 [0]); 74 } 75 } 76 } 77 } 78 | Popular Tags |