Revision ddbf7059

b/src/gr/grnet/pithos/web/client/FileShareDialog.java
34 34
 */
35 35
package gr.grnet.pithos.web.client;
36 36

  
37
import com.google.gwt.event.dom.client.*;
37 38
import com.google.gwt.http.client.URL;
39
import com.google.gwt.user.client.Event;
38 40
import com.google.gwt.user.client.ui.*;
39 41
import gr.grnet.pithos.web.client.foldertree.File;
40 42
import gr.grnet.pithos.web.client.rest.HeadRequest;
......
43 45
import com.google.gwt.core.client.GWT;
44 46
import com.google.gwt.core.client.Scheduler;
45 47
import com.google.gwt.dom.client.NativeEvent;
46
import com.google.gwt.event.dom.client.ClickEvent;
47
import com.google.gwt.event.dom.client.ClickHandler;
48
import com.google.gwt.event.dom.client.KeyCodes;
49 48
import com.google.gwt.http.client.Response;
50 49
import com.google.gwt.http.client.UrlBuilder;
51 50
import com.google.gwt.resources.client.ImageResource;
......
59 58
 * UI for the "Share" command.
60 59
 */
61 60
public class FileShareDialog extends AbstractPropertiesDialog {
61
    private static final class LinkTextContextMenu extends PopupPanel {
62
        private final TextBox toCopy;
63

  
64
        public LinkTextContextMenu(TextBox toCopy) {
65
            super(true); // autoHide
66

  
67
            this.toCopy = toCopy;
68

  
69
            final MenuBar contextMenu = new MenuBar(true);
70
            final MenuItem copy = new MenuItem("Copy", false, new Command() {
71
                @Override
72
                public void execute() {
73
                    Pithos.LOG("Copying ", LinkTextContextMenu.this.toCopy.getText());
74
                    LinkTextContextMenu.this.hide();
75
                    Helpers.copyToClipboardFrom(LinkTextContextMenu.this.toCopy.getElement());
76
                }
77
            });
78
            contextMenu.addItem(copy);
79

  
80
            add(contextMenu);
81
        }
82
    }
83

  
84
    private static final class LinkTextBox extends TextBox {
85
        public LinkTextBox() {
86
            sinkEvents(Event.ONCONTEXTMENU);
87

  
88
            addHandler(new ContextMenuHandler() {
89
                @Override
90
                public void onContextMenu(ContextMenuEvent event) {
91
                    final int x = event.getNativeEvent().getClientX();
92
                    final int y = event.getNativeEvent().getClientY();
93

  
94
                    final LinkTextContextMenu menu = new LinkTextContextMenu(LinkTextBox.this);
95
                    menu.setPopupPosition(x, y);
96
                    menu.show();
97

  
98
                }
99
            }, ContextMenuEvent.getType());
100
        }
101
    }
102

  
62 103
    // For public sharing
63 104
	private final HorizontalPanel publicPathPanel = new HorizontalPanel();
64
	private final TextBox publicPathText = new TextBox();
105
	private final TextBox publicPathText = new LinkTextBox();
65 106

  
66 107
    // For private sharing
67 108
    private final HorizontalPanel privatePathPanel = new HorizontalPanel();
68
    private final TextBox privatePathText = new TextBox();
69
    private final VerticalPanel privatePermSuperPanel = new VerticalPanel();
109
    private final TextBox privatePathText = new LinkTextBox();
70 110
    private PermissionsList permList;
71 111
	
72 112
	/**
......
314 354
        privatePathPanel.addStyleName("pithos-TabPanelBottom");
315 355

  
316 356
        privatePathText.setWidth(Const.PERCENT_100);
357

  
317 358
        privatePathText.addClickHandler(new ClickHandler() {
318 359
            @Override
319 360
            public void onClick(ClickEvent event) {
b/src/gr/grnet/pithos/web/client/Helpers.java
105 105
            }
106 106
        }
107 107
    }
108

  
109
    public static native void copyToClipboardFrom(com.google.gwt.user.client.Element element) /*-{
110
      $wnd.window.clipboardData.setData('text', element);
111
    }-*/;
108 112
}

Also available in: Unified diff