added information on triggerChar when the selected item event is launched

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/pickitem-widget@100389 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-10-02 16:19:43 +00:00
parent 98da8cf64a
commit 78d1ad33f2
2 changed files with 21 additions and 12 deletions

View File

@ -110,17 +110,20 @@ public class PickItemsDialog extends PopupPanel {
});
focusPanel.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
SelectableItem ut = (SelectableItem) mainPanel.getWidget(displayIndexSelected);
eventBus.fireEvent(new PickedItemEvent(new ItemBean("id", "username", ut.getItemName(), "thumb")));
hide();
select(0); //RESET
handleMouseDown();
}
});
}
private void handleMouseDown() {
SelectableItem ut = (SelectableItem) mainPanel.getWidget(displayIndexSelected);
eventBus.fireEvent(new PickedItemEvent(new ItemBean("id", "username", ut.getItemName(), "thumb"), this.triggerChar));
hide();
select(0); //RESET
}
/**
* called for each keyUp event from the user
* @param keyCode the event keycode
@ -178,7 +181,7 @@ public class PickItemsDialog extends PopupPanel {
ut = (SelectableItem) mainPanel.getWidget(0);
else
ut = (SelectableItem) mainPanel.getWidget(displayIndexSelected);
eventBus.fireEvent(new PickedItemEvent(new ItemBean("id", "username", ut.getItemName(), "thumb")));
eventBus.fireEvent(new PickedItemEvent(new ItemBean("id", "username", ut.getItemName(), "thumb"), this.triggerChar));
hide();
select(0); //RESET
}

View File

@ -10,13 +10,11 @@ public class PickedItemEvent extends GwtEvent<PickedItemEventHandler> {
public static Type<PickedItemEventHandler> TYPE = new Type<PickedItemEventHandler>();
private ItemBean item;
private String triggerChar;
public ItemBean getSelectedItem() {
return item;
}
public PickedItemEvent(ItemBean item) {
public PickedItemEvent(ItemBean item, String triggerChar) {
this.item = item;
this.triggerChar = triggerChar;
}
@Override
@ -28,4 +26,12 @@ public class PickedItemEvent extends GwtEvent<PickedItemEventHandler> {
protected void dispatch(PickedItemEventHandler handler) {
handler.onSelectedItem(this);
}
public ItemBean getSelectedItem() {
return item;
}
public String getTriggerChar() {
return triggerChar;
}
}