import gr.ebs.gss.client.commands.UploadFileCommand;\r
import gr.ebs.gss.client.rest.RestCommand;\r
import gr.ebs.gss.client.rest.resource.FileResource;\r
-import gr.ebs.gss.client.rest.resource.FolderResource;\r
import gr.ebs.gss.client.rest.resource.GroupUserResource;\r
\r
+import java.util.List;\r
+\r
+import com.google.gwt.event.dom.client.ClickEvent;\r
+import com.google.gwt.event.dom.client.ClickHandler;\r
import com.google.gwt.http.client.URL;\r
+import com.google.gwt.resources.client.ClientBundle;\r
+import com.google.gwt.resources.client.ImageResource;\r
import com.google.gwt.user.client.Command;\r
import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
-import com.google.gwt.user.client.ui.ClickListener;\r
import com.google.gwt.user.client.ui.MenuBar;\r
import com.google.gwt.user.client.ui.PopupPanel;\r
import com.google.gwt.user.client.ui.TreeItem;\r
-import com.google.gwt.user.client.ui.Widget;\r
\r
/**\r
* The 'File' menu implementation.\r
*/\r
-public class FileMenu extends PopupPanel implements ClickListener {\r
+public class FileMenu extends PopupPanel implements ClickHandler {\r
\r
/**\r
* The widget's images.\r
/**\r
* An image bundle for this widgets images.\r
*/\r
- public interface Images extends FilePropertiesDialog.Images {\r
+ public interface Images extends ClientBundle,FilePropertiesDialog.Images {\r
\r
- @Resource("gr/ebs/gss/resources/folder_new.png")\r
- AbstractImagePrototype folderNew();\r
+ @Source("gr/ebs/gss/resources/folder_new.png")\r
+ ImageResource folderNew();\r
\r
- @Resource("gr/ebs/gss/resources/folder_outbox.png")\r
- AbstractImagePrototype fileUpdate();\r
+ @Source("gr/ebs/gss/resources/folder_outbox.png")\r
+ ImageResource fileUpdate();\r
\r
- @Resource("gr/ebs/gss/resources/view_text.png")\r
- AbstractImagePrototype viewText();\r
+ @Source("gr/ebs/gss/resources/view_text.png")\r
+ ImageResource viewText();\r
\r
- @Resource("gr/ebs/gss/resources/folder_inbox.png")\r
- AbstractImagePrototype download();\r
+ @Source("gr/ebs/gss/resources/folder_inbox.png")\r
+ ImageResource download();\r
\r
- @Resource("gr/ebs/gss/resources/trashcan_empty.png")\r
- AbstractImagePrototype emptyTrash();\r
+ @Source("gr/ebs/gss/resources/trashcan_empty.png")\r
+ ImageResource emptyTrash();\r
\r
- @Resource("gr/ebs/gss/resources/internet.png")\r
- AbstractImagePrototype sharing();\r
+ @Source("gr/ebs/gss/resources/internet.png")\r
+ ImageResource sharing();\r
\r
- @Resource("gr/ebs/gss/resources/refresh.png")\r
- AbstractImagePrototype refresh();\r
+ @Source("gr/ebs/gss/resources/refresh.png")\r
+ ImageResource refresh();\r
}\r
\r
final MenuBar contextMenu = new MenuBar(true);\r
\r
}\r
\r
- public void onClick(final Widget sender) {\r
+ @Override\r
+ public void onClick(ClickEvent event) {\r
final FileMenu menu = new FileMenu(images);\r
- final int left = sender.getAbsoluteLeft();\r
- final int top = sender.getAbsoluteTop() + sender.getOffsetHeight();\r
+ final int left = event.getRelativeElement().getAbsoluteLeft();\r
+ final int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();\r
menu.setPopupPosition(left, top);\r
-\r
menu.show();\r
+\r
}\r
\r
+\r
/**\r
* Do some validation before downloading a file.\r
*/\r
* and save location\r
*/\r
void createDownloadLink(String[] link, boolean forceDownload) {\r
+ String downloadURL = getDownloadURL();\r
+ if (!downloadURL.isEmpty()) {\r
+ link[0] = "<a class='hidden-link' href='" + downloadURL\r
+ + (forceDownload ? "&dl=1" : "") + "' target='_blank'>";\r
+ link[1] = "</a>";\r
+ }\r
+ }\r
+\r
+ public String getDownloadURL() {\r
GSS app = GSS.get();\r
Object selection = app.getCurrentSelection();\r
if (selection != null && selection instanceof FileResource) {\r
FileResource file = (FileResource) selection;\r
+ return getDownloadURL(file);\r
+ }\r
+ return "";\r
+ }\r
+\r
+ public String getDownloadURL(FileResource file) {\r
+ GSS app = GSS.get();\r
+ if (file != null) {\r
String dateString = RestCommand.getDate();\r
String resource = file.getUri().substring(app.getApiPath().length()-1,file.getUri().length());\r
String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken()));\r
- link[0] = "<a class='hidden-link' href='" + file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString)\r
- + (forceDownload ? "&dl=1" : "") + "' target='_blank'>";\r
- link[1] = "</a>";\r
+ return file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString);\r
}\r
+ return "";\r
}\r
\r
public MenuBar createMenu() {\r
Folders folders = GSS.get().getFolders();\r
TreeItem selectedItem = folders.getCurrent();\r
boolean downloadVisible = GSS.get().getCurrentSelection() != null && GSS.get().getCurrentSelection() instanceof FileResource;\r
- boolean uploadVisible = GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource;\r
- boolean propertiesNotVisible = selectedItem != null && (folders.isTrash(selectedItem) || folders.isMyShares(selectedItem) || folders.isOthersShared(selectedItem) || selectedItem.getUserObject() instanceof GroupUserResource);\r
- contextMenu.addItem("<span>" + images.folderNew().getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images));\r
- contextMenu.addItem("<span>" + images.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this));\r
+ boolean propertiesVisible = !(selectedItem != null && (folders.isTrash(selectedItem) || folders.isMyShares(selectedItem) || folders.isOthersShared(selectedItem) || selectedItem.getUserObject() instanceof GroupUserResource || GSS.get().getCurrentSelection() instanceof List));\r
+ boolean newFolderVisible = !(selectedItem != null && (folders.isTrash(selectedItem) || folders.isMyShares(selectedItem)|| folders.isOthersShared(selectedItem)));\r
+ if(newFolderVisible)\r
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images));\r
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this));\r
if (downloadVisible) {\r
String[] link = {"", ""};\r
createDownloadLink(link, false);\r
- contextMenu.addItem("<span>" + link[0] + images.download().getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);\r
+ contextMenu.addItem("<span>" + link[0] + AbstractImagePrototype.create(images.download()).getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);\r
createDownloadLink(link, true);\r
- contextMenu.addItem("<span>" + link[0] + images.download().getHTML() + " Save file as" + link[1] + "</span>", true, downloadCmd);\r
+ contextMenu.addItem("<span>" + link[0] + AbstractImagePrototype.create(images.download()).getHTML() + " Save As" + link[1] + "</span>", true, downloadCmd);\r
}\r
- contextMenu.addItem("<span>" + images.emptyTrash().getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this));\r
- contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));\r
- contextMenu.addItem("<span>" + images.sharing().getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1))\r
- .setVisible(!propertiesNotVisible);\r
- contextMenu.addItem("<span>" + images.viewText().getHTML() + " Properties</span>", true, new PropertiesCommand(this, images, 0))\r
- .setVisible(!propertiesNotVisible);\r
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this));\r
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));\r
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1))\r
+ .setVisible(propertiesVisible);\r
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, images, 0))\r
+ .setVisible(propertiesVisible);\r
return contextMenu;\r
}\r
\r
+\r
+\r
}\r