001/* 002 * #%L 003 * GwtMaterial 004 * %% 005 * Copyright (C) 2015 - 2017 GwtMaterialDesign 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package gwt.material.design.addins.client.fileuploader.base; 021 022import com.google.gwt.event.shared.HandlerRegistration; 023import com.google.gwt.event.shared.HasHandlers; 024import gwt.material.design.addins.client.fileuploader.events.*; 025 026public interface HasFileUpload<T> extends HasHandlers { 027 028 /** 029 * When a file is added to the list. 030 */ 031 HandlerRegistration addAddedFileHandler(AddedFileEvent.AddedFileHandler<T> handler); 032 033 /** 034 * Called whenever a file is removed from the list. 035 * You can listen to this and delete the file from your server if you want to. 036 */ 037 HandlerRegistration addRemovedFileHandler(RemovedFileEvent.RemovedFileHandler<T> handler); 038 039 /** 040 * An error occured. Receives the errorMessage as second parameter and if 041 * the error was due to the XMLHttpRequest the xhr object as third. 042 */ 043 HandlerRegistration addErrorHandler(ErrorEvent.ErrorHandler<T> handler); 044 045 /** 046 * An unauthorized error occured. Probably because of session expiration. 047 * Receives the errorMessage as second parameter and if the error was due to 048 * the XMLHttpRequest the xhr object as third. 049 */ 050 HandlerRegistration addUnauthorizedHandler(UnauthorizedEvent.UnauthorizedHandler<T> handler); 051 052 /** 053 * Called with the total uploadProgress (0-100). This event can be used 054 * to show the overall upload progress of all files. 055 */ 056 HandlerRegistration addTotalUploadProgressHandler(TotalUploadProgressEvent.TotalUploadProgressHandler handler); 057 058 /** 059 * Gets called periodically whenever the file upload progress changes. 060 */ 061 HandlerRegistration addCurrentUploadProgressHandler(CurrentUploadProgressEvent.CurrentUploadProgressHandler handler); 062 063 /** 064 * Called just before each file is sent. 065 * Gets the xhr object and the formData objects as second and third parameters, 066 * so you can modify them (for example to add a CSRF token) or add additional data. 067 */ 068 HandlerRegistration addSendingHandler(SendingEvent.SendingHandler<T> handler); 069 070 /** 071 * The file has been uploaded successfully. 072 * Gets the server response as second argument.(This event was called finished previously). 073 */ 074 HandlerRegistration addSuccessHandler(SuccessEvent.SuccessHandler<T> handler); 075 076 /** 077 * Called when the upload was either successful or erroneous. 078 */ 079 HandlerRegistration addCompleteHandler(CompleteEvent.CompleteHandler<T> handler); 080 081 /** 082 * Called when a file upload gets canceled. 083 */ 084 HandlerRegistration addCancelHandler(CanceledEvent.CanceledHandler<T> handler); 085 086 /** 087 * Called when the number of files accepted reaches the maxFiles limit. 088 */ 089 HandlerRegistration addMaxFilesReachHandler(MaxFilesReachedEvent.MaxFilesReachedHandler<T> handler); 090 091 /** 092 * Called for each file that has been rejected because the number of files exceeds the maxFiles limit. 093 */ 094 HandlerRegistration addMaxFilesExceededHandler(MaxFilesExceededEvent.MaxFilesExceededHandler<T> handler); 095}