40 |
40 |
import com.google.gwt.json.client.JSONString;
|
41 |
41 |
import com.google.gwt.user.client.Command;
|
42 |
42 |
import com.google.gwt.user.client.DeferredCommand;
|
43 |
|
import com.google.gwt.user.client.Window;
|
44 |
43 |
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
45 |
44 |
import com.google.gwt.user.client.ui.Button;
|
46 |
45 |
import com.google.gwt.user.client.ui.CheckBox;
|
... | ... | |
327 |
326 |
Button removeVersionsButton = new Button(images.delete().getHTML(), new ClickListener() {
|
328 |
327 |
|
329 |
328 |
public void onClick(Widget sender) {
|
330 |
|
//TODO: replace javascript confirmation dialog
|
331 |
|
boolean confirm = Window.confirm("Really remove all previous versions?");
|
332 |
|
if (confirm)
|
333 |
|
hide();
|
334 |
|
removeAllOldVersions();
|
|
329 |
ConfirmationDialog confirm = new ConfirmationDialog(images,"Really remove all previous versions?","Remove"){
|
335 |
330 |
|
|
331 |
public void cancel() {
|
|
332 |
}
|
|
333 |
|
|
334 |
|
|
335 |
public void confirm() {
|
|
336 |
FilePropertiesDialog.this.hide();
|
|
337 |
removeAllOldVersions();
|
|
338 |
}
|
|
339 |
|
|
340 |
};
|
|
341 |
confirm.center();
|
336 |
342 |
}
|
337 |
343 |
|
338 |
344 |
});
|
... | ... | |
340 |
346 |
vPanel2.add(removeAllVersion);
|
341 |
347 |
vPanel2.add(removeVersionsButton);
|
342 |
348 |
verPanel.add(vPanel2);
|
|
349 |
if(!file.isVersioned())
|
|
350 |
vPanel2.setVisible(false);
|
343 |
351 |
outer.add(inner);
|
344 |
352 |
outer.add(buttons);
|
345 |
353 |
outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
|
... | ... | |
486 |
494 |
}
|
487 |
495 |
|
488 |
496 |
private void removeAllOldVersions() {
|
489 |
|
toggleVersioned(false);
|
490 |
|
toggleVersioned(true);
|
|
497 |
JSONObject json = new JSONObject();
|
|
498 |
json.put("versioned", JSONBoolean.getInstance(false));
|
|
499 |
GWT.log(json.toString(), null);
|
|
500 |
ExecutePost cf = new ExecutePost(file.getPath() + "?update=", json.toString(), 200) {
|
|
501 |
|
|
502 |
public void onComplete() {
|
|
503 |
toggleVersioned(true);
|
|
504 |
}
|
|
505 |
|
|
506 |
public void onError(Throwable t) {
|
|
507 |
GWT.log("", t);
|
|
508 |
if (t instanceof RestException) {
|
|
509 |
int statusCode = ((RestException) t).getHttpStatusCode();
|
|
510 |
if (statusCode == 405)
|
|
511 |
GSS.get().displayError("You don't have the necessary permissions");
|
|
512 |
else if (statusCode == 404)
|
|
513 |
GSS.get().displayError("User in permissions does not exist");
|
|
514 |
else if (statusCode == 409)
|
|
515 |
GSS.get().displayError("A folder with the same name already exists");
|
|
516 |
else if (statusCode == 413)
|
|
517 |
GSS.get().displayError("Your quota has been exceeded");
|
|
518 |
else
|
|
519 |
GSS.get().displayError("Unable to modify file:" + ((RestException) t).getHttpStatusText());
|
|
520 |
} else
|
|
521 |
GSS.get().displayError("System error moifying file:" + t.getMessage());
|
|
522 |
}
|
|
523 |
};
|
|
524 |
DeferredCommand.addCommand(cf);
|
491 |
525 |
}
|
492 |
526 |
|
493 |
527 |
private void toggleVersioned(boolean versionedValue) {
|