updated Edit Permissions

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@111517 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-01-28 17:22:52 +00:00
parent f56452a3dc
commit b26fda50b0
6 changed files with 184 additions and 34 deletions

View File

@ -19,4 +19,6 @@ public interface ConstantsSharing {
public static int HEIGHT_DIALOG = 430;
public static final String PATH_SEPARATOR = "/";
public static enum LOAD_CONTACTS_AS{SHARED_USER, ADMINISTRATOR}
}

View File

@ -8,11 +8,11 @@ package org.gcube.portlets.widgets.workspacesharingwidget.client;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Sep 22, 2014
*
* Defines customizable labels used by Simple MultiDrag Contant Dialog
* Defines customizable labels used by MultiDrag Dialog
*
* Sets following parameters to display custom labels into Dialog
*/
public abstract class SimpleMultiDragConstants {
public abstract class MultiDragConstants {
public static String HEADING_DIALOG = "Group dragging contacts";
public static String ALL_CONTACTS_LEFT_LIST = "All Contacts";

View File

@ -3,10 +3,13 @@
*/
package org.gcube.portlets.widgets.workspacesharingwidget.client;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.MessageBoxAlert;
import org.gcube.portlets.widgets.workspacesharingwidget.client.permissions.PanelTogglePermission;
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.UserStore;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.DialogMultiDragContact;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
@ -19,6 +22,7 @@ import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -31,30 +35,38 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
* @Jan 27, 2015
*
*/
public class MultiDragContactsEditPermissions extends SimpleMultiDragWorkspaceContact{
public class MultiDragContactsEditPermissions {
private PanelTogglePermission permission;
private HorizontalPanel hpPermission = new HorizontalPanel();
private DialogMultiDragContact dialog;
private Html htmlCurrentPermissions = new Html();
private UserStore userStore = new UserStore();
private ConstantsSharing.LOAD_CONTACTS_AS loadContactAs;
private DialogMultiDragContact dialogMultiDragContact = new DialogMultiDragContact(MultiDragConstants.HEADING_DIALOG, MultiDragConstants.ALL_CONTACTS_LEFT_LIST, MultiDragConstants.SHARE_WITH_RIGHT_LIST,false, false);
private List<InfoContactModel> sources = new ArrayList<InfoContactModel>();
private boolean hiddenMySelf;
private String workspaceItemId;
private String myLogin;
private InfoContactModel myContact;
/**
*
* @param load
* @param workspaceItemId
* @param readGroupsFromHL
* @param readGroupsFromPortal
* @param hiddenMySelf
*/
public MultiDragContactsEditPermissions(LOAD_CONTACTS_AS load, final String workspaceItemId, boolean readGroupsFromHL, boolean readGroupsFromPortal, boolean hiddenMySelf) {
super(load, workspaceItemId, readGroupsFromHL, readGroupsFromPortal,hiddenMySelf);
public MultiDragContactsEditPermissions(ConstantsSharing.LOAD_CONTACTS_AS load, final String workspaceItemId, boolean hiddenMySelf) {
initMultiDrag(load, workspaceItemId, hiddenMySelf);
dialog = super.getDialogMultiDragContact();
dialog.setScrollMode(Scroll.AUTOY);
// dialog = super.getDialogMultiDragContact();
dialogMultiDragContact.setScrollMode(Scroll.AUTOY);
// htmlCurrentPermissions.setReadOnly(true);
htmlCurrentPermissions.setWidth(MultiDragContact.WIDTH_CP);
htmlCurrentPermissions.setStyleAttribute("padding", MultiDragContact.PADDING+"px");
dialog.getLcTop().add(htmlCurrentPermissions);
dialogMultiDragContact.getLcTop().add(htmlCurrentPermissions);
// dialog.setHeight(dialog.getHeight()+100);
WorkspaceSharingController.rpcWorkspaceSharingService.getACLsDescriptionForSharedFolderId(workspaceItemId, new AsyncCallback<String>() {
@ -102,33 +114,25 @@ public class MultiDragContactsEditPermissions extends SimpleMultiDragWorkspaceCo
}
});
dialog.add(hpPermission);
dialogMultiDragContact.getLcBottom().add(hpPermission);
dialog.addListener(Events.Render, new Listener<BaseEvent>() {
dialogMultiDragContact.addListener(Events.Render, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
dialog.setHeight(dialog.getHeight()+100);
dialogMultiDragContact.setHeight(dialogMultiDragContact.getHeight()+100);
}
});
}
public void enableSubmit(boolean bool){
dialog.getButtonById(Dialog.OK).setEnabled(bool);
dialogMultiDragContact.getButtonById(Dialog.OK).setEnabled(bool);
}
public DialogMultiDragContact getDialog() {
return dialog;
return dialogMultiDragContact;
}
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact#show()
*/
@Override
public void show() {
dialog.show();
}
/**
* The HL ID of the selected ACL
* @return
@ -175,12 +179,144 @@ public class MultiDragContactsEditPermissions extends SimpleMultiDragWorkspaceCo
}
/**
* Load administrators or shared users to workspace item id
* @param load
* if LOAD_CONTACTS_AS.SHARED_USER loads source users from Shared Users
* if LOAD_CONTACTS_AS.ADMINISTRATOR loads source users from Administrators
*
* @param workspaceItemId
* @param hiddenMySelf if true the login read from ASL is hidden (so it's not removable to target users), the login returned anyway among the target users
*/
private void initMultiDrag(ConstantsSharing.LOAD_CONTACTS_AS load, String workspaceItemId, final boolean hiddenMySelf) {
this.loadContactAs = load;
this.hiddenMySelf = hiddenMySelf;
this.workspaceItemId = workspaceItemId;
if(hiddenMySelf)
loadMyLogin(true);
else
loadSharedContacts();
}
private void loadMyLogin(final boolean loadContacts){
WorkspaceSharingServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on loading my login is empty");
myLogin = "";
loadSharedContacts();
}
@Override
public void onSuccess(String result) {
GWT.log("My login is: "+result);
myLogin = result;
if(loadContacts)
loadSharedContacts();
}
});
}
/**
* Load the target contacts
*/
private void loadSharedContacts(){
switch (loadContactAs) {
case ADMINISTRATOR:
//LOADING LIST OF ALREADY SHARED USER
userStore.getAdministratorsByFolderId(workspaceItemId, new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on loading admnistrators");
MessageBox.alert("Error on loading admnistrators", caught.getMessage(), null);
}
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("Returned "+result.size()+" admin/s");
fillMultiDrag(result);
}
});
break;
case SHARED_USER:
//LOADING LIST OF ALREADY SHARED USER
userStore.getListSharedUserByFolderId(workspaceItemId, new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onSuccess(List<InfoContactModel> result) {
GWT.log("Returned "+result.size()+" contact/s");
fillMultiDrag(result);
}
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on loading shared contacts");
MessageBox.alert("Error on shared contacts", caught.getMessage(), null);
}
});
break;
default:
break;
}
}
public void addTargetContact(List<InfoContactModel> listContacts){
if(listContacts!=null){
for (InfoContactModel infoContactModel : listContacts) {
dialogMultiDragContact.getMultiDrag().addTargetContact(infoContactModel);
}
}
}
/**
*
* @param result
*/
private void fillMultiDrag(List<InfoContactModel> result){
GWT.log("Filling multi-drag..");
GWT.log("Hidden my self: "+hiddenMySelf);
for (InfoContactModel infoContactModel : result) {
if(infoContactModel.getLogin()!=null){
if(hiddenMySelf && (infoContactModel.getLogin().compareTo(myLogin)==0)){
myContact = infoContactModel;
GWT.log("Skipping myLogin as: "+myContact);
}else{
dialogMultiDragContact.getMultiDrag().addSourceContact(infoContactModel);
sources.add(infoContactModel);
}
}
}
}
public void show(){
dialogMultiDragContact.show();
}
/**
*
* @return
*/
public List<InfoContactModel> getTargetContacts() {
return super.getTargetContacts();
return dialogMultiDragContact.getMultiDrag().getTargetListContact();
}
/**
@ -188,7 +324,14 @@ public class MultiDragContactsEditPermissions extends SimpleMultiDragWorkspaceCo
* @return
*/
public List<InfoContactModel> getTargetContactsWithMyLogin() {
return super.getTargetContactsWithMyLogin();
List<InfoContactModel> contacts = getTargetContacts();
if(myContact == null){
GWT.log("TargetContactsWithMyLogin my Contact is null, skipping!");
}else
contacts.add(myContact);
return contacts;
}
}

