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:
Francesco Mangiacrapa 2014-07-08 16:41:14 +00:00
parent 0f3a4df954
commit 4b660cddb3
3 changed files with 87 additions and 14 deletions

View File

@ -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";
/***********************************************************************/
}

View File

@ -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<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) {
e.printStackTrace();

View File

@ -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<CredentialModel> 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<String>();
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;
}