Revision f72af3c3

b/web_client/src/gr/grnet/pithos/web/client/FileContextMenu.java
39 39
import gr.grnet.pithos.web.client.commands.DeleteCommand;
40 40
import gr.grnet.pithos.web.client.commands.PasteCommand;
41 41
import gr.grnet.pithos.web.client.commands.PropertiesCommand;
42
import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
42 43
import gr.grnet.pithos.web.client.commands.ToTrashCommand;
43 44
import gr.grnet.pithos.web.client.commands.UploadFileCommand;
44 45
import gr.grnet.pithos.web.client.foldertree.File;
......
186 187
		images = newImages;
187 188
        MenuBar contextMenu = new MenuBar(true);
188 189

  
189
        if (app.getClipboard().hasFiles()) {
190
            pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, selectedFolder));
191
            contextMenu.addItem(pasteItem);
192
        }
193

  
194
        MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(app, this, selectedFolder));
195
        contextMenu.addItem(upload);
190
        if (!selectedFolder.isInTrash()) {
191
	        if (app.getClipboard().hasFiles()) {
192
	            pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, selectedFolder));
193
	            contextMenu.addItem(pasteItem);
194
	        }
196 195

  
197
//        MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
198
//        contextMenu.addItem(refresh);
196
	        MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(app, this, selectedFolder));
197
	        contextMenu.addItem(upload);
199 198

  
200
//		if (isTrash) {
201
//			MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
202
//			contextMenu.addItem(restore);
203
//
204
//			MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(images.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, null, images));
205
//			contextMenu.addItem(delete);
206
//		} else {
207 199
			cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(app, this, selectedFiles));
208 200
            contextMenu.addItem(cutItem);
209 201

  
......
212 204

  
213 205
			trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(app, this, selectedFiles));
214 206
            contextMenu.addItem(trashItem);
207
        }
208
        else {
209
			MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(app, this, selectedFiles));
210
			contextMenu.addItem(restore);
211
        }
215 212

  
216
			deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, selectedFiles, MessagePanel.images));
217
            contextMenu.addItem(deleteItem);
213
		deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, selectedFiles, MessagePanel.images));
214
        contextMenu.addItem(deleteItem);
218 215

  
216
//      MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
217
//      contextMenu.addItem(refresh);
219 218
//			sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(this, images, 1));
220 219
//            contextMenu.addItem(sharingItem);
221

  
222
            contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, images, 0)));
220
        if (!selectedFolder.isInTrash()) {
221
        	contextMenu.addItem(new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, selectedFiles, images, 0)));
223 222

  
224 223
            if (!selectedFiles.isEmpty())
225 224
			    contextMenu.addItem(new MenuItem("<span><a class='hidden-link' href='" + app.getApiPath() + app.getUsername() + selectedFiles.get(0).getUri() + "?X-Auth-Token=" + app.getToken() + "' target='_blank'>" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download</a></span>", true, (Command) null));
226

  
227
			MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, new Command() {
228
                @Override
229
                public void execute() {
230
                    hide();
231
                    app.getFileList().clearSelectedRows();
232
                }
233
            });
234
			contextMenu.addItem(unSelect);
225
        }
226
		MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, new Command() {
227
            @Override
228
            public void execute() {
229
                hide();
230
                app.getFileList().clearSelectedRows();
231
            }
232
        });
233
		contextMenu.addItem(unSelect);
235 234

  
236 235
//		}
237 236
		add(contextMenu);
b/web_client/src/gr/grnet/pithos/web/client/FileList.java
315 315
            @Override
316 316
            public void onContextMenu(ContextMenuEvent event) {
317 317
                Folder selectedFolder = treeView.getSelection();
318
                if (!selectedFolder.isTrash()) {
319
                    FileContextMenu contextMenu = new FileContextMenu(app, images, selectedFolder, getSelectedFiles(), false);
320
                    int x = event.getNativeEvent().getClientX();
321
                    int y = event.getNativeEvent().getClientY();
322
                    contextMenu.setPopupPosition(x, y);
323
                    contextMenu.show();
324
                }
318
                FileContextMenu contextMenu = new FileContextMenu(app, images, selectedFolder, getSelectedFiles(), false);
319
                int x = event.getNativeEvent().getClientX();
320
                int y = event.getNativeEvent().getClientY();
321
                contextMenu.setPopupPosition(x, y);
322
                contextMenu.show();
325 323
            }
