Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: frontend/client/src/autotest/common/ui/RadioChooser.java

Issue 3554003: Merge remote branch 'cros/upstream' into tempbranch3 (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: frontend/client/src/autotest/common/ui/RadioChooser.java
diff --git a/frontend/client/src/autotest/common/ui/RadioChooser.java b/frontend/client/src/autotest/common/ui/RadioChooser.java
index 24d2331bc6f576538f161890d4842e909e20860c..fabe2e1a384e01b568294cbc1969c148494989b8 100644
--- a/frontend/client/src/autotest/common/ui/RadioChooser.java
+++ b/frontend/client/src/autotest/common/ui/RadioChooser.java
@@ -1,51 +1,50 @@
package autotest.common.ui;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Panel;
-import com.google.gwt.user.client.ui.RadioButton;
+import autotest.afe.IRadioButton;
import java.util.ArrayList;
import java.util.List;
-public class RadioChooser extends Composite {
+public class RadioChooser {
+ public static interface Display {
+ public IRadioButton generateRadioButton(String groupName, String choice);
+ }
+
private static int groupNameCounter = 0;
-
- private List<RadioButton> radioButtons = new ArrayList<RadioButton>();
- private RadioButton defaultButton;
- private Panel container = new HorizontalPanel();
private String groupName = getFreshGroupName();
-
- public RadioChooser() {
- initWidget(container);
- setStyleName("radio-chooser");
+ private List<IRadioButton> radioButtons = new ArrayList<IRadioButton>();
+ private IRadioButton defaultButton;
+
+ private Display display;
+
+ public void bindDisplay(Display display) {
+ this.display = display;
}
-
+
private static String getFreshGroupName() {
groupNameCounter++;
return "group" + Integer.toString(groupNameCounter);
}
-
+
public void addChoice(String choice) {
- RadioButton button = new RadioButton(groupName, choice);
+ IRadioButton button = display.generateRadioButton(groupName, choice);
if (radioButtons.isEmpty()) {
// first button in this group
defaultButton = button;
button.setValue(true);
}
radioButtons.add(button);
- container.add(button);
}
-
+
public String getSelectedChoice() {
- for (RadioButton button : radioButtons) {
+ for (IRadioButton button : radioButtons) {
if (button.getValue()) {
return button.getText();
}
}
throw new RuntimeException("No radio button selected");
}
-
+
public void reset() {
if (defaultButton != null) {
defaultButton.setValue(true);
@@ -59,9 +58,9 @@ public class RadioChooser extends Composite {
public void setSelectedChoice(String choice) {
findButtonForChoice(choice).setValue(true);
}
-
- private RadioButton findButtonForChoice(String choice) {
- for (RadioButton button : radioButtons) {
+
+ private IRadioButton findButtonForChoice(String choice) {
+ for (IRadioButton button : radioButtons) {
if (button.getText().equals(choice)) {
return button;
}

Powered by Google App Engine
This is Rietveld 408576698