1 // 2 // $Id$ 3 // 4 // jupload - A file upload applet. 5 // 6 // Copyright 2007 The JUpload Team 7 // 8 // Created: 10 oct. 07 9 // Creator: etienne_sf 10 // Last modified: $Date$ 11 // 12 // This program is free software; you can redistribute it and/or modify 13 // it under the terms of the GNU General Public License as published by 14 // the Free Software Foundation; either version 2 of the License, or 15 // (at your option) any later version. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of the GNU General Public License 23 // along with this program; if not, write to the Free Software 24 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 26 package wjhk.jupload2.policies; 27 28 import java.awt.BorderLayout; 29 import java.awt.GridLayout; 30 import java.awt.dnd.DropTargetDropEvent; 31 32 import wjhk.jupload2.context.JUploadContext; 33 import wjhk.jupload2.exception.JUploadException; 34 import wjhk.jupload2.gui.JUploadPanel; 35 36 /** 37 * 38 * Upload policy that is a simple box. It's a 'simple' drop target. Upload 39 * starts immediately, when files are dropped on the applet. <BR> 40 * The only component displayed on the applet is the progress bar. 41 * 42 * @author etienne_sf 43 * 44 */ 45 public class FilesTogetherUploadPolicy extends DefaultUploadPolicy { 46 47 /** 48 * The JUpload constructor for this upload policy. Like all upload policies, 49 * this constructor is called by the {@link UploadPolicyFactory} 50 * 51 * @param juploadContext 52 * @throws JUploadException 53 */ 54 public FilesTogetherUploadPolicy(JUploadContext juploadContext) 55 throws JUploadException { 56 super(juploadContext); 57 } 58 59 /** 60 * This methods allow the upload policy to override the default disposition 61 * of the components on the applet. 62 * 63 * @see UploadPolicy#addComponentsToJUploadPanel(JUploadPanel) 64 */ 65 66 @Override 67 public void addComponentsToJUploadPanel(JUploadPanel jUploadPanel) { 68 // Set the global layout of the panel. 69 jUploadPanel.getJComponent().setLayout(new GridLayout(1, 1)); 70 jUploadPanel.getJComponent().setLayout(new BorderLayout()); 71 // Then, add on the screen of the only component that is visible. 72 jUploadPanel.getJComponent().add(jUploadPanel.getUploadProgressBar(), 73 BorderLayout.CENTER); 74 // Now, we add the log window. 75 jUploadPanel.showOrHideLogWindow(); 76 jUploadPanel.getJComponent().add(jUploadPanel.getJLogWindowPane(), 77 BorderLayout.SOUTH); 78 } 79 80 /** 81 * Default reaction after a successful drop operation: no action. 82 * 83 * @see UploadPolicy#afterFileDropped(DropTargetDropEvent) 84 */ 85 86 @Override 87 public void afterFileDropped(DropTargetDropEvent dropEvent) { 88 getContext().getUploadPanel().doStartUpload(); 89 } 90 91 }