326 324
        }, ContextMenuEvent.getType());
327 325
		initWidget(vp);
b/web_client/src/gr/grnet/pithos/web/client/FolderContextMenu.java
37 37
import gr.grnet.pithos.web.client.commands.CopyCommand;
38 38
import gr.grnet.pithos.web.client.commands.CutCommand;
39 39
import gr.grnet.pithos.web.client.commands.DeleteCommand;
40
import gr.grnet.pithos.web.client.commands.EmptyTrashCommand;
40 41
import gr.grnet.pithos.web.client.commands.NewFolderCommand;
41 42
import gr.grnet.pithos.web.client.commands.PasteCommand;
42 43
import gr.grnet.pithos.web.client.commands.PropertiesCommand;
44
import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
43 45
import gr.grnet.pithos.web.client.commands.ToTrashCommand;
44 46
import gr.grnet.pithos.web.client.foldertree.Folder;
45 47

  
......
80 82
		images = newImages;
81 83
        MenuBar contextMenu = new MenuBar(true);
82 84

  
83
        MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(app, this, folder, images));
84
        contextMenu.addItem(newFolder);
85

  
86
        if (!folder.isContainer()) {
87
            MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(app, this, folder));
88
            contextMenu.addItem(cut);
89
        }
90

  
91
        MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(app, this, folder));
92
        contextMenu.addItem(copy);
93

  
94
        if (!app.getClipboard().isEmpty()) {
95
            pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, folder));
96
            contextMenu.addItem(pasteItem);
85
        if (!folder.isInTrash()) {
86
	        MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + "&nbsp;New Folder</span>", true, new NewFolderCommand(app, this, folder, images));
87
	        contextMenu.addItem(newFolder);
88

  
89
	        if (!folder.isContainer()) {
90
	            MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(app, this, folder));
91
	            contextMenu.addItem(cut);
92
	        }
93

  
94
	        MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(app, this, folder));
95
	        contextMenu.addItem(copy);
96
	
97
	        if (!app.getClipboard().isEmpty()) {
98
	            pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(app, this, folder));
99
	            contextMenu.addItem(pasteItem);
100
	        }
101

  
102
		    if (!folder.isContainer()) {
103
		        MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(app, this, folder));
104
		        contextMenu.addItem(moveToTrash);
105
		
106
		        MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
107
		        contextMenu.addItem(delete);
108
		
109
		        MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
110
		        contextMenu.addItem(properties);
111
		    }
97 112
        }
98

  
99
        if (!folder.isContainer()) {
100
            MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(app, this, folder));
101
            contextMenu.addItem(moveToTrash);
102

  
103
            MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
104
            contextMenu.addItem(delete);
105

  
106
            MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0));
107
            contextMenu.addItem(properties);
113
        else {
114
        	if (!folder.isTrash()) {
115
    			MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(images.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(app, this, folder));
116
    			contextMenu.addItem(restore);
117

  
118
    			MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images));
119
		        contextMenu.addItem(delete);
120
        	}
121
        	else {
122
    			MenuItem emptyTrash = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + "&nbsp;Empty Trash</span>", true, new EmptyTrashCommand(app, this));
123
    			contextMenu.addItem(emptyTrash);
124
        	}
108 125
        }
109 126

  
110 127
//        MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
b/web_client/src/gr/grnet/pithos/web/client/commands/EmptyTrashCommand.java
55 55

  
56 56
	@Override
57 57
	public void execute() {
58
		containerPanel.hide();
59
//		DeleteCommand df = new DeleteCommand(app, app.getTreeView().getTrash().getUri()){
60
//
61
//			@Override
62
//			public void onComplete() {
63
//				app.getTreeView().updateTrashNode();
64
//				app.showFileList(true);
65
//			}
66
//
67
//			@Override
68
//			public void onError(Throwable t) {
69
//				GWT.log("", t);
70
//				if(t instanceof RestException){
71
//					int statusCode = ((RestException)t).getHttpStatusCode();
72
//					if(statusCode == 405)
73
//						app.displayError("You don't have the necessary permissions");
74
//					else if(statusCode == 404)
75
//						app.displayError("Resource does not exist");
76
//					else
77
//						app.displayError("Unable to empty trash:"+((RestException)t).getHttpStatusText());
78
//				}
79
//				else
80
//					app.displayError("System error emptying trash:"+t.getMessage());
81
//			}
82
//		};
83
//		DeferredCommand.addCommand(df);
58
		if (containerPanel != null)
59
			containerPanel.hide();
84 60
	}
