001: /*
002: * Lucane - a collaborative platform
003: * Copyright (C) 2005 Vincent Fiack <vfiack@mail15.com>
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019:
020: package org.lucane.applications.sharedfolder.gui;
021:
022: import org.lucane.applications.sharedfolder.SharedFolderPlugin;
023: import org.lucane.applications.sharedfolder.gui.actions.*;
024:
025: import javax.swing.*;
026: import javax.swing.event.ListSelectionListener;
027: import javax.swing.event.ListSelectionEvent;
028: import javax.swing.event.TableModelListener;
029: import javax.swing.event.TableModelEvent;
030: import java.awt.event.MouseListener;
031: import java.awt.event.MouseEvent;
032: import java.awt.event.KeyListener;
033: import java.awt.event.KeyEvent;
034:
035: public class FolderTableListener implements MouseListener, KeyListener,
036: ListSelectionListener, TableModelListener {
037: private SharedFolderPlugin plugin;
038: private JTable table;
039: private ActionToolBar toolbar;
040: private boolean history;
041:
042: public FolderTableListener(SharedFolderPlugin plugin, JTable table,
043: ActionToolBar toolbar) {
044: this .plugin = plugin;
045: this .table = table;
046: this .toolbar = toolbar;
047: this .history = toolbar.isHistory();
048: }
049:
050: public void mouseEntered(MouseEvent e) {
051: }
052:
053: public void mouseExited(MouseEvent e) {
054: }
055:
056: public void mousePressed(MouseEvent e) {
057: }
058:
059: public void mouseReleased(MouseEvent e) {
060: }
061:
062: public void mouseClicked(MouseEvent me) {
063: if (me.getClickCount() == 2) {
064: new DownloadAction(plugin, table, history)
065: .actionPerformed(null);
066: new OpenFolderAction(plugin, table, history)
067: .actionPerformed(null);
068: }
069: }
070:
071: public void keyReleased(KeyEvent e) {
072: }
073:
074: public void keyTyped(KeyEvent e) {
075: }
076:
077: public void keyPressed(KeyEvent ke) {
078: if (ke.getKeyCode() == KeyEvent.VK_BACK_SPACE)
079: new OpenParentAction(plugin, table, history)
080: .actionPerformed(null);
081: else if (ke.getKeyCode() == KeyEvent.VK_DELETE)
082: new RemoveAction(plugin, table, history)
083: .actionPerformed(null);
084: else if (ke.getKeyCode() == KeyEvent.VK_F2)
085: new RenameAction(plugin, table, history)
086: .actionPerformed(null);
087: else if (ke.getKeyCode() == KeyEvent.VK_F5)
088: new RefreshAction(plugin, table, history)
089: .actionPerformed(null);
090: else if (ke.getKeyCode() == KeyEvent.VK_F7)
091: new CreateFolderAction(plugin, table, history)
092: .actionPerformed(null);
093: else if (ke.getKeyCode() == KeyEvent.VK_H)
094: new HistoryAction(plugin, table, history)
095: .actionPerformed(null);
096: else if (ke.getKeyCode() == KeyEvent.VK_ENTER) {
097: new DownloadAction(plugin, table, history)
098: .actionPerformed(null);
099: new OpenFolderAction(plugin, table, history)
100: .actionPerformed(null);
101: }
102: }
103:
104: public void valueChanged(ListSelectionEvent e) {
105: toolbar.refresh();
106: }
107:
108: public void tableChanged(TableModelEvent e) {
109: toolbar.refresh();
110: }
111: }
|