📄 xfilepopup.java
字号:
/** * File and FTP Explorer * Copyright 2002 * BOESCH Vincent * * 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 javaexplorer.gui.menu;import java.awt.*;import java.awt.event.*;import javaexplorer.Launcher;import javaexplorer.gui.listener.*;import javaexplorer.model.*;import javaexplorer.ressource.*;import javax.swing.*;/** *@author BOESCH Vincent *@created 21 janvier 2002 *@version 3.3 */public class XFilePopup extends JPopupMenu implements ActionListener { private JMenuItem _jmiAddShortcut = new JMenuItem(TextRessource.MAINFRAME_MENU_ADD_SHORTCUT, ImageRessource.iiAdd); private JMenuItem _jmiCopy = new JMenuItem(TextRessource.MAINFRAME_GLOBAL_COPY, ImageRessource.iiCopyThb); private JMenuItem _jmiDelete = new JMenuItem(TextRessource.MAINFRAME_MENU_DELETE, ImageRessource.iiDeleteThb); private JMenuItem _jmiFake = new JMenuItem(); private JMenuItem _jmiInfo = new JMenuItem(TextRessource.MAINFRAME_GLOBAL_INFO, ImageRessource.iiInfoThb); private JMenuItem _jmiMove = new JMenuItem(TextRessource.MAINFRAME_GLOBAL_MOVE, ImageRessource.iiCutThb); private JMenuItem _jmiNewDir = new JMenuItem(TextRessource.MAINFRAME_MENU_CREATEDIR, ImageRessource.iiNewFolderThb); private JMenuItem _jmiOpen = new JMenuItem(TextRessource.MAINFRAME_MENU_OPEN, ImageRessource.iiProcessThb); private JMenuItem _jmiPaste = new JMenuItem(TextRessource.MAINFRAME_MENU_PASTE, ImageRessource.iiPasteThb); private JMenuItem _jmiRename = new JMenuItem(TextRessource.MAINFRAME_MENU_RENAME, ImageRessource.iiRenameThb); private Launcher _launcher = null; private XFile[] _tb_xf = null; private MenuListener ml = new MenuListener(); /** * Constructeur objet XFilePopup * *@param launcher Description of the * Parameter */ public XFilePopup(Launcher launcher) { super(); _launcher = launcher; setBorderPainted(true); _jmiOpen.addActionListener(this); _jmiOpen.addMouseListener(ml); _jmiCopy.addActionListener(this); _jmiCopy.addMouseListener(ml); _jmiMove.addActionListener(this); _jmiMove.addMouseListener(ml); _jmiPaste.addActionListener(this); _jmiPaste.addMouseListener(ml); _jmiDelete.addActionListener(this); _jmiDelete.addMouseListener(ml); _jmiNewDir.addActionListener(this); _jmiNewDir.addMouseListener(ml); _jmiRename.addActionListener(this); _jmiRename.addMouseListener(ml); _jmiAddShortcut.addActionListener(this); _jmiAddShortcut.addMouseListener(ml); _jmiInfo.addActionListener(this); _jmiInfo.addMouseListener(ml); _jmiFake.addActionListener(this); Font f = _jmiFake.getFont(); _jmiFake.setFont(new Font(f.getName(), Font.BOLD, f.getSize() + 1)); add(_jmiFake); addSeparator(); add(_jmiOpen); addSeparator(); add(_jmiNewDir); add(_jmiRename); addSeparator(); add(_jmiCopy); add(_jmiMove); add(_jmiPaste); add(_jmiDelete); addSeparator(); add(_jmiAddShortcut); add(_jmiInfo); } /** * Description de la methode * *@param e Description of the Parameter */ public void actionPerformed(ActionEvent e) { Object obj = e.getSource(); if (obj == _jmiAddShortcut) { for (int i = 0; i < _tb_xf.length; i++) { _launcher.getMenuModel().shortcutFile(_tb_xf[i]); } } if (obj == _jmiNewDir) { if (_tb_xf[0].isDirectory() && (_tb_xf.length == 1)) { _launcher.getXUtil().makeNewDir(_tb_xf[0]); } else { _launcher.getXUtil().makeNewDir(_tb_xf[0].getXParent()); } } else if (obj == _jmiRename) { _launcher.getXUtil().rename(_tb_xf); } else if (obj == _jmiOpen) { _launcher.getFileModel().processXFileBuffer(_tb_xf); } else if (obj == _jmiCopy) { _launcher.getFileModel().getSelectBuffer().set(_tb_xf); _launcher.getMDIModel().updateStatus(); _launcher.getFileModel().copySelected(false); } else if (obj == _jmiMove) { _launcher.getFileModel().getSelectBuffer().set(_tb_xf); _launcher.getMDIModel().updateStatus(); _launcher.getFileModel().copySelected(true); } else if (obj == _jmiPaste) { if (_tb_xf.length == 1) { if (_tb_xf[0].isDirectory()) { _launcher.getFileModel().setCurrentDir(_tb_xf[0]); } else { _launcher.getFileModel().setCurrentDir(_tb_xf[0].getXParent()); } } else { _launcher.getFileModel().setCurrentDir(_tb_xf[0].getXParent()); } _launcher.getFileModel().performCopyOrMove(); } else if (obj == _jmiDelete) { _launcher.getFileModel().getSelectBuffer().set(_tb_xf); _launcher.getMDIModel().updateStatus(); _launcher.getFileModel().performDelete(); } else if (obj == _jmiInfo) { _launcher.getMDIModel().makeXFilesInfoFrame(_tb_xf); } this.setVisible(false); } /** * Description de la methode */ public void refreshLanguage() { _jmiOpen.setText(TextRessource.MAINFRAME_MENU_OPEN); _jmiCopy.setText(TextRessource.MAINFRAME_GLOBAL_COPY); _jmiMove.setText(TextRessource.MAINFRAME_GLOBAL_MOVE); _jmiPaste.setText(TextRessource.MAINFRAME_MENU_PASTE); _jmiDelete.setText(TextRessource.MAINFRAME_MENU_DELETE); _jmiNewDir.setText(TextRessource.MAINFRAME_MENU_CREATEDIR); _jmiRename.setText(TextRessource.MAINFRAME_MENU_RENAME); _jmiAddShortcut.setText(TextRessource.MAINFRAME_MENU_ADD_SHORTCUT); _jmiInfo.setText(TextRessource.MAINFRAME_GLOBAL_INFO); } /** * Sets the launcher attribute of the * XFilePopup object * *@param launcher The new launcher value */ public void setLauncher(Launcher launcher) { _launcher = launcher; } /** * Sets the xFiles attribute of the XFilePopup * object * *@param tb_xf The new xFiles value */ public void setXFiles(XFile[] tb_xf) { _tb_xf = tb_xf; if (_tb_xf == null) { return; } _jmiOpen.setEnabled(false); if (_tb_xf.length == 1) { String name = _tb_xf[0].getName(); if ((name == null) || (name.length() == 0)) { name = _tb_xf[0].toString(); } _jmiFake.setText(name); _jmiOpen.setEnabled(_tb_xf[0].canRead()); } else { _jmiFake.setText(TextRessource.MAINFRAME_GLOBAL_SELECTION); } if (_launcher.getFileModel().getCopyMoveBuffer().length() <= 0) { _jmiPaste.setEnabled(false); } else { _jmiPaste.setEnabled(true); } setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -