256: Workspace explorer
Task-Url: https://support.d4science.org/issues/256 Fix breadcrumbs git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@115727 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
af358fe827
commit
3f81a37a43
|
@ -145,6 +145,13 @@ public class WorkspaceExplorerController implements EventHandler {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the breadcrumbs
|
||||
*/
|
||||
public Breadcrumbs getBreadcrumbs() {
|
||||
return breadcrumbs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the workspace explorer panel.
|
||||
|
|
|
@ -140,7 +140,6 @@ public class WorkspaceExplorerLoadDialog extends Modal implements HasWorskpaceEx
|
|||
INSTANCE.hide();
|
||||
notifySelectedItem(item);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -64,15 +64,8 @@ public class Breadcrumbs extends Composite {
|
|||
resetBreadcrumbs();
|
||||
if (parents != null && parents.size() > 0) {
|
||||
for (Item parent : parents) {
|
||||
// if(!isRootOrSpecialFolder(parent)){ //SKIP ROOT AND SPECIAL FOLDER
|
||||
// addNavigationLink(parent);
|
||||
// hashListItems.put(parent.getId(), parent);
|
||||
// }
|
||||
|
||||
// if(!isRootOrSpecialFolder(parent)){ //SKIP ROOT AND SPECIAL FOLDER
|
||||
addNavigationLink(parent);
|
||||
hashListItems.put(parent.getId(), parent);
|
||||
// }
|
||||
addNavigationLink(parent);
|
||||
hashListItems.put(parent.getId(), parent);
|
||||
}
|
||||
lastParent = parents.get(parents.size() - 1);
|
||||
}
|
||||
|
@ -152,6 +145,7 @@ public class Breadcrumbs extends Composite {
|
|||
resetBreadcrumbs();
|
||||
addNavigationLink(item);
|
||||
hashListItems.put(item.getId(), item);
|
||||
lastParent = item;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -51,15 +51,9 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
|||
protected List<String> allowedMimeTypes = new ArrayList<String>();
|
||||
protected boolean showEmptyFolders = true;
|
||||
protected Map<String, String> requiredProperties = new HashMap<String, String>();
|
||||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting
|
||||
* service.
|
||||
*/
|
||||
|
||||
protected ScrollPanel explorerPanel;
|
||||
private ItemsTable itTables;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new workspace explorer.
|
||||
*
|
||||
|
|
|
@ -60,7 +60,6 @@ public abstract class AbstractItemsCellTable implements SelectionItem{
|
|||
cellTable = new CellTable<Item>(1, CellTableResources.INSTANCE);
|
||||
cellTable.addStyleName("table-overflow");
|
||||
cellTable.setStriped(true);
|
||||
// cellTable.setBordered(true);
|
||||
cellTable.setCondensed(true);
|
||||
cellTable.setWidth("100%", true);
|
||||
dataProvider.addDataDisplay(cellTable);
|
||||
|
@ -134,7 +133,7 @@ public abstract class AbstractItemsCellTable implements SelectionItem{
|
|||
options.addItem(openItem);
|
||||
final DialogBox menuWrapper = new DialogBox(true);
|
||||
menuWrapper.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
|
||||
menuWrapper.getElement().getStyle().setZIndex(100000);
|
||||
menuWrapper.getElement().getStyle().setZIndex(10000);
|
||||
menuWrapper.add(options);
|
||||
|
||||
cellTable.sinkEvents(Event.ONCONTEXTMENU);
|
||||
|
@ -142,7 +141,7 @@ public abstract class AbstractItemsCellTable implements SelectionItem{
|
|||
new ContextMenuHandler() {
|
||||
@Override
|
||||
public void onContextMenu(ContextMenuEvent event) {
|
||||
|
||||
GWT.log("On Context Menu");
|
||||
if(getSelectedItem().isFolder()){
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
@ -154,8 +153,6 @@ public abstract class AbstractItemsCellTable implements SelectionItem{
|
|||
}, ContextMenuEvent.getType()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the Items.
|
||||
|
|
|
@ -85,7 +85,6 @@ public class ItemsTable extends AbstractItemsCellTable {
|
|||
events.add("click");
|
||||
return events;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
icon = new Column<Item, ImageResource>(iconResourceCell) {
|
||||
|
@ -93,16 +92,6 @@ public class ItemsTable extends AbstractItemsCellTable {
|
|||
public ImageResource getValue(Item dataObj) {
|
||||
return Util.getImage(dataObj);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onBrowserEvent(Context context, Element elem, Item object, NativeEvent event) {
|
||||
// super.onBrowserEvent(context, elem, object, event);
|
||||
// if ("click".equals(event.getType())) {
|
||||
//// Window.open(object.getURL(), "_blank", "");
|
||||
//// GcubeReleasesAppController.eventBus.fireEvent(new PackageClickEvent(object, AccoutingReference.DOWNLOAD));
|
||||
// }
|
||||
// }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.user.cellview.client.Column#render(com.google.gwt.cell.client.Cell.Context, java.lang.Object, com.google.gwt.safehtml.shared.SafeHtmlBuilder)
|
||||
*/
|
||||
|
@ -157,53 +146,13 @@ public class ItemsTable extends AbstractItemsCellTable {
|
|||
}
|
||||
});
|
||||
packageTable.addColumnSortHandler(ownerColumnHandler);
|
||||
/*
|
||||
packageTable.addColumn(icon, "Download");
|
||||
packageTable.setColumnWidth(icon, 10.0, Unit.PCT);
|
||||
*/
|
||||
//MAVEN COORDS
|
||||
ImageResourceCell myImgMavenCell = new ImageResourceCell() {
|
||||
public Set<String> getConsumedEvents() {
|
||||
HashSet<String> events = new HashSet<String>();
|
||||
events.add("click");
|
||||
return events;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
//AS LINK
|
||||
final SafeHtmlRenderer<String> mvnCoordinatesRenderer = new AbstractSafeHtmlRenderer<String>() {
|
||||
@Override
|
||||
public SafeHtml render(String object) {
|
||||
SafeHtmlBuilder sb = new SafeHtmlBuilder();
|
||||
sb.appendHtmlConstant("<a target=\"_blank\" href=\""+object+"\">").appendEscaped("Maven Repo").appendHtmlConstant("</a>");
|
||||
return sb.toSafeHtml();
|
||||
}
|
||||
};
|
||||
|
||||
mvnCoordinates = new Column<Package, String>(new ClickableTextCell(mvnCoordinatesRenderer)) {
|
||||
@Override
|
||||
public String getValue(Package object) {
|
||||
return "http://maven.research-infrastructures.eu/nexus/index.html#nexus-search;quick~"+object.getArtifactID();
|
||||
}
|
||||
};
|
||||
*/
|
||||
// mvn.setSortable(false);
|
||||
|
||||
final SingleSelectionModel<Item> selectionModel = new SingleSelectionModel<Item>();
|
||||
selectionModel.addSelectionChangeHandler(new Handler() {
|
||||
@Override
|
||||
public void onSelectionChange(SelectionChangeEvent event) {
|
||||
// Package p = selectionModel.getSelectedObject();
|
||||
// CellTables.this.driver.edit(person);
|
||||
}
|
||||
});
|
||||
|
||||
// exampleTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
|
||||
// packageTable.setSelectionModel(selectionModel);
|
||||
// pager.setDisplay(exampleTable);
|
||||
// pagination.clear();
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerConstants;
|
|||
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class ItemBuilder.
|
||||
|
@ -29,7 +31,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
|||
*/
|
||||
public class ItemBuilder {
|
||||
|
||||
|
||||
public static final Logger _log = LoggerFactory.getLogger(ItemBuilder.class);
|
||||
/**
|
||||
* Purge empty folders.
|
||||
*
|
||||
|
@ -89,7 +91,7 @@ public class ItemBuilder {
|
|||
itemName = "My VRE Folders";
|
||||
}
|
||||
|
||||
Item item = new Item(parent, workspaceItem.getId(), itemName, type, workspaceItem.getPath(), UserUtil.getUserFullName(workspaceItem.getOwner().getPortalLogin()), workspaceItem.isFolder());
|
||||
Item item = new Item(parent, workspaceItem.getId(), itemName, type, workspaceItem.getPath(), UserUtil.getUserFullName(workspaceItem.getOwner().getPortalLogin()), workspaceItem.isFolder(), workspaceItem.isRoot());
|
||||
item.setSharedFolder(workspaceItem.getType()==WorkspaceItemType.SHARED_FOLDER);
|
||||
|
||||
/*
|
||||
|
@ -223,24 +225,36 @@ public class ItemBuilder {
|
|||
|
||||
String name = "";
|
||||
boolean isSpecialFolder = false;
|
||||
boolean isRoot = false;
|
||||
|
||||
|
||||
if(wsFolder.isRoot()){ //IS ROOT
|
||||
name = WorkspaceExplorerConstants.HOME_LABEL;
|
||||
isRoot = true;
|
||||
}else if(wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)){ //MANAGEMENT SHARED FOLDER NAME
|
||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wsFolder;
|
||||
name = shared.isVreFolder()?shared.getDisplayName():wsFolder.getName();
|
||||
//MANAGEMENT SPECIAL FOLDER
|
||||
}else if(wsFolder.getName().compareTo(WorkspaceExplorerConstants.SPECIAL_FOLDERS_LABEL)==0 && wsFolder.getParent()!=null && wsFolder.getParent().isRoot()){
|
||||
}else if(isSpecialFolder(wsFolder)){
|
||||
name = WorkspaceExplorerConstants.VRE_FOLDERS_LABEL;
|
||||
isSpecialFolder = true;
|
||||
}else
|
||||
name = wsFolder.getName();
|
||||
|
||||
//BUILDS A SIMPLE ITEM FOR BREADCRUMB
|
||||
Item item = new Item(null, wsFolder.getId(), name, ItemType.FOLDER, "", null, true);
|
||||
Item item = new Item(null, wsFolder.getId(), name, ItemType.FOLDER, "", null, true, isRoot);
|
||||
item.setSpecialFolder(isSpecialFolder);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static boolean isSpecialFolder(WorkspaceFolder wsFolder){
|
||||
|
||||
try {
|
||||
return (wsFolder.getName().compareTo(WorkspaceExplorerConstants.SPECIAL_FOLDERS_LABEL)==0 && wsFolder.getParent()!=null && wsFolder.getParent().isRoot());
|
||||
} catch (InternalErrorException e) {
|
||||
_log.warn("isSpecialFolder exception, returning false");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,12 +189,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
|||
}else if(fullName.indexOf(".")>0){
|
||||
fullName = fullName.substring(0, fullName.indexOf("."));
|
||||
}
|
||||
item = new Item(null, root.getId(), fullName+"'s", ItemType.ROOT, root.getPath(), root.getOwner().getPortalLogin(), root.isFolder());
|
||||
item = new Item(null, root.getId(), fullName+"'s", ItemType.ROOT, root.getPath(), root.getOwner().getPortalLogin(), true, true);
|
||||
break;
|
||||
}
|
||||
case VRE_FOLDER:{
|
||||
WorkspaceItem folder = workspace.getMySpecialFolders();
|
||||
item = new Item(null, folder.getId(), WorkspaceExplorerConstants.VRE_FOLDERS_LABEL, ItemType.ROOT, folder.getPath(), folder.getOwner().getPortalLogin(), folder.isFolder());
|
||||
item = new Item(null, folder.getId(), WorkspaceExplorerConstants.VRE_FOLDERS_LABEL, ItemType.FOLDER, folder.getPath(), folder.getOwner().getPortalLogin(), true, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -291,28 +291,35 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
|||
|
||||
Workspace workspace = getWorkspace();
|
||||
WorkspaceItem wsItem = workspace.getItem(itemIdentifier);
|
||||
|
||||
|
||||
_log.trace("workspace retrieve item name: "+wsItem.getName());
|
||||
|
||||
if(includeItemAsParent==true && wsItem.isFolder()){
|
||||
listParents.add(ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) wsItem, null));
|
||||
}
|
||||
|
||||
//HANDLE MY_SPECIAL_FOLDER
|
||||
if(wsItem.isFolder()){
|
||||
if(ItemBuilder.isSpecialFolder((WorkspaceFolder) wsItem))
|
||||
return listParents;
|
||||
}
|
||||
|
||||
//CREATING LIST PARENTS
|
||||
while(wsItem!=null && wsItem.getParent()!=null){
|
||||
WorkspaceFolder wsFolder = wsItem.getParent();
|
||||
Item parent = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) wsFolder, null);
|
||||
WorkspaceFolder wsParentFolder = wsItem.getParent();
|
||||
Item parent = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) wsParentFolder, null);
|
||||
listParents.add(parent);
|
||||
if(parent.isSpecialFolder()) //SKIP HOME PARENT TO MY_SPECIAL_FOLDER
|
||||
if(parent.isSpecialFolder()) //SKIP HOME PARENT FOR MY_SPECIAL_FOLDER
|
||||
break;
|
||||
wsItem = wsFolder;
|
||||
wsItem = wsParentFolder;
|
||||
}
|
||||
|
||||
Collections.reverse(listParents);
|
||||
|
||||
/*
|
||||
System.out.println("Parent's:");
|
||||
for (Item item : listParents) {
|
||||
System.out.println(item);
|
||||
}
|
||||
}*/
|
||||
|
||||
//SET PARENTS
|
||||
for(int i=0; i<listParents.size()-1; i++){
|
||||
|
|
|
@ -19,38 +19,33 @@ public class Item implements IsSerializable {
|
|||
protected String name;
|
||||
protected ItemType type;
|
||||
protected String path;
|
||||
protected boolean isSharedFolder;
|
||||
protected ArrayList<Item> children;
|
||||
private String owner;
|
||||
private boolean isFolder;
|
||||
private boolean isSpecialFolder;
|
||||
|
||||
private boolean isSharedFolder;
|
||||
private boolean isRoot;
|
||||
|
||||
/**
|
||||
* Instantiates a new item.
|
||||
*/
|
||||
public Item() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new item.
|
||||
*
|
||||
* @param parent
|
||||
* the parent
|
||||
* @param id
|
||||
* the id
|
||||
* @param name
|
||||
* the name
|
||||
* @param type
|
||||
* the type
|
||||
* @param path
|
||||
* the path
|
||||
* @param owner
|
||||
* the owner
|
||||
* @param isFolder
|
||||
* the is folder
|
||||
* @param parent the parent
|
||||
* @param id the id
|
||||
* @param name the name
|
||||
* @param type the type
|
||||
* @param path the path
|
||||
* @param owner the owner
|
||||
* @param isFolder the is folder
|
||||
* @param isRoot the is root
|
||||
*/
|
||||
public Item(Item parent, String id, String name, ItemType type,
|
||||
String path, String owner, boolean isFolder) {
|
||||
public Item(Item parent, String id, String name, ItemType type, String path, String owner, boolean isFolder, boolean isRoot) {
|
||||
this.parent = parent;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
@ -59,6 +54,27 @@ public class Item implements IsSerializable {
|
|||
this.children = new ArrayList<Item>();
|
||||
this.owner = owner;
|
||||
this.isFolder = isFolder;
|
||||
this.isRoot = isRoot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is root.
|
||||
*
|
||||
* @return true, if is root
|
||||
*/
|
||||
public boolean isRoot() {
|
||||
return isRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the is root.
|
||||
*
|
||||
* @param isRoot the is root
|
||||
* @return true, if successful
|
||||
*/
|
||||
public void setIsRoot(boolean isRoot) {
|
||||
this.isRoot = isRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,8 +170,9 @@ public class Item implements IsSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
|
@ -203,6 +220,8 @@ public class Item implements IsSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if is special folder.
|
||||
*
|
||||
* @return the isSpecialFolder
|
||||
*/
|
||||
public boolean isSpecialFolder() {
|
||||
|
@ -210,8 +229,9 @@ public class Item implements IsSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param isSpecialFolder
|
||||
* the isSpecialFolder to set
|
||||
* Sets the special folder.
|
||||
*
|
||||
* @param isSpecialFolder the isSpecialFolder to set
|
||||
*/
|
||||
public void setSpecialFolder(boolean isSpecialFolder) {
|
||||
this.isSpecialFolder = isSpecialFolder;
|
||||
|
|
Loading…
Reference in New Issue