enhancements on trash

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@95660 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-05-14 10:13:54 +00:00
parent 69d798737f
commit edeb0d00e2
3 changed files with 77 additions and 9 deletions

View File

@ -82,6 +82,7 @@ import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
import org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface;
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.FileTrashedModel;
import org.gcube.portlets.user.workspace.client.model.FolderModel;
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
import org.gcube.portlets.user.workspace.client.view.WorskpacePortlet;
@ -1672,7 +1673,7 @@ public class AppController implements SubscriberInterface {
* @param operation
* @param trashItemId
*/
private void executeTrashOperation(WorkspaceTrashOperation operation, List<FileModel> trashItemIds){
private void executeTrashOperation(final WorkspaceTrashOperation operation, List<FileModel> trashItemIds){
GWT.log("Executing trash operation: "+operation);
@ -1708,13 +1709,20 @@ public class AppController implements SubscriberInterface {
@Override
public void onSuccess(TrashOperationContent operationResult) {
WindowTrash.getInstance().unmaskContainer();
WindowTrash.getInstance().executeOperationOnTrashContainer(operationResult.getListTrashIds(), operationResult.getOperation());
wsPortlet.getGxtCardLayoutResultPanel().getToolBarItemDetails().updateTrashIcon(WindowTrash.getInstance().getTrashedFiles().size()>0);
//TODO POPUP ERROR
//SHOW POSSIBLY ERRORS
WindowTrash.getInstance().showTrashErrors(operation, operationResult.getListErrors());
if(operation.equals(WorkspaceTrashOperation.RESTORE)){
appContrExplorer.refreshRoot(true);
}
WindowTrash.getInstance().unmaskContainer();
}
});
}
@ -1732,11 +1740,19 @@ public class AppController implements SubscriberInterface {
@Override
public void onSuccess(TrashContent operationResult) {
WindowTrash.getInstance().unmaskContainer();
WindowTrash.getInstance().updateTrashContainer(operationResult.getTrashContent());
wsPortlet.getGxtCardLayoutResultPanel().getToolBarItemDetails().updateTrashIcon(operationResult.getTrashContent().size()>0);
//TODO POPUP ERROR
//SHOW POSSIBLY ERRORS
WindowTrash.getInstance().showTrashErrors(operation, operationResult.getListErrors());
if(operation.equals(WorkspaceTrashOperation.RESTORE_ALL)){
appContrExplorer.refreshRoot(true);
}
WindowTrash.getInstance().unmaskContainer();
}
});
@ -1744,8 +1760,7 @@ public class AppController implements SubscriberInterface {
}
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.SubscriberInterface#trashEvent(org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation, java.util.List)
*/

View File

@ -62,7 +62,7 @@ public class TrashInfoContainer extends LayoutContainer {
initContentPanel();
initGrid();
createToolBar();
initDropTarget();
// initDropTarget();
activeButtonOnSelection(false);
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.workspace.client.view.trash;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
@ -7,6 +8,11 @@ import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
@ -43,7 +49,7 @@ public class WindowTrash extends Window {
private void initAccounting() {
setLayout(new FitLayout());
setSize(750, 400);
setSize(760, 400);
setResizable(true);
setMaximizable(true);
this.trashContainers = new TrashInfoContainer();
@ -117,5 +123,52 @@ public class WindowTrash extends Window {
else
setIcon(Resources.getTrashEmpty());
}
public void showTrashErrors(WorkspaceTrashOperation operation, List<FileTrashedModel> errors){
if(errors!=null && errors.size()>0){
List<String> fileNames = new ArrayList<String>(errors.size());
//BUILDING NAMES
for (FileTrashedModel fileTrashedModel : errors) {
FileTrashedModel trashFile = trashContainers.getFileModelByIdentifier(fileTrashedModel.getIdentifier());
fileNames.add(trashFile.getName());
}
String htmlError = "<div style=\"padding:10px 10px 10px 10px\"><b style=\"font-size:12px\">Sorry an error occured on removing the ";
htmlError+=fileNames.size()>1?"items":"item";
htmlError+=": </b><br/>";
for (String fileName : fileNames) {
htmlError+="<br/> - "+fileName;
}
htmlError+="<br/><br/><b>"+"Try again later</b></div>";
Dialog dialog = new Dialog();
dialog.setStyleAttribute("background-color", "#FAFAFA");
dialog.setSize(380, 180);
dialog.setLayout(new FitLayout());
dialog.setIcon(Resources.getIconInfo());
dialog.setModal(true);
dialog.setHeading("Trash Errors");
dialog.setButtons(Dialog.OK);
dialog.setHideOnButtonClick(true);
dialog.setButtonAlign(HorizontalAlignment.CENTER);
// dialog.setSize(200, 150);
ContentPanel cp = new ContentPanel();
cp.setHeaderVisible(false);
cp.setFrame(false);
cp.setScrollMode(Scroll.AUTOY);
cp.add(new Html(htmlError));
dialog.add(cp);
dialog.show();
}
}
}