From 08b321cf877e815413507ec1a6bd1f8a23ae9ba3 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Fri, 5 Oct 2018 16:08:41 +0000 Subject: [PATCH] Working on move operation git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@171990 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/workspace/client/AppController.java | 8 +++- .../client/gridevent/GridRefreshEvent.java | 19 ++++++-- .../client/gridevent/MoveItemsGEvent.java | 46 +++++++++---------- .../toolbars/GxtToolBarItemFunctionality.java | 4 +- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java index 19ef4ff..3356370 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppController.java @@ -307,7 +307,11 @@ public class AppController implements SubscriberInterface { if(moveItemsEvent.getIds()!=null && moveItemsEvent.getIds().size()>0){ - AppControllerExplorer.getEventBus().fireEvent(new MoveItemsEvent(moveItemsEvent.getIds(), null)); + //THE SOURCE PARENT IS A VALID FROM THE EVENT OR READ FROM BREADCRUMB + FileModel sourceParent = moveItemsEvent.getSourceParentFolder()!=null? + moveItemsEvent.getSourceParentFolder():wsPortlet.getToolBarPath().getLastParent(); + //wsPortlet.getGridGroupContainer().mask("Moving",ConstantsExplorer.LOADINGSTYLE); + AppControllerExplorer.getEventBus().fireEvent(new MoveItemsEvent(moveItemsEvent.getIds(), null, sourceParent)); } } @@ -1941,6 +1945,8 @@ public class AppController implements SubscriberInterface { @Override public void moveEventIsCompleted(boolean isTreeRefreshable, String parentId) { + wsPortlet.getGridGroupContainer().unmask(); + if(isTreeRefreshable){ wsPortlet.getGridGroupContainer().unmask(); }else{ //FORCE GRID REFRESH diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/GridRefreshEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/GridRefreshEvent.java index 2a276b4..a8aee6e 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/GridRefreshEvent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/GridRefreshEvent.java @@ -2,26 +2,37 @@ package org.gcube.portlets.user.workspace.client.gridevent; import com.google.gwt.event.shared.GwtEvent; + /** - * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * The Class GridRefreshEvent. * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * Oct 5, 2018 */ public class GridRefreshEvent extends GwtEvent { public static Type TYPE = new Type(); + /** + * Instantiates a new grid refresh event. + */ public GridRefreshEvent() { } + /* (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(GridRefreshEventHandler handler) { handler.onGridRefresh(this); - + } } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/MoveItemsGEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/MoveItemsGEvent.java index 17b1d48..c324981 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/MoveItemsGEvent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/gridevent/MoveItemsGEvent.java @@ -4,15 +4,17 @@ import java.util.List; 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 MoveItemsEvent. + * The Class MoveItemsGEvent. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Oct 4, 2018 + * Oct 5, 2018 */ public class MoveItemsGEvent extends GwtEvent implements GuiEventInterface{ public static Type TYPE = new Type(); @@ -21,20 +23,21 @@ public class MoveItemsGEvent extends GwtEvent implements private List ids; - private String folderSourceId; //Used to move + private FileModel sourceParentFolder; //Used to move private boolean treeRefreshable; - /** - * Instantiates a new move items event. + * Instantiates a new move items g event. * * @param ids the ids * @param folderDestinationId the folder destination id + * @param sourceParentFolder the source parent folder */ - public MoveItemsGEvent(List ids, String folderDestinationId) { + public MoveItemsGEvent(List ids, String folderDestinationId, FileModel sourceParentFolder) { this.ids = ids; this.folderDestinationId = folderDestinationId; + this.sourceParentFolder = sourceParentFolder; } /* (non-Javadoc) @@ -89,24 +92,6 @@ public class MoveItemsGEvent extends GwtEvent implements this.ids = ids; } - /** - * Gets the folder source id. - * - * @return the folder source id - */ - public String getFolderSourceId() { - return folderSourceId; - } - - /** - * Sets the folder source id. - * - * @param folderSourceId the new folder source id - */ - public void setFolderSourceId(String folderSourceId) { - this.folderSourceId = folderSourceId; - } - /** * Sets the tree refreshable. * @@ -125,4 +110,17 @@ public class MoveItemsGEvent extends GwtEvent implements return treeRefreshable; } + + /** + * Gets the source parent folder. + * + * @return the sourceParentFolder + */ + public FileModel getSourceParentFolder() { + + return sourceParentFolder; + } + + + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemFunctionality.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemFunctionality.java index c6d44ab..6e50d70 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemFunctionality.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtToolBarItemFunctionality.java @@ -329,7 +329,9 @@ public class GxtToolBarItemFunctionality { List listTarget = gridGroupViewContainer.getIdsSelectedItems(); if(listTarget!=null && listTarget.size()>0){ - AppController.getEventBus().fireEvent(new MoveItemsGEvent(listTarget, null)); + //using the parent of the first item + FileModel sourceParentModel = gridGroupViewContainer.getSelectedItems().get(0).getParentFileModel(); + AppController.getEventBus().fireEvent(new MoveItemsGEvent(listTarget, null, sourceParentModel)); } }