View File

@ -24,9 +24,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public class SimpleMultiDragWorkspaceContact {
private UserStore userStore = new UserStore();
private LOAD_CONTACTS_AS loadContactAs;
public static enum LOAD_CONTACTS_AS{SHARED_USER, ADMINISTRATOR}
private DialogMultiDragContact dialogMultiDragContact = new DialogMultiDragContact(SimpleMultiDragConstants.HEADING_DIALOG, SimpleMultiDragConstants.ALL_CONTACTS_LEFT_LIST, SimpleMultiDragConstants.SHARE_WITH_RIGHT_LIST,false, false);
private ConstantsSharing.LOAD_CONTACTS_AS loadContactAs;
private DialogMultiDragContact dialogMultiDragContact = new DialogMultiDragContact(MultiDragConstants.HEADING_DIALOG, MultiDragConstants.ALL_CONTACTS_LEFT_LIST, MultiDragConstants.SHARE_WITH_RIGHT_LIST,false, false);
private List<InfoContactModel> targets = new ArrayList<InfoContactModel>();
private boolean readGroupsFromPortal;
private boolean readGroupsFromHL;
@ -46,7 +45,7 @@ public class SimpleMultiDragWorkspaceContact {
* @param readGroupsFromPortal
* @param hiddenMySelf if true the login read from ASL is hidden (so it's not removable to target users), the login returned anyway among the target users
*/
public SimpleMultiDragWorkspaceContact(LOAD_CONTACTS_AS load, String workspaceItemId, final boolean readGroupsFromHL, final boolean readGroupsFromPortal, final boolean hiddenMySelf) {
public SimpleMultiDragWorkspaceContact(ConstantsSharing.LOAD_CONTACTS_AS load, String workspaceItemId, final boolean readGroupsFromHL, final boolean readGroupsFromPortal, final boolean hiddenMySelf) {
this.loadContactAs = load;
this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal;

View File

@ -1,7 +1,5 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragWorkspaceContact.LOAD_CONTACTS_AS;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@ -92,7 +90,7 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
private void showSimpleMultiDrag(){
final SimpleMultiDragWorkspaceContact multiDragContact = new SimpleMultiDragWorkspaceContact(LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false, true);
final SimpleMultiDragWorkspaceContact multiDragContact = new SimpleMultiDragWorkspaceContact(ConstantsSharing.LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false, true);
Button openSharingWindow = new Button("Show Simple Multi Drag",
new ClickHandler() {

View File

@ -516,6 +516,14 @@ public class MultiDragContact extends ContentPanel {
storeTarget.add(listContact);
}
/**
* @param infoContactModel
*/
public void addSourceContact(InfoContactModel contact) {
if (contact != null)
storeSource.add(contact);
}
public void addTargetContact(InfoContactModel contact) {
if (contact != null)
storeTarget.add(contact);