Use separate progress bars next to each file, in order to better track the progress...
[pithos] / src / gr / ebs / gss / client / FilePropertiesDialog.java
1 /*\r
2  * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.\r
3  *\r
4  * This file is part of GSS.\r
5  *\r
6  * GSS is free software: you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation, either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * GSS is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with GSS.  If not, see <http://www.gnu.org/licenses/>.\r
18  */\r
19 package gr.ebs.gss.client;\r
20 \r
21 import gr.ebs.gss.client.rest.GetCommand;\r
22 import gr.ebs.gss.client.rest.PostCommand;\r
23 import gr.ebs.gss.client.rest.RestException;\r
24 import gr.ebs.gss.client.rest.resource.FileResource;\r
25 import gr.ebs.gss.client.rest.resource.GroupResource;\r
26 import gr.ebs.gss.client.rest.resource.PermissionHolder;\r
27 import gr.ebs.gss.client.rest.resource.TagsResource;\r
28 \r
29 import java.util.Iterator;\r
30 import java.util.List;\r
31 import java.util.Set;\r
32 \r
33 import com.google.gwt.core.client.GWT;\r
34 import com.google.gwt.i18n.client.DateTimeFormat;\r
35 import com.google.gwt.json.client.JSONArray;\r
36 import com.google.gwt.json.client.JSONBoolean;\r
37 import com.google.gwt.json.client.JSONObject;\r
38 import com.google.gwt.json.client.JSONString;\r
39 import com.google.gwt.user.client.Command;\r
40 import com.google.gwt.user.client.DeferredCommand;\r
41 import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
42 import com.google.gwt.user.client.ui.Button;\r
43 import com.google.gwt.user.client.ui.CheckBox;\r
44 import com.google.gwt.user.client.ui.ClickListener;\r
45 import com.google.gwt.user.client.ui.DialogBox;\r
46 import com.google.gwt.user.client.ui.DisclosurePanel;\r
47 import com.google.gwt.user.client.ui.FlexTable;\r
48 import com.google.gwt.user.client.ui.FlowPanel;\r
49 import com.google.gwt.user.client.ui.FocusPanel;\r
50 import com.google.gwt.user.client.ui.HTML;\r
51 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
52 import com.google.gwt.user.client.ui.HorizontalPanel;\r
53 import com.google.gwt.user.client.ui.KeyboardListener;\r
54 import com.google.gwt.user.client.ui.Label;\r
55 import com.google.gwt.user.client.ui.TabPanel;\r
56 import com.google.gwt.user.client.ui.TextBox;\r
57 import com.google.gwt.user.client.ui.VerticalPanel;\r
58 import com.google.gwt.user.client.ui.Widget;\r
59 \r
60 /**\r
61  * The 'File properties' dialog box implementation.\r
62  *\r
63  * @author past\r
64  */\r
65 public class FilePropertiesDialog extends DialogBox {\r
66 \r
67         final PermissionsList permList;\r
68 \r
69         private CheckBox readForAll;\r
70 \r
71         /**\r
72          * An image bundle for this widgets images.\r
73          */\r
74         public interface Images extends MessagePanel.Images {\r
75 \r
76                 @Resource("gr/ebs/gss/resources/edit_user.png")\r
77                 AbstractImagePrototype permUser();\r
78 \r
79                 @Resource("gr/ebs/gss/resources/groupevent.png")\r
80                 AbstractImagePrototype permGroup();\r
81 \r
82                 @Resource("gr/ebs/gss/resources/editdelete.png")\r
83                 AbstractImagePrototype delete();\r
84 \r
85                 @Resource("gr/ebs/gss/resources/db_update.png")\r
86                 AbstractImagePrototype restore();\r
87 \r
88                 @Resource("gr/ebs/gss/resources/folder_inbox.png")\r
89                 AbstractImagePrototype download();\r
90         }\r
91 \r
92         /**\r
93          * The widget that holds the name of the file.\r
94          */\r
95         private TextBox name = new TextBox();\r
96 \r
97         /**\r
98          * Text box with the tags associated with the file\r
99          */\r
100         private TextBox tags = new TextBox();\r
101 \r
102         /**\r
103          * A FlowPanel with all user tags\r
104          */\r
105         private FlowPanel allTagsContent;\r
106 \r
107         private final CheckBox versioned = new CheckBox();\r
108 \r
109         final FileResource file;\r
110 \r
111         String initialTagText;\r
112 \r
113         final TabPanel inner;\r
114 \r
115         /**\r
116          * The widget's constructor.\r
117          *\r
118          * @param images the dialog's ImageBundle\r
119          * @param groups\r
120          * @param bodies\r
121          */\r
122         public FilePropertiesDialog(final Images images, final List<GroupResource> groups, List<FileResource> bodies) {\r
123 \r
124                 // Enable IE selection for the dialog (must disable it upon closing it)\r
125                 GSS.enableIESelection();\r
126 \r
127                 // Set the dialog's caption.\r
128                 setText("File properties");\r
129                 setAnimationEnabled(true);\r
130                 file = (FileResource) GSS.get().getCurrentSelection();\r
131                 permList = new PermissionsList(images, file.getPermissions(), file.getOwner());\r
132 \r
133                 // Outer contains inner and buttons.\r
134                 final VerticalPanel outer = new VerticalPanel();\r
135                 final FocusPanel focusPanel = new FocusPanel(outer);\r
136                 // Inner contains generalPanel and permPanel.\r
137                 inner = new TabPanel();\r
138                 final VerticalPanel generalPanel = new VerticalPanel();\r
139                 final VerticalPanel permPanel = new VerticalPanel();\r
140                 final HorizontalPanel buttons = new HorizontalPanel();\r
141                 final HorizontalPanel permButtons = new HorizontalPanel();\r
142                 final HorizontalPanel permForAll = new HorizontalPanel();\r
143                 final HorizontalPanel pathPanel = new HorizontalPanel();\r
144                 final VerticalPanel verPanel = new VerticalPanel();\r
145                 final HorizontalPanel vPanel = new HorizontalPanel();\r
146                 final HorizontalPanel vPanel2 = new HorizontalPanel();\r
147 \r
148                 versioned.setChecked(file.isVersioned());\r
149                 inner.add(generalPanel, "General");\r
150                 inner.add(permPanel, "Sharing");\r
151                 inner.add(verPanel, "Versions");\r
152                 inner.selectTab(0);\r
153 \r
154                 final FlexTable generalTable = new FlexTable();\r
155                 generalTable.setText(0, 0, "Name");\r
156                 generalTable.setText(1, 0, "Folder");\r
157                 generalTable.setText(2, 0, "Owner");\r
158                 generalTable.setText(3, 0, "Date");\r
159                 generalTable.setText(4, 0, "Tags");\r
160                 name.setText(file.getName());\r
161                 generalTable.setWidget(0, 1, name);\r
162                 if(file.getFolderName() != null)\r
163                         generalTable.setText(1, 1, file.getFolderName());\r
164                 else\r
165                         generalTable.setText(1, 1, "-");\r
166                 generalTable.setText(2, 1, file.getOwner());\r
167                 final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");\r
168                 generalTable.setText(3, 1, formatter.format(file.getCreationDate()));\r
169                 // Get the tags.\r
170                 StringBuffer tagsBuffer = new StringBuffer();\r
171                 Iterator i = file.getTags().iterator();\r
172                 while (i.hasNext()) {\r
173                         String tag = (String) i.next();\r
174                         tagsBuffer.append(tag).append(", ");\r
175                 }\r
176                 if (tagsBuffer.length() > 1)\r
177                         tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1);\r
178                 initialTagText = tagsBuffer.toString();\r
179                 tags.setText(initialTagText);\r
180                 generalTable.setWidget(4, 1, tags);\r
181                 generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
182                 generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");\r
183                 generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");\r
184                 generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels");\r
185                 generalTable.getFlexCellFormatter().setStyleName(4, 0, "props-labels");\r
186                 generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");\r
187                 generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");\r
188                 generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");\r
189                 generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values");\r
190                 generalTable.getFlexCellFormatter().setStyleName(4, 1, "props-values");\r
191                 generalTable.setCellSpacing(4);\r
192 \r
193                 // Create the 'OK' button, along with a listener that hides the dialog\r
194                 // when the button is clicked.\r
195                 final Button ok = new Button("OK", new ClickListener() {\r
196 \r
197                         public void onClick(Widget sender) {\r
198                                 accept();\r
199                                 closeDialog();\r
200                         }\r
201                 });\r
202                 buttons.add(ok);\r
203                 buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
204                 // Create the 'Cancel' button, along with a listener that hides the\r
205                 // dialog when the button is clicked.\r
206                 final Button cancel = new Button("Cancel", new ClickListener() {\r
207 \r
208                         public void onClick(Widget sender) {\r
209                                 closeDialog();\r
210                         }\r
211                 });\r
212                 buttons.add(cancel);\r
213                 buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
214                 buttons.setSpacing(8);\r
215                 buttons.addStyleName("gwt-TabPanelBottom");\r
216 \r
217                 generalPanel.add(generalTable);\r
218 \r
219                 // Asynchronously retrieve the tags defined by this user.\r
220                 DeferredCommand.addCommand(new Command() {\r
221 \r
222                         public void execute() {\r
223                                 updateTags();\r
224                         }\r
225                 });\r
226 \r
227                 DisclosurePanel allTags = new DisclosurePanel("All tags");\r
228                 allTagsContent = new FlowPanel();\r
229                 allTags.setContent(allTagsContent);\r
230                 generalPanel.add(allTags);\r
231                 generalPanel.setSpacing(4);\r
232 \r
233                 final Button add = new Button("Add Group", new ClickListener() {\r
234 \r
235                         public void onClick(Widget sender) {\r
236                                 PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, false);\r
237                                 dlg.center();\r
238                         }\r
239                 });\r
240                 permButtons.add(add);\r
241                 permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER);\r
242 \r
243                 final Button addUser = new Button("Add User", new ClickListener() {\r
244 \r
245                         public void onClick(Widget sender) {\r
246                                 PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, true);\r
247                                 dlg.center();\r
248                         }\r
249                 });\r
250                 permButtons.add(addUser);\r
251                 permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER);\r
252 \r
253                 permButtons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
254                 permButtons.setSpacing(8);\r
255                 permButtons.addStyleName("gwt-TabPanelBottom");\r
256 \r
257                 final Label readForAllNote = new Label("When this option is enabled, the file will be readable" +\r
258                                         " by everyone. By checking this option, you are certifying that you have the right to " +\r
259                                         "distribute this file and that it does not violate the Terms of Use.", true);\r
260                 readForAllNote.setVisible(false);\r
261                 readForAllNote.setStylePrimaryName("gss-readForAllNote");\r
262 \r
263                 readForAll = new CheckBox();\r
264                 readForAll.setChecked(file.isReadForAll());\r
265                 readForAll.addClickListener(new ClickListener() {\r
266 \r
267                         public void onClick(Widget sender) {\r
268                                 if (readForAll.isChecked()) {\r
269                                         readForAllNote.setVisible(true);\r
270                                         pathPanel.setVisible(true);\r
271                                 }\r
272                                 else {\r
273                                         readForAllNote.setVisible(false);\r
274                                         pathPanel.setVisible(false);\r
275                                 }\r
276                         }\r
277 \r
278                 });\r
279 \r
280                 permPanel.add(permList);\r
281                 permPanel.add(permButtons);\r
282                 // Only show the read for all permission if the user is the owner.\r
283                 if (file.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) {\r
284                         permForAll.add(new Label("Make Public"));\r
285                         permForAll.add(readForAll);\r
286                         permForAll.setSpacing(8);\r
287                         permForAll.addStyleName("gwt-TabPanelBottom");\r
288                         permPanel.add(permForAll);\r
289                         permPanel.add(readForAllNote);\r
290                 }\r
291 \r
292                 TextBox path = new TextBox();\r
293                 path.addClickListener(new ClickListener () {\r
294 \r
295                         public void onClick(Widget sender) {\r
296                                 GSS.enableIESelection();\r
297                                 ((TextBox) sender).selectAll();\r
298                                 GSS.preventIESelection();\r
299                         }\r
300 \r
301                 });\r
302                 path.setText(file.getUri());\r
303                 path.setTitle("Use this URI for sharing this file with the world");\r
304                 path.setReadOnly(true);\r
305                 pathPanel.add(new Label("Sharing URI"));\r
306                 pathPanel.setSpacing(8);\r
307                 pathPanel.addStyleName("gwt-TabPanelBottom");\r
308                 pathPanel.add(path);\r
309                 pathPanel.setVisible(file.isReadForAll());\r
310                 permPanel.add(pathPanel);\r
311 \r
312                 VersionsList verList = new VersionsList(this, images, bodies);\r
313                 verPanel.add(verList);\r
314 \r
315                 vPanel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
316                 vPanel.setSpacing(8);\r
317                 vPanel.addStyleName("gwt-TabPanelBottom");\r
318                 vPanel.add(new Label("Versioned"));\r
319 \r
320                 vPanel.add(versioned);\r
321                 verPanel.add(vPanel);\r
322                 vPanel2.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
323                 vPanel2.setSpacing(8);\r
324                 vPanel2.addStyleName("gwt-TabPanelBottom");\r
325                 Button removeVersionsButton = new Button(images.delete().getHTML(), new ClickListener() {\r
326 \r
327                         public void onClick(Widget sender) {\r
328                                 ConfirmationDialog confirm = new ConfirmationDialog("Really " +\r
329                                                 "remove all previous versions?", "Remove") {\r
330 \r
331                                         @Override\r
332                                         public void cancel() {\r
333                                         }\r
334 \r
335                                         @Override\r
336                                         public void confirm() {\r
337                                                 FilePropertiesDialog.this.closeDialog();\r
338                                                 removeAllOldVersions();\r
339                                         }\r
340 \r
341                                 };\r
342                                 confirm.center();\r
343                         }\r
344 \r
345                 });\r
346                 HTML removeAllVersion = new HTML("<span>Remove all previous versions?</span>");\r
347                 vPanel2.add(removeAllVersion);\r
348                 vPanel2.add(removeVersionsButton);\r
349                 verPanel.add(vPanel2);\r
350                 if(!file.isVersioned())\r
351                         vPanel2.setVisible(false);\r
352                 outer.add(inner);\r
353                 outer.add(buttons);\r
354                 outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
355                 outer.addStyleName("gwt-TabPanelBottom");\r
356 \r
357                 focusPanel.setFocus(true);\r
358                 setWidget(outer);\r
359         }\r
360 \r
361         /**\r
362          * Retrieves all user tags from the server and updates the FlowPanel\r
363          *\r
364          * @param userId\r
365          */\r
366         private void updateTags() {\r
367                 GetCommand<TagsResource> tc = new GetCommand<TagsResource>(TagsResource.class, GSS.get().getCurrentUserResource().getTagsPath()) {\r
368 \r
369                         @Override\r
370                         public void onComplete() {\r
371                                 allTagsContent.clear();\r
372                                 TagsResource tagr = getResult();\r
373                                 List<String> userTags = tagr.getTags();\r
374                                 Iterator t = userTags.iterator();\r
375                                 while (t.hasNext()) {\r
376                                         final Button tag = new Button((String) t.next(), new ClickListener() {\r
377 \r
378                                                 public void onClick(Widget sender) {\r
379                                                         String existing = tags.getText();\r
380                                                         String newTag = ((Button) sender).getText().trim();\r
381                                                         // insert the new tag only if it is not in the list\r
382                                                         // already\r
383                                                         if (existing.indexOf(newTag + ",") == -1 && !existing.trim().endsWith(newTag))\r
384                                                                 tags.setText(existing.trim() + (existing.length() > 0 ? ", " : "") + newTag);\r
385                                                 }\r
386                                         });\r
387                                         allTagsContent.add(tag);\r
388                                 }\r
389                         }\r
390 \r
391                         @Override\r
392                         public void onError(Throwable t) {\r
393                                 GWT.log("", t);\r
394                                 GSS.get().displayError("Unable to fetch user tags");\r
395                         }\r
396                 };\r
397                 DeferredCommand.addCommand(tc);\r
398 \r
399         }\r
400 \r
401         @Override\r
402         @SuppressWarnings("fallthrough")\r
403         public boolean onKeyDownPreview(char key, int modifiers) {\r
404                 // Use the popup's key preview hooks to close the dialog when either\r
405                 // enter or escape is pressed.\r
406                 switch (key) {\r
407                         case KeyboardListener.KEY_ENTER:\r
408                                 accept();\r
409                         case KeyboardListener.KEY_ESCAPE:\r
410                                 closeDialog();\r
411                                 break;\r
412                 }\r
413 \r
414                 return true;\r
415         }\r
416 \r
417         /**\r
418          * Accepts any change and updates the file\r
419          *\r
420          * @param userId\r
421          */\r
422         private void accept() {\r
423                 permList.updatePermissionsAccordingToInput();\r
424                 Set<PermissionHolder> perms = permList.getPermissions();\r
425                 JSONObject json = new JSONObject();\r
426                 if (!name.getText().equals(file.getName()))\r
427                         json.put("name", new JSONString(name.getText()));\r
428                 if (versioned.isChecked() != file.isVersioned())\r
429                         json.put("versioned", JSONBoolean.getInstance(versioned.isChecked()));\r
430                 //only update the read for all perm if the user is the owner\r
431                 if (readForAll.isChecked() != file.isReadForAll())\r
432                         if (file.getOwner().equals(GSS.get().getCurrentUserResource().getUsername()))\r
433                                 json.put("readForAll", JSONBoolean.getInstance(readForAll.isChecked()));\r
434                 int i = 0;\r
435                 if (permList.hasChanges()) {\r
436                         GWT.log("Permissions change", null);\r
437                         JSONArray perma = new JSONArray();\r
438 \r
439                         for (PermissionHolder p : perms) {\r
440                                 JSONObject po = new JSONObject();\r
441                                 if (p.getUser() != null)\r
442                                         po.put("user", new JSONString(p.getUser()));\r
443                                 if (p.getGroup() != null)\r
444                                         po.put("group", new JSONString(p.getGroup()));\r
445                                 po.put("read", JSONBoolean.getInstance(p.isRead()));\r
446                                 po.put("write", JSONBoolean.getInstance(p.isWrite()));\r
447                                 po.put("modifyACL", JSONBoolean.getInstance(p.isModifyACL()));\r
448                                 perma.set(i, po);\r
449                                 i++;\r
450                         }\r
451                         json.put("permissions", perma);\r
452                 }\r
453                 JSONArray taga = new JSONArray();\r
454                 i = 0;\r
455                 if (!tags.getText().equals(initialTagText)) {\r
456                         String[] tagset = tags.getText().split(",");\r
457                         for (String t : tagset) {\r
458                                 JSONString to = new JSONString(t);\r
459                                 taga.set(i, to);\r
460                                 i++;\r
461                         }\r
462                         json.put("tags", taga);\r
463                 }\r
464                 String jsonString = json.toString();\r
465                 if(jsonString.equals("{}")){\r
466                         GWT.log("NO CHANGES", null);\r
467                         return;\r
468                 }\r
469                 PostCommand cf = new PostCommand(file.getUri() + "?update=", jsonString, 200) {\r
470 \r
471                         @Override\r
472                         public void onComplete() {\r
473                                 GSS.get().getFileList().updateFileCache(true, false /* do not clear selected file*/);\r
474                         }\r
475 \r
476                         @Override\r
477                         public void onError(Throwable t) {\r
478                                 GWT.log("", t);\r
479                                 if (t instanceof RestException) {\r
480                                         int statusCode = ((RestException) t).getHttpStatusCode();\r
481                                         if (statusCode == 405)\r
482                                                 GSS.get().displayError("You don't have the necessary permissions");\r
483                                         else if (statusCode == 404)\r
484                                                 GSS.get().displayError("User in permissions does not exist");\r
485                                         else if (statusCode == 409)\r
486                                                 GSS.get().displayError("A file with the same name already exists");\r
487                                         else if (statusCode == 413)\r
488                                                 GSS.get().displayError("Your quota has been exceeded");\r
489                                         else\r
490                                                 GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
491                                 } else\r
492                                         GSS.get().displayError("System error modifying file:" + t.getMessage());\r
493                         }\r
494 \r
495                 };\r
496                 DeferredCommand.addCommand(cf);\r
497 \r
498         }\r
499 \r
500         private void removeAllOldVersions() {\r
501                 JSONObject json = new JSONObject();\r
502                 json.put("versioned", JSONBoolean.getInstance(false));\r
503                 GWT.log(json.toString(), null);\r
504                 PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
505 \r
506                         @Override\r
507                         public void onComplete() {\r
508                                 toggleVersioned(true);\r
509                         }\r
510 \r
511                         @Override\r
512                         public void onError(Throwable t) {\r
513                                 GWT.log("", t);\r
514                                 if (t instanceof RestException) {\r
515                                         int statusCode = ((RestException) t).getHttpStatusCode();\r
516                                         if (statusCode == 405)\r
517                                                 GSS.get().displayError("You don't have the necessary permissions");\r
518                                         else if (statusCode == 404)\r
519                                                 GSS.get().displayError("User in permissions does not exist");\r
520                                         else if (statusCode == 409)\r
521                                                 GSS.get().displayError("A folder with the same name already exists");\r
522                                         else if (statusCode == 413)\r
523                                                 GSS.get().displayError("Your quota has been exceeded");\r
524                                         else\r
525                                                 GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
526                                 } else\r
527                                         GSS.get().displayError("System error moifying file:" + t.getMessage());\r
528                         }\r
529                 };\r
530                 DeferredCommand.addCommand(cf);\r
531         }\r
532 \r
533         private void toggleVersioned(boolean versionedValue) {\r
534                 JSONObject json = new JSONObject();\r
535                 json.put("versioned", JSONBoolean.getInstance(versionedValue));\r
536                 GWT.log(json.toString(), null);\r
537                 PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
538 \r
539                         @Override\r
540                         public void onComplete() {\r
541                                 GSS.get().getFileList().updateFileCache(true, false /* do not clear selected file*/);\r
542                         }\r
543 \r
544                         @Override\r
545                         public void onError(Throwable t) {\r
546                                 GWT.log("", t);\r
547                                 if (t instanceof RestException) {\r
548                                         int statusCode = ((RestException) t).getHttpStatusCode();\r
549                                         if (statusCode == 405)\r
550                                                 GSS.get().displayError("You don't have the necessary permissions");\r
551                                         else if (statusCode == 404)\r
552                                                 GSS.get().displayError("User in permissions does not exist");\r
553                                         else if (statusCode == 409)\r
554                                                 GSS.get().displayError("A folder with the same name already exists");\r
555                                         else if (statusCode == 413)\r
556                                                 GSS.get().displayError("Your quota has been exceeded");\r
557                                         else\r
558                                                 GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
559                                 } else\r
560                                         GSS.get().displayError("System error moifying file:" + t.getMessage());\r
561                         }\r
562                 };\r
563                 DeferredCommand.addCommand(cf);\r
564         }\r
565 \r
566         public void selectTab(int _tab) {\r
567                 inner.selectTab(_tab);\r
568         }\r
569 \r
570         /**\r
571          * Enables IE selection prevention and hides the dialog\r
572          * (we disable the prevention on creation of the dialog)\r
573          */\r
574         public void closeDialog() {\r
575                 GSS.preventIESelection();\r
576                 hide();\r
577         }\r
578 \r
579 }\r