Group within vre are now supported. They are special ItemBeans

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/pickitem-widget@128817 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-05-25 10:18:44 +00:00
parent c7c24ed7ab
commit 332b8d0f5b
4 changed files with 48 additions and 19 deletions

View File

@ -4,9 +4,6 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ClientBundle.Source;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.resources.client.ImageResource.RepeatStyle;
public interface CssAndImages extends ClientBundle {
@ -15,4 +12,7 @@ public interface CssAndImages extends ClientBundle {
@Source("PickItem.css")
public CssResource css();
@Source("team-icon.gif")
public ImageResource iconTeam();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -18,7 +18,6 @@ import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.PopupPanel;
@ -62,7 +61,7 @@ public class PickItemsDialog extends PopupPanel {
private FocusPanel focusPanel = new FocusPanel();
private VerticalPanel mainPanel = new VerticalPanel();
private char triggerChar;
private ArrayList<ItemBean> users;
private ArrayList<ItemBean> beans;
//needed because is selected when it popups
private Widget first;
@ -81,7 +80,7 @@ public class PickItemsDialog extends PopupPanel {
* @param hasPhoto tell of you have want to show photo for the item or not
* @param includeTriggerChar true if your suggestions start with the trigger char (e.g. #anHashTag triggered by #) false otherwise
*/
public PickItemsDialog(char triggerChar, ArrayList<ItemBean> users, final HandlerManager eventBus, int widthInPixel) {
public PickItemsDialog(char triggerChar, ArrayList<ItemBean> beans, final HandlerManager eventBus, int widthInPixel) {
super(true, false);
if (widthInPixel < 200) {
throw new IllegalArgumentException("width must be greater than 199");
@ -90,7 +89,7 @@ public class PickItemsDialog extends PopupPanel {
this.triggerChar = triggerChar;
this.includeTriggerChar = false;
this.hasPhoto = false;
this.users = users;
this.beans = beans;
focusPanel.setWidth(widthInPixel+"px");
mainPanel.setWidth(widthInPixel+"px");
setWidth(widthInPixel+"px");
@ -99,8 +98,13 @@ public class PickItemsDialog extends PopupPanel {
setStyleName("pickDialog");
//add the user fill names to the oracle
for (ItemBean user : users) {
oracle.add(user.getAlternativeName());
for (ItemBean bean : beans) {
oracle.add(bean.getAlternativeName());
// if it is a team, set the avatar
if(bean.isItemGroup())
bean.setThumbnailURL(CssAndImages.INSTANCE.iconTeam().getURL());
}
//remove the first selected when hovering
@ -264,9 +268,9 @@ public class PickItemsDialog extends PopupPanel {
}
private ItemBean getUserModelBySuggestion(Suggestion suggestion) {
for (ItemBean user : users) {
if (suggestion.getReplacementString().compareTo(user.getAlternativeName()) ==0)
return user;
for (ItemBean bean : beans) {
if (suggestion.getReplacementString().compareTo(bean.getAlternativeName()) ==0)
return bean;
}
return new ItemBean("no-match","no-match","no-match","no-match");
}

View File

@ -8,10 +8,18 @@ public class ItemBean implements Serializable {
private String name;
private String alternativeName;
private String thumbnailURL;
private boolean isItemGroup;
public ItemBean() {
super();
}
/**
* Use it when the Item represents a user.
* @param id
* @param username
* @param fullName
* @param thumbnailURL
*/
public ItemBean(String id, String username, String fullName, String thumbnailURL) {
super();
this.id = id;
@ -19,6 +27,24 @@ public class ItemBean implements Serializable {
this.alternativeName = fullName;
this.thumbnailURL = thumbnailURL;
}
/**
* Use it when the Item represents a group of users (namely a team).
* @param id
* @param teamName
*/
public ItemBean(String id, String teamName) {
super();
this.id = id;
this.name = teamName;
this.alternativeName = teamName;
this.isItemGroup = true;
}
public boolean isItemGroup() {
return isItemGroup;
}
public void setItemGroup(boolean isItemGroup) {
this.isItemGroup = isItemGroup;
}
public String getId() {
return id;
}
@ -37,7 +63,7 @@ public class ItemBean implements Serializable {
public void setAlternativeName(String altname) {
this.alternativeName = altname;
}
public String getThumbnailURL() {
return thumbnailURL;
}
@ -46,9 +72,8 @@ public class ItemBean implements Serializable {
}
@Override
public String toString() {
return "ItemBean [id=" + id + ", name=" + name
+ ", alternativeName=" + alternativeName + ", thumbnailURL=" + thumbnailURL
+ "]";
}
return "ItemBean [id=" + id + ", name=" + name + ", alternativeName="
+ alternativeName + ", thumbnailURL=" + thumbnailURL
+ ", isItemGroup=" + isItemGroup + "]";
}
}