Fixed bug on breadcrumb

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-explorer-app@131358 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-09-14 14:46:22 +00:00
parent a1e756f694
commit 9654a5da91
4 changed files with 108 additions and 20 deletions

View File

@ -62,6 +62,7 @@ public class WorkspaceExplorerAppController {
}, ContextMenuEvent.getType());
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(eventBus, folderId, false);
wsResourcesExplorerPanel.loadParentBreadcrumbByItemId(folderId, true);
WorskpaceExplorerSelectNotificationListener listener = new WorskpaceExplorerSelectNotificationListener() {
@Override
@ -103,6 +104,7 @@ public class WorkspaceExplorerAppController {
}.schedule(1000);*/
mainPanel = new WorkspaceExplorerAppPanel(wsResourcesExplorerPanel);
}
catch (Exception e) {
e.printStackTrace();

View File

@ -314,7 +314,7 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
* @param itemIdentifier the item identifier
* @param includeItemAsParent the include item as parent
*/
private void loadParentBreadcrumbByItemId(final String itemIdentifier, boolean includeItemAsParent){
protected void loadParentBreadcrumbByItemId(final String itemIdentifier, boolean includeItemAsParent){
GWT.log("Reload Parent Breadcrumb: [Item id: "+itemIdentifier+"]");

View File

@ -69,13 +69,18 @@ public class Breadcrumbs extends Composite {
*/
public void setPath(List<Item> parents) {
resetBreadcrumbs();
if (parents != null && parents.size() > 0) {
for (Item parent : parents) {
GWT.log("parent is: "+parent);
addNavigationLink(parent);
hashListItems.put(parent.getId(), parent);
if(parents!=null){
GWT.log("parent size is: "+parents.size());
if (parents.size() > 0) {
for (Item parent : parents) {
GWT.log("parent is: "+parent);
if(parent!=null){ //PARENTS NULL ARE SKIPPED, THEY ARE NULL WHEN BREADCRUMB LIMIT IS reached
addNavigationLink(parent);
hashListItems.put(parent.getId(), parent);
}
}
lastParent = parents.get(parents.size() - 1);
}
lastParent = parents.get(parents.size() - 1);
}
}

View File

@ -262,13 +262,53 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
logger.trace("parents size: "+parents.size());
Item[] arrayParents;
if(includeItemAsParent==true && wsItem.isFolder()){
switch (parents.size()) {
case 0: // itemIdentifier is ROOT
logger.trace("itemIdentifier isRoot...");
if (includeItemAsParent) { //ADDIND ROOT
WorkspaceFolder wsFolder =(WorkspaceFolder) workspace.getItem(itemIdentifier);
Item root = ItemBuilder.buildFolderForBreadcrumbs(wsFolder, null);
List<Item> listParents = new ArrayList<Item>(1);
listParents.add(root);
// workspaceLogger.trace("returning: "+listParents.toString());
return listParents;
}
else{
logger.trace("returning empty list");
return new ArrayList<Item>(); // empty list
}
case 1: //itemIdentifier is first level from root
logger.trace("itemIdentifier is first level...");
List<Item> listParents = new ArrayList<Item>();
WorkspaceFolder wsRootFolder = (WorkspaceFolder) parents.get(0); //isRoot
Item root = ItemBuilder.buildFolderForBreadcrumbs(wsRootFolder, null);
Item parent = null;
if(includeItemAsParent){
WorkspaceFolder wsFolder1 =(WorkspaceFolder) workspace.getItem(itemIdentifier); //root
parent = ItemBuilder.buildFolderForBreadcrumbs(wsFolder1, null);
}
listParents.add(root);
if(parent!=null)
listParents.add(parent);
// workspaceLogger.trace("returning: "+listParents.toString());
return listParents;
default:
break;
}
WorkspaceItem lastItem = parents.get(parents.size()-1);
//CONVERTING LAST ELEMENT IF NECESSARY
logger.trace("converting last element..");
if(includeItemAsParent && lastItem.isFolder()){ //FIX BUG #298
arrayParents = new Item[parents.size()];
arrayParents[parents.size()-1] = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) wsItem, null);
}
else {
logger.debug("including last item into path: "+lastItem.getName());
arrayParents[parents.size()-1] = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) lastItem, null);
}else
arrayParents = new Item[parents.size()-1];
}
/** HANDLE MY_SPECIAL_FOLDER TO AVOID COMPLETE PATH WORKSPACE/MY_SPECIAL_FOLDER
* BUT RETURNING ONLY /MY_SPECIAL_FOLDER
@ -319,7 +359,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
/**
* Gets the parents by item identifier to limit.
*
* when limit is reached parents are null
* @param itemIdentifier the item identifier
* @param parentLimit the parent limit
* @param includeItemAsParent the include item as parent
@ -338,15 +378,56 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
logger.trace("parents size: "+parents.size());
Item[] arrayParents;
if(includeItemAsParent==true && wsItem.isFolder()){
arrayParents = new Item[parents.size()];
arrayParents[parents.size()-1] = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) wsItem, null);
}
else {
arrayParents = new Item[parents.size()-1];
parentLimit = parentLimit!=null?parentLimit:"";
switch (parents.size()) {
case 0: // itemIdentifier is ROOT
logger.trace("itemIdentifier isRoot...");
if (includeItemAsParent) { //ADDIND ROOT
WorkspaceFolder wsFolder =(WorkspaceFolder) workspace.getItem(itemIdentifier);
Item root = ItemBuilder.buildFolderForBreadcrumbs(wsFolder, null);
List<Item> listParents = new ArrayList<Item>(1);
listParents.add(root);
return listParents;
}
else{
logger.trace("returning empty list");
return new ArrayList<Item>(); // empty list
}
case 1: //itemIdentifier is first level from root
logger.trace("itemIdentifier is first level...");
List<Item> listParents = new ArrayList<Item>();
WorkspaceFolder wsRootFolder = (WorkspaceFolder) parents.get(0); //isRoot
Item root = ItemBuilder.buildFolderForBreadcrumbs(wsRootFolder, null);
Item parent = null;
if(includeItemAsParent){
WorkspaceFolder wsFolder1 =(WorkspaceFolder) workspace.getItem(itemIdentifier); //root
parent = ItemBuilder.buildFolderForBreadcrumbs(wsFolder1, null);
}
if(root.getId().compareTo(parentLimit)!=0)
listParents.add(root);
if(parent!=null)
listParents.add(parent);
// workspaceLogger.trace("returning: "+listParents.toString());
return listParents;
default:
break;
}
parentLimit = parentLimit!=null?parentLimit:"";
WorkspaceItem lastItem = parents.get(parents.size()-1);
//CONVERTING LAST ELEMENT IF NECESSARY
logger.trace("converting last element..");
if(includeItemAsParent && lastItem.isFolder()){ //FIX BUG #298
arrayParents = new Item[parents.size()];
logger.debug("including last item into path: "+lastItem.getName());
arrayParents[parents.size()-1] = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) lastItem, null);
}else
arrayParents = new Item[parents.size()-1];
/** HANDLE MY_SPECIAL_FOLDER TO AVOID COMPLETE PATH WORKSPACE/MY_SPECIAL_FOLDER
* BUT RETURNING ONLY /MY_SPECIAL_FOLDER