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
This commit is contained in:
parent
0f3a4df954
commit
4b660cddb3
|
@ -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";
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,14 @@
|
||||||
package org.gcube.portlets.widgets.workspacesharingwidget.client;
|
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.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.extjs.gxt.ui.client.widget.Window;
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
@ -43,7 +50,10 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
|
||||||
FileModel file = new FileModel("123", "test", false);
|
FileModel file = new FileModel("123", "test", false);
|
||||||
WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(file, null, false, 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",
|
Button openSharingWindow = new Button("Show Smart Share Window",
|
||||||
new ClickHandler() {
|
new ClickHandler() {
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
@ -53,6 +63,31 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
|
||||||
});
|
});
|
||||||
|
|
||||||
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
|
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
|
||||||
|
|
||||||
|
sharingWindow.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
|
||||||
|
|
||||||
|
@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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
|
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.resources.Resources;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiValuePanel;
|
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<CredentialModel> listAlreadySharedContact){
|
public void updateSharingDialog(FileModel fileModel, List<CredentialModel> listAlreadySharedContact){
|
||||||
this.fileToShare = fileModel;
|
this.fileToShare = fileModel;
|
||||||
|
String heading;
|
||||||
String heading = "Share";
|
if(SmartConstants.HEADER_TITLE==null){
|
||||||
if(fileModel.isDirectory())
|
heading = "Share";
|
||||||
heading+=" folder: ";
|
if(fileModel.isDirectory())
|
||||||
else
|
heading+=" folder: ";
|
||||||
heading+= " : ";
|
else
|
||||||
|
heading+= " : ";
|
||||||
setHeading(heading+fileModel.getName());
|
|
||||||
|
setHeading(heading+fileModel.getName());
|
||||||
|
}else
|
||||||
|
setHeading(SmartConstants.HEADER_TITLE);
|
||||||
|
|
||||||
txtName = new TextField<String>();
|
txtName = new TextField<String>();
|
||||||
txtName.setAllowBlank(false);
|
txtName.setAllowBlank(false);
|
||||||
txtName.setValue(fileModel.getName());
|
txtName.setValue(fileModel.getName());
|
||||||
txtName.setReadOnly(true);
|
txtName.setReadOnly(true);
|
||||||
txtName.setAutoValidate(true);
|
txtName.setAutoValidate(true);
|
||||||
txtName.setFieldLabel("Item Name");
|
|
||||||
|
|
||||||
|
if(SmartConstants.ITEM_NAME!=null)
|
||||||
|
txtName.setFieldLabel(SmartConstants.ITEM_NAME);
|
||||||
|
|
||||||
|
|
||||||
final LayoutContainer lc = new LayoutContainer();
|
final LayoutContainer lc = new LayoutContainer();
|
||||||
lc.setStyleAttribute("margin-top", "10px");
|
lc.setStyleAttribute("margin-top", "10px");
|
||||||
|
@ -131,14 +137,20 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
|
|
||||||
final FlexTable flexTable = new FlexTable();
|
final FlexTable flexTable = new FlexTable();
|
||||||
flexTable.setStyleName("userssuggest");
|
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, 0, labelShareWith);
|
||||||
flexTable.setWidget(0, 1, suggestPanel);
|
flexTable.setWidget(0, 1, suggestPanel);
|
||||||
|
|
||||||
buttonMultiDrag.setStyleName("wizardButton");
|
buttonMultiDrag.setStyleName("wizardButton");
|
||||||
|
|
||||||
|
Label labelAddMore = new Label("");
|
||||||
flexTable.setWidget(1, 0, new Label("Add more"));
|
if(SmartConstants.ADD_MORE!=null)
|
||||||
|
labelAddMore.setText(SmartConstants.ADD_MORE);
|
||||||
|
|
||||||
|
flexTable.setWidget(1, 0, labelAddMore);
|
||||||
flexTable.setWidget(1, 1, buttonMultiDrag);
|
flexTable.setWidget(1, 1, buttonMultiDrag);
|
||||||
|
|
||||||
|
|
||||||
|
@ -393,7 +405,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
|
||||||
|
|
||||||
if(getSharedListUsers().size()==0){
|
if(getSharedListUsers().size()==0){
|
||||||
if(displayAlert)
|
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();
|
suggestPanel.boxSetFocus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue