source: 3thparty/jupload/src/main/java/wjhk/jupload2/gui/JUploadFileChooser.java @ 3951

Revision 3951, 4.0 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #1709 - Adicao de codigo fonte java do componente jupload

Line 
1//
2// $Id: JUploadPanelImpl.java 205 2007-05-28 20:24:01 +0000 (lun., 28 mai 2007)
3// felfert $
4//
5// jupload - A file upload applet.
6// Copyright 2007 The JUpload Team
7//
8// Created: ?
9// Creator: etienne_sf
10// Last modified: $Date: 2007-05-28 20:24:01 +0000 (lun., 28 mai 2007) $
11//
12// This program is free software; you can redistribute it and/or modify it under
13// the terms of the GNU General Public License as published by the Free Software
14// Foundation; either version 2 of the License, or (at your option) any later
15// version. This program is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18// details. You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software Foundation, Inc.,
20// 675 Mass Ave, Cambridge, MA 02139, USA.
21
22package wjhk.jupload2.gui;
23
24import javax.swing.JFileChooser;
25
26import wjhk.jupload2.policies.UploadPolicy;
27
28/**
29 * This class allows easy personalization of the java file chooser. It asks the
30 * current upload policy for all current configuration parameters. It is created
31 * by the {@link JUploadPanel} instances.
32 */
33@SuppressWarnings("serial")
34public class JUploadFileChooser extends JFileChooser {
35
36    // /////////////////////////////////////////////////////////////////////////////////////////////////////
37    // /////////////////////////////// Attributes
38    // /////////////////////////////////////////////////////////////////////////////////////////////////////
39
40    /** The current upload policy */
41    private UploadPolicy uploadPolicy = null;
42
43    private JUploadFileFilter fileFilter = null;
44
45    /** This file view add picture management capabilities to the file chooser */
46    private JUploadFileView fileView = null;
47
48    // /////////////////////////////////////////////////////////////////////////////////////////////////////
49    // /////////////////////////////// Methods
50    // /////////////////////////////////////////////////////////////////////////////////////////////////////
51
52    /**
53     * The 'standard' constructor for our file chooser
54     *
55     * @param uploadPolicyParam
56     */
57    public JUploadFileChooser(UploadPolicy uploadPolicyParam) {
58        super(uploadPolicyParam.getCurrentBrowsingDirectory());
59
60        uploadPolicyParam.displayDebug(
61                "Starting JUploadFileChooser constructor", 80);
62        this.uploadPolicy = uploadPolicyParam;
63
64        this.fileFilter = new JUploadFileFilter(this.uploadPolicy);
65        this.fileView = new JUploadFileView(this.uploadPolicy, this);
66
67        // TODO This breaks usability. probably use a persistent value of a
68        // cookie later.
69        // this.fileChooser.setCurrentDirectory(new File(System
70        // .getProperty("user.dir")));
71        setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
72        setMultiSelectionEnabled(true);
73
74        // Hidden file should not be visible.
75        setFileHidingEnabled(true);
76
77        // The file view must be set, whether or not a file filter exists
78        // for this upload policy.
79        setFileView(this.fileView);
80        if (this.uploadPolicy.fileFilterGetDescription() != null) {
81            setFileFilter(this.fileFilter);
82            // If a file filter has been given to the applet, only these file
83            // should be allowed.
84            setAcceptAllFileFilterUsed(false);
85        }
86    }
87
88    /**
89     * Shutdown any running task. Currently, only the JUploadFileView may have
90     * running tasks, when calculating icon for picture files.
91     */
92    public void shutdownNow() {
93        this.fileView.shutdownNow();
94    }
95
96    /**
97     * This method is called when the file chooser is closed. We just shutdown
98     * any running job.
99     */
100    @Override
101    public void approveSelection() {
102        shutdownNow();
103        super.approveSelection();
104    }
105
106}
Note: See TracBrowser for help on using the repository browser.