2014-02-17 19:20:45 +01:00
|
|
|
package org.gcube.portlets.user.workspace.client.view.trash;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
2014-05-13 11:27:30 +02:00
|
|
|
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
2014-02-17 19:20:45 +01:00
|
|
|
|
|
|
|
import com.extjs.gxt.ui.client.widget.Window;
|
|
|
|
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
|
|
* @May 23, 2013
|
|
|
|
*
|
|
|
|
* Singleton
|
|
|
|
*/
|
|
|
|
public class WindowTrash extends Window {
|
|
|
|
|
|
|
|
private List<FileTrashedModel> trashedFiles;
|
|
|
|
private TrashInfoContainer trashContainers;
|
|
|
|
private static WindowTrash INSTANCE = null;
|
|
|
|
|
|
|
|
|
|
|
|
private WindowTrash() {
|
|
|
|
initAccounting();
|
|
|
|
setIcon(Resources.getTrash()); //TODO
|
|
|
|
setHeading("Trash");
|
|
|
|
// addResizeListner();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public static synchronized WindowTrash getInstance(){
|
|
|
|
if(INSTANCE==null)
|
|
|
|
INSTANCE = new WindowTrash();
|
|
|
|
|
|
|
|
return INSTANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// public void addResizeListner(){
|
|
|
|
//
|
|
|
|
// this.addListener(Events.Resize, new Listener<WindowEvent>() {
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void handleEvent(WindowEvent we )
|
|
|
|
// {
|
|
|
|
//
|
|
|
|
// if(trashContainers!=null){
|
|
|
|
//// System.out.println("Size in event: " + we.getWidth() + "x" + we.getHeight() );
|
|
|
|
//// accountingsContainers.setPanelSize(we.getWidth()-14, we.getHeight()-30);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// public WindowTrash(List<FileModel> trashFiles) {
|
|
|
|
// updateTrashContainer(trashFiles);
|
|
|
|
// }
|
|
|
|
|
|
|
|
private void initAccounting() {
|
|
|
|
// setModal(true);
|
|
|
|
setLayout(new FitLayout());
|
|
|
|
setSize(700, 350);
|
|
|
|
setResizable(true);
|
|
|
|
setMaximizable(true);
|
|
|
|
// setCollapsible(true);
|
|
|
|
this.trashContainers = new TrashInfoContainer();
|
|
|
|
add(trashContainers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setWindowTitle(String title) {
|
|
|
|
this.setHeading(title);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param fileModelId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public boolean deleteFileFromTrash(String fileModelId){
|
|
|
|
return this.trashContainers.deleteItem(fileModelId);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updateTrashContainer(List<FileTrashedModel> trashFiles) {
|
|
|
|
|
|
|
|
this.trashContainers.resetStore();
|
|
|
|
this.trashedFiles = trashFiles;
|
|
|
|
this.trashContainers.updateTrash(trashFiles);
|
|
|
|
}
|
2014-05-13 11:27:30 +02:00
|
|
|
|
|
|
|
public void executeOperationOnTrashContainer(List<String> trashIds, WorkspaceTrashOperation operation) {
|
|
|
|
|
|
|
|
if(operation.equals(WorkspaceTrashOperation.DELETE_PERMANENTLY)){
|
|
|
|
deleteListItems(trashIds);
|
|
|
|
|
|
|
|
}else if(operation.equals(WorkspaceTrashOperation.RESTORE)){
|
|
|
|
deleteListItems(trashIds);
|
|
|
|
}
|
|
|
|
}
|
2014-02-17 19:20:45 +01:00
|
|
|
|
|
|
|
public List<FileTrashedModel> getTrashedFiles() {
|
|
|
|
return trashedFiles;
|
|
|
|
}
|
|
|
|
|
2014-05-13 11:27:30 +02:00
|
|
|
private void deleteListItems(List<String> trashIds){
|
|
|
|
|
|
|
|
for (String identifier : trashIds) {
|
|
|
|
this.trashContainers.deleteItem(identifier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 19:20:45 +01:00
|
|
|
public void maskAccountingInfo(boolean bool){
|
|
|
|
|
|
|
|
// if(accountingsContainers!=null){
|
|
|
|
//
|
|
|
|
// if(bool)
|
|
|
|
// accountingsContainers.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
|
|
|
|
// else
|
|
|
|
// accountingsContainers.unmask();
|
|
|
|
// }
|
|
|
|
|
|
|
|
if(bool)
|
|
|
|
this.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
|
|
|
|
else
|
|
|
|
this.unmask();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|