/**
* Copyright (C) 2003 Alexander Kout
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package de.kout.wlFxp.view;
import javax.swing.*;
import java.awt.event.*;
import de.kout.wlFxp.ftp.FtpFile;
/**
* the context menu for the view
*
*@author Alexander Kout
*@created 30. M�rz 2002
*/
public class ViewContextMenu
extends JPopupMenu
implements ActionListener {
MainPanel panel;
/**
* Constructor for the ListContextMenu object
*
*@param panel Description of Parameter
*/
public ViewContextMenu(MainPanel panel) {
this.panel = panel;
// open
JMenuItem mi;
mi = new JMenuItem("transfer");
mi.addActionListener(this);
add(mi);
// queue
mi = new JMenuItem("queue");
mi.addActionListener(this);
add(mi);
// Separator
addSeparator();
if (panel.mode == panel.LOCAL) {
mi = new JMenuItem("open");
mi.addActionListener(this);
add(mi);
}
// Delete
mi = new JMenuItem("delete");
mi.addActionListener(this);
add(mi);
// rename
mi = new JMenuItem("Rename");
mi.addActionListener(this);
add(mi);
if (panel.mode == panel.FTP) {
// command
addSeparator();
// add(panel.commandsMenu);
add(new CommandsMenu(null, panel));
}
addSeparator();
// Makedir
mi = new JMenuItem("Make Directory");
mi.addActionListener(this);
add(mi);
addSeparator();
mi = new JMenuItem("refresh");
mi.addActionListener(this);
add(mi);
}
/**
* Description of the Method
*
*@param e Description of Parameter
*/
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if (cmd.equals("delete")) {
panel.delete(e);
} else if (cmd.equals("Make Directory")) {
new InputDialog(panel, "Make", "newdir", false);
} else if (cmd.equals("do command")) {
new InputDialog(panel, "Command", "stat", false);
} else if (cmd.equals("queue")) {
panel.addTransfers();
} else if (cmd.equals("open")) {
panel.open();
} else if (cmd.equals("Rename")) {
int row = panel.view.getSelectedIndex();
if (row == 0)
return;
FtpFile entry = (FtpFile) panel.view.getElementAt(row);
panel.renameFile = entry;
new InputDialog(panel, "Rename", entry.getName(), false);
} else if (cmd.equals("refresh")) {
panel.updateView();
} else if (cmd.equals("transfer")) {
panel.addTransfers();
panel.frame.transfer();
}
}
}