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 b4e8c60..07d257b 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 @@ -37,6 +37,8 @@ import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.Download 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.CopytemEvent; +import org.gcube.portlets.user.workspace.client.event.CopytemEventHandler; 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; @@ -477,11 +479,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt if(refreshtemEvent.getFolderTarget()!=null){ explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshtemEvent.getFolderTarget().getIdentifier(), true); - notifySubscriber(refreshtemEvent); +// notifySubscriber(refreshtemEvent); } else GWT.log("warn: escape refresh because item is null"); + + notifySubscriber(refreshtemEvent); + } }); @@ -508,6 +513,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt } }); + + eventBus.addHandler(CopytemEvent.TYPE, new CopytemEventHandler() { + + @Override + public void onCopyItem(CopytemEvent copytemEvent) { + notifySubscriber(copytemEvent); + } + }); eventBus.addHandler(PasteItemEvent.TYPE, new PasteItemEventHandler() { @@ -1678,6 +1691,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt sub.pasteEventIsCompleted(); + }else if(event instanceof CopytemEvent){ + + sub.copyEventIsCompleted(); + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/CopytemEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/CopytemEvent.java new file mode 100644 index 0000000..7c3f0ad --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/CopytemEvent.java @@ -0,0 +1,40 @@ +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 com.google.gwt.event.shared.GwtEvent; + +public class CopytemEvent extends GwtEvent implements GuiEventInterface{ + public static Type TYPE = new Type(); + + private String itemId = null; + + public CopytemEvent(String itemId) { + this.itemId = itemId; + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(CopytemEventHandler handler) { + handler.onCopyItem(this); + + } + + public String getItemId() { + return itemId; + } + + /* (non-Javadoc) + * @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey() + */ + @Override + public EventsTypeEnum getKey() { + return EventsTypeEnum.COPY_EVENT; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/CopytemEventHandler.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/CopytemEventHandler.java new file mode 100644 index 0000000..bd500b2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/CopytemEventHandler.java @@ -0,0 +1,10 @@ +package org.gcube.portlets.user.workspace.client.event; + +import com.google.gwt.event.shared.EventHandler; + +public interface CopytemEventHandler extends EventHandler { + /** + * @param copytemEvent + */ + void onCopyItem(CopytemEvent copytemEvent); +} \ 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 c9eb8a8..a992371 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 @@ -28,5 +28,6 @@ public enum EventsTypeEnum REPLY_FORWARD_MESSAGE, FILE_DOWNLAD_EVENT, SESSION_EXPIRED, - PASTED_EVENT + PASTED_EVENT, + COPY_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 75fb5bd..20537ae 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 @@ -46,5 +46,9 @@ public interface SubscriberInterface { * */ void pasteEventIsCompleted(); + /** + * + */ + void copyEventIsCompleted(); } 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 6ee52bd..957a19e 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 @@ -9,6 +9,7 @@ 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; import org.gcube.portlets.user.workspace.client.event.AddFolderEvent; +import org.gcube.portlets.user.workspace.client.event.CopytemEvent; import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent; import org.gcube.portlets.user.workspace.client.event.CreateUrlEvent; import org.gcube.portlets.user.workspace.client.event.DeleteItemEvent; @@ -321,6 +322,7 @@ public class ContextMenuTree { for (FileModel target : listSelectedItems) { if(target.getIdentifier()!=null){ CopyAndPaste.copy(target.getIdentifier()); + eventBus.fireEvent(new CopytemEvent(target.getIdentifier())); } }