| 3872 |
chandransh |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
|
|
3 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
4 |
import com.google.gwt.event.dom.client.ClickHandler;
|
| 3876 |
chandransh |
5 |
import com.google.gwt.event.dom.client.KeyCodes;
|
|
|
6 |
import com.google.gwt.event.dom.client.KeyDownEvent;
|
|
|
7 |
import com.google.gwt.event.dom.client.KeyDownHandler;
|
| 3872 |
chandransh |
8 |
import com.google.gwt.user.client.ui.Button;
|
|
|
9 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
10 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
11 |
import com.google.gwt.user.client.ui.Label;
|
|
|
12 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
13 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
14 |
|
|
|
15 |
public class SearchItemBox extends DialogBox {
|
|
|
16 |
|
| 3876 |
chandransh |
17 |
private Label searchLabel = new Label("Search for:");
|
| 3872 |
chandransh |
18 |
private TextBox searchBox = new TextBox();
|
|
|
19 |
|
|
|
20 |
private Button submitButton = new Button("Search");
|
|
|
21 |
|
|
|
22 |
private HorizontalPanel hpanel;
|
|
|
23 |
|
|
|
24 |
private VerticalPanel vpanel = new VerticalPanel();
|
|
|
25 |
|
|
|
26 |
public SearchItemBox(final ItemList itemList){
|
|
|
27 |
hpanel = new HorizontalPanel();
|
|
|
28 |
hpanel.setSpacing(5);
|
|
|
29 |
hpanel.add(searchLabel);
|
|
|
30 |
hpanel.add(searchBox);
|
|
|
31 |
hpanel.setCellWidth(searchLabel, "50px");
|
|
|
32 |
vpanel.add(hpanel);
|
|
|
33 |
|
|
|
34 |
vpanel.add(submitButton);
|
|
|
35 |
|
|
|
36 |
setWidget(vpanel);
|
|
|
37 |
setAutoHideEnabled(true);
|
|
|
38 |
setGlassEnabled(true);
|
|
|
39 |
setText("Search for items:");
|
|
|
40 |
setModal(true);
|
|
|
41 |
|
|
|
42 |
submitButton.addClickHandler(new ClickHandler() {
|
|
|
43 |
|
|
|
44 |
@Override
|
|
|
45 |
public void onClick(ClickEvent event) {
|
|
|
46 |
itemList.searchForItems(searchBox.getText());
|
|
|
47 |
hide();
|
|
|
48 |
}
|
|
|
49 |
});
|
| 3876 |
chandransh |
50 |
|
|
|
51 |
searchBox.addKeyDownHandler(new KeyDownHandler() {
|
|
|
52 |
|
|
|
53 |
@Override
|
|
|
54 |
public void onKeyDown(KeyDownEvent event) {
|
|
|
55 |
if(event.getNativeKeyCode() == KeyCodes.KEY_ENTER){
|
|
|
56 |
itemList.searchForItems(searchBox.getText());
|
|
|
57 |
hide();
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
});
|
| 3872 |
chandransh |
61 |
}
|
|
|
62 |
}
|