Fixed bug on breadcrumb

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@172016 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-10-08 09:50:17 +00:00
parent 8c6e61254f
commit a2f5be0a06
4 changed files with 63 additions and 43 deletions

View File

@ -1,11 +1,6 @@
package org.gcube.portlets.widgets.wsexplorer.client;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.shared.GWT;
/**

View File

@ -59,7 +59,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
*/
public WorkspaceExplorerSelectDialog(String captionTxt) {
controller = new WorkspaceExplorerController(WorkspaceExplorerConstants.HEIGHT_EXPLORER_PANEL);
loadExplorer(captionTxt, null);
loadExplorer(captionTxt, null, null);
}
/**
@ -70,7 +70,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
*/
public WorkspaceExplorerSelectDialog(String captionTxt, FilterCriteria filterCriteria) {
controller = new WorkspaceExplorerController(filterCriteria, WorkspaceExplorerConstants.HEIGHT_EXPLORER_PANEL);
loadExplorer(captionTxt, null);
loadExplorer(captionTxt, null, null);
}
/**
@ -88,7 +88,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
itemsType = selectableTypes.toArray(itemsType);
setSelectableTypes(selectableTypes.toArray(itemsType));
}
loadExplorer(captionTxt, null);
loadExplorer(captionTxt, null, null);
}
@ -117,7 +117,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
setShowableTypes(showableTypes.toArray(itemsType));
}
loadExplorer(captionTxt, folderId);
loadExplorer(captionTxt, folderId, null);
}
@ -141,7 +141,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
setShowableTypes(itemsType);
}
loadExplorer(captionTxt, null);
loadExplorer(captionTxt, null, null);
}
/**
@ -151,7 +151,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
* @param showOnlyFolders the show only folders
* @param baseFolderId the base folder id
*/
public WorkspaceExplorerSelectDialog(String captionTxt, boolean showOnlyFolders, String baseFolderId) {
public WorkspaceExplorerSelectDialog(String captionTxt, boolean showOnlyFolders, String baseFolderId, String baseFolderName) {
controller = new WorkspaceExplorerController(WorkspaceExplorerConstants.HEIGHT_EXPLORER_PANEL);
if(showOnlyFolders){
ItemType[] itemsType = new ItemType[4];
@ -164,7 +164,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
setShowableTypes(itemsType);
}
loadExplorer(captionTxt, baseFolderId);
loadExplorer(captionTxt, baseFolderId, baseFolderName);
}
/**
@ -190,10 +190,29 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
setShowableTypes(showableTypes.toArray(itemsType));
}
loadExplorer(captionTxt, null);
loadExplorer(captionTxt, null, null);
}
// /**
// * Load explorer.
// * If folder id is null or empty the explorer loads the root element
// * Otherwise, it loads the folder id
// *
// * @param captionTxt the caption txt
// * @param folderId the folder id
// */
// private void loadExplorer(String captionTxt, String folderId){
//
// if(folderId==null || folderId.isEmpty())
// controller.getEventBus().fireEvent(new LoadRootEvent());
// else{
// Item item = new Item(folderId, "", true);
// controller.getEventBus().fireEvent(new LoadFolderEvent<Item>(item));
// }
// initDialog(captionTxt);
// }
/**
* Load explorer.
* If folder id is null or empty the explorer loads the root element
@ -202,12 +221,12 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
* @param captionTxt the caption txt
* @param folderId the folder id
*/
private void loadExplorer(String captionTxt, String folderId){
private void loadExplorer(String captionTxt, String folderId, String baseFolderName){
if(folderId==null || folderId.isEmpty())
controller.getEventBus().fireEvent(new LoadRootEvent());
else{
Item item = new Item(folderId, "", true);
Item item = new Item(folderId, baseFolderName, true);
controller.getEventBus().fireEvent(new LoadFolderEvent<Item>(item));
}
initDialog(captionTxt);

View File

@ -4,7 +4,6 @@
package org.gcube.portlets.widgets.wsexplorer.client.select;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.portlets.widgets.wsexplorer.client.Util;

View File

@ -10,7 +10,6 @@ import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item;
@ -45,9 +44,9 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/
@Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item getRoot(
List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria)
List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria)
throws WorkspaceNavigatorServiceException {
_log.trace("getRoot showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+ filterCriteria);
try {
@ -82,10 +81,10 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/
@Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item getFolder(
ItemInterface item, List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria,
boolean loadGcubeProperties)
ItemInterface item, List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria,
boolean loadGcubeProperties)
throws WorkspaceNavigatorServiceException {
_log.trace("getFolder folderId: "+item.getId()+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria);
@ -95,7 +94,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
String scope = pContext.getCurrentScope(getThreadLocalRequest());
String authorizationToken = pContext.getCurrentUserToken(scope, userName);
SecurityTokenProvider.instance.set(authorizationToken);
SecurityTokenProvider.instance.set(authorizationToken);
Item folder = StorageHubServiceUtil.getItem(getThreadLocalRequest(), item.getId());
_log.trace("GetFolder - Replying folder");
@ -158,14 +157,14 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
String vreFolderId = StorageHubServiceUtil.getVREFoldersId(getThreadLocalRequest());
Item folder = StorageHubServiceUtil.getItem(getThreadLocalRequest(), vreFolderId);
item = new org.gcube.portlets.widgets.wsexplorer.shared.Item(
null,
folder.getId(),
WorkspaceExplorerConstants.VRE_FOLDERS_LABEL,
ItemType.FOLDER,
folder.getPath(),
folder.getOwner(),
null,
true,
null,
folder.getId(),
WorkspaceExplorerConstants.VRE_FOLDERS_LABEL,
ItemType.FOLDER,
folder.getPath(),
folder.getOwner(),
null,
true,
false);
//SET SPECIAL FOLDER /Workspace/MySpecialFolders
item.setSpecialFolder(true);
@ -184,9 +183,9 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/
@Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item getMySpecialFolder(
List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria)
List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria)
throws WorkspaceNavigatorServiceException {
_log.trace("GetMySpecialFolder showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria);
@ -240,7 +239,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/
@Override
public ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item> getBreadcrumbsByItemIdentifier(
String itemIdentifier, String itemName, boolean includeItemAsParent)
String itemIdentifier, String itemName, boolean includeItemAsParent)
throws Exception {
System.out.println("ListParents By Item id "+ itemIdentifier + " name="+itemName);
try {
@ -253,7 +252,15 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
}
Collections.reverse(toReturn);
String theClickedFolderName = (itemName == null || itemName.equals("")) ? "current folder" : itemName;
Item theFolder;
if(itemName==null || itemName.isEmpty()){
theFolder = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemIdentifier);
itemName = theFolder.getName();
}
String theClickedFolderName = itemName == null || itemName.equals("") ? "current folder" : itemName;
toReturn.add(new org.gcube.portlets.widgets.wsexplorer.shared.Item(itemIdentifier, theClickedFolderName, true)); //this is the last non clickable item on the BC
return toReturn;
} catch (Exception e) {
@ -287,11 +294,11 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
Item folderItem = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemIdentifier);
String theClickedFolderName = folderItem.getTitle();
if((theClickedFolderName.compareTo(WorkspaceExplorerConstants.SPECIAL_FOLDERS_NAME) == 0)){
if(theClickedFolderName.compareTo(WorkspaceExplorerConstants.SPECIAL_FOLDERS_NAME) == 0){
theClickedFolderName = WorkspaceExplorerConstants.VRE_FOLDERS_LABEL;
} else {
ItemType type = ItemBuilder.getItemType(folderItem);
boolean isSharedFolder = (type.equals(ItemType.SHARED_FOLDER) || type.equals(ItemType.VRE_FOLDER )) ? true : false;
boolean isSharedFolder = type.equals(ItemType.SHARED_FOLDER) || type.equals(ItemType.VRE_FOLDER ) ? true : false;
if(isSharedFolder){
SharedFolder shared = (SharedFolder) folderItem;
theClickedFolderName = shared.isVreFolder() ? shared.getDisplayName() : folderItem.getTitle();
@ -305,7 +312,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
for (org.gcube.portlets.widgets.wsexplorer.shared.Item item : toWorkOn) {
if (item.getId().compareTo(parentLimit)==0) found = true;
if (found)
toReturn.add(item);
toReturn.add(item);
}
return toReturn;
} catch (Exception e) {
@ -329,7 +336,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
_log.debug("get Size By ItemId "+ itemId);
Item wsItem = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemId);
_log.trace("workspace retrieved item name: "+wsItem.getName());
if((wsItem instanceof FolderItem)) //if is a folder no Size
if(wsItem instanceof FolderItem) //if is a folder no Size
return 0L;
AbstractFileItem file = (AbstractFileItem) wsItem;
@ -351,7 +358,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
_log.debug("get MimeType By ItemId "+ itemId);
Item wsItem = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemId);
_log.trace("workspace retrieved item name: "+wsItem.getName());
if((wsItem instanceof FolderItem)) //if is a folder no mime
if(wsItem instanceof FolderItem) //if is a folder no mime
return null;
AbstractFileItem file = (AbstractFileItem) wsItem;
return file.getContent().getMimeType();