added no photo display option

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/pickitem-widget@100369 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-10-02 13:07:19 +00:00
parent 10812592ef
commit c64bf9cc15
6 changed files with 87 additions and 8 deletions

View File

@ -23,7 +23,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">

View File

@ -48,7 +48,7 @@ public class PickItem implements EntryPoint {
final TextBox tb = new TextBox();
final int popUpY = tb.getAbsoluteTop()+30;
final PickItemsDialog pickUserDlg = new PickItemsDialog('#', users, eventbus, 300);
final PickItemsDialog pickUserDlg = new PickItemsDialog('#', users, eventbus, 300, true);
tb.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {

View File

@ -1,4 +1,4 @@
@external pickDialog, pick-label, pickperson, pickperson-selected, pickperson-photo, user-table, user-table-row, user-table-col, user-table-col.content, .user-table-col.smallphoto, user-token, content, smallphoto;
@external pick-item, pickDialog, pick-label, pickperson, pickperson-selected, pickperson-photo, user-table, user-table-row, user-table-col, user-table-col.content, .user-table-col.smallphoto, user-token, content, smallphoto;
.pickDialog {
border: 1px solid #333;
@ -12,6 +12,13 @@
color: inherit;
}
.pick-item {
font-family: 'Helvetica Neue', Arial, sans-serif;
font-size: 13px;
color: inherit;
padding: 0 4px;
}
.pickperson {
color: #0B61A4;

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import org.gcube.portlets.widgets.pickitem.client.bundle.CssAndImages;
import org.gcube.portlets.widgets.pickitem.client.events.PickedItemEvent;
import org.gcube.portlets.widgets.pickitem.client.uibinder.NoPhotoTemplate;
import org.gcube.portlets.widgets.pickitem.client.uibinder.SelectableItem;
import org.gcube.portlets.widgets.pickitem.client.uibinder.WithPhotoTemplate;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
@ -59,6 +60,7 @@ public class PickItemsDialog extends PopupPanel {
//needed because is selected when it popups
private Widget first;
private boolean hasPhoto;
static {
CssAndImages.INSTANCE.css().ensureInjected();
@ -68,14 +70,16 @@ public class PickItemsDialog extends PopupPanel {
* @param the list of user to pick
* @param eventBus the event bus on where the widget will fire the selected user event
* @param widthInPixel the desired width (grater than 199 pixel)
* @param hasPhoto tell of you have want to show photo for the item or not
*/
public PickItemsDialog(char triggerChar, ArrayList<ItemBean> users, final HandlerManager eventBus, int widthInPixel) {
public PickItemsDialog(char triggerChar, ArrayList<ItemBean> users, final HandlerManager eventBus, int widthInPixel, boolean hasPhoto) {
super(true, false);
if (widthInPixel < 200) {
throw new IllegalArgumentException("width must be greater than 199");
}
this.eventBus = eventBus;
this.triggerChar = ""+triggerChar;
this.hasPhoto = hasPhoto;
this.users = users;
focusPanel.setWidth(widthInPixel+"px");
mainPanel.setWidth(widthInPixel+"px");
@ -192,12 +196,12 @@ public class PickItemsDialog extends PopupPanel {
int i = 0;
for (Suggestion s : response.getSuggestions()) {
if (i == 0) {
first = getUserTemplate(getUserModelBySuggestion(s), i);
first = getUserTemplate(getUserModelBySuggestion(s), i, hasPhoto);
first.addStyleName("pickperson-selected");
mainPanel.add(first);
}
else
mainPanel.add(getUserTemplate(getUserModelBySuggestion(s), i));
mainPanel.add(getUserTemplate(getUserModelBySuggestion(s), i, hasPhoto));
i++;
}
if (i > 0) {
@ -216,8 +220,10 @@ public class PickItemsDialog extends PopupPanel {
return new ItemBean("no-match","no-match","no-match","no-match");
}
private WithPhotoTemplate getUserTemplate(ItemBean user, int displayIndex) {
return new WithPhotoTemplate(this, user, displayIndex);
private Widget getUserTemplate(ItemBean user, int displayIndex, boolean hasPhoto) {
if (hasPhoto)
return new WithPhotoTemplate(this, user, displayIndex);
return new NoPhotoTemplate(this, user, displayIndex);
}
/**

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.widgets.pickitem.client.uibinder;
import org.gcube.portlets.widgets.pickitem.client.dialog.PickItemsDialog;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
public class NoPhotoTemplate extends Composite implements SelectableItem {
private static NoPhotoTemplateUiBinder uiBinder = GWT
.create(NoPhotoTemplateUiBinder.class);
interface NoPhotoTemplateUiBinder extends UiBinder<Widget, NoPhotoTemplate> {
}
PickItemsDialog owner;
private int currDisplayIndex;
@UiField
FocusPanel focusDiv;
@UiField
HTML contentArea;
public NoPhotoTemplate(PickItemsDialog owner, ItemBean user, int displayIndex) {
initWidget(uiBinder.createAndBindUi(this));
this.owner = owner;
currDisplayIndex = displayIndex;
contentArea.setHTML(user.getAlternativeName());
}
@UiHandler("focusDiv")
void onMouseOver(MouseOverEvent e) {
owner.select(currDisplayIndex);
}
@Override
public String getItemName() {
return contentArea.getText();
}
}

View File

@ -0,0 +1,15 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:FocusPanel ui:field="focusDiv" styleName="user-table pickperson">
<g:HTMLPanel ui:field="mainDiv">
<div class="user-table-row">
<div class="user-table-col">
<div>
<g:HTML styleName="pick-item" ui:field="contentArea" />
</div>
</div>
</div>
</g:HTMLPanel>
</g:FocusPanel>
</ui:UiBinder>