当前位置: 首页>>代码示例>>Java>>正文


Java FormEntryCaption.getFormElement方法代码示例

本文整理汇总了Java中org.javarosa.form.api.FormEntryCaption.getFormElement方法的典型用法代码示例。如果您正苦于以下问题:Java FormEntryCaption.getFormElement方法的具体用法?Java FormEntryCaption.getFormElement怎么用?Java FormEntryCaption.getFormElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.javarosa.form.api.FormEntryCaption的用法示例。


在下文中一共展示了FormEntryCaption.getFormElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:19,代码来源:FormParseInit.java

示例2: 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;
	}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:25,代码来源:FormWrapper.java

示例3: getFirstQuestionDef

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
/**
 * @return the first questionDef found in the form.
 */
public QuestionDef getFirstQuestionDef(){
	//go to the beginning of the form
	fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
	do{
		FormEntryCaption fep = femodel.getCaptionPrompt();
		if(fep.getFormElement() instanceof QuestionDef){
			return (QuestionDef)fep.getFormElement();
		}
	}while(fec.stepToNextEvent()!=FormEntryController.EVENT_END_OF_FORM);
	
	return null;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:16,代码来源:FormParseInit.java

示例4: getCurrentQuestion

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
/**
 * Gets the current question based off of
 * @return the question after getFirstQuestionDef()
 */
public QuestionDef getCurrentQuestion(){
	FormEntryCaption fep = femodel.getCaptionPrompt();
	if(fep.getFormElement() instanceof QuestionDef){
		return (QuestionDef)fep.getFormElement();
	}		
	return null;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:12,代码来源:FormParseInit.java

示例5: 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;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:FormParseInit.java

示例6: printStuff

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
public String printStuff(){
	String stuff = "";
	//go to the beginning of the form
	fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
	do{
		FormEntryCaption fep = femodel.getCaptionPrompt();
		boolean choiceFlag = false;
		
		if(fep.getFormElement() instanceof QuestionDef){
			stuff+="\t[Type:QuestionDef, ";
			List<SelectChoice> s = ((QuestionDef)fep.getFormElement()).getChoices();
			stuff+="ContainsChoices: "+ ((s != null && s.size() > 0) ? "true " : "false" ) +", ";
			if(s != null && s.size() > 0) choiceFlag = true;
		}else if(fep.getFormElement() instanceof FormDef){
			stuff+="\t[Type:FormDef, ";
		}else if(fep.getFormElement() instanceof GroupDef){
			stuff+="\t[Type:GroupDef, ";
		}else{
			stuff+="\t[Type:Unknown]\n";
			continue;
		}
		
		stuff+="ID:"+fep.getFormElement().getID()+", TextID:"+fep.getFormElement().getTextID()+",InnerText:"+fep.getFormElement().getLabelInnerText();
		if(choiceFlag){
			
			stuff+="] \n\t\t---Choices:"+((QuestionDef)fep.getFormElement()).getChoices().toString()+"\n";
		}else{
			stuff+="]\n";
		}
	}while(fec.stepToNextEvent()!=fec.EVENT_END_OF_FORM);
	
	return stuff;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:34,代码来源:FormParseInit.java

示例7: getFirstQuestionDef

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
/**
 * @return the first questionDef found in the form.
 */
public QuestionDef getFirstQuestionDef() {
    //go to the beginning of the form
    fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
    do {
        FormEntryCaption fep = femodel.getCaptionPrompt();
        if (fep.getFormElement() instanceof QuestionDef) {
            return (QuestionDef)fep.getFormElement();
        }
    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);

    return null;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:16,代码来源:FormParseInit.java

示例8: getCurrentQuestion

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
/**
 * Gets the current question based off of
 *
 * @return the question after getFirstQuestionDef()
 */
public QuestionDef getCurrentQuestion() {
    FormEntryCaption fep = femodel.getCaptionPrompt();
    if (fep.getFormElement() instanceof QuestionDef) {
        return (QuestionDef)fep.getFormElement();
    }
    return null;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:13,代码来源:FormParseInit.java

示例9: printStuff

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
public String printStuff() {
    String stuff = "";
    //go to the beginning of the form
    fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
    do {
        FormEntryCaption fep = femodel.getCaptionPrompt();
        boolean choiceFlag = false;

        if (fep.getFormElement() instanceof QuestionDef) {
            stuff += "\t[Type:QuestionDef, ";
            Vector s = ((QuestionDef)fep.getFormElement()).getChoices();
            stuff += "ContainsChoices: " + ((s != null && s.size() > 0) ? "true " : "false") + ", ";
            if (s != null && s.size() > 0) choiceFlag = true;
        } else if (fep.getFormElement() instanceof FormDef) {
            stuff += "\t[Type:FormDef, ";
        } else if (fep.getFormElement() instanceof GroupDef) {
            stuff += "\t[Type:GroupDef, ";
        } else {
            stuff += "\t[Type:Unknown]\n";
            continue;
        }

        stuff += "ID:" + fep.getFormElement().getID() + ", TextID:" + fep.getFormElement().getTextID() + ",InnerText:" + fep.getFormElement().getLabelInnerText();
        if (choiceFlag) {

            stuff += "] \n\t\t---Choices:" + ((QuestionDef)fep.getFormElement()).getChoices().toString() + "\n";
        } else {
            stuff += "]\n";
        }
    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);

    return stuff;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:34,代码来源:FormParseInit.java

示例10: stepToPreviousScreenEvent

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
/**
 * Move the current form index to the index of the previous question in the form.
 * Step backward out of repeats and groups as needed. If the resulting question 
 * is itself within a field-list, move upward to the group or repeat defining that
 * field-list.
 * 
 * @return
 */
public int stepToPreviousScreenEvent() {
    if (getEvent() != FormEntryController.EVENT_BEGINNING_OF_FORM) {
        int event = stepToPreviousEvent();

        while (event == FormEntryController.EVENT_REPEAT_JUNCTURE ||
        	   event == FormEntryController.EVENT_PROMPT_NEW_REPEAT ||
        	   (event == FormEntryController.EVENT_QUESTION && indexIsInFieldList()) ||
               ((event == FormEntryController.EVENT_GROUP 
                 || event == FormEntryController.EVENT_REPEAT) && !indexIsInFieldList())) {
            event = stepToPreviousEvent();
        }
        
        // Work-around for broken field-list handling from 1.1.7 which breaks either
        // build-generated forms or XLSForm-generated forms.  If the current group
        // is a GROUP with field-list and it is nested within a group or repeat with just
        // this containing group, and that is also a field-list, then return the parent group.
        if ( getEvent() == FormEntryController.EVENT_GROUP ) {
        	FormIndex currentIndex = getFormIndex();
        	IFormElement element = mFormEntryController.getModel().getForm().getChild(currentIndex);
            if (element instanceof GroupDef) {
            	GroupDef gd = (GroupDef) element;
            	if ( ODKView.FIELD_LIST.equalsIgnoreCase(gd.getAppearanceAttr()) ) {
            		// OK this group is a field-list... see what the parent is...
            		FormEntryCaption[] fclist = this.getCaptionHierarchy(currentIndex);
            		if ( fclist.length > 1) {
            			FormEntryCaption fc = fclist[fclist.length-2];
            			GroupDef pd = (GroupDef) fc.getFormElement();
            			if ( pd.getChildren().size() == 1 &&
            				 ODKView.FIELD_LIST.equalsIgnoreCase(pd.getAppearanceAttr()) ) {
            				mFormEntryController.jumpToIndex(fc.getIndex());
            			}
            		}
            	}
            }
        }
    }
    return getEvent();
}
 
开发者ID:sages-health,项目名称:sagesmobile-mCollect,代码行数:47,代码来源:FormController.java

示例11: getFirstQuestionDef

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private QuestionDef getFirstQuestionDef() {
	controller.jumpToIndex(FormIndex.createBeginningOfFormIndex());
	do {
		FormEntryCaption fec = fem.getCaptionPrompt();
		if(fec.getFormElement() instanceof QuestionDef)
			return (QuestionDef) fec.getFormElement();
	} while(controller.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);

	return null;
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:12,代码来源:FormWrapper.java

示例12: getCurrentQuestionDef

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private QuestionDef getCurrentQuestionDef() {
	FormEntryCaption fec = fem.getCaptionPrompt();
	if(fec.getFormElement() instanceof QuestionDef)
		return (QuestionDef) fec.getFormElement();

	return null;
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:9,代码来源:FormWrapper.java

示例13: stepToPreviousScreenEvent

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
/**
 * Move the current form index to the index of the previous question in the form.
 * Step backward out of repeats and groups as needed. If the resulting question
 * is itself within a field-list, move upward to the group or repeat defining that
 * field-list.
 *
 * @return
 */
public int stepToPreviousScreenEvent() throws JavaRosaException {
    try {
        if (getEvent() != FormEntryController.EVENT_BEGINNING_OF_FORM) {
            int event = stepToPreviousEvent();

            while (event == FormEntryController.EVENT_REPEAT_JUNCTURE ||
                   event == FormEntryController.EVENT_PROMPT_NEW_REPEAT ||
                   (event == FormEntryController.EVENT_QUESTION && indexIsInFieldList()) ||
                   ((event == FormEntryController.EVENT_GROUP
                     || event == FormEntryController.EVENT_REPEAT) && !indexIsInFieldList())) {
                event = stepToPreviousEvent();
            }

            // Work-around for broken field-list handling from 1.1.7 which breaks either
            // build-generated forms or XLSForm-generated forms.  If the current group
            // is a GROUP with field-list and it is nested within a group or repeat with just
            // this containing group, and that is also a field-list, then return the parent group.
            if ( getEvent() == FormEntryController.EVENT_GROUP ) {
                FormIndex currentIndex = getFormIndex();
                IFormElement element = mFormEntryController.getModel().getForm().getChild(currentIndex);
                if (element instanceof GroupDef) {
                    GroupDef gd = (GroupDef) element;
                    if ( ODKView.FIELD_LIST.equalsIgnoreCase(gd.getAppearanceAttr()) ) {
                        // OK this group is a field-list... see what the parent is...
                        FormEntryCaption[] fclist = this.getCaptionHierarchy(currentIndex);
                        if ( fclist.length > 1) {
                            FormEntryCaption fc = fclist[fclist.length-2];
                            GroupDef pd = (GroupDef) fc.getFormElement();
                            if ( pd.getChildren().size() == 1 &&
                                 ODKView.FIELD_LIST.equalsIgnoreCase(pd.getAppearanceAttr()) ) {
                                mFormEntryController.jumpToIndex(fc.getIndex());
                            }
                        }
                    }
                }
            }
        }
        return getEvent();
    } catch (RuntimeException e) {
        throw new JavaRosaException(e);
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:51,代码来源:FormController.java

示例14: stepToPreviousScreenEvent

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
/**
 * Move the current form index to the index of the previous question in the form.
 * Step backward out of repeats and groups as needed. If the resulting question
 * is itself within a field-list, move upward to the group or repeat defining that
 * field-list.
 *
 * @return
 */
public int stepToPreviousScreenEvent() throws JavaRosaException {
    try {
        if (getEvent() != FormEntryController.EVENT_BEGINNING_OF_FORM) {
            int event = stepToPreviousEvent();

            while (event == FormEntryController.EVENT_REPEAT_JUNCTURE ||
                   event == FormEntryController.EVENT_PROMPT_NEW_REPEAT ||
                   (event == FormEntryController.EVENT_QUESTION && indexIsInFieldList()) ||
                   ((event == FormEntryController.EVENT_GROUP
                     || event == FormEntryController.EVENT_REPEAT) && !indexIsInFieldList())) {
                event = stepToPreviousEvent();
            }

            // Work-around for broken field-list handling from 1.1.7 which breaks either
            // build-generated forms or XLSForm-generated forms.  If the current group
            // is a GROUP with field-list and it is nested within a group or repeat with just
            // this containing group, and that is also a field-list, then return the parent group.
            if ( getEvent() == FormEntryController.EVENT_GROUP ) {
                FormIndex currentIndex = getFormIndex();
                IFormElement element = mFormEntryController.getModel().getForm().getChild(currentIndex);
                if (element instanceof GroupDef) {
                    GroupDef gd = (GroupDef) element;
                    if ( FormController.FIELD_LIST.equalsIgnoreCase(gd.getAppearanceAttr()) ) {
                        // OK this group is a field-list... see what the parent is...
                        FormEntryCaption[] fclist = this.getCaptionHierarchy(currentIndex);
                        if ( fclist.length > 1) {
                            FormEntryCaption fc = fclist[fclist.length-2];
                            GroupDef pd = (GroupDef) fc.getFormElement();
                            if ( pd.getChildren().size() == 1 &&
                            		FormController.FIELD_LIST.equalsIgnoreCase(pd.getAppearanceAttr()) ) {
                                mFormEntryController.jumpToIndex(fc.getIndex());
                            }
                        }
                    }
                }
            }
        }
        return getEvent();
    } catch (RuntimeException e) {
        throw new JavaRosaException(e);
    }
}
 
开发者ID:smap-consulting,项目名称:smap-survey-manager,代码行数:51,代码来源:FormController.java

示例15: init

import org.javarosa.form.api.FormEntryCaption; //导入方法依赖的package包/类
private List<QD> init(byte[] oldAnswers) {
	EvaluationContext ec = new EvaluationContext();		
	form_def.setEvaluationContext(ec);

	fem = new FormEntryModel(form_def);
	controller = new FormEntryController(fem);

	if(oldAnswers != null && oldAnswers.length > 0)
		inflatePreviousAnswers(oldAnswers);
	else
		form_def.initialize(true);

	title = controller.getModel().getForm().getTitle();
	form_index = controller.getModel().getFormIndex();

	controller.jumpToIndex(FormIndex.createBeginningOfFormIndex());
	Localizer l = form_def.getLocalizer();
	l.setDefaultLocale(l.getAvailableLocales()[0]);
	l.setLocale(l.getAvailableLocales()[0]);

	do {
		FormEntryCaption fec = fem.getCaptionPrompt();
		if(fec.getFormElement() instanceof QuestionDef) {
			if(questions == null)
				questions = new ArrayList<QD>();

			QuestionDef qd = (QuestionDef) fec.getFormElement();
			//Log.d(LOG, "this question def textId: " + qd.getTextID());
			QD questionDef = null;

			if(answers != null && answers.containsKey(qd.getTextID()))
				questionDef = new QD(qd, answers.get(qd.getTextID()));
			else
				questionDef = new QD(qd);

			FormEntryPrompt fep = fem.getQuestionPrompt();
			questionDef.questionText = fep.getQuestionText();

			if(fep.getHelpText() != null)
				questionDef.helperText = fep.getHelpText();

			if(fep.getControlType() == org.javarosa.core.model.Constants.CONTROL_SELECT_MULTI || fep.getControlType() == org.javarosa.core.model.Constants.CONTROL_SELECT_ONE) {
				questionDef.selectChoiceText = new ArrayList<String>();
				for(SelectChoice sc : fep.getSelectChoices()) {
					questionDef.selectChoiceText.add(fep.getSelectChoiceText(sc));
				}
			}


			questions.add(questionDef);
		}

	} while(controller.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);

	num_questions = questions.size();
	return questions;
}
 
开发者ID:guardianproject,项目名称:CameraV,代码行数:58,代码来源:FormWrapper.java


注:本文中的org.javarosa.form.api.FormEntryCaption.getFormElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。