ref 17169: Selection of users in the Sharing panel

https://support.d4science.org/issues/17169

Updated support to VREs discovery

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@181382 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-07-31 18:03:33 +00:00
parent 234bb80439
commit bb814fc3ea
2 changed files with 63 additions and 11 deletions

View File

@ -59,13 +59,12 @@ import com.google.gwt.user.client.ui.FlexTable;
*/
public class PanelMultiDragContactAdmin extends ContentPanel {
//
private String workspaceItemId;
private String myLogin;
private InfoContactModel myContact;
private InfoContactModel owner;
private List<InfoContactModel> targetContact;
private List<UserVRE> vresList;
private HashMap<UserVRE, List<InfoContactModel>> contactsMap;
@ -76,12 +75,12 @@ public class PanelMultiDragContactAdmin extends ContentPanel {
//
public static final String LOADING = "Loading";
public static final String LOADINGSTYLE = "x-mask-loading";
private static final int HEIGHT_VRE_PANEL = 40;
private static final int WIDTH_VRE_PANEL = 597;
private static final int HEIGHT_CONTACTS_PANEL = 400;
private static final int WIDTH_CONTACTS_PANEL = 597;
private static final int WIDTH_VRE_LIST_COMBO = 550;
private static final int HEIGHT_GRID = 310;
@ -136,16 +135,38 @@ public class PanelMultiDragContactAdmin extends ContentPanel {
public void onFailure(Throwable caught) {
GWT.log("Error retrieving my login");
myLogin = null;
retrieveListOfAdmin();
retrieveOwner();
}
@Override
public void onSuccess(String result) {
GWT.log("My login is: " + result);
myLogin = result;
retrieveOwner();
}
});
}
private void retrieveOwner() {
WorkspaceSharingServiceAsync.INSTANCE.getOwnerByItemId(workspaceItemId, new AsyncCallback<InfoContactModel>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error retrieving owner");
owner = null;
retrieveListOfAdmin();
}
@Override
public void onSuccess(InfoContactModel result) {
GWT.log("Owner is: " + result);
owner = result;
retrieveListOfAdmin();
}
});
}
@ -169,14 +190,32 @@ public class PanelMultiDragContactAdmin extends ContentPanel {
break;
}
}
}
if (myContact != null) {
result.remove(myContact);
targetContact = result;
if (owner != null) {
if (InfoContactModel.COMPARATORLOGINS.compare(myContact, owner) == 0) {
result.remove(myContact);
targetContact = result;
} else {
result.remove(myContact);
result.remove(owner);
targetContact = result;
}
} else {
result.remove(myContact);
targetContact = result;
}
} else {
targetContact = result;
if (owner != null) {
result.remove(owner);
targetContact = result;
} else {
targetContact = result;
}
}
storeTarget.removeAll();
storeTarget.add(targetContact);
storeTarget.commitChanges();
@ -417,7 +456,6 @@ public class PanelMultiDragContactAdmin extends ContentPanel {
GWT.log("PanelMultiDragContactAdmin view Created");
}
private void retrieveContactList(final UserVRE userVRE) {
if (!contactsMap.isEmpty() && contactsMap.containsKey(userVRE)) {
@ -638,7 +676,22 @@ public class PanelMultiDragContactAdmin extends ContentPanel {
public List<InfoContactModel> getTargetListContactWithMyLogin() {
List<InfoContactModel> target = new ArrayList<>();
target.addAll(storeTarget.getModels());
target.add(myContact);
if (myContact != null) {
if (owner != null) {
if (InfoContactModel.COMPARATORLOGINS.compare(myContact, owner) == 0) {
target.add(owner);
} else {
target.add(owner);
target.add(myContact);
}
} else {
target.add(myContact);
}
} else {
if (owner != null) {
target.add(owner);
}
}
return target;
}

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.ContactFetcher;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;