From 6285a31c940828f1ca4d99db680ac552070b5974 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 9 Oct 2018 10:16:10 +0000 Subject: [PATCH] added refresh folder git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@172055 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/workspace/client/AppController.java | 46 ++++++++++++++-- .../client/view/toolbars/Breadcrumbs.java | 18 ++++++- .../view/toolbars/GxtBreadcrumbPathPanel.java | 52 ++++++++++++++++--- 3 files changed, 103 insertions(+), 13 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 7739d41..3051186 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 @@ -1487,7 +1487,7 @@ public class AppController implements SubscriberInterface { if(folder==null) return; - //CREATE FOLDER PARENT FOR RPC + //CREATING FOLDER PARENT FOR RPC final FileModel parent = new FolderModel(folder.getIdentifier(), folder.getName(), folder.getParentFileModel(), true, folder.isShared(), folder.isVreFolder(), folder.isPublic()); wsPortlet.getGridGroupContainer().mask(ConstantsExplorer.LOADING,ConstantsExplorer.LOADINGSTYLE); @@ -1868,6 +1868,23 @@ public class AppController implements SubscriberInterface { GWT.log("folderTarget is null, refresh skypped"); } + /* (non-Javadoc) + * @see org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface#refreshFolder(org.gcube.portlets.user.workspace.client.model.FileModel, boolean, boolean) + */ + @Override + public void loadFolder(FileModel folderTarget){ + + resetSmartFolderSelected(); + + GWT.log("Loading Folder: "+folderTarget); + if(folderTarget!=null){ + GWT.log("Loading folder: "+ folderTarget.getName()); + updateStoreByRpc(folderTarget); + loadBreadcrumbByFileModel(folderTarget, true); + } + + } + /* (non-Javadoc) * @see org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface#fileDownloaded(java.lang.String) */ @@ -1950,14 +1967,33 @@ public class AppController implements SubscriberInterface { if(refreshingTheTree){ wsPortlet.getGridGroupContainer().unmask(); }else{ //FORCE GRID REFRESH - FileModel lastBreadCrumb = wsPortlet.getToolBarPath().getLastParent(); + FileModel theFolder = wsPortlet.getToolBarPath().getParentFolder(parentId); GWT.log("moveEventIsCompleted tree is not refreshable"); - if(lastBreadCrumb!=null){ - GWT.log("Comparing breadcrumb id: "+lastBreadCrumb.getIdentifier() + " and parent id: "+parentId); - if(lastBreadCrumb.getIdentifier().compareToIgnoreCase(parentId)==0){ + if(theFolder!=null){ + //THE FOLDER IS IN THE BREADCRUMB + GWT.log("Comparing breadcrumb id: "+theFolder.getIdentifier() + " and parent id: "+parentId); + if(theFolder.getIdentifier().compareToIgnoreCase(parentId)==0){ eventBus.fireEvent(new GridRefreshEvent()); } + }else{ + //MOVING HAS BEEN PERFORMED IN A FOLDER MISSING IN THE BREADCRUMB, SO LOADING IT A NEW ONE + //FOR DISPLAYING + GWT.log("Loading grid on the parent folder of: "+parentId); + + AppControllerExplorer.rpcWorkspaceService.getParentByItemId(parentId, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + + } + + @Override + public void onSuccess(FileModel result) { + loadFolder(result); + } + }); + } } // Info.display("Info", "paste submitting..."); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/Breadcrumbs.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/Breadcrumbs.java index 6f1d316..eb71819 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/Breadcrumbs.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/Breadcrumbs.java @@ -24,8 +24,8 @@ import com.google.gwt.user.client.ui.Widget; /** * The Class Breadcrumbs. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Dec 14, 2015 + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * Oct 9, 2018 */ public class Breadcrumbs extends Composite { @@ -89,6 +89,20 @@ public class Breadcrumbs extends Composite { + /** + * Gets the parent folder. + * + * @param folderId the folder id + * @return the parent folder + */ + public FileModel getParentFolder(String folderId){ + + return hashFileModel.get(folderId); + + } + + + /** * Reset breadcrumbs. */ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBreadcrumbPathPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBreadcrumbPathPanel.java index 5006ea6..0113338 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBreadcrumbPathPanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBreadcrumbPathPanel.java @@ -6,37 +6,77 @@ import org.gcube.portlets.user.workspace.client.model.FileModel; import com.google.gwt.user.client.ui.Composite; + /** - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * The Class GxtBreadcrumbPathPanel. * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * Oct 9, 2018 */ public class GxtBreadcrumbPathPanel { private static final String ROOT_NAME = ""; private Breadcrumbs breadCrumbs = new Breadcrumbs(ROOT_NAME); - + + /** + * Instantiates a new gxt breadcrumb path panel. + */ public GxtBreadcrumbPathPanel() { } - + + /** + * Gets the tool bar path panel. + * + * @return the tool bar path panel + */ public Composite getToolBarPathPanel() { return breadCrumbs; } + /** + * Sets the path. + * + * @param parents the new path + */ public void setPath(List parents) { breadCrumbs.setPath(parents); } - + + /** + * Breadcrumb is empty. + * + * @return true, if successful + */ public boolean breadcrumbIsEmpty(){ return breadCrumbs.breadcrumbIsEmpty(); } - + + /** + * Gets the last parent. + * + * @return the last parent + */ public FileModel getLastParent(){ return breadCrumbs.getLastParent(); } /** - * + * Gets the parent folder. + * + * @param folderId the folder id + * @return the parent folder + */ + public FileModel getParentFolder(String folderId){ + + if(folderId==null) + return null; + + return breadCrumbs.getParentFolder(folderId); + } + + /** + * Refresh size. */ public void refreshSize() { // TODO Auto-generated method stub