Refactor with enum WS_UPLOAD_TYPE
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@119431 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
365b683889
commit
3620e1483e
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WsPortletInitOperation;
|
||||
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEventHandler;
|
||||
|
@ -42,7 +43,6 @@ import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent.UploadType;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.FilterScopeEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.FilterScopeEventHandler;
|
||||
|
@ -1123,26 +1123,19 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
doFileUploadEvent(fileUploadEvent);
|
||||
}
|
||||
|
||||
private void doFileUploadEvent(FileUploadEvent fileUploadEvent) {
|
||||
private void doFileUploadEvent(final FileUploadEvent fileUploadEvent) {
|
||||
GWT.log("FileUploadEvent...");
|
||||
FileModel folder = fileUploadEvent.getTargetFolderModel();
|
||||
|
||||
if(folder == null)
|
||||
folder = explorerPanel.getAsycTreePanel().getRootItem();
|
||||
|
||||
String uploadType = null;
|
||||
if(fileUploadEvent.getUploadTypeToString().equals(UploadType.ARCHIVE.toString())){
|
||||
uploadType = ConstantsExplorer.ARCHIVE;
|
||||
}else{
|
||||
uploadType = ConstantsExplorer.FILE;
|
||||
}
|
||||
|
||||
String caption = "Upload ";
|
||||
UPLOAD_TYPE upType = UPLOAD_TYPE.File;
|
||||
if(uploadType.compareTo(ConstantsExplorer.ARCHIVE)==0){
|
||||
if(fileUploadEvent.getUploadType().compareTo(WS_UPLOAD_TYPE.Archive)==0){
|
||||
caption+= " a zip Archive";
|
||||
upType = UPLOAD_TYPE.Archive;
|
||||
}else if(uploadType.compareTo(ConstantsExplorer.FILE)==0){
|
||||
}else if(fileUploadEvent.getUploadType().compareTo(WS_UPLOAD_TYPE.File)==0){
|
||||
caption+= "File";
|
||||
upType = UPLOAD_TYPE.File;
|
||||
}
|
||||
|
@ -1150,13 +1143,12 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
caption+= " in: "+folder.getName();
|
||||
|
||||
MultipleDilaogUpload uploadStream = new MultipleDilaogUpload(caption, folder.getIdentifier(), upType);
|
||||
final String type = uploadType;
|
||||
WorskpaceUploadNotificationListener listener = new WorskpaceUploadNotificationListener() {
|
||||
|
||||
@Override
|
||||
public void onUploadCompleted(String parentId, String itemId) {
|
||||
GWT.log("Upload completed: [parentID: "+parentId+", itemId: "+itemId+", uploadType: "+type+"]");
|
||||
eventBus.fireEvent(new CompletedFileUploadEvent(parentId, itemId, type));
|
||||
GWT.log("Upload completed: [parentID: "+parentId+", itemId: "+itemId+", uploadType: "+fileUploadEvent.getUploadType()+"]");
|
||||
eventBus.fireEvent(new CompletedFileUploadEvent(parentId, itemId, fileUploadEvent.getUploadType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1976,7 +1968,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
|
||||
CreateUrlEvent createUrlEvent = (CreateUrlEvent) event;
|
||||
|
||||
sub.addedFile(createUrlEvent.getItemIdentifier(), createUrlEvent.getParentFileModel(), ConstantsExplorer.FILE);
|
||||
sub.addedFile(createUrlEvent.getItemIdentifier(), createUrlEvent.getParentFileModel(), WS_UPLOAD_TYPE.File);
|
||||
|
||||
}else if(event instanceof MoveItemEvent){
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ public class ConstantsExplorer {
|
|||
public static final String MOVING = "Moving...";
|
||||
|
||||
public static final String FILEUPLOADHEADER = "File upload in: ";
|
||||
public static final String FILE = "File";
|
||||
public static final String ARCHIVE = "Archive";
|
||||
// public static final String FILE = "File";
|
||||
// public static final String ARCHIVE = "Archive";
|
||||
|
||||
public static enum WS_UPLOAD_TYPE {File, Archive};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
|
@ -18,9 +19,9 @@ public class CompletedFileUploadEvent extends GwtEvent<CompletedFileUploadEventH
|
|||
|
||||
private String itemIdentifier;
|
||||
private String parentId;
|
||||
private String uploadType;
|
||||
private WS_UPLOAD_TYPE uploadType;
|
||||
private FileModel parentModel;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new completed file upload event.
|
||||
*
|
||||
|
@ -28,7 +29,7 @@ public class CompletedFileUploadEvent extends GwtEvent<CompletedFileUploadEventH
|
|||
* @param itemIdentifier the item identifier
|
||||
* @param uploadType the upload type
|
||||
*/
|
||||
public CompletedFileUploadEvent(String parentId, String itemIdentifier, String uploadType) {
|
||||
public CompletedFileUploadEvent(String parentId, String itemIdentifier, WS_UPLOAD_TYPE uploadType) {
|
||||
this.parentId = parentId;
|
||||
this.itemIdentifier = itemIdentifier;
|
||||
this.uploadType = uploadType;
|
||||
|
@ -111,11 +112,12 @@ public class CompletedFileUploadEvent extends GwtEvent<CompletedFileUploadEventH
|
|||
public FileModel getParentModel() {
|
||||
return parentModel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the uploadType
|
||||
*/
|
||||
public String getUploadType() {
|
||||
public WS_UPLOAD_TYPE getUploadType() {
|
||||
return uploadType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,47 +1,73 @@
|
|||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class FileUploadEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Oct 6, 2015
|
||||
*/
|
||||
public class FileUploadEvent extends GwtEvent<FileUploadEventHandler> implements GuiEventInterface{
|
||||
public static Type<FileUploadEventHandler> TYPE = new Type<FileUploadEventHandler>();
|
||||
public enum UploadType {ARCHIVE, FILE};
|
||||
private FileModel targetFolder = null;
|
||||
private UploadType uploadType;
|
||||
private WS_UPLOAD_TYPE uploadType;
|
||||
|
||||
public FileUploadEvent(FileModel targetFolder, UploadType uploadType) {
|
||||
/**
|
||||
* Instantiates a new file upload event.
|
||||
*
|
||||
* @param targetFolder the target folder
|
||||
* @param uploadType the upload type
|
||||
*/
|
||||
public FileUploadEvent(FileModel targetFolder, WS_UPLOAD_TYPE uploadType) {
|
||||
this.targetFolder = targetFolder;
|
||||
this.uploadType = uploadType;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<FileUploadEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(FileUploadEventHandler handler) {
|
||||
handler.onFileUploadEvent(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
||||
*/
|
||||
@Override
|
||||
public EventsTypeEnum getKey() {
|
||||
return EventsTypeEnum.FILE_UPLOAD_EVENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target folder model.
|
||||
*
|
||||
* @return the target folder model
|
||||
*/
|
||||
public FileModel getTargetFolderModel() {
|
||||
return targetFolder;
|
||||
}
|
||||
|
||||
public UploadType getUploadType() {
|
||||
/**
|
||||
* Gets the upload type.
|
||||
*
|
||||
* @return the upload type
|
||||
*/
|
||||
public WS_UPLOAD_TYPE getUploadType() {
|
||||
return uploadType;
|
||||
}
|
||||
|
||||
public String getUploadTypeToString() {
|
||||
return uploadType.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.ViewSwitchType;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
||||
|
@ -19,14 +20,15 @@ import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
|||
*/
|
||||
public interface SubscriberInterface {
|
||||
|
||||
|
||||
/**
|
||||
* Added file.
|
||||
*
|
||||
* @param itemIdentifier the item identifier
|
||||
* @param parent the parent
|
||||
* @param uploadType the upload type
|
||||
* @param file the file
|
||||
*/
|
||||
void addedFile(String itemIdentifier, FileModel parent, String uploadType);
|
||||
void addedFile(String itemIdentifier, FileModel parent, WS_UPLOAD_TYPE file);
|
||||
|
||||
/**
|
||||
* Selected item.
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
|
||||
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent;
|
||||
|
@ -18,7 +19,6 @@ import org.gcube.portlets.user.workspace.client.event.EditUserPermissionEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.FileUploadEvent.UploadType;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||
|
@ -534,7 +534,7 @@ public class ContextMenuTree {
|
|||
for (final FileModel sel : listSelectedItems) {
|
||||
|
||||
FileModel parent = getDirectoryOrParent(sel);
|
||||
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.FILE));
|
||||
eventBus.fireEvent(new FileUploadEvent(parent, WS_UPLOAD_TYPE.File));
|
||||
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,7 @@ public class ContextMenuTree {
|
|||
|
||||
FileModel parent = getDirectoryOrParent(sel);
|
||||
|
||||
eventBus.fireEvent(new FileUploadEvent(parent, UploadType.ARCHIVE));
|
||||
eventBus.fireEvent(new FileUploadEvent(parent, WS_UPLOAD_TYPE.Archive));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue