Use Lytebox (a Lightbox clone) for quick viewing images.
[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                         permForAll.add(readForAllNote);\r
289                         permPanel.add(permForAll);\r
290                 }\r
291 \r
292                 TextBox path = new TextBox();\r
293                 path.setWidth("100%");\r
294                 path.addClickListener(new ClickListener () {\r
295 \r
296                         public void onClick(Widget sender) {\r
297                                 GSS.enableIESelection();\r
298                                 ((TextBox) sender).selectAll();\r
299                                 GSS.preventIESelection();\r
300                         }\r
301 \r
302                 });\r
303                 path.setText(file.getUri());\r
304                 path.setTitle("Use this URI for sharing this file with the world (crtl-C/cmd-C to copy to system clipboard)");\r
305                 path.setWidth("100%");\r
306                 path.setReadOnly(true);\r
307                 pathPanel.setWidth("100%");\r
308                 pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\r
309                 pathPanel.add(new Label("Sharing URI"));\r
310                 pathPanel.setSpacing(8);\r
311                 pathPanel.addStyleName("gwt-TabPanelBottom");\r
312                 pathPanel.add(path);\r
313                 pathPanel.setVisible(file.isReadForAll());\r
314                 permPanel.add(pathPanel);\r
315 \r
316                 VersionsList verList = new VersionsList(this, images, bodies);\r
317                 verPanel.add(verList);\r
318 \r
319                 vPanel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
320                 vPanel.setSpacing(8);\r
321                 vPanel.addStyleName("gwt-TabPanelBottom");\r
322                 vPanel.add(new Label("Versioned"));\r
323 \r
324                 vPanel.add(versioned);\r
325                 verPanel.add(vPanel);\r
326                 vPanel2.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
327                 vPanel2.setSpacing(8);\r
328                 vPanel2.addStyleName("gwt-TabPanelBottom");\r
329                 Button removeVersionsButton = new Button(images.delete().getHTML(), new ClickListener() {\r
330 \r
331                         public void onClick(Widget sender) {\r
332                                 ConfirmationDialog confirm = new ConfirmationDialog("Really " +\r
333                                                 "remove all previous versions?", "Remove") {\r
334 \r
335                                         @Override\r
336                                         public void cancel() {\r
337                                         }\r
338 \r
339                                         @Override\r
340                                         public void confirm() {\r
341                                                 FilePropertiesDialog.this.closeDialog();\r
342                                                 removeAllOldVersions();\r
343                                         }\r
344 \r
345                                 };\r
346                                 confirm.center();\r
347                         }\r
348 \r
349                 });\r
350                 HTML removeAllVersion = new HTML("<span>Remove all previous versions?</span>");\r
351                 vPanel2.add(removeAllVersion);\r
352                 vPanel2.add(removeVersionsButton);\r
353                 verPanel.add(vPanel2);\r
354                 if(!file.isVersioned())\r
355                         vPanel2.setVisible(false);\r
356                 outer.add(inner);\r
357                 outer.add(buttons);\r
358                 outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
359                 outer.addStyleName("gwt-TabPanelBottom");\r
360 \r
361                 focusPanel.setFocus(true);\r
362                 setWidget(outer);\r
363         }\r
364 \r
365         /**\r
366          * Retrieves all user tags from the server and updates the FlowPanel\r
367          *\r
368          * @param userId\r
369          */\r
370         private void updateTags() {\r
371                 GetCommand<TagsResource> tc = new GetCommand<TagsResource>(TagsResource.class, GSS.get().getCurrentUserResource().getTagsPath()) {\r
372 \r
373                         @Override\r
374                         public void onComplete() {\r
375                                 allTagsContent.clear();\r
376                                 TagsResource tagr = getResult();\r
377                                 List<String> userTags = tagr.getTags();\r
378                                 Iterator t = userTags.iterator();\r
379                                 while (t.hasNext()) {\r
380                                         final Button tag = new Button((String) t.next(), new ClickListener() {\r
381 \r
382                                                 public void onClick(Widget sender) {\r
383                                                         String existing = tags.getText();\r
384                                                         String newTag = ((Button) sender).getText().trim();\r
385                                                         // insert the new tag only if it is not in the list\r
386                                                         // already\r
387                                                         if (existing.indexOf(newTag + ",") == -1 && !existing.trim().endsWith(newTag))\r
388                                                                 tags.setText(existing.trim() + (existing.length() > 0 ? ", " : "") + newTag);\r
389                                                 }\r
390                                         });\r
391                                         allTagsContent.add(tag);\r
392                                 }\r
393                         }\r
394 \r
395                         @Override\r
396                         public void onError(Throwable t) {\r
397                                 GWT.log("", t);\r
398                                 GSS.get().displayError("Unable to fetch user tags");\r
399                         }\r
400                 };\r
401                 DeferredCommand.addCommand(tc);\r
402 \r
403         }\r
404 \r
405         @Override\r
406         @SuppressWarnings("fallthrough")\r
407         public boolean onKeyDownPreview(char key, int modifiers) {\r
408                 // Use the popup's key preview hooks to close the dialog when either\r
409                 // enter or escape is pressed.\r
410                 switch (key) {\r
411                         case KeyboardListener.KEY_ENTER:\r
412                                 accept();\r
413                         case KeyboardListener.KEY_ESCAPE:\r
414                                 closeDialog();\r
415                                 break;\r
416                 }\r
417 \r
418                 return true;\r
419         }\r
420 \r
421         /**\r
422          * Accepts any change and updates the file\r
423          *\r
424          * @param userId\r
425          */\r
426         private void accept() {\r
427                 permList.updatePermissionsAccordingToInput();\r
428                 Set<PermissionHolder> perms = permList.getPermissions();\r
429                 JSONObject json = new JSONObject();\r
430                 if (!name.getText().equals(file.getName()))\r
431                         json.put("name", new JSONString(name.getText()));\r
432                 if (versioned.isChecked() != file.isVersioned())\r
433                         json.put("versioned", JSONBoolean.getInstance(versioned.isChecked()));\r
434                 //only update the read for all perm if the user is the owner\r
435                 if (readForAll.isChecked() != file.isReadForAll())\r
436                         if (file.getOwner().equals(GSS.get().getCurrentUserResource().getUsername()))\r
437                                 json.put("readForAll", JSONBoolean.getInstance(readForAll.isChecked()));\r
438                 int i = 0;\r
439                 if (permList.hasChanges()) {\r
440                         GWT.log("Permissions change", null);\r
441                         JSONArray perma = new JSONArray();\r
442 \r
443                         for (PermissionHolder p : perms) {\r
444                                 JSONObject po = new JSONObject();\r
445                                 if (p.getUser() != null)\r
446                                         po.put("user", new JSONString(p.getUser()));\r
447                                 if (p.getGroup() != null)\r
448                                         po.put("group", new JSONString(p.getGroup()));\r
449                                 po.put("read", JSONBoolean.getInstance(p.isRead()));\r
450                                 po.put("write", JSONBoolean.getInstance(p.isWrite()));\r
451                                 po.put("modifyACL", JSONBoolean.getInstance(p.isModifyACL()));\r
452                                 perma.set(i, po);\r
453                                 i++;\r
454                         }\r
455                         json.put("permissions", perma);\r
456                 }\r
457                 JSONArray taga = new JSONArray();\r
458                 i = 0;\r
459                 if (!tags.getText().equals(initialTagText)) {\r
460                         String[] tagset = tags.getText().split(",");\r
461                         for (String t : tagset) {\r
462                                 JSONString to = new JSONString(t);\r
463                                 taga.set(i, to);\r
464                                 i++;\r
465                         }\r
466                         json.put("tags", taga);\r
467                 }\r
468                 String jsonString = json.toString();\r
469                 if(jsonString.equals("{}")){\r
470                         GWT.log("NO CHANGES", null);\r
471                         return;\r
472                 }\r
473                 PostCommand cf = new PostCommand(file.getUri() + "?update=", jsonString, 200) {\r
474 \r
475                         @Override\r
476                         public void onComplete() {\r
477                                 GSS.get().getFileList().updateFileCache(true, false /* do not clear selected file*/);\r
478                         }\r
479 \r
480                         @Override\r
481                         public void onError(Throwable t) {\r
482                                 GWT.log("", t);\r
483                                 if (t instanceof RestException) {\r
484                                         int statusCode = ((RestException) t).getHttpStatusCode();\r
485                                         if (statusCode == 405)\r
486                                                 GSS.get().displayError("You don't have the necessary permissions");\r
487                                         else if (statusCode == 404)\r
488                                                 GSS.get().displayError("User in permissions does not exist");\r
489                                         else if (statusCode == 409)\r
490                                                 GSS.get().displayError("A file with the same name already exists");\r
491                                         else if (statusCode == 413)\r
492                                                 GSS.get().displayError("Your quota has been exceeded");\r
493                                         else\r
494                                                 GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
495                                 } else\r
496                                         GSS.get().displayError("System error modifying file:" + t.getMessage());\r
497                         }\r
498 \r
499                 };\r
500                 DeferredCommand.addCommand(cf);\r
501 \r
502         }\r
503 \r
504         private void removeAllOldVersions() {\r
505                 JSONObject json = new JSONObject();\r
506                 json.put("versioned", JSONBoolean.getInstance(false));\r
507                 GWT.log(json.toString(), null);\r
508                 PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
509 \r
510                         @Override\r
511                         public void onComplete() {\r
512                                 toggleVersioned(true);\r
513                         }\r
514 \r
515                         @Override\r
516                         public void onError(Throwable t) {\r
517                                 GWT.log("", t);\r
518                                 if (t instanceof RestException) {\r
519                                         int statusCode = ((RestException) t).getHttpStatusCode();\r
520                                         if (statusCode == 405)\r
521                                                 GSS.get().displayError("You don't have the necessary permissions");\r
522                                         else if (statusCode == 404)\r
523                                                 GSS.get().displayError("User in permissions does not exist");\r
524                                         else if (statusCode == 409)\r
525                                                 GSS.get().displayError("A folder with the same name already exists");\r
526                                         else if (statusCode == 413)\r
527                                                 GSS.get().displayError("Your quota has been exceeded");\r
528                                         else\r
529                                                 GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
530                                 } else\r
531                                         GSS.get().displayError("System error moifying file:" + t.getMessage());\r
532                         }\r
533                 };\r
534                 DeferredCommand.addCommand(cf);\r
535         }\r
536 \r
537         private void toggleVersioned(boolean versionedValue) {\r
538                 JSONObject json = new JSONObject();\r
539                 json.put("versioned", JSONBoolean.getInstance(versionedValue));\r
540                 GWT.log(json.toString(), null);\r
541                 PostCommand cf = new PostCommand(file.getUri() + "?update=", json.toString(), 200) {\r
542 \r
543                         @Override\r
544                         public void onComplete() {\r
545                                 GSS.get().getFileList().updateFileCache(true, false /* do not clear selected file*/);\r
546                         }\r
547 \r
548                         @Override\r
549                         public void onError(Throwable t) {\r
550                                 GWT.log("", t);\r
551                                 if (t instanceof RestException) {\r
552                                         int statusCode = ((RestException) t).getHttpStatusCode();\r
553                                         if (statusCode == 405)\r
554                                                 GSS.get().displayError("You don't have the necessary permissions");\r
555                                         else if (statusCode == 404)\r
556                                                 GSS.get().displayError("User in permissions does not exist");\r
557                                         else if (statusCode == 409)\r
558                                                 GSS.get().displayError("A folder with the same name already exists");\r
559                                         else if (statusCode == 413)\r
560                                                 GSS.get().displayError("Your quota has been exceeded");\r
561                                         else\r
562                                                 GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());\r
563                                 } else\r
564                                         GSS.get().displayError("System error moifying file:" + t.getMessage());\r
565                         }\r
566                 };\r
567                 DeferredCommand.addCommand(cf);\r
568         }\r
569 \r
570         public void selectTab(int _tab) {\r
571                 inner.selectTab(_tab);\r
572         }\r
573 \r
574         /**\r
575          * Enables IE selection prevention and hides the dialog\r
576          * (we disable the prevention on creation of the dialog)\r
577          */\r
578         public void closeDialog() {\r
579                 GSS.preventIESelection();\r
580                 hide();\r
581         }\r
582 \r
583 }\r