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:
parent
c7c24ed7ab
commit
332b8d0f5b
|
@ -4,9 +4,6 @@ import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.resources.client.ClientBundle;
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
import com.google.gwt.resources.client.CssResource;
|
import com.google.gwt.resources.client.CssResource;
|
||||||
import com.google.gwt.resources.client.ImageResource;
|
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 {
|
public interface CssAndImages extends ClientBundle {
|
||||||
|
|
||||||
|
@ -15,4 +12,7 @@ public interface CssAndImages extends ClientBundle {
|
||||||
@Source("PickItem.css")
|
@Source("PickItem.css")
|
||||||
public CssResource css();
|
public CssResource css();
|
||||||
|
|
||||||
|
@Source("team-icon.gif")
|
||||||
|
public ImageResource iconTeam();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
|
@ -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.MouseOverEvent;
|
||||||
import com.google.gwt.event.dom.client.MouseOverHandler;
|
import com.google.gwt.event.dom.client.MouseOverHandler;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
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.FocusPanel;
|
||||||
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||||
import com.google.gwt.user.client.ui.PopupPanel;
|
import com.google.gwt.user.client.ui.PopupPanel;
|
||||||
|
@ -62,7 +61,7 @@ public class PickItemsDialog extends PopupPanel {
|
||||||
private FocusPanel focusPanel = new FocusPanel();
|
private FocusPanel focusPanel = new FocusPanel();
|
||||||
private VerticalPanel mainPanel = new VerticalPanel();
|
private VerticalPanel mainPanel = new VerticalPanel();
|
||||||
private char triggerChar;
|
private char triggerChar;
|
||||||
private ArrayList<ItemBean> users;
|
private ArrayList<ItemBean> beans;
|
||||||
|
|
||||||
//needed because is selected when it popups
|
//needed because is selected when it popups
|
||||||
private Widget first;
|
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 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
|
* @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);
|
super(true, false);
|
||||||
if (widthInPixel < 200) {
|
if (widthInPixel < 200) {
|
||||||
throw new IllegalArgumentException("width must be greater than 199");
|
throw new IllegalArgumentException("width must be greater than 199");
|
||||||
|
@ -90,7 +89,7 @@ public class PickItemsDialog extends PopupPanel {
|
||||||
this.triggerChar = triggerChar;
|
this.triggerChar = triggerChar;
|
||||||
this.includeTriggerChar = false;
|
this.includeTriggerChar = false;
|
||||||
this.hasPhoto = false;
|
this.hasPhoto = false;
|
||||||
this.users = users;
|
this.beans = beans;
|
||||||
focusPanel.setWidth(widthInPixel+"px");
|
focusPanel.setWidth(widthInPixel+"px");
|
||||||
mainPanel.setWidth(widthInPixel+"px");
|
mainPanel.setWidth(widthInPixel+"px");
|
||||||
setWidth(widthInPixel+"px");
|
setWidth(widthInPixel+"px");
|
||||||
|
@ -99,8 +98,13 @@ public class PickItemsDialog extends PopupPanel {
|
||||||
setStyleName("pickDialog");
|
setStyleName("pickDialog");
|
||||||
|
|
||||||
//add the user fill names to the oracle
|
//add the user fill names to the oracle
|
||||||
for (ItemBean user : users) {
|
for (ItemBean bean : beans) {
|
||||||
oracle.add(user.getAlternativeName());
|
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
|
//remove the first selected when hovering
|
||||||
|
@ -264,9 +268,9 @@ public class PickItemsDialog extends PopupPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemBean getUserModelBySuggestion(Suggestion suggestion) {
|
private ItemBean getUserModelBySuggestion(Suggestion suggestion) {
|
||||||
for (ItemBean user : users) {
|
for (ItemBean bean : beans) {
|
||||||
if (suggestion.getReplacementString().compareTo(user.getAlternativeName()) ==0)
|
if (suggestion.getReplacementString().compareTo(bean.getAlternativeName()) ==0)
|
||||||
return user;
|
return bean;
|
||||||
}
|
}
|
||||||
return new ItemBean("no-match","no-match","no-match","no-match");
|
return new ItemBean("no-match","no-match","no-match","no-match");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,18 @@ public class ItemBean implements Serializable {
|
||||||
private String name;
|
private String name;
|
||||||
private String alternativeName;
|
private String alternativeName;
|
||||||
private String thumbnailURL;
|
private String thumbnailURL;
|
||||||
|
private boolean isItemGroup;
|
||||||
|
|
||||||
public ItemBean() {
|
public ItemBean() {
|
||||||
super();
|
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) {
|
public ItemBean(String id, String username, String fullName, String thumbnailURL) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -19,6 +27,24 @@ public class ItemBean implements Serializable {
|
||||||
this.alternativeName = fullName;
|
this.alternativeName = fullName;
|
||||||
this.thumbnailURL = thumbnailURL;
|
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() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +63,7 @@ public class ItemBean implements Serializable {
|
||||||
public void setAlternativeName(String altname) {
|
public void setAlternativeName(String altname) {
|
||||||
this.alternativeName = altname;
|
this.alternativeName = altname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getThumbnailURL() {
|
public String getThumbnailURL() {
|
||||||
return thumbnailURL;
|
return thumbnailURL;
|
||||||
}
|
}
|
||||||
|
@ -46,9 +72,8 @@ public class ItemBean implements Serializable {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ItemBean [id=" + id + ", name=" + name
|
return "ItemBean [id=" + id + ", name=" + name + ", alternativeName="
|
||||||
+ ", alternativeName=" + alternativeName + ", thumbnailURL=" + thumbnailURL
|
+ alternativeName + ", thumbnailURL=" + thumbnailURL
|
||||||
+ "]";
|
+ ", isItemGroup=" + isItemGroup + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue