From b12da07a708bfe82a683f83bbeebe5a8f61f8283 Mon Sep 17 00:00:00 2001 From: Christos KK Loverdos Date: Fri, 19 Apr 2013 16:06:01 +0300 Subject: [PATCH] Informational dialog when trying to unchek "Private Sharing" while shares exist Refs #3593 --- .../grnet/pithos/web/client/FileShareDialog.java | 65 +++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/src/gr/grnet/pithos/web/client/FileShareDialog.java b/src/gr/grnet/pithos/web/client/FileShareDialog.java index e1318da..b57aac5 100644 --- a/src/gr/grnet/pithos/web/client/FileShareDialog.java +++ b/src/gr/grnet/pithos/web/client/FileShareDialog.java @@ -59,6 +59,57 @@ import java.util.Map; * UI for the "Share" command. */ public class FileShareDialog extends AbstractPropertiesDialog { + private static final class PremissionsUncheckWarning extends AbstractPropertiesDialog { + private PremissionsUncheckWarning(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." + + "
" + + "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(); @@ -235,16 +286,23 @@ public class FileShareDialog extends AbstractPropertiesDialog { 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 PremissionsUncheckWarning(app).center(); + } } else { - // This is the value *after* the click is applied :) - boolean isChecked = privateCheckBox.getValue(); - privatePermPanel.setVisible(isChecked); + privatePermPanel.setVisible(userCheckedIt); } } }); @@ -569,6 +627,7 @@ public class FileShareDialog extends AbstractPropertiesDialog { permList.getPermissions() ); } + @Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); -- 1.7.10.4