OLD | NEW |
(Empty) | |
| 1 package autotest.planner; |
| 2 |
| 3 import com.google.gwt.event.dom.client.ClickEvent; |
| 4 import com.google.gwt.event.dom.client.ClickHandler; |
| 5 import com.google.gwt.event.dom.client.HasClickHandlers; |
| 6 import com.google.gwt.event.dom.client.HasKeyPressHandlers; |
| 7 import com.google.gwt.event.dom.client.KeyCodes; |
| 8 import com.google.gwt.event.dom.client.KeyPressEvent; |
| 9 import com.google.gwt.event.dom.client.KeyPressHandler; |
| 10 import com.google.gwt.user.client.ui.HasText; |
| 11 |
| 12 public class TestPlanSelector implements ClickHandler, KeyPressHandler { |
| 13 |
| 14 public static interface Display { |
| 15 public HasText getInputText(); |
| 16 public HasClickHandlers getShowButton(); |
| 17 public HasKeyPressHandlers getInputField(); |
| 18 } |
| 19 |
| 20 |
| 21 private Display display; |
| 22 private String selectedPlan; |
| 23 |
| 24 public void bindDisplay(Display display) { |
| 25 this.display = display; |
| 26 display.getShowButton().addClickHandler(this); |
| 27 display.getInputField().addKeyPressHandler(this); |
| 28 } |
| 29 |
| 30 @Override |
| 31 public void onClick(ClickEvent event) { |
| 32 selectPlan(); |
| 33 } |
| 34 |
| 35 @Override |
| 36 public void onKeyPress(KeyPressEvent event) { |
| 37 if (event.getCharCode() == KeyCodes.KEY_ENTER) { |
| 38 selectPlan(); |
| 39 } |
| 40 } |
| 41 |
| 42 private void selectPlan() { |
| 43 selectedPlan = display.getInputText().getText(); |
| 44 } |
| 45 |
| 46 public String getSelectedPlan() { |
| 47 return selectedPlan; |
| 48 } |
| 49 } |
OLD | NEW |