* UI for the "Share" command.
*/
public class FileShareDialog extends AbstractPropertiesDialog {
+ 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);
+
+ VerticalPanel inner = new VerticalPanel();
+ inner.addStyleName("inner");
+
+ 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 Button ok = new Button("OK", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ hide();
+ }
+ });
+
+ ok.addStyleName("button");
+ inner.add(ok);
+
+ panel.add(inner);
+ panel.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
+
+ setWidget(panel);
+ }
+
+ @Override
+ protected boolean accept() {
+ return true;
+ }
+ }
+
// For public sharing
private final HorizontalPanel publicPathPanel = new HorizontalPanel();
private final TextBox publicPathText = new TextBox();
// For private sharing
private final HorizontalPanel privatePathPanel = new HorizontalPanel();
private final TextBox privatePathText = new TextBox();
- private final VerticalPanel privatePermSuperPanel = new VerticalPanel();
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);
/**
}
});
// Set the dialog's caption.
- setText("Share");
+ setText(Const.TXT_SHARE_FILE);
setGlassEnabled(true);
setStyleName("pithos-DialogBox");
publicPathPanel.setVisible(false);
publicPathPanel.setWidth(Const.PERCENT_100);
publicPathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
- publicPathPanel.add(new Label("Link"));
+ publicPathPanel.add(new Label(Const.TXT_PUBLIC_LINK));
publicPathPanel.setSpacing(8);
publicPathPanel.addStyleName("pithos-TabPanelBottom");
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);
}
}
});
permButtons.add(addUser);
final boolean haveGroups = app.getAccount().getGroups().size() > 0;
- Button addGroup = new Button("Add Group", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
- dlg.center();
- permList.updatePermissionTable();
- }
- });
- addGroup.addStyleName("button");
- addGroup.setEnabled(haveGroups);
- if(!haveGroups) {
- addGroup.setTitle("You do not have any groups");
+
+ if(haveGroups) {
+ Button addGroup = new Button("Add Group", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
+ dlg.center();
+ permList.updatePermissionTable();
+ }
+ });
+ addGroup.addStyleName("button");
+
+ permButtons.add(addGroup);
+ permButtons.setCellHorizontalAlignment(addGroup, HasHorizontalAlignment.ALIGN_CENTER);
}
- permButtons.add(addGroup);
- Button addEverybody = new Button("Add everybody", new ClickHandler() {
+ final Button addEverybody = new Button("Add everybody", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Pithos.LOG("Adding to Everybody");
addEverybody.addStyleName("button");
permButtons.add(addEverybody);
- permButtons.setCellHorizontalAlignment(addGroup, HasHorizontalAlignment.ALIGN_CENTER);
privatePermPanel.add(permList);
privatePermPanel.add(permButtons);
privatePathPanel.setVisible(false);
privatePathPanel.setWidth(Const.PERCENT_100);
privatePathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
- privatePathPanel.add(new Label("Link"));
+ privatePathPanel.add(new Label(Const.TXT_PRIVATE_LINK));
privatePathPanel.setSpacing(8);
privatePathPanel.addStyleName("pithos-TabPanelBottom");
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);