import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
+import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.Tooltip;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
private static final int VISIBLE_COUNT = 10;
- protected ListBox select;
+ protected TooltipListBox select;
private int lastSelectedIndex = -1;
- private class MyListBox extends ListBox {
- MyListBox() {
- super();
- sinkEvents(Tooltip.TOOLTIP_EVENTS);
- }
-
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, IListSelect.this);
- }
- }
- }
-
public IListSelect() {
- // TODO use myListBox to have Tooltips
- super(new ListBox(), CLASSNAME);
- select = (ListBox) optionsContainer;
+ super(new TooltipListBox(true), CLASSNAME);
+ select = (TooltipListBox) optionsContainer;
+ select.setSelect(this);
select.addChangeListener(this);
select.addClickListener(this);
select.setStyleName(CLASSNAME + "-select");
}
protected void buildOptions(UIDL uidl) {
+ select.setClient(client);
select.setMultipleSelect(isMultiselect());
select.setEnabled(!isDisabled() && !isReadonly());
select.clear();
}
}
+
+/**
+ * Extended ListBox to listen tooltip events and forward them to generic
+ * handler.
+ */
+class TooltipListBox extends ListBox {
+ private ApplicationConnection client;
+ private Paintable pntbl;
+
+ TooltipListBox(boolean isMultiselect) {
+ super(isMultiselect);
+ sinkEvents(Tooltip.TOOLTIP_EVENTS);
+ }
+
+ public void setClient(ApplicationConnection client) {
+ this.client = client;
+ }
+
+ public void setSelect(Paintable s) {
+ pntbl = s;
+ }
+
+ public void onBrowserEvent(Event event) {
+ super.onBrowserEvent(event);
+ if (client != null) {
+ client.handleTooltipEvent(event, pntbl);
+ }
+ }
+}
\ No newline at end of file
import java.util.Iterator;
import java.util.Vector;
-import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public static final String CLASSNAME = "i-select";
- protected ListBox select;
+ protected TooltipListBox select;
public INativeSelect() {
- super(new ListBox(false), CLASSNAME);
- select = (ListBox) optionsContainer;
+ super(new TooltipListBox(false), CLASSNAME);
+ select = (TooltipListBox) optionsContainer;
+ select.setSelect(this);
select.setVisibleItemCount(1);
select.addChangeListener(this);
select.setStyleName(CLASSNAME + "-select");
}
protected void buildOptions(UIDL uidl) {
+ select.setClient(client);
select.setEnabled(!isDisabled() && !isReadonly());
select.clear();
if (isNullSelectionAllowed() && !isNullSelectionItemAvailable()) {