718: Workspace: breadcrumb problem on VRE Folders after a two consecutive selection

Task-Url: https://support.d4science.org/issues/show/718

Fixed breadcrumb
Removed unused code

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@118952 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-09-18 14:51:38 +00:00
parent 0cb675e8eb
commit 8ac3a7d3c9
4 changed files with 220 additions and 71 deletions

View File

@ -173,8 +173,9 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.HasWidgets;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * The Class AppControllerExplorer.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*/ */
public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface{ public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface{
@ -192,6 +193,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private static AppControllerExplorer singleton; private static AppControllerExplorer singleton;
/**
* Instantiates a new app controller explorer.
*/
public AppControllerExplorer() { public AppControllerExplorer() {
Registry.register(ConstantsExplorer.RPC_WORKSPACE_SERVICE, rpcWorkspaceService); Registry.register(ConstantsExplorer.RPC_WORKSPACE_SERVICE, rpcWorkspaceService);
subscribers = new HashMap<EventsTypeEnum, ArrayList<SubscriberInterface>>(); subscribers = new HashMap<EventsTypeEnum, ArrayList<SubscriberInterface>>();
@ -200,19 +204,37 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/**
* Gets the single instance of AppControllerExplorer.
*
* @return single instance of AppControllerExplorer
*/
public static AppControllerExplorer getInstance() { public static AppControllerExplorer getInstance() {
return singleton; return singleton;
} }
/**
* Gets the event bus.
*
* @return the event bus
*/
public static HandlerManager getEventBus() { public static HandlerManager getEventBus() {
return eventBus; return eventBus;
} }
/**
* Gets the rpc workspace service.
*
* @return the rpc workspace service
*/
public GWTWorkspaceServiceAsync getRpcWorkspaceService() { public GWTWorkspaceServiceAsync getRpcWorkspaceService() {
return rpcWorkspaceService; return rpcWorkspaceService;
} }
/**
* Bind.
*/
private void bind() { private void bind() {
eventBus.addHandler(UpdateWorkspaceSizeEvent.TYPE, new UpdateWorkspaceSizeEventHandler() { eventBus.addHandler(UpdateWorkspaceSizeEvent.TYPE, new UpdateWorkspaceSizeEventHandler() {
@ -1811,13 +1833,19 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
/** /**
* @param updateWorkspaceSizeEvent * Do update workspace size.
* *
* @param updateWorkspaceSizeEvent the update workspace size event
*/ */
protected void doUpdateWorkspaceSize(UpdateWorkspaceSizeEvent updateWorkspaceSizeEvent) { protected void doUpdateWorkspaceSize(UpdateWorkspaceSizeEvent updateWorkspaceSizeEvent) {
notifySubscriber(updateWorkspaceSizeEvent); notifySubscriber(updateWorkspaceSizeEvent);
} }
/**
* Portal url.
*
* @return the string
*/
public static native String portalURL()/*-{ public static native String portalURL()/*-{
return $wnd.location.href; return $wnd.location.href;
}-*/; }-*/;
@ -1826,6 +1854,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
//Method Notify Subscriber //Method Notify Subscriber
/**
* Notify subscriber.
*
* @param event the event
*/
public void notifySubscriber(GuiEventInterface event) public void notifySubscriber(GuiEventInterface event)
{ {
if (subscribers.containsKey(event.getKey())) if (subscribers.containsKey(event.getKey()))
@ -1983,14 +2016,22 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/** /**
* * Tree level is expanded.
* @param folderId *
* @return * @param folderId the folder id
* @return true, if successful
*/ */
public boolean treeLevelIsExpanded(String folderId){ public boolean treeLevelIsExpanded(String folderId){
return explorerPanel.getAsycTreePanel().isExpanded(folderId); return explorerPanel.getAsycTreePanel().isExpanded(folderId);
} }
/**
* Gets the list parents.
*
* @param listParentModel the list parent model
* @param item the item
* @return the list parents
*/
private List<FileModel> getListParents(List<FileModel> listParentModel, FileModel item){ private List<FileModel> getListParents(List<FileModel> listParentModel, FileModel item){
getParents(listParentModel, item); getParents(listParentModel, item);
@ -2001,10 +2042,15 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/**
* Gets the parents.
*
* @param listParents the list parents
* @param item the item
* @return the parents
*/
private void getParents(List<FileModel> listParents, FileModel item){ private void getParents(List<FileModel> listParents, FileModel item){
// System.out.println("item is: "+item);
// System.out.println("parent is: "+item.getParentFileModel());
if(item==null || item.getParentFileModel()==null){ if(item==null || item.getParentFileModel()==null){
return; return;
} }
@ -2018,12 +2064,24 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
getParents(listParents, item.getParentFileModel()); getParents(listParents, item.getParentFileModel());
} }
/**
* Subscribe.
*
* @param subscriber the subscriber
* @param keys the keys
*/
public void subscribe(SubscriberInterface subscriber, EventsTypeEnum[] keys) public void subscribe(SubscriberInterface subscriber, EventsTypeEnum[] keys)
{ {
for (EventsTypeEnum m : keys) for (EventsTypeEnum m : keys)
subscribe(subscriber, m); subscribe(subscriber, m);
} }
/**
* Subscribe.
*
* @param subscriber the subscriber
* @param key the key
*/
public void subscribe(SubscriberInterface subscriber, EventsTypeEnum key) public void subscribe(SubscriberInterface subscriber, EventsTypeEnum key)
{ {
if (subscribers.containsKey(key)) if (subscribers.containsKey(key))
@ -2036,12 +2094,27 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
} }
/**
* Unsubscribe.
*
* @param subscriber the subscriber
* @param key the key
*/
public void unsubscribe(SubscriberInterface subscriber, EventsTypeEnum key) public void unsubscribe(SubscriberInterface subscriber, EventsTypeEnum key)
{ {
if (subscribers.containsKey(key)) if (subscribers.containsKey(key))
subscribers.get(key).remove(subscriber); subscribers.get(key).remove(subscriber);
} }
/**
* Go.
*
* @param rootPanel the root panel
* @param onlyTree the only tree
* @param instancingSmartFolder the instancing smart folder
* @param instancingMessages the instancing messages
* @param selectRootItem the select root item
*/
public void go(final HasWidgets rootPanel, boolean onlyTree, boolean instancingSmartFolder, boolean instancingMessages, boolean selectRootItem) { public void go(final HasWidgets rootPanel, boolean onlyTree, boolean instancingSmartFolder, boolean instancingMessages, boolean selectRootItem) {
if(onlyTree){ if(onlyTree){
@ -2060,9 +2133,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/** /**
* Use method getPanel * Use method getPanel.
*
* @return ExplorerPanel * @return ExplorerPanel
* @deprecated * @deprecated
*/ */
public ExplorerPanel getTreePanel(){ public ExplorerPanel getTreePanel(){
@ -2072,6 +2146,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
/** /**
* Instance only Async Tree with specific width - height - select by default the root item . * Instance only Async Tree with specific width - height - select by default the root item .
*
* @param width the width
* @param height the height
* @return AsyncTreePanel * @return AsyncTreePanel
*/ */
@ -2084,13 +2161,17 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
return explorerPanel.getAsycTreePanel(); return explorerPanel.getAsycTreePanel();
} }
/**
* Hide sharing facilities.
*/
public void hideSharingFacilities() { public void hideSharingFacilities() {
explorerPanel.getAsycTreePanel().getContextMenuTree().setHideSharing(); explorerPanel.getAsycTreePanel().getContextMenuTree().setHideSharing();
} }
/** /**
* * Refresh root.
* @param selectRootItem *
* @param selectRootItem the select root item
*/ */
public void refreshRoot(boolean selectRootItem){ public void refreshRoot(boolean selectRootItem){
if(explorerPanel.getAsycTreePanel()!=null) if(explorerPanel.getAsycTreePanel()!=null)
@ -2103,40 +2184,33 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
* @return ExplorerPanel * @return ExplorerPanel
*/ */
public ExplorerPanel getPanel(){ public ExplorerPanel getPanel(){
this.explorerPanel = new ExplorerPanel(true, true); this.explorerPanel = new ExplorerPanel(true, true);
loadMyLogin(); loadMyLogin();
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
// PollingWorkspace.pollBulkCreator(15000);
return this.explorerPanel; return this.explorerPanel;
} }
/** /**
* Instance by default asyncronus Tree while Smart Folders and Messages was instanced as input value * Instance by default asyncronus Tree while Smart Folders and Messages was instanced as input value.
* @param instancingSmartFolder *
* @param instancingMessages * @param instancingSmartFolder the instancing smart folder
* @param instancingMessages the instancing messages
* @param selectRootItem the select root item
* @return ExplorerPanel * @return ExplorerPanel
*/ */
public ExplorerPanel getPanel(boolean instancingSmartFolder, boolean instancingMessages, boolean selectRootItem){ public ExplorerPanel getPanel(boolean instancingSmartFolder, boolean instancingMessages, boolean selectRootItem){
this.explorerPanel = new ExplorerPanel(instancingSmartFolder, instancingMessages, selectRootItem); this.explorerPanel = new ExplorerPanel(instancingSmartFolder, instancingMessages, selectRootItem);
this.selectRootItem=selectRootItem; this.selectRootItem=selectRootItem;
loadMyLogin(); loadMyLogin();
// if(instancingMessages)
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
// PollingWorkspace.pollBulkCreator(ConstantsExplorer.TIME_BULK_CREATOR_POLLING);
return this.explorerPanel; return this.explorerPanel;
} }
/**
* Edi permissions.
*
* @param file the file
*/
private void ediPermissions(final FileModel file) { private void ediPermissions(final FileModel file) {
GWT.log("Edit Permissions on "+file); GWT.log("Edit Permissions on "+file);
@ -2243,9 +2317,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/** /**
* * Show add administrators dialog.
* @param file *
* @param showAlert * @param file the file
*/ */
private void showAddAdministratorsDialog(final FileModel file) { private void showAddAdministratorsDialog(final FileModel file) {
@ -2320,6 +2394,12 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/**
* Do add administrator to folder id.
*
* @param file the file
* @param logins the logins
*/
private void doAddAdministratorToFolderId(final FileModel file, final List<String> logins) { private void doAddAdministratorToFolderId(final FileModel file, final List<String> logins) {
rpcWorkspaceService.addAdministratorsByFolderId(file.getIdentifier(), logins, new AsyncCallback<Boolean>() { rpcWorkspaceService.addAdministratorsByFolderId(file.getIdentifier(), logins, new AsyncCallback<Boolean>() {
@ -2338,6 +2418,13 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}); });
} }
/**
* Sets the acl to folder id.
*
* @param folderId the folder id
* @param logins the logins
* @param aclTypeID the acl type id
*/
private void setACLToFolderId(final String folderId, final List<String> logins, String aclTypeID) { private void setACLToFolderId(final String folderId, final List<String> logins, String aclTypeID) {
rpcWorkspaceService.setACLs(folderId, logins, aclTypeID, new AsyncCallback<Void>() { rpcWorkspaceService.setACLs(folderId, logins, aclTypeID, new AsyncCallback<Void>() {
@ -2357,6 +2444,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/**
* Load my login.
*/
private void loadMyLogin(){ private void loadMyLogin(){
rpcWorkspaceService.getMyLogin(new AsyncCallback<UserBean>() { rpcWorkspaceService.getMyLogin(new AsyncCallback<UserBean>() {
@ -2378,6 +2468,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/**
* Load item from workspace.
*
* @param itemIdentifier the item identifier
*/
private void loadItemFromWorkspace(final String itemIdentifier){ private void loadItemFromWorkspace(final String itemIdentifier){
@ -2390,8 +2485,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
explorerPanel.getAsycTreePanel().unmask(); explorerPanel.getAsycTreePanel().unmask();
new MessageBoxAlert("Error", "Sorry - getChildrenSubTreeToRootByIdentifier", null); new MessageBoxAlert("Error", "Sorry - getChildrenSubTreeToRootByIdentifier", null);
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
} }
@Override @Override
@ -2400,9 +2493,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
boolean foundAncestor = false; boolean foundAncestor = false;
// int index = 0; // int index = 0;
int i = 0; int i = 0;
try{ try{
while (!foundAncestor) { while (!foundAncestor) {
if(i<result.size()){ if(i<result.size()){
@ -2416,7 +2507,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
else else
break; break;
} }
explorerPanel.getAsycTreePanel().setSubTreeLoaded(true); explorerPanel.getAsycTreePanel().setSubTreeLoaded(true);
@ -2434,28 +2524,18 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
explorerPanel.getAsycTreePanel().addChildrenToFolder(subTree.getParent().getIdentifier(),subTree.getChildren()); // Add level explorerPanel.getAsycTreePanel().addChildrenToFolder(subTree.getParent().getIdentifier(),subTree.getChildren()); // Add level
explorerPanel.getAsycTreePanel().setExpandTreeLevel(subTree.getParent().getIdentifier(), true); // Expand level explorerPanel.getAsycTreePanel().setExpandTreeLevel(subTree.getParent().getIdentifier(), true); // Expand level
} }
ArrayList<FileModel> pathParentsList = (ArrayList<FileModel>) getListParentsByIdentifierFromTree(itemIdentifier); ArrayList<FileModel> pathParentsList = (ArrayList<FileModel>) getListParentsByIdentifierFromTree(itemIdentifier);
// FileModel fileModel = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
// if(fileModel != null && !fileModel.isDirectory())
// explorerPanel.getAsycTreePanel().selectItem(itemIdentifier);
selectItemInTree(itemIdentifier); selectItemInTree(itemIdentifier);
explorerPanel.getAsycTreePanel().setSubTreeLoaded(false); explorerPanel.getAsycTreePanel().setSubTreeLoaded(false);
explorerPanel.getAsycTreePanel().unmask(); explorerPanel.getAsycTreePanel().unmask();
eventBus.fireEvent(new SubTreeLoadedEvent(pathParentsList)); eventBus.fireEvent(new SubTreeLoadedEvent(pathParentsList));
} }
} }catch (Exception e) {
catch (Exception e) {
new MessageBoxAlert("Error", "Sorry, e "+e.getMessage(), null); new MessageBoxAlert("Error", "Sorry, e "+e.getMessage(), null);
} }
} }
@ -2463,6 +2543,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}); });
} }
/**
* Deselecte current selection.
*/
private void deselecteCurrentSelection(){ private void deselecteCurrentSelection(){
FileModel fileModelSelected = explorerPanel.getAsycTreePanel().getSelectedFileModelItem(); FileModel fileModelSelected = explorerPanel.getAsycTreePanel().getSelectedFileModelItem();
if(fileModelSelected!=null) if(fileModelSelected!=null)
@ -2470,6 +2553,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
//********METHODS TO NOTIFY TREE //********METHODS TO NOTIFY TREE
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#getListParentsByIdentifierFromTree(java.lang.String)
*/
@Override @Override
public List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier) { public List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier) {
@ -2478,8 +2564,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
FileModel item = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier); FileModel item = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
if(item==null){ if(item==null){
// System.out.println(" LOAD****");
// selectedItemInTree(itemIdentifier); //Load from HL
return null; return null;
} }
else{ else{
@ -2487,18 +2571,29 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#renameItem(java.lang.String, java.lang.String, java.lang.String)
*/
@Override @Override
public boolean renameItem(String itemIdentifier, String newName, String extension) { public boolean renameItem(String itemIdentifier, String newName, String extension) {
return this.explorerPanel.getAsycTreePanel().renameItem(itemIdentifier, newName, extension); return this.explorerPanel.getAsycTreePanel().renameItem(itemIdentifier, newName, extension);
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#deleteItem(java.lang.String)
*/
@Override @Override
public boolean deleteItem(String itemIdentifier) { public boolean deleteItem(String itemIdentifier) {
return this.explorerPanel.getAsycTreePanel().deleteItem(itemIdentifier); return this.explorerPanel.getAsycTreePanel().deleteItem(itemIdentifier);
} }
/** /**
* method not used * method not used.
*
* @param itemIdentifier the item identifier
* @param name the name
* @param parentIdentifier the parent identifier
* @return true, if successful
*/ */
@Override @Override
public boolean addFolder(String itemIdentifier, String name, String parentIdentifier) { public boolean addFolder(String itemIdentifier, String name, String parentIdentifier) {
@ -2506,7 +2601,12 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/** /**
* method not used * method not used.
*
* @param itemIdentifier the item identifier
* @param name the name
* @param parentIdentifier the parent identifier
* @return true, if successful
*/ */
@Override @Override
public boolean addFile(String itemIdentifier, String name, String parentIdentifier) { public boolean addFile(String itemIdentifier, String name, String parentIdentifier) {
@ -2514,7 +2614,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/** /**
* method not used * method not used.
*
* @param itemIdentifier the item identifier
* @return true, if successful
*/ */
@Override @Override
public boolean reloadFolderChildren(String itemIdentifier) { public boolean reloadFolderChildren(String itemIdentifier) {
@ -2522,19 +2625,25 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
/** /**
* method not used * method not used.
*
* @param type the new visualization type
*/ */
@Override @Override
public void setVisualizationType(VisualizationType type) { public void setVisualizationType(VisualizationType type) {
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#selectRootItem()
*/
@Override @Override
public void selectRootItem(){ public void selectRootItem(){
this.explorerPanel.getAsycTreePanel().selectRootItem(); this.explorerPanel.getAsycTreePanel().selectRootItem();
} }
/** /**
* * Gets the selected folder in tree.
*
* @return FileModel parent selected or root item if no directory is selected * @return FileModel parent selected or root item if no directory is selected
*/ */
@Override @Override
@ -2548,6 +2657,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
return fileModel.getParentFileModel(); return fileModel.getParentFileModel();
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#findItemAndSelectItemInTree(java.lang.String)
*/
@Override @Override
public void findItemAndSelectItemInTree(String itemIdentifier) { public void findItemAndSelectItemInTree(String itemIdentifier) {
@ -2564,6 +2676,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
} }
/**
* Select item in tree.
*
* @param itemIdentifier the item identifier
*/
private void selectItemInTree(String itemIdentifier){ private void selectItemInTree(String itemIdentifier){
FileModel fileModel = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier); FileModel fileModel = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
@ -2584,13 +2701,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
} }
/*
private void markItemInTreeAsRead(String itemId, boolean bool){
FileModel file = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemId);
}
*/
public AsyncCallback<WindowOpenParameter> downloadHandlerCallback = new AsyncCallback<WindowOpenParameter>() { public AsyncCallback<WindowOpenParameter> downloadHandlerCallback = new AsyncCallback<WindowOpenParameter>() {
@Override @Override
@ -2616,6 +2726,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
}; };
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#expandFolder(java.lang.String)
*/
@Override @Override
/** /**
* Called when path item is clicked * Called when path item is clicked
@ -2634,12 +2747,20 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
} }
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#searching(boolean)
*/
@Override @Override
public void searching(boolean isSearch){ public void searching(boolean isSearch){
// deselecteCurrentSelection(); // deselecteCurrentSelection();
explorerPanel.getAsycTreePanel().setSearch(isSearch); explorerPanel.getAsycTreePanel().setSearch(isSearch);
} }
/**
* Do click url.
*
* @param openUrlEvent the open url event
*/
public void doClickUrl(OpenUrlEvent openUrlEvent) { public void doClickUrl(OpenUrlEvent openUrlEvent) {
final FileModel fileModel = openUrlEvent.getSourceFileModel(); final FileModel fileModel = openUrlEvent.getSourceFileModel();

View File

@ -39,4 +39,20 @@ public class SubTree extends BaseModelData implements Serializable {
public String getParentId(){ public String getParentId(){
return this.parent.getIdentifier(); return this.parent.getIdentifier();
} }
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SubTree [parent=");
builder.append(parent);
builder.append(", children=");
builder.append(children!=null?children.size():"null");
builder.append("]");
return builder.toString();
}
} }

View File

@ -1271,6 +1271,7 @@ public class GWTWorkspaceBuilder {
FolderModel folder = new FolderModel(wsFolder.getId(), name, parent, true, wsFolder.isShared(), false); FolderModel folder = new FolderModel(wsFolder.getId(), name, parent, true, wsFolder.isShared(), false);
folder.setShareable(true); folder.setShareable(true);
folder.setIsRoot(wsFolder.isRoot());
folder.setDescription(wsFolder.getDescription()); folder.setDescription(wsFolder.getDescription());
// folder.setOwner(wsFolder.getOwner()); // folder.setOwner(wsFolder.getOwner());

View File

@ -44,7 +44,6 @@ import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel; import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel; import org.gcube.portlets.user.workspace.client.model.FileModel;
@ -1000,9 +999,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
workspaceLogger.trace("search itemId: "+itemIdentifier); workspaceLogger.trace("search itemId: "+itemIdentifier);
WorkspaceItem item = workspace.getItem(itemIdentifier); //get item from workspace WorkspaceItem item = workspace.getItem(itemIdentifier); //get item from workspace
getListsChildrenByParents(listSubTree, item); getListsChildrenByParent(listSubTree, item);
Collections.reverse(listSubTree); //reverse order of array Collections.reverse(listSubTree); //reverse order of array
//SET THE ROOT
if(listSubTree.size()>0){
workspaceLogger.trace("set: "+listSubTree.get(0).getParent().getName() +" as root");
listSubTree.get(0).getParent().setIsRoot(true);
}
workspaceLogger.trace("getChildrenSubTreeToRootByIdentifier returning list SubTree: "+listSubTree);
} catch (Exception e) { } catch (Exception e) {
workspaceLogger.error("Error in server find Item", e); workspaceLogger.error("Error in server find Item", e);
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
@ -1073,19 +1080,23 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* @return the lists children by parents * @return the lists children by parents
* @throws Exception the exception * @throws Exception the exception
*/ */
private void getListsChildrenByParents(ArrayList<SubTree> listSubTree, WorkspaceItem parent) throws Exception{ private void getListsChildrenByParent(ArrayList<SubTree> listSubTree, WorkspaceItem parent) throws Exception{
if(parent==null || parent.getParent()==null) if(parent==null)
return; return;
workspaceLogger.trace("getListsChildrenByParents: "+parent.getName()); if(!parent.isFolder()){
workspaceLogger.warn("getListsChildrenByParent returning: "+parent.getName() +" is not a folder");
return;
}
workspaceLogger.trace("getListsChildrenByParent: "+parent.getName());
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
FolderModel parentModel = (FolderModel) builder.buildGXTFileModelItem(parent, null); FolderModel parentModel = (FolderModel) builder.buildGXTFileModelItem(parent, null); //get folder
List<FileModel> childrenList = getFolderChildren(parentModel); //create children list List<FileModel> childrenList = getFolderChildren(parentModel); //get children
SubTree subTree = new SubTree(parentModel, childrenList); SubTree subTree = new SubTree(parentModel, childrenList);
listSubTree.add(subTree); listSubTree.add(subTree);
getListsChildrenByParents(listSubTree, parent.getParent()); getListsChildrenByParent(listSubTree, parent.getParent());
} }
/* (non-Javadoc) /* (non-Javadoc)