本文整理汇总了Java中org.javarosa.form.api.FormEntryCaption类的典型用法代码示例。如果您正苦于以下问题:Java FormEntryCaption类的具体用法?Java FormEntryCaption怎么用?Java FormEntryCaption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormEntryCaption类属于org.javarosa.form.api包,在下文中一共展示了FormEntryCaption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseTabGroups
import org.javarosa.form.api.FormEntryCaption; //导入依赖的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.form.api.FormEntryCaption; //导入依赖的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.form.api.FormEntryCaption; //导入依赖的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.form.api.FormEntryCaption; //导入依赖的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: indexIsInFieldList
import org.javarosa.form.api.FormEntryCaption; //导入依赖的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;
}
}
示例6: getGroupsForCurrentIndex
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
/**
* Returns an array of FormEntryCaptions for current FormIndex.
*
* @return
*/
public FormEntryCaption[] getGroupsForCurrentIndex() {
// return an empty array if you ask for something impossible
if (!(getEvent() == FormEntryController.EVENT_QUESTION
|| getEvent() == FormEntryController.EVENT_PROMPT_NEW_REPEAT
|| getEvent() == FormEntryController.EVENT_GROUP
|| getEvent() == FormEntryController.EVENT_REPEAT)) {
return new FormEntryCaption[0];
}
// the first caption is the question, so we skip it if it's an EVENT_QUESTION
// otherwise, the first caption is a group so we start at index 0
int lastquestion = 1;
if (getEvent() == FormEntryController.EVENT_PROMPT_NEW_REPEAT
|| getEvent() == FormEntryController.EVENT_GROUP
|| getEvent() == FormEntryController.EVENT_REPEAT) {
lastquestion = 0;
}
FormEntryCaption[] v = getCaptionHierarchy();
FormEntryCaption[] groups = new FormEntryCaption[v.length - lastquestion];
for (int i = 0; i < v.length - lastquestion; i++) {
groups[i] = v[i];
}
return groups;
}
示例7: getHeaderText
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
private String getHeaderText(FormEntryCaption[] hierachy) {
String headertext = "";
for (FormEntryCaption caption : hierachy) {
String c = caption.getLongText();
if(c != null) {
headertext += c;
if (caption.getIndex().getInstanceIndex() > -1) {
headertext += " " + (caption.getMultiplicity() + 1);
}
headertext += ": ";
}
}
if (headertext.endsWith(": "))
headertext = headertext.substring(0, headertext.length() - 2);
return headertext;
}
示例8: createHeaderForElement
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
private void createHeaderForElement(FormIndex questionIndex, boolean newRepeat) {
FormEntryCaption prompt = model.getCaptionPrompt(questionIndex);
String headerText; //decide what text form to use.
boolean isNew = uncommittedRepeats.contains(model.decrementIndex(questionIndex)); //this is ghetto
headerText = prompt.getRepetitionText(isNew); //droos: this doesn't feel right... should this if/else be wrapped up in the caption?
if (headerText == null)
headerText = prompt.getLongText();
if(headerText != null) {
if (newRepeat) {
removeFrame(activeQuestionIndex);
}
ChatterboxWidget headerWidget = widgetFactory.getNewLabelWidget(questionIndex, headerText);
//If there is no valid header, there's no valid header. Possibly no label.
this.append(headerWidget);
this.questionIndexes.add(questionIndex);
headerWidget.setPinned(true);
}
}
示例9: getRepeatJunctureWidget
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
public ChatterboxWidget getRepeatJunctureWidget (FormIndex index, FormEntryModel model, Chatterbox cbox) {
FormEntryCaption capt = model.getCaptionPrompt(index);
Vector<String> choices = capt.getRepetitionsText();
FormEntryCaption.RepeatOptions repopt = capt.getRepeatOptions();
FakedFormEntryPrompt prompt = new FakedFormEntryPrompt(repopt.header, Constants.CONTROL_SELECT_ONE, Constants.DATATYPE_TEXT);
for (int i = 0; i < choices.size(); i++) {
prompt.addSelectChoice(new SelectChoice(null, choices.elementAt(i), "rep" + i, false));
}
if (repopt.add != null) {
prompt.addSelectChoice(new SelectChoice(null, repopt.add, "new", false));
}
if (repopt.delete != null) {
prompt.addSelectChoice(new SelectChoice(null, repopt.delete, "del", false));
}
prompt.addSelectChoice(new SelectChoice(null, repopt.done, "done", false));
return new ChatterboxWidget(cbox, prompt, ChatterboxWidget.VIEW_EXPANDED, new CollapsedWidget(), new SelectOneEntryWidget(ChoiceGroup.EXCLUSIVE));
}
示例10: getNextQuestion
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
/**
* @return the next question in the form (QuestionDef), or null if the end of the form has been reached.
*/
public QuestionDef getNextQuestion() {
// jump to next event and check for end of form
if (fec.stepToNextEvent() == FormEntryController.EVENT_END_OF_FORM) {
return null;
}
FormEntryCaption fep = this.getFormEntryModel().getCaptionPrompt();
do {
if (fep.getFormElement() instanceof QuestionDef)
return (QuestionDef)fep.getFormElement();
} while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
return null;
}
示例11: createHelpLayout
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
/**
* Build MediaLayout for displaying any help associated with given FormEntryPrompt.
*/
private MediaLayout createHelpLayout() {
TextView text = new TextView(getContext());
String markdownText = mPrompt.getHelpMultimedia(FormEntryCaption.TEXT_FORM_MARKDOWN);
if (markdownText != null) {
text.setText(forceMarkdown(markdownText));
text.setMovementMethod(LinkMovementMethod.getInstance());
} else {
text.setText(mPrompt.getHelpText());
}
text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize);
int padding = (int)getResources().getDimension(R.dimen.help_text_padding);
text.setPadding(0, 0, 0, 7);
text.setId(38475483); // assign random id
MediaLayout helpLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), text,
mPrompt.getHelpMultimedia(FormEntryCaption.TEXT_FORM_AUDIO),
mPrompt.getHelpMultimedia(FormEntryCaption.TEXT_FORM_IMAGE),
mPrompt.getHelpMultimedia(FormEntryCaption.TEXT_FORM_VIDEO),
null);
helpLayout.setPadding(padding, padding, padding, padding);
return helpLayout;
}
示例12: indexIsInFieldList
import org.javarosa.form.api.FormEntryCaption; //导入依赖的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;
}
}
示例13: getGroupsForCurrentIndex
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
/**
* Returns an array of FormEntryCaptions for current FormIndex.
*
* @return
*/
public FormEntryCaption[] getGroupsForCurrentIndex() {
// return an empty array if you ask for something impossible
if (!(getEvent() == FormEntryController.EVENT_QUESTION
|| getEvent() == FormEntryController.EVENT_PROMPT_NEW_REPEAT
|| getEvent() == FormEntryController.EVENT_GROUP
|| getEvent() == FormEntryController.EVENT_REPEAT)) {
return new FormEntryCaption[0];
}
// the first caption is the question, so we skip it if it's an EVENT_QUESTION
// otherwise, the first caption is a group so we start at index 0
int lastquestion = 1;
if (getEvent() == FormEntryController.EVENT_PROMPT_NEW_REPEAT
|| getEvent() == FormEntryController.EVENT_GROUP
|| getEvent() == FormEntryController.EVENT_REPEAT) {
lastquestion = 0;
}
FormEntryCaption[] v = getCaptionHierarchy();
FormEntryCaption[] groups = new FormEntryCaption[v.length - lastquestion];
for (int i = 0; i < v.length - lastquestion; i++) {
groups[i] = v[i];
}
return groups;
}
示例14: answerQuestion
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
public boolean answerQuestion(QuestionDef qd, IAnswerData answer) {
int event = controller.jumpToIndex(FormIndex.createBeginningOfFormIndex());
do {
FormEntryCaption fec = fem.getCaptionPrompt();
if(fec.getFormElement() instanceof QuestionDef && ((QuestionDef) fec.getFormElement()).equals(qd)) {
try {
if(answer.getValue() != null && !answer.getValue().equals("null")) {
//Log.d(LOG, "fyi answer data: " + answer.hashCode() + " (" + answer.getValue() + ")");
controller.answerQuestion(answer);
return controller.saveAnswer(answer);
}
} catch(NullPointerException e) {
Log.d(LOG, e.toString());
e.printStackTrace();
}
}
} while((event = controller.stepToNextEvent()) != FormEntryController.EVENT_END_OF_FORM);
return false;
}
示例15: parseSchema
import org.javarosa.form.api.FormEntryCaption; //导入依赖的package包/类
public void parseSchema(String path) {
fem = FileUtil.readXmlContent(path);
FormIndex currentIndex = fem.getModel().getFormIndex();
IFormElement element = fem.getModel().getForm().getChild(currentIndex);
FormIndex groupIndex = fem.getModel().incrementIndex(currentIndex, true);
int groups = element.getChildren().size();
for (int i = 0; i < groups; i++) {
element = fem.getModel().getForm().getChild(groupIndex);
if (element instanceof GroupDef) {
GroupDef tabGroupElement = (GroupDef) element;
FormEntryCaption tabGroupCaption = fem.getModel().getCaptionPrompt(groupIndex);
String tabGroupName = tabGroupCaption.getIndex().getReference().getNameLast();
if("style".equals(tabGroupName)){
parseStyle(tabGroupElement, groupIndex);
}else{
parseTabGroups(tabGroupElement, groupIndex, tabGroupCaption, tabGroupName);
}
groupIndex = fem.getModel().incrementIndex(groupIndex, false);
}
}
}