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 c405baf..36ed1a3 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 @@ -84,6 +84,8 @@ import org.gcube.portlets.user.workspace.client.event.SubTreeLoadedEvent; import org.gcube.portlets.user.workspace.client.event.SubTreeLoadedEventHandler; import org.gcube.portlets.user.workspace.client.event.SwitchViewEvent; import org.gcube.portlets.user.workspace.client.event.SwitchViewEventHandler; +import org.gcube.portlets.user.workspace.client.event.TrashEvent; +import org.gcube.portlets.user.workspace.client.event.TrashEventHandler; import org.gcube.portlets.user.workspace.client.event.UnShareFolderEvent; import org.gcube.portlets.user.workspace.client.event.UnShareFolderEventHandler; import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent; @@ -241,6 +243,15 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt } }); + eventBus.addHandler(TrashEvent.TYPE, new TrashEventHandler() { + + @Override + public void onTrashEvent(TrashEvent trashEvent) { + + notifySubscriber(trashEvent); + } + }); + eventBus.addHandler(GetInfoEvent.TYPE, new GetInfoEventHandler() { @Override @@ -1709,9 +1720,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt sub.copyEventIsCompleted(); + }else if(event instanceof TrashEvent){ + TrashEvent trashEvent = (TrashEvent) event; + sub.trashEvent(trashEvent.getTrashOperation(), trashEvent.getTargetFileModel()); } - - } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/TrashEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/TrashEvent.java new file mode 100644 index 0000000..2f4adab --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/TrashEvent.java @@ -0,0 +1,70 @@ +package org.gcube.portlets.user.workspace.client.event; + +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; + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @May 23, 2013 + * + */ +public class TrashEvent extends GwtEvent implements GuiEventInterface{ + + public static Type TYPE = new Type(); + + public static enum TRASHOPERATION {SHOW, MOVETO, RESTOREFROM} + + private FileModel targetFileModel; + private TRASHOPERATION trashOperation; + + public TrashEvent(TRASHOPERATION trashOperation, FileModel target) { + this.trashOperation = trashOperation; + this.setTargetFileModel(target); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(TrashEventHandler handler) { + handler.onTrashEvent(this); + } + + /** + * @return the targetFileModel + */ + public FileModel getTargetFileModel() { + return targetFileModel; + } + + /** + * @param targetFileModel the targetFileModel to set + */ + public void setTargetFileModel(FileModel targetFileModel) { + this.targetFileModel = targetFileModel; + } + + public TRASHOPERATION getTrashOperation() { + return trashOperation; + } + + public void setSetTrashOperation(TRASHOPERATION setTrashOperation) { + this.trashOperation = setTrashOperation; + } + + /* (non-Javadoc) + * @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey() + */ + @Override + public EventsTypeEnum getKey() { + return EventsTypeEnum.TRASH_EVENT; + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/TrashEventHandler.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/TrashEventHandler.java new file mode 100644 index 0000000..b2ef92a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/TrashEventHandler.java @@ -0,0 +1,16 @@ +package org.gcube.portlets.user.workspace.client.event; + +import com.google.gwt.event.shared.EventHandler; + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @May 23, 2013 + * + */ +public interface TrashEventHandler extends EventHandler { + /** + * @param accountingHistoryEvent + */ + void onTrashEvent(TrashEvent trashEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/EventsTypeEnum.java b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/EventsTypeEnum.java index a992371..ed8635d 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/EventsTypeEnum.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/interfaces/EventsTypeEnum.java @@ -29,5 +29,6 @@ public enum EventsTypeEnum FILE_DOWNLAD_EVENT, SESSION_EXPIRED, PASTED_EVENT, - COPY_EVENT; + COPY_EVENT, + TRASH_EVENT; } \ No newline at end of file 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 f2ae5be..786c140 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.event.TrashEvent.TRASHOPERATION; import org.gcube.portlets.user.workspace.client.model.FileModel; import org.gcube.portlets.user.workspace.client.model.FolderModel; @@ -50,5 +51,10 @@ public interface SubscriberInterface { * */ void copyEventIsCompleted(); + /** + * @param trashOperation + * @param targetFileModel + */ + void trashEvent(TRASHOPERATION trashOperation, FileModel targetFileModel); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java index 9bd7e44..72b46a3 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java @@ -286,5 +286,8 @@ public interface Icons extends ClientBundle { @Source("icons/sharelink.png") ImageResource publicLink(); + + @Source("icons/trash.png") + ImageResource trash(); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java index 9367beb..c5d0752 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java @@ -50,6 +50,11 @@ public class Resources { return AbstractImagePrototype.create(ICONS.shareLink()); } + public static AbstractImagePrototype getTrash(){ + + return AbstractImagePrototype.create(ICONS.trash()); + } + public static AbstractImagePrototype getIconCreateNew(){ return AbstractImagePrototype.create(ICONS.createNew()); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/trash.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/trash.png new file mode 100644 index 0000000..aac5230 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/trash.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java index 350a8fd..821c128 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java @@ -57,9 +57,9 @@ public class WindowTrash extends Window { // }); // } - public WindowTrash(List trashFiles) { - updateTrashContainer(trashFiles); - } +// public WindowTrash(List trashFiles) { +// updateTrashContainer(trashFiles); +// } private void initAccounting() { setModal(true);