1 19 20 package org.lucane.applications.sharedfolder.gui; 21 22 import org.lucane.applications.sharedfolder.SharedFolderPlugin; 23 import org.lucane.applications.sharedfolder.gui.actions.*; 24 25 import javax.swing.*; 26 import javax.swing.event.ListSelectionListener ; 27 import javax.swing.event.ListSelectionEvent ; 28 import javax.swing.event.TableModelListener ; 29 import javax.swing.event.TableModelEvent ; 30 import java.awt.event.MouseListener ; 31 import java.awt.event.MouseEvent ; 32 import java.awt.event.KeyListener ; 33 import java.awt.event.KeyEvent ; 34 35 public class FolderTableListener 36 implements MouseListener , KeyListener , ListSelectionListener , TableModelListener 37 { 38 private SharedFolderPlugin plugin; 39 private JTable table; 40 private ActionToolBar toolbar; 41 private boolean history; 42 43 public FolderTableListener(SharedFolderPlugin plugin, JTable table, ActionToolBar toolbar) 44 { 45 this.plugin = plugin; 46 this.table = table; 47 this.toolbar = toolbar; 48 this.history = toolbar.isHistory(); 49 } 50 51 public void mouseEntered(MouseEvent e) {} 52 public void mouseExited(MouseEvent e) {} 53 public void mousePressed(MouseEvent e) {} 54 public void mouseReleased(MouseEvent e) {} 55 public void mouseClicked(MouseEvent me) 56 { 57 if(me.getClickCount() == 2) 58 { 59 new DownloadAction(plugin, table, history).actionPerformed(null); 60 new OpenFolderAction(plugin, table, history).actionPerformed(null); 61 } 62 } 63 64 public void keyReleased(KeyEvent e) {} 65 public void keyTyped(KeyEvent e) {} 66 public void keyPressed(KeyEvent ke) 67 { 68 if(ke.getKeyCode() == KeyEvent.VK_BACK_SPACE) 69 new OpenParentAction(plugin, table, history).actionPerformed(null); 70 else if(ke.getKeyCode() == KeyEvent.VK_DELETE) 71 new RemoveAction(plugin, table, history).actionPerformed(null); 72 else if(ke.getKeyCode() == KeyEvent.VK_F2) 73 new RenameAction(plugin, table, history).actionPerformed(null); 74 else if(ke.getKeyCode() == KeyEvent.VK_F5) 75 new RefreshAction(plugin, table, history).actionPerformed(null); 76 else if(ke.getKeyCode() == KeyEvent.VK_F7) 77 new CreateFolderAction(plugin, table, history).actionPerformed(null); 78 else if(ke.getKeyCode() == KeyEvent.VK_H) 79 new HistoryAction(plugin, table, history).actionPerformed(null); 80 else if(ke.getKeyCode() == KeyEvent.VK_ENTER) 81 { 82 new DownloadAction(plugin, table, history).actionPerformed(null); 83 new OpenFolderAction(plugin, table, history).actionPerformed(null); 84 } 85 } 86 87 public void valueChanged(ListSelectionEvent e) { 88 toolbar.refresh(); 89 } 90 91 public void tableChanged(TableModelEvent e) { 92 toolbar.refresh(); 93 } 94 } | Popular Tags |