diff --git a/src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/CssAndImages.java b/src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/CssAndImages.java index 7ecc676..b7a59ee 100644 --- a/src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/CssAndImages.java +++ b/src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/CssAndImages.java @@ -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(); + } diff --git a/src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/team-icon.gif b/src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/team-icon.gif new file mode 100644 index 0000000..4c67c70 Binary files /dev/null and b/src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/team-icon.gif differ diff --git a/src/main/java/org/gcube/portlets/widgets/pickitem/client/dialog/PickItemsDialog.java b/src/main/java/org/gcube/portlets/widgets/pickitem/client/dialog/PickItemsDialog.java index 7ba52a7..e6970a2 100644 --- a/src/main/java/org/gcube/portlets/widgets/pickitem/client/dialog/PickItemsDialog.java +++ b/src/main/java/org/gcube/portlets/widgets/pickitem/client/dialog/PickItemsDialog.java @@ -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 users; + private ArrayList 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 users, final HandlerManager eventBus, int widthInPixel) { + public PickItemsDialog(char triggerChar, ArrayList 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"); } diff --git a/src/main/java/org/gcube/portlets/widgets/pickitem/shared/ItemBean.java b/src/main/java/org/gcube/portlets/widgets/pickitem/shared/ItemBean.java index f37f80e..9e2aa0b 100644 --- a/src/main/java/org/gcube/portlets/widgets/pickitem/shared/ItemBean.java +++ b/src/main/java/org/gcube/portlets/widgets/pickitem/shared/ItemBean.java @@ -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 + "]"; + } }