use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.
the class SpinnerWidget method getAnswer.
@Override
public IAnswerData getAnswer() {
clearFocus();
int i = spinner.getSelectedItemPosition();
if (i == -1 || i == items.size()) {
return null;
} else {
SelectChoice sc = items.get(i);
return new SelectOneData(new Selection(sc));
}
}
use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.
the class SpinnerMultiWidgetTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
List<SelectChoice> selectChoices = getSelectChoices();
for (SelectChoice selectChoice : selectChoices) {
when(formEntryPrompt.getSelectChoiceText(selectChoice)).thenReturn(selectChoice.getValue());
}
}
use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.
the class GeneralSelectMultiWidgetTest method getNextAnswer.
@NonNull
@Override
public SelectMultiData getNextAnswer() {
List<SelectChoice> selectChoices = getSelectChoices();
int selectedIndex = Math.abs(random.nextInt()) % selectChoices.size();
SelectChoice selectChoice = selectChoices.get(selectedIndex);
Selection selection = new Selection(selectChoice);
return new SelectMultiData(ImmutableList.of(selection));
}
use of org.javarosa.core.model.SelectChoice in project collect by opendatakit.
the class SelectWidgetTest method createSelectChoices.
private List<SelectChoice> createSelectChoices() {
int choiceCount = (Math.abs(random.nextInt()) % 3) + 2;
List<SelectChoice> selectChoices = new ArrayList<>();
for (int i = 0; i < choiceCount; i++) {
SelectChoice selectChoice = new SelectChoice(Integer.toString(i), RandomString.make());
selectChoice.setIndex(i);
selectChoices.add(selectChoice);
}
return selectChoices;
}
use of org.javarosa.core.model.SelectChoice in project javarosa by opendatakit.
the class SelectOneDataTests method setUp.
/* (non-Javadoc)
* @see j2meunit.framework.TestCase#setUp()
*/
public void setUp() throws Exception {
super.setUp();
question = new QuestionDef();
question.setID(57);
for (int i = 0; i < 3; i++) {
question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection" + i, false));
}
one = new Selection("Selection1");
one.attachChoice(question);
two = new Selection("Selection2");
two.attachChoice(question);
}
Aggregations