⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 juploadfilechooser.java

📁 [linux.rar] - 嵌入式linux开发教程
💻 JAVA
字号:
//
// $Id: JUploadPanel.java 205 2007-05-28 20:24:01 +0000 (lun., 28 mai 2007)
// felfert $
//
// jupload - A file upload applet.
// Copyright 2007 The JUpload Team
//
// Created: ?
// Creator: etienne_sf
// Last modified: $Date: 2007-05-28 20:24:01 +0000 (lun., 28 mai 2007) $
//
// 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.,
// 675 Mass Ave, Cambridge, MA 02139, USA.

package wjhk.jupload2.gui;

import java.io.File;

import javax.swing.JFileChooser;

import wjhk.jupload2.policies.UploadPolicy;

/**
 * This class allows easy personalization of the java file chooser. It asks the
 * current upload policy for all current configuration parameters. It is created
 * by the {@link JUploadPanel} class.
 */
public class JUploadFileChooser extends JFileChooser {

    // /////////////////////////////////////////////////////////////////////////////////////////////////////
    // /////////////////////////////// Attributes
    // /////////////////////////////////////////////////////////////////////////////////////////////////////

    /** A generated serialVersionUID, to avoid warning during compilation */
    private static final long serialVersionUID = 6829111419069956687L;

    /** The current upload policy */
    private UploadPolicy uploadPolicy = null;

    private JUploadFileFilter fileFilter = null;

    /** This file view add picture management capabilities to the file chooser */
    private JUploadFileView fileView = null;

    // /////////////////////////////////////////////////////////////////////////////////////////////////////
    // /////////////////////////////// Methods
    // /////////////////////////////////////////////////////////////////////////////////////////////////////

    /**
     * The 'standard' constructor for our file chooser
     * 
     * @param uploadPolicyParam
     */
    public JUploadFileChooser(UploadPolicy uploadPolicyParam) {
        this.uploadPolicy = uploadPolicyParam;

        this.fileFilter = new JUploadFileFilter(this.uploadPolicy);
        this.fileView = new JUploadFileView(this.uploadPolicy, this);

        // TODO This breaks usability. probably use a persistent value of a
        // cookie later.
        // this.fileChooser.setCurrentDirectory(new File(System
        // .getProperty("user.dir")));
        setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        setMultiSelectionEnabled(true);

        // The current Directory can controlled by the applet
        File currentDirectory = this.uploadPolicy.getCurrentBrowsingDirectory();
        if (currentDirectory != null) {
            setCurrentDirectory(currentDirectory);
        }

        // Hidden file should not be visible.
        setFileHidingEnabled(true);

        // The file view must be set, whether or not a file filter exists
        // for this upload policy.
        setFileView(this.fileView);
        if (this.uploadPolicy.fileFilterGetDescription() != null) {
            setFileFilter(this.fileFilter);
            // If a file filter has been given to the applet, only these file
            // should be allowed.
            setAcceptAllFileFilterUsed(false);
        }
    }

    /**
     * Shutdown any running task. Currently, only the JUploadFileView may have
     * running tasks, when calculating icon for picture files.
     */
    public void shutdownNow() {
        this.fileView.shutdownNow();
    }

    /**
     * This method is called when the file chooser is closed. We just shutdown
     * any running job.
     */
    public void approveSelection() {
        shutdownNow();
        super.approveSelection();
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -