From 332b8d0f5b2893443cd72d9d1696db3df1740930 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Wed, 25 May 2016 10:18:44 +0000 Subject: [PATCH] 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 --- .../pickitem/client/bundle/CssAndImages.java | 6 +-- .../pickitem/client/bundle/team-icon.gif | Bin 0 -> 2638 bytes .../client/dialog/PickItemsDialog.java | 22 ++++++---- .../widgets/pickitem/shared/ItemBean.java | 39 ++++++++++++++---- 4 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/widgets/pickitem/client/bundle/team-icon.gif 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 0000000000000000000000000000000000000000..4c67c70c73135c0d9e4517995961bb81274a7dd6 GIT binary patch literal 2638 zcmb_ddmxkj9$%&CpcJ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rayList 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 + "]"; + } }