本文整理汇总了Java中org.javarosa.core.model.FormIndex类的典型用法代码示例。如果您正苦于以下问题:Java FormIndex类的具体用法?Java FormIndex怎么用?Java FormIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormIndex类属于org.javarosa.core.model包,在下文中一共展示了FormIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseTabGroups
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
private void parseTabGroups(GroupDef tabGroupElement, FormIndex groupIndex, FormEntryCaption tabGroupCaption, String tabGroupName) {
IFormElement element;
String archEntType = tabGroupCaption.getFormElement().getAdditionalAttribute(null, "faims_archent_type");
String relType = tabGroupCaption.getFormElement().getAdditionalAttribute(null, "faims_rel_type");
String tabGroupLabel = tabGroupCaption.getQuestionText();
String tabGroupRef = tabGroupName;
TabGroupGenerator tabGroupGen = new TabGroupGenerator(tabGroupRef, tabGroupLabel, archEntType, relType);
tabGroupGeneratorList.add(tabGroupGen);
// descend into group
FormIndex tabIndex = this.fem.getModel().incrementIndex(groupIndex,true);
int tabs = tabGroupElement.getChildren().size();
for (int i = 0; i < tabs; i++) {
element = this.fem.getModel().getForm().getChild(tabIndex);
if (element instanceof GroupDef) {
parseTab(element, tabIndex, tabGroupRef, tabGroupGen);
}
tabIndex = this.fem.getModel().incrementIndex(tabIndex, false);
}
}
示例2: parseTab
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
private void parseTab(IFormElement element, FormIndex tabIndex, String tabGroupRef, TabGroupGenerator tabGroupGen) {
GroupDef tabElement = (GroupDef) element;
FormEntryCaption tabCaption = this.fem.getModel().getCaptionPrompt(tabIndex);
String tabName = tabCaption.getIndex().getReference().getNameLast();
boolean faims_hidden = "true".equals(tabElement.getAdditionalAttribute(null, "faims_hidden"));
boolean faims_scrollable = !"false".equals(tabElement.getAdditionalAttribute(null, "faims_scrollable"));
String tabRef = tabGroupRef + "/" + tabName;
TabGenerator tabGen = new TabGenerator(tabRef, tabName, tabCaption.getQuestionText(), faims_hidden, faims_scrollable, activityRef);
tabGroupGen.addTabGenerator(tabGen);
// descend into group
FormIndex containerIndex = this.fem.getModel().incrementIndex(tabIndex, true);
for (int i = 0; i < tabElement.getChildren().size(); i++) {
element = this.fem.getModel().getForm().getChild(containerIndex);
if (element instanceof GroupDef) {
parseContainer(element, containerIndex, tabRef, tabGen, null);
} else {
parseInput(element, containerIndex, tabRef, tabGen, null);
}
containerIndex = this.fem.getModel().incrementIndex(containerIndex, false);
}
}
示例3: parseContainer
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
private void parseContainer(IFormElement element, FormIndex childIndex, String tabRef, TabGenerator tabGen, ContainerGenerator parentContainerGen) {
GroupDef childContainerElement = (GroupDef) element;
String style = childContainerElement.getAdditionalAttribute(null,"faims_style");
FormEntryCaption viewCaption = this.fem.getModel().getCaptionPrompt(childIndex);
String viewName = viewCaption.getIndex().getReference().getNameLast();
String viewRef = parentContainerGen != null ? parentContainerGen.getRef() + "/" + viewName : tabRef + "/" + viewName;
FormIndex inputIndex = this.fem.getModel().incrementIndex(childIndex,true);
ContainerGenerator containerGen = new ContainerGenerator(viewRef, style);
if (parentContainerGen != null) {
parentContainerGen.addViewContainer(containerGen);
} else {
tabGen.addViewContainer(containerGen);
}
for (int i = 0; i < childContainerElement.getChildren().size(); i++) {
element = this.fem.getModel().getForm().getChild(inputIndex);
if (element instanceof GroupDef) {
parseContainer(element, inputIndex, tabRef, tabGen, containerGen);
} else {
parseInput(element, inputIndex, tabRef, tabGen, containerGen);
}
inputIndex = this.fem.getModel().incrementIndex(inputIndex, false);
}
}
示例4: parseStyle
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
private void parseStyle(GroupDef tabGroupElement, FormIndex groupIndex) {
FormIndex tabIndex = this.fem.getModel().incrementIndex(groupIndex,true);
int tabs = tabGroupElement.getChildren().size();
for (int i = 0; i < tabs; i++) {
IFormElement element = this.fem.getModel().getForm().getChild(tabIndex);
if (element instanceof GroupDef) {
GroupDef tabElement = (GroupDef) element;
FormEntryCaption tabCaption = this.fem.getModel().getCaptionPrompt(tabIndex);
String styleName = tabCaption.getIndex().getReference().getNameLast();
FormIndex inputIndex = this.fem.getModel().incrementIndex(tabIndex, true);
Map<String, String> attributes = new HashMap<String, String>();
for (int j = 0; j < tabElement.getChildren().size(); j++) {
FormEntryPrompt input = this.fem.getModel().getQuestionPrompt(inputIndex);
String attributeName = input.getIndex().getReference().getNameLast();
String attributeValue = input.getQuestionText();
attributes.put(attributeName, attributeValue);
inputIndex = this.fem.getModel().incrementIndex(inputIndex, false);
}
styles.put(styleName, attributes);
}
tabIndex = this.fem.getModel().incrementIndex(tabIndex, false);
}
}
示例5: getAnswers
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
/**
* @return a HashMap of answers entered by the user for this set of widgets
*/
public LinkedHashMap<FormIndex, IAnswerData> getAnswers() {
LinkedHashMap<FormIndex, IAnswerData> answers = new LinkedHashMap<FormIndex, IAnswerData>();
Iterator<QuestionWidget> i = widgets.iterator();
while (i.hasNext()) {
/*
* The FormEntryPrompt has the FormIndex, which is where the answer gets stored. The
* QuestionWidget has the answer the user has entered.
*/
QuestionWidget q = i.next();
FormEntryPrompt p = q.getPrompt();
answers.put(p.getIndex(), q.getAnswer());
}
return answers;
}
示例6: onSaveInstanceState
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_FORMPATH, mFormPath);
FormController formController = Collect.getInstance()
.getFormController();
if (formController != null) {
outState.putString(KEY_INSTANCEPATH, formController
.getInstancePath().getAbsolutePath());
outState.putString(KEY_XPATH,
formController.getXPath(formController.getFormIndex()));
FormIndex waiting = formController.getIndexWaitingForData();
if (waiting != null) {
outState.putString(KEY_XPATH_WAITING_FOR_DATA,
formController.getXPath(waiting));
}
// save the instance to a temp path...
nonblockingCreateSavePointData();
}
outState.putBoolean(NEWFORM, false);
outState.putString(KEY_ERROR, mErrorMessage);
outState.putBoolean(KEY_AUTO_SAVED, mAutoSaved);
}
示例7: saveAnswersForCurrentScreen
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
/**
* Attempt to save the answer(s) in the current screen to into the data
* model.
*
* @param evaluateConstraints
* @return false if any error occurs while saving (constraint violated,
* etc...), true otherwise.
*/
private boolean saveAnswersForCurrentScreen(boolean evaluateConstraints) {
FormController formController = Collect.getInstance()
.getFormController();
// only try to save if the current event is a question or a field-list
// group
if (formController.currentPromptIsQuestion()) {
LinkedHashMap<FormIndex, IAnswerData> answers = ((ODKView) mCurrentView)
.getAnswers();
try {
FailedConstraint constraint = formController.saveAllScreenAnswers(answers, evaluateConstraints);
if (constraint != null) {
createConstraintToast(constraint.index, constraint.status);
return false;
}
} catch (JavaRosaException e) {
Log.e(t, e.getMessage(), e);
createErrorDialog(e.getCause().getMessage(), DO_NOT_EXIT);
return false;
}
}
return true;
}
示例8: getCurrentPath
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
private String getCurrentPath() {
FormController formController = Collect.getInstance().getFormController();
FormIndex index = formController.getFormIndex();
// move to enclosing group...
index = formController.stepIndexOut(index);
String path = "";
while (index != null) {
path =
formController.getCaptionPrompt(index).getLongText()
+ " ("
+ (formController.getCaptionPrompt(index)
.getMultiplicity() + 1) + ") > " + path;
index = formController.stepIndexOut(index);
}
// return path?
return path.substring(0, path.length() - 2);
}
示例9: insertContentValues
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
private void insertContentValues(ContentValues cv, FormIndex index) {
synchronized(mScrollActions) {
try {
while ( !mScrollActions.isEmpty() ) {
ContentValues scv = mScrollActions.removeFirst();
mDb.insert(DATABASE_TABLE, null, scv);
}
if ( cv != null ) {
String idx = "";
if ( index != null ) {
idx = getXPath(index);
}
cv.put(QUESTION,idx);
mDb.insert(DATABASE_TABLE, null, cv);
}
} catch (SQLiteConstraintException e) {
System.err.println("Error: " + e.getMessage());
}
}
}
示例10: indexIsInFieldList
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
/**
* Tests if the FormIndex 'index' is located inside a group that is marked as a "field-list"
*
* @param index
* @return true if index is in a "field-list". False otherwise.
*/
private boolean indexIsInFieldList(FormIndex index) {
int event = getEvent(index);
if (event == FormEntryController.EVENT_QUESTION) {
// caption[0..len-1]
// caption[len-1] == the question itself
// caption[len-2] == the first group it is contained in.
FormEntryCaption[] captions = getCaptionHierarchy(index);
if (captions.length < 2) {
// no group
return false;
}
FormEntryCaption grp = captions[captions.length - 2];
return groupIsFieldList(grp.getIndex());
} else if (event == FormEntryController.EVENT_GROUP) {
return groupIsFieldList(index);
} else if (event == FormEntryController.EVENT_REPEAT) {
return repeatIsFieldList(index);
} else {
// right now we only test Questions and Groups. Should we also handle
// repeats?
return false;
}
}
示例11: stepOverGroup
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
/**
* If using a view like HierarchyView that doesn't support multi-question per screen, step over
* the group represented by the FormIndex.
*
* @return
*/
private int stepOverGroup() {
ArrayList<FormIndex> indicies = new ArrayList<FormIndex>();
GroupDef gd =
(GroupDef) mFormEntryController.getModel().getForm()
.getChild(getFormIndex());
FormIndex idxChild =
mFormEntryController.getModel().incrementIndex(
getFormIndex(), true); // descend into group
for (int i = 0; i < gd.getChildren().size(); i++) {
indicies.add(idxChild);
// don't descend
idxChild = mFormEntryController.getModel().incrementIndex(idxChild, false);
}
// jump to the end of the group
mFormEntryController.jumpToIndex(indicies.get(indicies.size() - 1));
return stepToNextEvent(STEP_OVER_GROUP);
}
示例12: FormEntryModel
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
/**
* Creates a new entry model for the form with the appropriate
* repeat structure
*
* @param form
* @param repeatStructure The structure of repeats (the repeat signals which should
* be sent during form entry)
* @throws IllegalArgumentException If repeatStructure is not valid
*/
public FormEntryModel(FormDef form, int repeatStructure) {
this.form = form;
if(repeatStructure != REPEAT_STRUCTURE_LINEAR && repeatStructure != REPEAT_STRUCTURE_NON_LINEAR) {
throw new IllegalArgumentException(repeatStructure +": does not correspond to a valid repeat structure");
}
//We need to see if there are any guessed repeat counts in the form, which prevents
//us from being able to use the new repeat style
//Unfortunately this is probably (A) slow and (B) might overflow the stack. It's not the only
//recursive walk of the form, though, so (B) isn't really relevant
if(repeatStructure == REPEAT_STRUCTURE_NON_LINEAR && containsRepeatGuesses(form)) {
repeatStructure = REPEAT_STRUCTURE_LINEAR;
}
this.repeatStructure = repeatStructure;
this.currentFormIndex = FormIndex.createBeginningOfFormIndex();
}
示例13: getCaptionHierarchy
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
/**
* 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);
}
示例14: isIndexReadonly
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
/**
* @param index
* @return true if the element at the specified index is read only
*/
public boolean isIndexReadonly(FormIndex index) {
if (index.isBeginningOfFormIndex() || index.isEndOfFormIndex())
return true;
TreeReference ref = form.getChildInstanceRef(index);
boolean isAskNewRepeat = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT ||
getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);
if (isAskNewRepeat) {
return false;
} else {
TreeElement node = form.getMainInstance().resolveReference(ref);
return !node.isEnabled();
}
}
示例15: isIndexCompoundElement
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
public boolean isIndexCompoundElement(FormIndex index) {
//Can't be a subquestion if it's not even a question!
if(getEvent(index) != FormEntryController.EVENT_QUESTION) {
return false;
}
//get the set of nested groups that this question is in.
FormEntryCaption[] captions = getCaptionHierarchy(index);
for(FormEntryCaption caption : captions) {
//If one of this question's parents is a group, this question is inside of it.
if(isIndexCompoundContainer(caption.getIndex())) {
return true;
}
}
return false;
}