From 4b660cddb3ef13d85e95afe22306ad4fcbb15ca4 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 8 Jul 2014 16:41:14 +0000 Subject: [PATCH] updated smart sharing to manage https://support.social.isti.cnr.it/ticket/126 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@98505 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/SmartConstants.java | 26 +++++++++++++ .../WorkspaceSharingWidgetEntryPoint.java | 37 +++++++++++++++++- .../client/view/sharing/SmartShare.java | 38 ++++++++++++------- 3 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/SmartConstants.java diff --git a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/SmartConstants.java b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/SmartConstants.java new file mode 100644 index 0000000..1220d1a --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/SmartConstants.java @@ -0,0 +1,26 @@ +/** + * + */ +package org.gcube.portlets.widgets.workspacesharingwidget.client; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @Jul 8, 2014 + * + * Defines customizable labels used by Smart Sharing Dialog + * + * + */ +public abstract class SmartConstants { + + /*********************************************************************** + * Sets following parameters to display custom labels for smart panel + */ + public static String ITEM_NAME = "Item Name"; + public static String SHARE_WITH_USERS = "Share with users"; + public static String HEADER_TITLE = null; //if null sets the header title for the panel as "Share [Folder Name]" + public static String ADD_MORE = "Add More"; + public static String ERROR_NO_USER_SELECTED = "You must pick at least one user with which share the folder"; + /***********************************************************************/ + +} diff --git a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/WorkspaceSharingWidgetEntryPoint.java b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/WorkspaceSharingWidgetEntryPoint.java index b38102a..944b5ff 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/WorkspaceSharingWidgetEntryPoint.java +++ b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/WorkspaceSharingWidgetEntryPoint.java @@ -1,7 +1,14 @@ package org.gcube.portlets.widgets.workspacesharingwidget.client; +import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.SmartShare; +import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel; +import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; +import com.extjs.gxt.ui.client.event.BaseEvent; +import com.extjs.gxt.ui.client.event.Events; +import com.extjs.gxt.ui.client.event.Listener; +import com.extjs.gxt.ui.client.widget.Dialog; import com.extjs.gxt.ui.client.widget.Window; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.dom.client.ClickEvent; @@ -43,7 +50,10 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint { FileModel file = new FileModel("123", "test", false); WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(file, null, false, false); - final Window sharingWindow = controller.getSharingDialog(); + SmartConstants.HEADER_TITLE = "puppa"; + SmartConstants.ITEM_NAME = "aa"; + + final SmartShare sharingWindow = controller.getSharingDialog(); Button openSharingWindow = new Button("Show Smart Share Window", new ClickHandler() { public void onClick(ClickEvent event) { @@ -53,6 +63,31 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint { }); RootPanel.get("workpacesharingwidget").add(openSharingWindow); + + sharingWindow.getButtonById(Dialog.OK).addListener(Events.Select, new Listener() { + + @Override + public void handleEvent(BaseEvent be) { + + if(sharingWindow.isValidForm(true)){ + //THAT'S OK + + sharingWindow.getSharedListUsers(); //@return the selected contacts (as InfoContactModel) + + sharingWindow.getSharedListUsersCredential(); //@return the selected contacts (as CredentialModel) + + for (InfoContactModel contact : sharingWindow.getSharedListUsers()) { + System.out.println(contact); + } + + for (CredentialModel credential : sharingWindow.getSharedListUsersCredential()) { + System.out.println(credential); + } + + } + + } + }); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/view/sharing/SmartShare.java b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/view/sharing/SmartShare.java index 9e49482..f81d1ba 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/view/sharing/SmartShare.java +++ b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/view/sharing/SmartShare.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing; +import org.gcube.portlets.widgets.workspacesharingwidget.client.SmartConstants; import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.Resources; import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact; import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiValuePanel; @@ -107,22 +108,27 @@ public class SmartShare extends Dialog implements SmartDialogInterface{ public void updateSharingDialog(FileModel fileModel, List listAlreadySharedContact){ this.fileToShare = fileModel; - - String heading = "Share"; - if(fileModel.isDirectory()) - heading+=" folder: "; - else - heading+= " : "; - - setHeading(heading+fileModel.getName()); + String heading; + if(SmartConstants.HEADER_TITLE==null){ + heading = "Share"; + if(fileModel.isDirectory()) + heading+=" folder: "; + else + heading+= " : "; + + setHeading(heading+fileModel.getName()); + }else + setHeading(SmartConstants.HEADER_TITLE); txtName = new TextField(); txtName.setAllowBlank(false); txtName.setValue(fileModel.getName()); txtName.setReadOnly(true); txtName.setAutoValidate(true); - txtName.setFieldLabel("Item Name"); + if(SmartConstants.ITEM_NAME!=null) + txtName.setFieldLabel(SmartConstants.ITEM_NAME); + final LayoutContainer lc = new LayoutContainer(); lc.setStyleAttribute("margin-top", "10px"); @@ -131,14 +137,20 @@ public class SmartShare extends Dialog implements SmartDialogInterface{ final FlexTable flexTable = new FlexTable(); flexTable.setStyleName("userssuggest"); - Label labelShareWith = new Label("Share with users"); + Label labelShareWith = new Label(""); + if(SmartConstants.SHARE_WITH_USERS!=null) + labelShareWith.setText(SmartConstants.SHARE_WITH_USERS); + flexTable.setWidget(0, 0, labelShareWith); flexTable.setWidget(0, 1, suggestPanel); buttonMultiDrag.setStyleName("wizardButton"); - - flexTable.setWidget(1, 0, new Label("Add more")); + Label labelAddMore = new Label(""); + if(SmartConstants.ADD_MORE!=null) + labelAddMore.setText(SmartConstants.ADD_MORE); + + flexTable.setWidget(1, 0, labelAddMore); flexTable.setWidget(1, 1, buttonMultiDrag); @@ -393,7 +405,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{ if(getSharedListUsers().size()==0){ if(displayAlert) - MessageBox.alert("Attention", "You must pick at least one user with which share the folder", null); + MessageBox.alert("Attention", SmartConstants.ERROR_NO_USER_SELECTED, null); suggestPanel.boxSetFocus(); return false; }