本文整理汇总了Java中org.javarosa.core.model.FormIndex类的典型用法代码示例。如果您正苦于以下问题:Java FormIndex类的具体用法?Java FormIndex怎么用?Java FormIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormIndex类属于org.javarosa.core.model包,在下文中一共展示了FormIndex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:FAIMS,项目名称:faims-android,代码行数:25,代码来源:UIRenderer.java
示例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);
}
}
开发者ID:FAIMS,项目名称:faims-android,代码行数:27,代码来源:UIRenderer.java
示例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);
}
}
开发者ID:FAIMS,项目名称:faims-android,代码行数:27,代码来源:UIRenderer.java
示例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);
}
}
开发者ID:FAIMS,项目名称:faims-android,代码行数:26,代码来源:UIRenderer.java
示例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;
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:19,代码来源:ODKView.java
示例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);
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:24,代码来源:FormEntryActivity.java
示例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;
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:31,代码来源:FormEntryActivity.java
示例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);
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:21,代码来源:FormHierarchyActivity.java
示例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());
}
}
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:22,代码来源:ActivityLogger.java
示例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;
}
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:31,代码来源:FormController.java
示例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);
}
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:25,代码来源:FormController.java
示例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();
}
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:FormEntryModel.java
示例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);
}
开发者ID:medic,项目名称:javarosa,代码行数:30,代码来源:FormEntryModel.java
示例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();
}
}
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:FormEntryModel.java
示例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;
}
开发者ID:medic,项目名称:javarosa,代码行数:18,代码来源:FormEntryModel.java
示例16: getCompoundIndices
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
public FormIndex[] getCompoundIndices(FormIndex container) {
//ArrayLists are a no-go for J2ME
List<FormIndex> indices = new ArrayList<FormIndex>();
FormIndex walker = incrementIndex(container);
while(FormIndex.isSubElement(container, walker)) {
if(isIndexRelevant(walker)) {
indices.add(walker);
}
walker = incrementIndex(walker);
}
FormIndex[] array = new FormIndex[indices.size()];
for(int i = 0 ; i < indices.size() ; ++i) {
array[i] = indices.get(i);
}
return array;
}
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:FormEntryModel.java
示例17: incrementIndex
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
public FormIndex incrementIndex(FormIndex index, boolean descend) {
List<Integer> indexes = new ArrayList<Integer>();
List<Integer> multiplicities = new ArrayList<Integer>();
List<IFormElement> elements = new ArrayList<IFormElement>();
if (index.isEndOfFormIndex()) {
return index;
} else if (index.isBeginningOfFormIndex()) {
if (form.getChildren() == null || form.getChildren().size() == 0) {
return FormIndex.createEndOfFormIndex();
}
} else {
form.collapseIndex(index, indexes, multiplicities, elements);
}
incrementHelper(indexes, multiplicities, elements, descend);
if (indexes.size() == 0) {
return FormIndex.createEndOfFormIndex();
} else {
return form.buildIndex(indexes, multiplicities, elements);
}
}
开发者ID:medic,项目名称:javarosa,代码行数:24,代码来源:FormEntryModel.java
示例18: decrementIndex
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
public FormIndex decrementIndex(FormIndex index) {
List<Integer> indexes = new ArrayList<Integer>();
List<Integer> multiplicities = new ArrayList<Integer>();
List<IFormElement> elements = new ArrayList<IFormElement>();
if (index.isBeginningOfFormIndex()) {
return index;
} else if (index.isEndOfFormIndex()) {
if (form.getChildren() == null || form.getChildren().size() == 0) {
return FormIndex.createBeginningOfFormIndex();
}
} else {
form.collapseIndex(index, indexes, multiplicities, elements);
}
decrementHelper(indexes, multiplicities, elements);
if (indexes.size() == 0) {
return FormIndex.createBeginningOfFormIndex();
} else {
return form.buildIndex(indexes, multiplicities, elements);
}
}
开发者ID:medic,项目名称:javarosa,代码行数:24,代码来源:FormEntryModel.java
示例19: testNonLocalizedText
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
public void testNonLocalizedText(){
FormEntryController fec = fpi.getFormEntryController();
fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
boolean testFlag = false;
Localizer l = fpi.getFormDef().getLocalizer();
l.setDefaultLocale(l.getAvailableLocales()[0]);
l.setLocale(l.getAvailableLocales()[0]);
do{
if(fpi.getCurrentQuestion()==null) continue;
QuestionDef q = fpi.getCurrentQuestion();
fep = fpi.getFormEntryModel().getQuestionPrompt();
String t = fep.getQuestionText();
if(t==null) continue;
if(t.equals("Non-Localized label inner text!")) testFlag = true;
}while(fec.stepToNextEvent()!=FormEntryController.EVENT_END_OF_FORM);
if(!testFlag) fail("Failed to fallback to labelInnerText in testNonLocalizedText()");
}
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:TextFormTests.java
示例20: testAnswerConstraint
import org.javarosa.core.model.FormIndex; //导入依赖的package包/类
public void testAnswerConstraint(){
IntegerData ans = new IntegerData(13);
FormEntryController fec = fpi.getFormEntryController();
fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
do{
QuestionDef q = fpi.getCurrentQuestion();
if(q==null || q.getTextID() == null || q.getTextID() == "")continue;
if(q.getTextID().equals("constraint-test")){
int response = fec.answerQuestion(ans, true);
if(response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED){
fail("Answer Constraint test failed.");
}else if(response == FormEntryController.ANSWER_OK){
break;
}else{
fail("Bad response from fec.answerQuestion()");
}
}
}while(fec.stepToNextEvent()!=FormEntryController.EVENT_END_OF_FORM);
}
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:FormDefTest.java
注:本文中的org.javarosa.core.model.FormIndex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论