use of org.javarosa.core.model.FormIndex in project collect by opendatakit.
the class FormController method stepOverGroup.
/**
* If using a view like HierarchyView that doesn't support multi-question per screen, step over
* the group represented by the FormIndex.
*/
private int stepOverGroup() {
GroupDef gd = (GroupDef) formEntryController.getModel().getForm().getChild(getFormIndex());
List<FormIndex> indices = getIndicesForGroup(gd);
// jump to the end of the group
formEntryController.jumpToIndex(indices.get(indices.size() - 1));
return stepToNextEvent(STEP_OVER_GROUP);
}
use of org.javarosa.core.model.FormIndex in project collect by opendatakit.
the class QuestionWidget method clearNextLevelsOfCascadingSelect.
/**
* It's needed only for external choices. Everything works well and
* out of the box when we use internal choices instead
*/
protected void clearNextLevelsOfCascadingSelect() {
FormController formController = Collect.getInstance().getFormController();
if (formController == null) {
return;
}
if (formController.currentCaptionPromptIsQuestion()) {
try {
FormIndex startFormIndex = formController.getQuestionPrompt().getIndex();
formController.stepToNextScreenEvent();
while (formController.currentCaptionPromptIsQuestion() && formController.getQuestionPrompt().getFormElement().getAdditionalAttribute(null, "query") != null) {
formController.saveAnswer(formController.getQuestionPrompt().getIndex(), null);
formController.stepToNextScreenEvent();
}
formController.jumpToIndex(startFormIndex);
} catch (JavaRosaException e) {
Timber.d(e);
}
}
}
use of org.javarosa.core.model.FormIndex in project javarosa by opendatakit.
the class FormEntryModel method getCaptionHierarchy.
/**
* Returns a hierarchical list of FormEntryCaption objects for the given
* FormIndex
*
* @param index
* @return list of FormEntryCaptions in hierarchical order
*/
public FormEntryCaption[] getCaptionHierarchy(FormIndex index) {
List<FormEntryCaption> captions = new ArrayList<FormEntryCaption>();
FormIndex remaining = index;
while (remaining != null) {
remaining = remaining.getNextLevel();
FormIndex localIndex = index.diff(remaining);
IFormElement element = form.getChild(localIndex);
if (element != null) {
FormEntryCaption caption = null;
if (element instanceof GroupDef)
caption = new FormEntryCaption(getForm(), localIndex);
else if (element instanceof QuestionDef)
caption = new FormEntryPrompt(getForm(), localIndex);
if (caption != null) {
captions.add(caption);
}
}
}
FormEntryCaption[] captionArray = new FormEntryCaption[captions.size()];
return captions.toArray(captionArray);
}
use of org.javarosa.core.model.FormIndex in project javarosa by opendatakit.
the class RecalculateTest method testComputedConstraintText.
@Test
public void testComputedConstraintText() {
FormIndex nowNoteField = new FormIndex(0, 0, formDef.getMainInstance().getRoot().getChild("now_note", 0).getRef());
String actualQuestionText = new FormEntryPrompt(formDef, nowNoteField).getQuestionText();
assertEquals("2018-01-01T10:20:30.400", actualQuestionText);
}
use of org.javarosa.core.model.FormIndex in project javarosa by opendatakit.
the class FormIndexSerializationTest method testBeginningOfForm.
@Test
public void testBeginningOfForm() throws IOException, ClassNotFoundException {
FormIndex formIndexToSerialize = FormIndex.createBeginningOfFormIndex();
byte[] serializedObject = serializeObject(formIndexToSerialize);
FormIndex formIndexDeserialized = deserializeFormIndex(serializedObject);
assertFormIndex(formIndexToSerialize, formIndexDeserialized);
}
Aggregations