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;
/**
* @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{
@ -192,6 +193,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private static AppControllerExplorer singleton;
/**
* Instantiates a new app controller explorer.
*/
public AppControllerExplorer() {
Registry.register(ConstantsExplorer.RPC_WORKSPACE_SERVICE, rpcWorkspaceService);
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() {
return singleton;
}
/**
* Gets the event bus.
*
* @return the event bus
*/
public static HandlerManager getEventBus() {
return eventBus;
}
/**
* Gets the rpc workspace service.
*
* @return the rpc workspace service
*/
public GWTWorkspaceServiceAsync getRpcWorkspaceService() {
return rpcWorkspaceService;
}
/**
* Bind.
*/
private void bind() {
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) {
notifySubscriber(updateWorkspaceSizeEvent);
}
/**
* Portal url.
*
* @return the string
*/
public static native String portalURL()/*-{
return $wnd.location.href;
}-*/;
@ -1826,6 +1854,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
//Method Notify Subscriber
/**
* Notify subscriber.
*
* @param event the event
*/
public void notifySubscriber(GuiEventInterface event)
{
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){
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){
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){
// System.out.println("item is: "+item);
// System.out.println("parent is: "+item.getParentFileModel());
if(item==null || item.getParentFileModel()==null){
return;
}
@ -2018,12 +2064,24 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
getParents(listParents, item.getParentFileModel());
}
/**
* Subscribe.
*
* @param subscriber the subscriber
* @param keys the keys
*/
public void subscribe(SubscriberInterface subscriber, EventsTypeEnum[] keys)
{
for (EventsTypeEnum m : keys)
subscribe(subscriber, m);
}
/**
* Subscribe.
*
* @param subscriber the subscriber
* @param key the key
*/
public void subscribe(SubscriberInterface subscriber, EventsTypeEnum 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)
{
if (subscribers.containsKey(key))
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) {
if(onlyTree){
@ -2060,7 +2133,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
/**
* Use method getPanel
* Use method getPanel.
*
* @return ExplorerPanel
* @deprecated
*/
@ -2072,6 +2146,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
/**
* Instance only Async Tree with specific width - height - select by default the root item .
*
* @param width the width
* @param height the height
* @return AsyncTreePanel
*/
@ -2084,13 +2161,17 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
return explorerPanel.getAsycTreePanel();
}
/**
* Hide sharing facilities.
*/
public void hideSharingFacilities() {
explorerPanel.getAsycTreePanel().getContextMenuTree().setHideSharing();
}
/**
* Refresh root.
*
* @param selectRootItem
* @param selectRootItem the select root item
*/
public void refreshRoot(boolean selectRootItem){
if(explorerPanel.getAsycTreePanel()!=null)
@ -2103,40 +2184,33 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
* @return ExplorerPanel
*/
public ExplorerPanel getPanel(){
this.explorerPanel = new ExplorerPanel(true, true);
loadMyLogin();
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
// PollingWorkspace.pollBulkCreator(15000);
return this.explorerPanel;
}
/**
* Instance by default asyncronus Tree while Smart Folders and Messages was instanced as input value
* @param instancingSmartFolder
* @param instancingMessages
* Instance by default asyncronus Tree while Smart Folders and Messages was instanced as input value.
*
* @param instancingSmartFolder the instancing smart folder
* @param instancingMessages the instancing messages
* @param selectRootItem the select root item
* @return ExplorerPanel
*/
public ExplorerPanel getPanel(boolean instancingSmartFolder, boolean instancingMessages, boolean selectRootItem){
this.explorerPanel = new ExplorerPanel(instancingSmartFolder, instancingMessages, selectRootItem);
this.selectRootItem=selectRootItem;
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;
}
/**
* Edi permissions.
*
* @param file the file
*/
private void ediPermissions(final FileModel 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) {
@ -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) {
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) {
rpcWorkspaceService.setACLs(folderId, logins, aclTypeID, new AsyncCallback<Void>() {
@ -2357,6 +2444,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
/**
* Load my login.
*/
private void loadMyLogin(){
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){
@ -2390,8 +2485,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
explorerPanel.getAsycTreePanel().unmask();
new MessageBoxAlert("Error", "Sorry - getChildrenSubTreeToRootByIdentifier", null);
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
}
@Override
@ -2400,9 +2493,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
boolean foundAncestor = false;
// int index = 0;
int i = 0;
try{
while (!foundAncestor) {
if(i<result.size()){
@ -2416,7 +2507,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
else
break;
}
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().setExpandTreeLevel(subTree.getParent().getIdentifier(), true); // Expand level
}
ArrayList<FileModel> pathParentsList = (ArrayList<FileModel>) getListParentsByIdentifierFromTree(itemIdentifier);
// FileModel fileModel = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
// if(fileModel != null && !fileModel.isDirectory())
// explorerPanel.getAsycTreePanel().selectItem(itemIdentifier);
selectItemInTree(itemIdentifier);
explorerPanel.getAsycTreePanel().setSubTreeLoaded(false);
explorerPanel.getAsycTreePanel().unmask();
eventBus.fireEvent(new SubTreeLoadedEvent(pathParentsList));
}
}
catch (Exception e) {
}catch (Exception e) {
new MessageBoxAlert("Error", "Sorry, e "+e.getMessage(), null);
}
}
@ -2463,6 +2543,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
});
}
/**
* Deselecte current selection.
*/
private void deselecteCurrentSelection(){
FileModel fileModelSelected = explorerPanel.getAsycTreePanel().getSelectedFileModelItem();
if(fileModelSelected!=null)
@ -2470,6 +2553,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
//********METHODS TO NOTIFY TREE
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#getListParentsByIdentifierFromTree(java.lang.String)
*/
@Override
public List<FileModel> getListParentsByIdentifierFromTree(String itemIdentifier) {
@ -2478,8 +2564,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
FileModel item = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
if(item==null){
// System.out.println(" LOAD****");
// selectedItemInTree(itemIdentifier); //Load from HL
return null;
}
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
public boolean renameItem(String itemIdentifier, String newName, String 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
public boolean deleteItem(String 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
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
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
public boolean reloadFolderChildren(String itemIdentifier) {
@ -2522,18 +2625,24 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
/**
* method not used
* method not used.
*
* @param type the new visualization type
*/
@Override
public void setVisualizationType(VisualizationType type) {
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#selectRootItem()
*/
@Override
public void selectRootItem(){
this.explorerPanel.getAsycTreePanel().selectRootItem();
}
/**
* Gets the selected folder in tree.
*
* @return FileModel parent selected or root item if no directory is selected
*/
@ -2548,6 +2657,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
return fileModel.getParentFileModel();
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.TreeAppControllerInterface#findItemAndSelectItemInTree(java.lang.String)
*/
@Override
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){
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>() {
@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
/**
* 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
public void searching(boolean isSearch){
// deselecteCurrentSelection();
explorerPanel.getAsycTreePanel().setSearch(isSearch);
}
/**
* Do click url.
*
* @param openUrlEvent the open url event
*/
public void doClickUrl(OpenUrlEvent openUrlEvent) {
final FileModel fileModel = openUrlEvent.getSourceFileModel();

View File

@ -39,4 +39,20 @@ public class SubTree extends BaseModelData implements Serializable {
public String getParentId(){
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);
folder.setShareable(true);
folder.setIsRoot(wsFolder.isRoot());
folder.setDescription(wsFolder.getDescription());
// 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.portlets.user.workspace.client.ConstantsExplorer;
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.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel;
@ -1000,9 +999,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
Workspace workspace = getWorkspace();
workspaceLogger.trace("search itemId: "+itemIdentifier);
WorkspaceItem item = workspace.getItem(itemIdentifier); //get item from workspace
getListsChildrenByParents(listSubTree, item);
getListsChildrenByParent(listSubTree, item);
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) {
workspaceLogger.error("Error in server find Item", e);
throw new Exception(e.getMessage());
@ -1073,19 +1080,23 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* @return the lists children by parents
* @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;
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();
FolderModel parentModel = (FolderModel) builder.buildGXTFileModelItem(parent, null);
List<FileModel> childrenList = getFolderChildren(parentModel); //create children list
FolderModel parentModel = (FolderModel) builder.buildGXTFileModelItem(parent, null); //get folder
List<FileModel> childrenList = getFolderChildren(parentModel); //get children
SubTree subTree = new SubTree(parentModel, childrenList);
listSubTree.add(subTree);
getListsChildrenByParents(listSubTree, parent.getParent());
getListsChildrenByParent(listSubTree, parent.getParent());
}
/* (non-Javadoc)