diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index ee50d89..0bcb61b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -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){ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java index 5f102fc..7df9e53 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java @@ -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}; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/CompletedFileUploadEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/CompletedFileUploadEvent.java index 150af4c..a75921f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/event/CompletedFileUploadEvent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/CompletedFileUploadEvent.java @@ -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 implements GuiEventInterface{ public static Type TYPE = new Type(); - 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 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(); - } - } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java index 6b73dc3..fd77046 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/SubscriberInterface.java @@ -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. diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java index f58dd41..a507515 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java @@ -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)); } }