multi selection support is available to remove items from grid

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@90132 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-01-15 11:49:40 +00:00
parent f6bc9c0dea
commit ebae3cc0bc
9 changed files with 118 additions and 10 deletions

View File

@ -239,7 +239,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onSuccess(Boolean result) {
if(result) //REFRESH PARENT FOLDER
eventBus.fireEvent(new RefreshFolderEvent(source.getParentFileModel(), true, false));
eventBus.fireEvent(new RefreshFolderEvent(source.getParentFileModel(), true, false, false));
}
});
@ -371,7 +371,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
else
parentToRefresh = parentFileModel;
eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false));
eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false, false));
GWT.log("share completed refresh folder : "+parentModel.getName());
}
explorerPanel.unmask();
@ -518,14 +518,22 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(refreshItemEvent.getFolderTarget()!=null){
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
if(!refreshItemEvent.isIfExists()){ //CAlled Tree side
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
notifySubscriber(refreshItemEvent);
}
else{ //Valitaing folder existence - called portlet side
FileModel target = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(refreshItemEvent.getFolderTarget().getIdentifier());
if(target!=null)
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
}
// notifySubscriber(refreshtemEvent);
}
else
GWT.log("warn: escape refresh because item is null");
notifySubscriber(refreshItemEvent);
}
});
@ -594,7 +602,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
public void onSuccess(Boolean result) {
if(result)
eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true));
eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true, false));
notifySubscriber(pasteItemEvent);
}
@ -1867,9 +1875,13 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
explorerPanel.getAsycTreePanel().getContextMenuTree().setHideSharing();
}
public void refreshRoot(){
/**
*
* @param selectRootItem
*/
public void refreshRoot(boolean selectRootItem){
if(explorerPanel.getAsycTreePanel()!=null)
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(selectRootItem);
}

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.workspace.client.event;
import java.util.List;
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
import org.gcube.portlets.user.workspace.client.model.FileModel;
@ -10,9 +12,19 @@ public class DeleteItemEvent extends GwtEvent<DeleteItemEventHandler> implements
public static Type<DeleteItemEventHandler> TYPE = new Type<DeleteItemEventHandler>();
private FileModel fileTarget = null;
private List<String> listTarget;
private boolean isMultiSelection;
public DeleteItemEvent(FileModel fileModel) {
this.fileTarget = fileModel;
this.isMultiSelection = false;
}
public DeleteItemEvent(List<String> listTarget) {
this.listTarget = listTarget;
this.isMultiSelection = true;
}
@Override
@ -36,4 +48,12 @@ public class DeleteItemEvent extends GwtEvent<DeleteItemEventHandler> implements
public FileModel getFileTarget() {
return fileTarget;
}
public List<String> getListTarget() {
return listTarget;
}
public boolean isMultiSelection() {
return isMultiSelection;
}
}

View File

@ -14,11 +14,14 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
private boolean expandFolder = true; //DEFAULT EXPAND FOLDER
private boolean forceRefresh;
private boolean ifExists = false;
public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh) {
public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh, boolean ifExists) {
this.folderTarget = folderTarget;
this.expandFolder = expandFolder;
this.forceRefresh = forceRefresh;
this.ifExists = ifExists;
}
@ -61,4 +64,9 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
public void setForceRefresh(boolean forceRefresh) {
this.forceRefresh = forceRefresh;
}
public boolean isIfExists() {
return ifExists;
}
}

View File

@ -31,7 +31,7 @@ public interface SubscriberInterface {
void smartFolderSelected(String folderId, String category);
void movedItems(String sourceParentIdentifier, FileModel targetParent);
void switchView(ViewSwitchType type);
void refreshFolder(FileModel fileModel, boolean forzed);
void refreshFolder(FileModel fileModel, boolean forced);
// void updatePrevieMessage(String fromLogin, String subject, String date, String body, List<FileModel> attachs);
void createNewMessage(HashMap<String, String> hashAttachs);

View File

@ -171,5 +171,8 @@ public interface GWTWorkspaceService extends RemoteService{
throws Exception;
boolean isSessionExpired() throws Exception;
void deleteListItemsForIds(List<String> ids) throws Exception;
}

View File

@ -162,5 +162,6 @@ public interface GWTWorkspaceServiceAsync {
*/
void isSessionExpired(AsyncCallback<Boolean> callback);
void deleteListItemsForIds(List<String> ids, AsyncCallback<Void> callback);
}

View File

@ -1079,11 +1079,19 @@ public class AsyncTreePanel extends LayoutContainer {
this.isSubTreeLoaded = isSubTreeLoaded;
}
/**
* Select root by default
*/
public void removeAllAndRecoveryRoot(){
store.removeAll();
loadRootItem(scopeId,true);
}
public void removeAllAndRecoveryRoot(boolean selectRoot){
store.removeAll();
loadRootItem(scopeId,selectRoot);
}
public void selectRootItem(){
FileModel selectedItem = treePanel.getSelectionModel().getSelectedItem();
if(selectedItem!=null)

View File

@ -561,7 +561,7 @@ public class ContextMenuTree {
public void componentSelected(MenuEvent ce) {
for (FileModel sel : listSelectedItems) {
eventBus.fireEvent(new RefreshFolderEvent(sel, true, false));
eventBus.fireEvent(new RefreshFolderEvent(sel, true, false, false));
}
}
});

View File

@ -2267,4 +2267,60 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
public boolean isSessionExpired() throws Exception {
return WsUtil.isSessionExpired(this.getThreadLocalRequest().getSession());
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#deleteListItemsForIds(java.util.List)
*/
@Override
public void deleteListItemsForIds(List<String> ids) throws Exception {
try {
if(ids == null)
throw new Exception("List identifiers is null");
Workspace workspace = getWorkspace();
workspaceLogger.trace("removeItem item for list size: "+ids.size());
for (String itemId : ids) {
//NOTIFICATION
WorkspaceItem wsItem = workspace.getItem(itemId);
//SAVING ATTRIBUTE FOR NOTIFICATION
boolean sourceItemIsShared = wsItem.isShared();
String itemName = wsItem.getName();
String sourceFolderSharedId = null;
if(sourceItemIsShared){
sourceFolderSharedId = wsItem.getIdSharedFolder();
}
//REMOVE ITEM
workspace.removeItem(itemId);
//IF SOURCE SHARED FOLDER IS NOT NULL
if(sourceFolderSharedId!=null)
NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest().getSession(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId);
}
} catch (InsufficientPrivilegesException e) {
workspaceLogger.error("Error in server Item remove", e);
String error = "An error occurred on deleting item. "+e.getMessage();
throw new Exception(error);
}catch (ItemNotFoundException e) {
String error = "An error occurred on deleting item. "+ConstantsExplorer.ERROR_ITEM_DOES_NOT_EXIST;
workspaceLogger.error(error, e);
throw new Exception(error);
} catch (Exception e) {
workspaceLogger.error("Error in server Item remove", e);
String error = ConstantsExplorer.SERVER_ERROR +" deleting item. "+e.getMessage();
throw new Exception(error);
}
}
}