85

  
86 61
}
b/web_client/src/gr/grnet/pithos/web/client/commands/RestoreTrashCommand.java
34 34
 */
35 35
package gr.grnet.pithos.web.client.commands;
36 36

  
37
import java.util.Iterator;
38
import java.util.List;
39

  
37 40
import gr.grnet.pithos.web.client.Pithos;
41
import gr.grnet.pithos.web.client.foldertree.File;
42
import gr.grnet.pithos.web.client.foldertree.Folder;
43
import gr.grnet.pithos.web.client.foldertree.Resource;
44
import gr.grnet.pithos.web.client.rest.DeleteRequest;
45
import gr.grnet.pithos.web.client.rest.PutRequest;
46
import gr.grnet.pithos.web.client.rest.RestException;
38 47

  
48
import com.google.gwt.core.client.GWT;
49
import com.google.gwt.core.client.Scheduler;
39 50
import com.google.gwt.user.client.Command;
40 51
import com.google.gwt.user.client.ui.PopupPanel;
41 52

  
......
45 56
 * Restore trashed files and folders.
46 57
 *
47 58
 */
48
public class RestoreTrashCommand implements Command{
59
public class RestoreTrashCommand implements Command {
49 60
	private PopupPanel containerPanel;
50
    private Pithos app;
61
	protected Pithos app;
62
	protected Object resource;
51 63

  
52
	public RestoreTrashCommand(Pithos _app, PopupPanel _containerPanel){
53
        app = _app;
64
	public RestoreTrashCommand(Pithos _app, PopupPanel _containerPanel, Object _resource){
54 65
		containerPanel = _containerPanel;
66
        app = _app;
67
        resource = _resource;
55 68
	}
56 69

  
57 70
	@Override
58 71
	public void execute() {
59
		containerPanel.hide();
60
//		Object selection = app.getCurrentSelection();
61
//		if (selection == null){
62
//			// Check to see if Trash Node is selected.
63
//			List folderList = new ArrayList();
64
//			TrashResource trashItem = app.getTreeView().getTrash();
65
//			for(int i=0 ; i < trashItem.getFolders().size() ; i++)
66
//				folderList.add(trashItem.getFolders().get(i));
67
//			return;
68
//		}
69
//		GWT.log("selection: " + selection.toString(), null);
70
//		if (selection instanceof FileResource) {
71
//			final FileResource resource = (FileResource)selection;
72
//			PostCommand rt = new PostCommand(app, resource.getUri()+"?restore=","", 200){
73
//
74
//				@Override
75
//				public void onComplete() {
76
//					//TODO:CELLTREE
77
//					//app.getFolders().update(app.getFolders().getTrashItem());
78
//
79
//					app.showFileList(true);
80
//				}
81
//
82
//				@Override
83
//				public void onError(Throwable t) {
84
//					GWT.log("", t);
85
//					if(t instanceof RestException){
86
//						int statusCode = ((RestException)t).getHttpStatusCode();
87
//						if(statusCode == 405)
88
//							app.displayError("You don't have the necessary permissions");
89
//						else if(statusCode == 404)
90
//							app.displayError("File does not exist");
91
//						else if(statusCode == 409)
92
//							app.displayError("A file with the same name already exists");
93
//						else if(statusCode == 413)
94
//							app.displayError("Your quota has been exceeded");
95
//						else
96
//							app.displayError("Unable to restore file:"+((RestException)t).getHttpStatusText());
97
//					}
98
//					else
99
//						app.displayError("System error restoring file:"+t.getMessage());
100
//				}
101
//			};
102
//			DeferredCommand.addCommand(rt);
103
//		}
104
//		else if (selection instanceof List) {
105
//			final List<FileResource> fdtos = (List<FileResource>) selection;
106
//			final List<String> fileIds = new ArrayList<String>();
107
//			for(FileResource f : fdtos)
108
//				fileIds.add(f.getUri()+"?restore=");
109
//			MultiplePostCommand rt = new MultiplePostCommand(app, fileIds.toArray(new String[0]), 200){
110
//
111
//				@Override
112
//				public void onComplete() {
113
//					//TODO:CELLTREE
114
//					//app.getFolders().update(app.getFolders().getTrashItem());
115
//					app.showFileList(true);
116
//				}
117
//
118
//				@Override
119
//				public void onError(String p, Throwable t) {
120
//					GWT.log("", t);
121
//					if(t instanceof RestException){
122
//						int statusCode = ((RestException)t).getHttpStatusCode();
123
//						if(statusCode == 405)
124
//							app.displayError("You don't have the necessary permissions");
125
//						else if(statusCode == 404)
126
//							app.displayError("File does not exist");
127
//						else if(statusCode == 409)
128
//							app.displayError("A file with the same name already exists");
129
//						else if(statusCode == 413)
130
//							app.displayError("Your quota has been exceeded");
131
//						else
132
//							app.displayError("Unable to restore file::"+((RestException)t).getHttpStatusText());
133
//					}
134
//					else
135
//						app.displayError("System error restoring file:"+t.getMessage());
136
//				}
137
//			};
138
//			DeferredCommand.addCommand(rt);
139
//		}
140
//		else if (selection instanceof TrashFolderResource) {
141
//			final FolderResource resource = ((TrashFolderResource)selection).getResource();
142
//			PostCommand rt = new PostCommand(app, resource.getUri()+"?restore=","", 200){
143
//
144
//				@Override
145
//				public void onComplete() {
146
//					//TODO:CELLTREE
147
//					/*
148
//					app.getFolders().updateFolder((DnDTreeItem) app.getFolders().getRootItem());
149
//
150
//					app.getFolders().update(app.getFolders().getTrashItem());
151
//					*/
152
//
153
//					app.getTreeView().updateTrashNode();
154
//					app.getTreeView().updateRootNode();
155
//				}
156
//
157
//				@Override
158
//				public void onError(Throwable t) {
159
//					GWT.log("", t);
160
//					if(t instanceof RestException){
161
//						int statusCode = ((RestException)t).getHttpStatusCode();
162
//						if(statusCode == 405)
163
//							app.displayError("You don't have the necessary permissions");
164
//						else if(statusCode == 404)
165
//							app.displayError("Folder does not exist");
166
//						else if(statusCode == 409)
167
//							app.displayError("A folder with the same name already exists");
168
//						else if(statusCode == 413)
169
//							app.displayError("Your quota has been exceeded");
170
//						else
171
//							app.displayError("Unable to restore folder::"+((RestException)t).getHttpStatusText());
172
//					}
173
//					else
174
//						app.displayError("System error restoring folder:"+t.getMessage());
175
//				}
176
//			};
177
//			DeferredCommand.addCommand(rt);
178
//		}
72
        if (containerPanel != null)
73
    		containerPanel.hide();
74
        if (resource instanceof List) {
75
            @SuppressWarnings("unchecked")
76
			Iterator<File> iter = ((List<File>) resource).iterator();
77
            untrashFiles(iter, new Command() {
78
                @SuppressWarnings("unchecked")
79
				@Override
80
                public void execute() {
81
                    app.updateFolder(((List<File>) resource).get(0).getParent(), true, null);
82
                }
83
            });
84
        }
85
        else if (resource instanceof Folder) {
86
            final Folder toBeUnTrashed = (Folder) resource;
87
            untrashFolder(toBeUnTrashed, new Command() {
88
                @Override
89
                public void execute() {
90
                    app.updateFolder(toBeUnTrashed.getParent(), true, null);
91
                }
92
            });
179 93

  
94
        }
180 95
	}
181 96

  
97
    private void untrashFolder(final Folder f, final Command callback) {
98
        String path = "/" + Pithos.HOME_CONTAINER + "/" + f.getPrefix();
99
        PutRequest createFolder = new PutRequest(app.getApiPath(), app.getUsername(), path) {
100
            @Override
101
            public void onSuccess(@SuppressWarnings("unused") Resource result) {
102
                Iterator<File> iter = f.getFiles().iterator();
103
                untrashFiles(iter, new Command() {
104
                    @Override
105
                    public void execute() {
106
                        Iterator<Folder> iterf = f.getSubfolders().iterator();
107
                        untrashSubfolders(iterf, new Command() {
108
							
109
							@Override
110
							public void execute() {
111
								DeleteRequest deleteFolder = new DeleteRequest(app.getApiPath(), f.getOwner(), f.getUri()) {
112
									
113
									@Override
114
									public void onSuccess(Resource result) {
115
										if (callback != null)
116
											callback.execute();
117
									}
118
									
119
									@Override
120
									public void onError(Throwable t) {
121
					                    GWT.log("", t);
122
					                    if (t instanceof RestException) {
123
					                        app.displayError("Unable to delete folder: " + ((RestException) t).getHttpStatusText());
124
					                    }
125
					                    else
126
					                        app.displayError("System error unable to delete folder: "+t.getMessage());
127
									}
128
								};
129
								deleteFolder.setHeader("X-Auth-Token", app.getToken());
130
								Scheduler.get().scheduleDeferred(deleteFolder);
131
							}
132
						});
133
                    }
134
                });
135
            }
136

  
137
            @Override
138
            public void onError(Throwable t) {
139
                GWT.log("", t);
140
                if (t instanceof RestException) {
141
                    app.displayError("Unable to create folder:" + ((RestException) t).getHttpStatusText());
142
                }
143
                else
144
                    app.displayError("System error creating folder:" + t.getMessage());
145
            }
146
        };
147
        createFolder.setHeader("X-Auth-Token", app.getToken());
148
        createFolder.setHeader("Accept", "*/*");
149
        createFolder.setHeader("Content-Length", "0");
150
        createFolder.setHeader("Content-Type", "application/folder");
151
        Scheduler.get().scheduleDeferred(createFolder);
152
    }
153

  
154
    protected void untrashFiles(final Iterator<File> iter, final Command callback) {
155
        if (iter.hasNext()) {
156
            File file = iter.next();
157
            String path = "/" + Pithos.HOME_CONTAINER + "/" + file.getPath();
158
            PutRequest untrashFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {
159
                @Override
160
                public void onSuccess(@SuppressWarnings("unused") Resource result) {
161
                    untrashFiles(iter, callback);
162
                }
163

  
164
                @Override
165
                public void onError(Throwable t) {
166
                    GWT.log("", t);
167
                    if (t instanceof RestException) {
168
                        app.displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText());
169
                    }
170
                    else
171
                        app.displayError("System error unable to copy file: "+t.getMessage());
172
                }
173
            };
174
            untrashFile.setHeader("X-Auth-Token", app.getToken());
175
            untrashFile.setHeader("X-Move-From", file.getUri());
176
            Scheduler.get().scheduleDeferred(untrashFile);
177
        }
178
        else if (callback != null) {
179
            callback.execute();
180
        }
181
    }
182

  
183
    protected void untrashSubfolders(final Iterator<Folder> iter, final Command callback) {
184
        if (iter.hasNext()) {
185
            final Folder f = iter.next();
186
            untrashFolder(f, callback);
187
        }
188
        else  {
189
        	if (callback != null)
190
        		callback.execute();
191
        }
192
    }
182 193
}
b/web_client/src/gr/grnet/pithos/web/client/foldertree/Folder.java
306 306
		return !permissions.isEmpty();
307 307
	}
