*/
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;
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;
* UI for the "Share" command.
*/
public class FileShareDialog extends AbstractPropertiesDialog {
- private static final class LinkTextContextMenu extends PopupPanel {
- private final TextBox toCopy;
+ private static final class PermissionsUncheckWarning extends AbstractPropertiesDialog {
+ private PermissionsUncheckWarning(Pithos app) {
+ super(app);
+ final Anchor close = new Anchor("close");
+ close.addStyleName("close");
+ close.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ hide();
+ }
+ });
+ final String dialogText = "Info";
+ setText(dialogText);
+ setStyleName("pithos-DialogBox");
+
+ final VerticalPanel panel = new VerticalPanel();
+ panel.add(close);
- public LinkTextContextMenu(TextBox toCopy) {
- super(true); // autoHide
+ VerticalPanel inner = new VerticalPanel();
+ inner.addStyleName("inner");
- this.toCopy = toCopy;
+ inner.add(
+ new InlineHTML(
+ "It seems you are already sharing this file with some users." +
+ "<br>" +
+ "Please remove all users from the sharing list, to be able to uncheck this option."
+ )
+ );
- final MenuBar contextMenu = new MenuBar(true);
- final MenuItem copy = new MenuItem("Copy", false, new Command() {
+ final Button ok = new Button("OK", new ClickHandler() {
@Override
- public void execute() {
- Pithos.LOG("Copying ", LinkTextContextMenu.this.toCopy.getText());
- LinkTextContextMenu.this.hide();
- Helpers.copyToClipboardFrom(LinkTextContextMenu.this.toCopy.getElement());
+ public void onClick(ClickEvent event) {
+ hide();
}
});
- contextMenu.addItem(copy);
- add(contextMenu);
- }
- }
+ ok.addStyleName("button");
+ inner.add(ok);
- private static final class LinkTextBox extends TextBox {
- public LinkTextBox() {
- sinkEvents(Event.ONCONTEXTMENU);
+ panel.add(inner);
+ panel.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
- 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();
+ setWidget(panel);
+ }
- }
- }, ContextMenuEvent.getType());
+ @Override
+ protected boolean accept() {
+ return true;
}
}
// For public sharing
private final HorizontalPanel publicPathPanel = new HorizontalPanel();
- private final TextBox publicPathText = new LinkTextBox();
+ private final TextBox publicPathText = new TextBox();
// For private sharing
private final HorizontalPanel privatePathPanel = new HorizontalPanel();
- private final TextBox privatePathText = new LinkTextBox();
+ private final TextBox privatePathText = new TextBox();
private PermissionsList permList;
-
- /**
- * An image bundle for this widgets images.
- */
- public interface PublicSharingImages extends MessagePanel.Images {
-
- @Source("gr/grnet/pithos/resources/edit_user.png")
- ImageResource permUser();
-
- @Source("gr/grnet/pithos/resources/groups22.png")
- ImageResource permGroup();
-
- @Source("gr/grnet/pithos/resources/editdelete.png")
- ImageResource delete();
- }
public interface PrivateSharingImages extends MessagePanel.Images {
private final File file;
- private final PublicSharingImages publicSharingImages = GWT.create(PublicSharingImages.class);
private final PrivateSharingImages privateSharingImages = GWT.create(PrivateSharingImages.class);
/**
Pithos.preventIESelection();
}
});
- publicPathText.setText(Window.Location.getHost() + file.getPublicUri());
+
+ publicPathText.setText(""); // check: showLinkForPublicSharing();
publicPathText.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");
publicPathText.setReadOnly(true);
publicPathPanel.add(publicPathText);
privateCheckBox.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
+ // This is the value *after* the click is applied :)
+ boolean userCheckedIt = privateCheckBox.getValue();
+ boolean userUncheckedIt = !userCheckedIt;
+
if(isFilePrivatelyShared()) {
// ignore the click, set it always to "checked"
privateCheckBox.setValue(true);
// show permissions
privatePermPanel.setVisible(true);
+
+ // Refs #3593
+ if(userUncheckedIt) {
+ new PermissionsUncheckWarning(app).center();
+ }
}
else {
- // This is the value *after* the click is applied :)
- boolean isChecked = privateCheckBox.getValue();
- privatePermPanel.setVisible(isChecked);
+ privatePermPanel.setVisible(userCheckedIt);
}
}
});
privatePathPanel.addStyleName("pithos-TabPanelBottom");
privatePathText.setWidth(Const.PERCENT_100);
-
privatePathText.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Pithos.preventIESelection();
}
});
- privatePathText.setText(Window.Location.getHost() + file.getPublicUri());
+
+ privatePathText.setText(""); // check: showLinkForPrivateSharing();
privatePathText.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");
privatePathText.setWidth(Const.PERCENT_100);
privatePathText.setReadOnly(true);
private void showLinkForPublicSharing() {
if (isFilePubliclyShared()) {
- UrlBuilder b = Window.Location.createUrlBuilder();
- b.setPath(file.getPublicUri());
- publicPathText.setText(b.buildString());
+ // Transitional: When the server returns the full URL in X-Object-Public,
+ // just use it.
+ final String filePublicURI = file.getPublicUri();
+ final String shownPublicURI;
+ if(filePublicURI.toLowerCase().startsWith("http")) {
+ shownPublicURI = filePublicURI;
+ }
+ else {
+ UrlBuilder b = Window.Location.createUrlBuilder();
+ b.setPath(filePublicURI);
+ shownPublicURI = b.buildString();
+ }
+
+ publicPathText.setText(shownPublicURI);
publicPathPanel.setVisible(true);
}
else {
private void showLinkForPrivateSharing() {
if (isFilePrivatelyShared()) {
- UrlBuilder b = Window.Location.createUrlBuilder();
- b.setPath(app.getApiPath() + file.getOwnerID() + file.getUri());
+ final String fileViewURL = Pithos.getFileViewURL(file);
+ final String shownViewURL;
+ if(fileViewURL.toLowerCase().startsWith("http")) {
+ shownViewURL = fileViewURL;
+ }
+ else {
+ UrlBuilder b = Window.Location.createUrlBuilder();
+ b.setPath(fileViewURL);
+ shownViewURL = b.buildString();
+ }
+
String href = Window.Location.getHref();
boolean hasParameters = href.contains(Const.QUESTION_MARK);
- privatePathText.setText(href + (hasParameters ? Const.AMPERSAND : Const.QUESTION_MARK) + Const.GOTO_EQ + b.buildString());
+ privatePathText.setText(href + (hasParameters ? Const.AMPERSAND : Const.QUESTION_MARK) + Const.GOTO_EQ + shownViewURL);
privatePathPanel.setVisible(true);
}
else {
PostRequest updateFile = new PostRequest(api, owner, path) {
@Override
public void onSuccess(Resource result) {
- HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwnerID(), path, file) {
+ HeadRequest<File> headFile = new HeadRequest<File>(File.class, Pithos.getStorageAPIURL(), file.getOwnerID(), path, file) {
@Override
public void onSuccess(File _result) {
}
protected void updateMetaDataForPublicSharing(Boolean published) {
updateMetaDataForPublicSharing(
- app.getApiPath(),
+ Pithos.getStorageAPIURL(),
app.getUserID(),
file.getUri() + Const.QUESTION_MARK_UPDATE_EQ,
published
PostRequest updateFile = new PostRequest(api, owner, path) {
@Override
public void onSuccess(Resource result) {
- HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwnerID(), path, file) {
+ HeadRequest<File> headFile = new HeadRequest<File>(File.class, Pithos.getStorageAPIURL(), file.getOwnerID(), path, file) {
@Override
public void onSuccess(File _result) {
}
protected void updateMetaDataForPrivateSharing() {
updateMetaDataForPrivateSharing(
- app.getApiPath(),
+ Pithos.getStorageAPIURL(),
app.getUserID(),
file.getUri() + Const.QUESTION_MARK_UPDATE_EQ,
permList.getPermissions()
);
}
+
@Override
protected void onPreviewNativeEvent(NativePreviewEvent preview) {
super.onPreviewNativeEvent(preview);