commit ddbf705922a5abb92c92205ebc98cc97fbd89aeb
Author: Christos KK Loverdos <loverdos@gmail.com>
Date:   Fri Apr 19 15:12:29 2013 +0300

    Provide RightClick/CopyToClipboard functionality for "Public/Private Link" in File/Share dialog
    
    It does not work. I think there is no standard way to do it.
    Which browser versions do we support anyway?
    
    I am committing the work, since it has been done but the intention
    is to revert it immediately
    
    Refs #3575

diff --git a/src/gr/grnet/pithos/web/client/FileShareDialog.java b/src/gr/grnet/pithos/web/client/FileShareDialog.java
index e1318da..18c0d4e 100644
--- a/src/gr/grnet/pithos/web/client/FileShareDialog.java
+++ b/src/gr/grnet/pithos/web/client/FileShareDialog.java
@@ -34,7 +34,9 @@
  */
 package gr.grnet.pithos.web.client;
 
+import com.google.gwt.event.dom.client.*;
 import com.google.gwt.http.client.URL;
+import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.*;
 import gr.grnet.pithos.web.client.foldertree.File;
 import gr.grnet.pithos.web.client.rest.HeadRequest;
@@ -43,9 +45,6 @@ import gr.grnet.pithos.web.client.rest.PostRequest;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.core.client.Scheduler;
 import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
 import com.google.gwt.http.client.Response;
 import com.google.gwt.http.client.UrlBuilder;
 import com.google.gwt.resources.client.ImageResource;
@@ -59,14 +58,55 @@ import java.util.Map;
  * UI for the "Share" command.
  */
 public class FileShareDialog extends AbstractPropertiesDialog {
+    private static final class LinkTextContextMenu extends PopupPanel {
+        private final TextBox toCopy;
+
+        public LinkTextContextMenu(TextBox toCopy) {
+            super(true); // autoHide
+
+            this.toCopy = toCopy;
+
+            final MenuBar contextMenu = new MenuBar(true);
+            final MenuItem copy = new MenuItem("Copy", false, new Command() {
+                @Override
+                public void execute() {
+                    Pithos.LOG("Copying ", LinkTextContextMenu.this.toCopy.getText());
+                    LinkTextContextMenu.this.hide();
+                    Helpers.copyToClipboardFrom(LinkTextContextMenu.this.toCopy.getElement());
+                }
+            });
+            contextMenu.addItem(copy);
+
+            add(contextMenu);
+        }
+    }
+
+    private static final class LinkTextBox extends TextBox {
+        public LinkTextBox() {
+            sinkEvents(Event.ONCONTEXTMENU);
+
+            addHandler(new ContextMenuHandler() {
+                @Override
+                public void onContextMenu(ContextMenuEvent event) {
+                    final int x = event.getNativeEvent().getClientX();
+                    final int y = event.getNativeEvent().getClientY();
+
+                    final LinkTextContextMenu menu = new LinkTextContextMenu(LinkTextBox.this);
+                    menu.setPopupPosition(x, y);
+                    menu.show();
+
+                }
+            }, ContextMenuEvent.getType());
+        }
+    }
+
     // For public sharing
 	private final HorizontalPanel publicPathPanel = new HorizontalPanel();
-	private final TextBox publicPathText = new TextBox();
+	private final TextBox publicPathText = new LinkTextBox();
 
     // For private sharing
     private final HorizontalPanel privatePathPanel = new HorizontalPanel();
-    private final TextBox privatePathText = new TextBox();
-    private final VerticalPanel privatePermSuperPanel = new VerticalPanel();
+    private final TextBox privatePathText = new LinkTextBox();
     private PermissionsList permList;
 	
 	/**
@@ -314,6 +354,7 @@ public class FileShareDialog extends AbstractPropertiesDialog {
         privatePathPanel.addStyleName("pithos-TabPanelBottom");
 
         privatePathText.setWidth(Const.PERCENT_100);
+
         privatePathText.addClickHandler(new ClickHandler() {
             @Override
             public void onClick(ClickEvent event) {
diff --git a/src/gr/grnet/pithos/web/client/Helpers.java b/src/gr/grnet/pithos/web/client/Helpers.java
index 5522d77..a717180 100644
--- a/src/gr/grnet/pithos/web/client/Helpers.java
+++ b/src/gr/grnet/pithos/web/client/Helpers.java
@@ -105,4 +105,8 @@ public final class Helpers {
             }
         }
     }
+
+    public static native void copyToClipboardFrom(com.google.gwt.user.client.Element element) /*-{
+      $wnd.window.clipboardData.setData('text', element);
+    }-*/;
 }
