Revision 07a1b5fe
b/src/gr/grnet/pithos/web/client/FileList.java | ||
---|---|---|
638 | 638 |
Folder selectedItem = treeView.getSelection(); |
639 | 639 |
|
640 | 640 |
provider.setList(files); |
641 |
provider.refresh(); |
|
642 |
celltable.redrawHeaders(); |
|
643 | 641 |
} |
644 | 642 |
|
645 | 643 |
/** |
b/src/gr/grnet/pithos/web/client/GSS.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import com.google.gwt.core.client.Scheduler; |
7 | 7 |
import com.google.gwt.core.client.Scheduler.ScheduledCommand; |
8 |
import com.google.gwt.user.client.ui.DockPanel; |
|
9 |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
|
10 |
import com.google.gwt.view.client.ListDataProvider; |
|
11 | 8 |
import com.google.gwt.view.client.SelectionChangeEvent; |
12 |
import com.google.gwt.view.client.SelectionChangeEvent.Handler; |
|
13 | 9 |
import com.google.gwt.view.client.SingleSelectionModel; |
14 |
import com.google.gwt.view.client.TreeViewModel.NodeInfo; |
|
15 | 10 |
import gr.grnet.pithos.web.client.clipboard.Clipboard; |
16 | 11 |
import gr.grnet.pithos.web.client.commands.GetUserCommand; |
17 | 12 |
import gr.grnet.pithos.web.client.foldertree.AccountResource; |
... | ... | |
46 | 41 |
import com.google.gwt.i18n.client.DateTimeFormat; |
47 | 42 |
import com.google.gwt.resources.client.ClientBundle; |
48 | 43 |
import com.google.gwt.resources.client.ImageResource; |
49 |
import com.google.gwt.user.client.Command; |
|
50 | 44 |
import com.google.gwt.user.client.Cookies; |
51 | 45 |
import com.google.gwt.user.client.DOM; |
52 |
import com.google.gwt.user.client.DeferredCommand; |
|
53 | 46 |
import com.google.gwt.user.client.Event; |
54 | 47 |
import com.google.gwt.user.client.History; |
55 | 48 |
import com.google.gwt.user.client.Window; |
... | ... | |
309 | 302 |
} |
310 | 303 |
|
311 | 304 |
private void showFiles(Folder f) { |
312 |
Set<File> files = f.getFiles(); |
|
313 |
fileList.setFiles(new ArrayList<File>(files)); |
|
314 | 305 |
inner.selectTab(0); |
306 |
Set<File> files = f.getFiles(); |
|
307 |
Iterator<File> iter = files.iterator(); |
|
308 |
fetchFile(iter, files); |
|
309 |
} |
|
310 |
|
|
311 |
private void fetchFile(final Iterator<File> iter, final Set<File> files) { |
|
312 |
if (iter.hasNext()) { |
|
313 |
File file = iter.next(); |
|
314 |
String path = getApiPath() + username + "/" + file.getContainer() + "/" + file.getPath() + "?format=json"; |
|
315 |
GetRequest<File> getFile = new GetRequest<File>(File.class, path, file) { |
|
316 |
@Override |
|
317 |
public void onSuccess(File result) { |
|
318 |
fetchFile(iter, files); |
|
319 |
} |
|
320 |
|
|
321 |
@Override |
|
322 |
public void onError(Throwable t) { |
|
323 |
GWT.log("Error getting file", t); |
|
324 |
if (t instanceof RestException) |
|
325 |
GSS.get().displayError("Error getting file: " + ((RestException) t).getHttpStatusText()); |
|
326 |
else |
|
327 |
GSS.get().displayError("System error fetching file: " + t.getMessage()); |
|
328 |
} |
|
329 |
}; |
|
330 |
getFile.setHeader("X-Auth-Token", "0000"); |
|
331 |
Scheduler.get().scheduleDeferred(getFile); |
|
332 |
} |
|
333 |
else |
|
334 |
fileList.setFiles(new ArrayList<File>(files)); |
|
315 | 335 |
} |
316 | 336 |
|
317 | 337 |
/** |
b/src/gr/grnet/pithos/web/client/foldertree/File.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
package gr.grnet.pithos.web.client.foldertree; |
6 | 6 |
|
7 |
import com.google.gwt.http.client.Response; |
|
8 |
import com.google.gwt.i18n.client.DateTimeFormat; |
|
9 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; |
|
7 | 10 |
import com.google.gwt.i18n.client.NumberFormat; |
8 | 11 |
import com.google.gwt.json.client.JSONObject; |
12 |
import com.google.gwt.json.client.JSONParser; |
|
13 |
import com.google.gwt.json.client.JSONValue; |
|
9 | 14 |
import java.util.Date; |
10 | 15 |
|
11 | 16 |
public class File extends Resource { |
... | ... | |
31 | 36 |
|
32 | 37 |
private boolean inTrash; |
33 | 38 |
|
39 |
private String container; |
|
40 |
|
|
34 | 41 |
public String getContentType() { |
35 | 42 |
return contentType; |
36 | 43 |
} |
... | ... | |
99 | 106 |
return inTrash; |
100 | 107 |
} |
101 | 108 |
|
102 |
public void populate(JSONObject o) { |
|
103 |
String path = unmarshallString(o, "name");
|
|
109 |
public void populate(JSONObject o, String container) {
|
|
110 |
path = unmarshallString(o, "name"); |
|
104 | 111 |
if (path.contains("/")) |
105 | 112 |
name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix |
106 | 113 |
else |
... | ... | |
112 | 119 |
lastModified = unmarshallDate(o, "last_modified"); |
113 | 120 |
modifiedBy = unmarshallString(o, "modified_by"); |
114 | 121 |
versionTimestamp = unmarshallDate(o, "version_timestamp"); |
122 |
this.container = container; |
|
115 | 123 |
} |
116 | 124 |
|
117 | 125 |
public boolean equals(Object other) { |
... | ... | |
125 | 133 |
public int hashCode() { |
126 | 134 |
return name.hashCode(); |
127 | 135 |
} |
136 |
|
|
137 |
public String getContainer() { |
|
138 |
return container; |
|
139 |
} |
|
140 |
|
|
141 |
public static File createFromResponse(Response response, File result) { |
|
142 |
result.populate(response); |
|
143 |
return result; |
|
144 |
} |
|
145 |
|
|
146 |
private void populate(Response response) { |
|
147 |
String header = response.getHeader("X-Object-Meta-Trash"); |
|
148 |
if (header != null) |
|
149 |
inTrash = Boolean.valueOf(header); |
|
150 |
else |
|
151 |
inTrash = false; |
|
152 |
|
|
153 |
JSONValue json = JSONParser.parseStrict(response.getText()); |
|
154 |
JSONObject o = json.isObject(); |
|
155 |
} |
|
128 | 156 |
} |
b/src/gr/grnet/pithos/web/client/foldertree/Folder.java | ||
---|---|---|
100 | 100 |
JSONObject o = array.get(i).isObject(); |
101 | 101 |
if (o != null) { |
102 | 102 |
String contentType = unmarshallString(o, "content_type"); |
103 |
if (o.containsKey("subdir") || (contentType != null && contentType.startsWith("application/directory"))) {
|
|
103 |
if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) {
|
|
104 | 104 |
Folder f = new Folder(); |
105 | 105 |
f.populate(o, container); |
106 | 106 |
subfolders.add(f); |
107 | 107 |
} |
108 | 108 |
else { |
109 | 109 |
File file = new File(); |
110 |
file.populate(o); |
|
110 |
file.populate(o, container);
|
|
111 | 111 |
files.add(file); |
112 | 112 |
} |
113 | 113 |
} |
b/src/gr/grnet/pithos/web/client/foldertree/Resource.java | ||
---|---|---|
71 | 71 |
else if (aClass.equals(Folder.class)) { |
72 | 72 |
result = (T) Folder.createFromResponse(response, (Folder) result); |
73 | 73 |
} |
74 |
else if (aClass.equals(File.class)) { |
|
75 |
result = (T) File.createFromResponse(response, (File) result); |
|
76 |
} |
|
74 | 77 |
return result; |
75 | 78 |
} |
76 | 79 |
} |
Also available in: Unified diff