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 bc7b433..9c7b8cf 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 @@ -239,7 +239,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onSuccess(Boolean result) { if(result) //REFRESH PARENT FOLDER - eventBus.fireEvent(new RefreshFolderEvent(source.getParentFileModel(), true, false)); + eventBus.fireEvent(new RefreshFolderEvent(source.getParentFileModel(), true, false, false)); } }); @@ -371,7 +371,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt else parentToRefresh = parentFileModel; - eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false)); + eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false, false)); GWT.log("share completed refresh folder : "+parentModel.getName()); } explorerPanel.unmask(); @@ -518,14 +518,22 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt if(refreshItemEvent.getFolderTarget()!=null){ - explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder()); + if(!refreshItemEvent.isIfExists()){ //CAlled Tree side + explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder()); + notifySubscriber(refreshItemEvent); + } + else{ //Valitaing folder existence - called portlet side + FileModel target = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(refreshItemEvent.getFolderTarget().getIdentifier()); + if(target!=null) + explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder()); + } // notifySubscriber(refreshtemEvent); } else GWT.log("warn: escape refresh because item is null"); - notifySubscriber(refreshItemEvent); + } }); @@ -594,7 +602,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt public void onSuccess(Boolean result) { if(result) - eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true)); + eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true, false)); notifySubscriber(pasteItemEvent); } @@ -1867,9 +1875,13 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt explorerPanel.getAsycTreePanel().getContextMenuTree().setHideSharing(); } - public void refreshRoot(){ + /** + * + * @param selectRootItem + */ + public void refreshRoot(boolean selectRootItem){ if(explorerPanel.getAsycTreePanel()!=null) - explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); + explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(selectRootItem); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/DeleteItemEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/DeleteItemEvent.java index a7d3965..4c75465 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/event/DeleteItemEvent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/DeleteItemEvent.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.workspace.client.event; +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; @@ -10,9 +12,19 @@ public class DeleteItemEvent extends GwtEvent implements public static Type TYPE = new Type(); private FileModel fileTarget = null; + + private List listTarget; + + private boolean isMultiSelection; public DeleteItemEvent(FileModel fileModel) { this.fileTarget = fileModel; + this.isMultiSelection = false; + } + + public DeleteItemEvent(List listTarget) { + this.listTarget = listTarget; + this.isMultiSelection = true; } @Override @@ -36,4 +48,12 @@ public class DeleteItemEvent extends GwtEvent implements public FileModel getFileTarget() { return fileTarget; } + + public List getListTarget() { + return listTarget; + } + + public boolean isMultiSelection() { + return isMultiSelection; + } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/event/RefreshFolderEvent.java b/src/main/java/org/gcube/portlets/user/workspace/client/event/RefreshFolderEvent.java index 00d3277..0a95bbb 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/event/RefreshFolderEvent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/event/RefreshFolderEvent.java @@ -14,11 +14,14 @@ public class RefreshFolderEvent extends GwtEvent implem private boolean expandFolder = true; //DEFAULT EXPAND FOLDER private boolean forceRefresh; + + private boolean ifExists = false; - public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh) { + public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh, boolean ifExists) { this.folderTarget = folderTarget; this.expandFolder = expandFolder; this.forceRefresh = forceRefresh; + this.ifExists = ifExists; } @@ -61,4 +64,9 @@ public class RefreshFolderEvent extends GwtEvent implem public void setForceRefresh(boolean forceRefresh) { this.forceRefresh = forceRefresh; } + + + public boolean isIfExists() { + return ifExists; + } } 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 786c140..7dfe86e 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 @@ -31,7 +31,7 @@ public interface SubscriberInterface { void smartFolderSelected(String folderId, String category); void movedItems(String sourceParentIdentifier, FileModel targetParent); void switchView(ViewSwitchType type); - void refreshFolder(FileModel fileModel, boolean forzed); + void refreshFolder(FileModel fileModel, boolean forced); // void updatePrevieMessage(String fromLogin, String subject, String date, String body, List attachs); void createNewMessage(HashMap hashAttachs); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index fd22e5c..9287cfe 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -171,5 +171,8 @@ public interface GWTWorkspaceService extends RemoteService{ throws Exception; boolean isSessionExpired() throws Exception; + + + void deleteListItemsForIds(List ids) throws Exception; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index 464ac10..731a4eb 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -162,5 +162,6 @@ public interface GWTWorkspaceServiceAsync { */ void isSessionExpired(AsyncCallback callback); + void deleteListItemsForIds(List ids, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java index 696321d..1d4b427 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java @@ -1079,11 +1079,19 @@ public class AsyncTreePanel extends LayoutContainer { this.isSubTreeLoaded = isSubTreeLoaded; } + /** + * Select root by default + */ public void removeAllAndRecoveryRoot(){ store.removeAll(); loadRootItem(scopeId,true); } + public void removeAllAndRecoveryRoot(boolean selectRoot){ + store.removeAll(); + loadRootItem(scopeId,selectRoot); + } + public void selectRootItem(){ FileModel selectedItem = treePanel.getSelectionModel().getSelectedItem(); if(selectedItem!=null) 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 cd2440e..6ceaf9c 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 @@ -561,7 +561,7 @@ public class ContextMenuTree { public void componentSelected(MenuEvent ce) { for (FileModel sel : listSelectedItems) { - eventBus.fireEvent(new RefreshFolderEvent(sel, true, false)); + eventBus.fireEvent(new RefreshFolderEvent(sel, true, false, false)); } } }); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 2143edb..11d7565 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -2267,4 +2267,60 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT public boolean isSessionExpired() throws Exception { return WsUtil.isSessionExpired(this.getThreadLocalRequest().getSession()); } + + /* (non-Javadoc) + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#deleteListItemsForIds(java.util.List) + */ + @Override + public void deleteListItemsForIds(List ids) throws Exception { + + try { + + if(ids == null) + throw new Exception("List identifiers is null"); + + Workspace workspace = getWorkspace(); + + workspaceLogger.trace("removeItem item for list size: "+ids.size()); + + for (String itemId : ids) { + + //NOTIFICATION + WorkspaceItem wsItem = workspace.getItem(itemId); + + //SAVING ATTRIBUTE FOR NOTIFICATION + boolean sourceItemIsShared = wsItem.isShared(); + String itemName = wsItem.getName(); + String sourceFolderSharedId = null; + + if(sourceItemIsShared){ + sourceFolderSharedId = wsItem.getIdSharedFolder(); + } + + //REMOVE ITEM + workspace.removeItem(itemId); + + //IF SOURCE SHARED FOLDER IS NOT NULL + if(sourceFolderSharedId!=null) + NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest().getSession(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId); + + } + + + } catch (InsufficientPrivilegesException e) { + workspaceLogger.error("Error in server Item remove", e); + String error = "An error occurred on deleting item. "+e.getMessage(); + throw new Exception(error); + + }catch (ItemNotFoundException e) { + String error = "An error occurred on deleting item. "+ConstantsExplorer.ERROR_ITEM_DOES_NOT_EXIST; + workspaceLogger.error(error, e); + throw new Exception(error); + } catch (Exception e) { + workspaceLogger.error("Error in server Item remove", e); + String error = ConstantsExplorer.SERVER_ERROR +" deleting item. "+e.getMessage(); + throw new Exception(error); + } + + } }