fixed uploading from grid

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@71703 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-03-25 14:31:14 +00:00
parent 08604da86c
commit 125b1cc3df
4 changed files with 113 additions and 12 deletions

View File

@ -33,6 +33,8 @@ import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEventHandler;
import org.gcube.portlets.user.workspace.client.event.LoadAllScopeEvent;
import org.gcube.portlets.user.workspace.client.event.LoadAllScopeEventHandler;
import org.gcube.portlets.user.workspace.client.event.LoadBreadcrumbEvent;
import org.gcube.portlets.user.workspace.client.event.LoadBreadcrumbEventHandler;
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEvent;
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEventHandler;
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
@ -312,8 +314,14 @@ public class AppController implements SubscriberInterface {
//COMMENTED 01-02-2013
// appContrExplorer.expandFolder(event.getIdentifier());
FolderModel folder = new FolderModel(fileModel.getIdentifier(), fileModel.getName(), fileModel.getParentFileModel(), true, fileModel.isShared());
updateStoreByRpc(folder);
if(fileModel.getIdentifier()!=null){
FolderModel folder = new FolderModel(fileModel.getIdentifier(), fileModel.getName(), fileModel.getParentFileModel(), true, fileModel.isShared());
updateStoreByRpc(folder);
wsPortlet.getGridGroupContainer().setCurrentFolderView(folder);
loadBreadcrumbById(fileModel, true);
}
else
GWT.log("an error occurred in double click on grid, item select is null");
}
});
@ -426,7 +434,21 @@ public class AppController implements SubscriberInterface {
@Override
public void onFileUploadEvent(FileUploadEvent fileUploadEvent) {
AppControllerExplorer.getEventBus().fireEvent(new FileUploadEvent(null,fileUploadEvent.getUploadType()));
FileModel parent = null;
//FILE UPLOAD CASES..
if(fileUploadEvent.getParentFileModel()!=null){
parent = fileUploadEvent.getParentFileModel();
GWT.log("get parent item for uploading from parent of file model: " +fileUploadEvent.getParentFileModel().getName());
}else if(wsPortlet.getGridGroupContainer().getCurrentFolderView()!=null && !isSearchActive){
parent = wsPortlet.getGridGroupContainer().getCurrentFolderView();
GWT.log("get parent item for uploading from CurrentFolderView: " +parent.getName());
}else if(wsPortlet.getToolBarPath().getLastParent()!=null){
parent = wsPortlet.getToolBarPath().getLastParent();
GWT.log("get parent item for uploading from breadcrumb: " +parent.getName());
}
AppControllerExplorer.getEventBus().fireEvent(new FileUploadEvent(fileUploadEvent.getParentFileModel(),fileUploadEvent.getUploadType()));
}
});
@ -469,6 +491,16 @@ public class AppController implements SubscriberInterface {
AppControllerExplorer.getEventBus().fireEvent(new RenameItemEvent(event.getFileTarget()));
}
});
eventBus.addHandler(LoadBreadcrumbEvent.TYPE, new LoadBreadcrumbEventHandler() {
@Override
public void loadBreadcrumb(LoadBreadcrumbEvent loadBreadcrumbEvent) {
if(loadBreadcrumbEvent.getFileModel()!=null)
loadBreadcrumbById(loadBreadcrumbEvent.getFileModel(), true);
}
});
}
private void doElementGridSelected(boolean isSelected, FileModel target) {
@ -484,20 +516,25 @@ public class AppController implements SubscriberInterface {
//RELOAD breadcrumb only if last parent id is changed
if(parentChanged)
loadBreadcrumbById(target.getIdentifier());
loadBreadcrumbById(target,false);
}
else
loadBreadcrumbById(target.getIdentifier());
loadBreadcrumbById(target,false);
}
}
private void loadBreadcrumbById(String itemIdentifier){
/**
*
* @param item
* @param isLastParent - if is true, load the item passed in input as last item of the resulted list
*/
private void loadBreadcrumbById(final FileModel item, final boolean isLastParent){
System.out.println("Reload Breadcrumb...");
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(itemIdentifier, new AsyncCallback<List<FileModel>>() {
AppControllerExplorer.rpcWorkspaceService.getListParentsByItemIdentifier(item.getIdentifier(), new AsyncCallback<List<FileModel>>() {
@Override
public void onFailure(Throwable caught) {
@ -507,8 +544,14 @@ public class AppController implements SubscriberInterface {
@Override
public void onSuccess(List<FileModel> result) {
if(isLastParent){
result.add(item);
}
setPathInView(result); //Set file path in tab panel on current item selected
}
});

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.user.workspace.client.event;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import com.google.gwt.event.shared.GwtEvent;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class LoadBreadcrumbEvent extends GwtEvent<LoadBreadcrumbEventHandler> {
public static Type<LoadBreadcrumbEventHandler> TYPE = new Type<LoadBreadcrumbEventHandler>();
private FileModel fileModel;
public FileModel getFileModel() {
return fileModel;
}
public LoadBreadcrumbEvent(FileModel item) {
this.fileModel = item;
}
@Override
public Type<LoadBreadcrumbEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(LoadBreadcrumbEventHandler handler) {
handler.loadBreadcrumb(this);
}
}

View File

@ -0,0 +1,11 @@
package org.gcube.portlets.user.workspace.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public interface LoadBreadcrumbEventHandler extends EventHandler {
void loadBreadcrumb(LoadBreadcrumbEvent loadBreadcrumbEvent);
}

View File

@ -253,8 +253,13 @@ public class GxtToolBarItem {
@Override
public void componentSelected(ButtonEvent ce) {
AppController.getEventBus().fireEvent(
new FileUploadEvent(null, UploadType.FILE));
final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
if(fileGridModel!=null)
AppController.getEventBus().fireEvent(new FileUploadEvent(fileGridModel.getParentFileModel(), UploadType.FILE));
else
AppController.getEventBus().fireEvent(new FileUploadEvent(null, UploadType.FILE));
}
});
@ -262,8 +267,13 @@ public class GxtToolBarItem {
@Override
public void componentSelected(ButtonEvent ce) {
AppController.getEventBus().fireEvent(
new FileUploadEvent(null, UploadType.ARCHIVE));
final FileGridModel fileGridModel = gridGroupViewContainer.getSelectedItem();
if(fileGridModel!=null)
AppController.getEventBus().fireEvent(new FileUploadEvent(fileGridModel.getParentFileModel(), UploadType.ARCHIVE));
else
AppController.getEventBus().fireEvent(new FileUploadEvent(null, UploadType.ARCHIVE));
}
});