X-Git-Url: https://code.grnet.gr/git/pithos-web-client/blobdiff_plain/5d18aa8264cb997c267c3dba8d27f7cbf66d9150..e6e9f6e6eb4911bb9d8bcb308bd353551b01fe4f:/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java diff --git a/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java index 06c9328..d33cd27 100644 --- a/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java +++ b/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2012 GRNET S.A. All rights reserved. + * Copyright 2011-2013 GRNET S.A. All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following @@ -35,10 +35,10 @@ package gr.grnet.pithos.web.client; import gr.grnet.pithos.web.client.foldertree.File; -import gr.grnet.pithos.web.client.foldertree.Resource; import gr.grnet.pithos.web.client.rest.PostRequest; import gr.grnet.pithos.web.client.rest.PutRequest; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -55,7 +55,6 @@ import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; @@ -81,7 +80,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { super(_app); file = _file; - Anchor close = new Anchor(); + Anchor close = new Anchor("close"); close.addStyleName("close"); close.addClickHandler(new ClickHandler() { @@ -92,7 +91,6 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { }); // Set the dialog's caption. setText("File properties"); - setAnimationEnabled(true); setGlassEnabled(true); setStyleName("pithos-DialogBox"); @@ -135,11 +133,24 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { name.setWidth("100%"); name.setText(file.getName()); generalTable.setWidget(0, 1, name); - if(file.getParent() != null) + if(file.getParent() != null) { generalTable.setText(1, 1, file.getParent().getName()); - else + } + else { generalTable.setText(1, 1, "-"); - generalTable.setText(2, 1, file.getOwner()); + } + + final String ownerID = file.getOwnerID(); + final String displayName = app.getDisplayNameForUserID(ownerID); + final String ownerDisplayName; + if(displayName == null) { + // FIXME: Get the actual display name and do not use the id + ownerDisplayName = ownerID; + } + else { + ownerDisplayName = displayName; + } + generalTable.setText(2, 1, ownerDisplayName); final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); generalTable.setText(3, 1, file.getLastModified() != null ? formatter.format(file.getLastModified()) : ""); @@ -163,8 +174,8 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { meta.addStyleName("pithos-metaTitle"); metaTitlePanel.add(meta); - Image plus = new Image(); - plus.addStyleName("pithos-addMetaImg"); + Anchor plus = new Anchor("add"); + plus.addStyleName(Pithos.resources.pithosCss().commandAnchor()); metaTitlePanel.add(plus); generalPanel.add(metaTitlePanel); @@ -208,8 +219,8 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { table.setWidget(row, 1, valueBox); table.getFlexCellFormatter().setStyleName(1, 1, "props-values"); - Image delete = new Image(); - delete.addStyleName("pithos-metaDeleteImg"); + Anchor delete = new Anchor("remove"); + delete.addStyleName(Pithos.resources.pithosCss().commandAnchor()); delete.addClickHandler(new ClickHandler() { @Override @@ -250,10 +261,10 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { if (newFilename != null) { final String path = file.getParent().getUri() + "/" + newFilename; - PutRequest updateFile = new PutRequest(app.getApiPath(), app.getUsername(), path) { + PutRequest updateFile = new PutRequest(app.getApiPath(), app.getUserID(), path) { @Override public void onSuccess(Resource result) { - updateMetaData(app.getApiPath(), file.getOwner(), path + "?update=", newMeta); + updateMetaData(app.getApiPath(), file.getOwnerID(), path, newMeta); } @Override @@ -268,7 +279,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { app.sessionExpired(); } }; - updateFile.setHeader("X-Auth-Token", app.getToken()); + updateFile.setHeader("X-Auth-Token", app.getUserToken()); updateFile.setHeader("X-Move-From", URL.encodePathSegment(file.getUri())); updateFile.setHeader("Content-Type", file.getContentType()); for (String key : file.getMeta().keySet()) @@ -302,13 +313,13 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { Scheduler.get().scheduleDeferred(updateFile); } else - updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", newMeta); + updateMetaData(app.getApiPath(), app.getUserID(), file.getUri(), newMeta); return true; } - protected void updateMetaData(String api, String owner, String path, Map newMeta) { + protected void updateMetaData(final String api, final String owner, final String path, Map newMeta) { if (newMeta != null) { - PostRequest updateFile = new PostRequest(api, owner, path) { + PostRequest updateFile = new PostRequest(api, owner, path + "?update=") { @Override public void onSuccess(Resource result) { if (!app.isMySharedSelected()) @@ -316,11 +327,19 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { @Override public void execute() { + app.getFileList().selectByUrl(Arrays.asList(api + owner + path)); app.updateMySharedRoot(); } }, true); - else - app.updateSharedFolder(file.getParent(), true); + else { + app.updateSharedFolder(file.getParent(), true, new Command() { + + @Override + public void execute() { + app.getFileList().selectByUrl(Arrays.asList(api + owner + path)); + } + }); + } } @Override @@ -335,7 +354,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { app.sessionExpired(); } }; - updateFile.setHeader("X-Auth-Token", app.getToken()); + updateFile.setHeader("X-Auth-Token", app.getUserToken()); for (String t : file.getMeta().keySet()) { updateFile.setHeader("X-Object-Meta-" + URL.encodePathSegment(t.trim()), "~"); @@ -351,11 +370,14 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog { @Override public void execute() { + app.getFileList().selectByUrl(Arrays.asList(api + owner + path)); if (file.isSharedOrPublished()) app.updateMySharedRoot(); } }, true); - else + else { + app.getFileList().selectByUrl(Arrays.asList(api + owner + path)); app.updateSharedFolder(file.getParent(), true); + } } }