ref 17169: Selection of users in the Sharing panel

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

Added support to workspace users discovery by VREs

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@181370 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-07-30 17:01:21 +00:00
parent 61486dc721
commit d66d46fc39
1 changed files with 24 additions and 20 deletions

View File

@ -4,9 +4,11 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.client.view.sharing.ContactFetcher;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
@ -44,7 +46,6 @@ public class MultiValuePanel extends Composite {
private SuggestBox box; private SuggestBox box;
// private ContactFetcher userFetch; // private ContactFetcher userFetch;
private ServerMultiWordSuggestOracle oracle = new ServerMultiWordSuggestOracle(); // ORACLE private ServerMultiWordSuggestOracle oracle = new ServerMultiWordSuggestOracle(); // ORACLE
/** /**
* Instantiates a new multi value panel. * Instantiates a new multi value panel.
@ -139,29 +140,32 @@ public class MultiValuePanel extends Composite {
*/ */
private void chosenContactItem(InfoContactModelSuggestion suggest, final TextBox itemBox, final BulletList list) { private void chosenContactItem(InfoContactModelSuggestion suggest, final TextBox itemBox, final BulletList list) {
if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) { if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) {
final ListItem displayItem = new ListItem(); if (users.containsKey(suggest.getInfoContactModel().getName())) {
displayItem.setStyleName("multivalue-panel-token-ws"); GWT.log("User already selected: " + suggest.getInfoContactModel().getName());
Paragraph p = new Paragraph(suggest.getInfoContactModel().getName()); MessageBox.alert("Attention", "The user selected is already present in the list.", null);
itemBox.setValue("");
} else {
GWT.log("Adding selected user: " + suggest.getInfoContactModel().getName());
users.put(suggest.getInfoContactModel().getName(), suggest.getInfoContactModel());
Span span = new Span("x"); final ListItem displayItem = new ListItem();
span.addClickHandler(new ClickHandler() { displayItem.setStyleName("multivalue-panel-token-ws");
public void onClick(ClickEvent clickEvent) { Paragraph p = new Paragraph(suggest.getInfoContactModel().getName());
removeListItem(displayItem, list);
}
});
displayItem.add(p); Span span = new Span("x");
displayItem.add(span); span.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
removeListItem(displayItem, list);
}
});
// original value of the item selected displayItem.add(p);
GWT.log("Adding selected user '" + suggest.getInfoContactModel().getName()); displayItem.add(span);
// itemsSelected.add(itemBox.getValue());
// GWT.log("Total: " + itemsSelected);
users.put(suggest.getInfoContactModel().getName(), suggest.getInfoContactModel());
list.insert(displayItem, list.getWidgetCount() - 1); list.insert(displayItem, list.getWidgetCount() - 1);
itemBox.setValue(""); itemBox.setValue("");
itemBox.setFocus(true); itemBox.setFocus(true);
}
} }
} }