308 308

  
309
	/**
310
	 * I am THE trash
311
	 * 
312
	 * @return
313
	 */
309 314
	public boolean isTrash() {
310 315
		return isContainer() && name.equals(Pithos.TRASH_CONTAINER);
311 316
	}
317
	
318
	/**
319
	 * I am IN THE trash
320
	 * 
321
	 * @return
322
	 */
323
	public boolean isInTrash() {
324
		return container.equals(Pithos.TRASH_CONTAINER);
325
	}
312 326

  
313 327
	public boolean isHome() {
314 328
		return isContainer() && name.equals(Pithos.HOME_CONTAINER);
b/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java
89 89
        public void onBrowserEvent(@SuppressWarnings("unused") Cell.Context context, @SuppressWarnings("unused") com.google.gwt.dom.client.Element parent, Folder folder, com.google.gwt.dom.client.NativeEvent event, @SuppressWarnings("unused") com.google.gwt.cell.client.ValueUpdater<Folder> valueUpdater) {
90 90
            if (event.getType().equals(ContextMenuEvent.getType().getName())) {
91 91
                FolderTreeViewModel.this.selectionModel.setSelected(folder, true);
92
                if (!folder.isTrash()) {
93
                    FolderContextMenu menu = new FolderContextMenu(app, FolderTreeView.images, folder);
94
                    menu.setPopupPosition(event.getClientX(), event.getClientY());
95
                    menu.show();
96
                }
92
                FolderContextMenu menu = new FolderContextMenu(app, FolderTreeView.images, folder);
93
                menu.setPopupPosition(event.getClientX(), event.getClientY());
94
                menu.show();
97 95
            }
98 96
        }
99 97
    };

Also available in: Unified diff