Revision f98f18c2

b/gss/src/gr/ebs/gss/client/FilePropertiesDialog.java
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) {
b/gss/src/gr/ebs/gss/client/commands/PropertiesCommand.java
27 27
import gr.ebs.gss.client.rest.ExecuteHead;
28 28
import gr.ebs.gss.client.rest.ExecuteMultipleGet;
29 29
import gr.ebs.gss.client.rest.ExecuteMultipleHead;
30
import gr.ebs.gss.client.rest.RestException;
30 31
import gr.ebs.gss.client.rest.resource.FileResource;
31 32
import gr.ebs.gss.client.rest.resource.FolderResource;
32 33
import gr.ebs.gss.client.rest.resource.GroupResource;
......
107 108

  
108 109
				@Override
109 110
				public void onError(Throwable t) {
110

  
111
					if(t instanceof RestException)
112
						GSS.get().displayError("Unable to retrieve file details:"+((RestException)t).getHttpStatusText());
111 113
				}
112 114

  
113 115
			};
......
207 209
			GWT.log("File is versioned:" + afile.isVersioned(), null);
208 210
			if (afile.isVersioned()) {
209 211
				List<String> paths = new ArrayList<String>();
210
				for (int i = 0; i < afile.getVersion(); i++)
212
				for (int i = 1; i <= afile.getVersion(); i++)
211 213
					paths.add(afile.getPath() + "?version=" + i);
212 214
				ExecuteMultipleHead<FileResource> gv = new ExecuteMultipleHead<FileResource>(FileResource.class, paths.toArray(new String[] {})) {
213 215

  

Also available in: Unified diff