KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > sharedfolder > gui > FolderTableListener


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2005 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.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 JavaDoc;
27 import javax.swing.event.ListSelectionEvent JavaDoc;
28 import javax.swing.event.TableModelListener JavaDoc;
29 import javax.swing.event.TableModelEvent JavaDoc;
30 import java.awt.event.MouseListener JavaDoc;
31 import java.awt.event.MouseEvent JavaDoc;
32 import java.awt.event.KeyListener JavaDoc;
33 import java.awt.event.KeyEvent JavaDoc;
34
35 public class FolderTableListener
36 implements MouseListener JavaDoc, KeyListener JavaDoc, ListSelectionListener JavaDoc, TableModelListener JavaDoc
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 JavaDoc e) {}
52     public void mouseExited(MouseEvent JavaDoc e) {}
53     public void mousePressed(MouseEvent JavaDoc e) {}
54     public void mouseReleased(MouseEvent JavaDoc e) {}
55     public void mouseClicked(MouseEvent JavaDoc 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 JavaDoc e) {}
65     public void keyTyped(KeyEvent JavaDoc e) {}
66     public void keyPressed(KeyEvent JavaDoc 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 JavaDoc e) {
88         toolbar.refresh();
89     }
90
91     public void tableChanged(TableModelEvent JavaDoc e) {
92         toolbar.refresh();
93     }
94 }
Popular Tags