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


Java FormEntryModel.getQuestionPrompt方法代码示例

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


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

示例1: countUnansweredQuestions

import org.javarosa.form.api.FormEntryModel; //导入方法依赖的package包/类
/**
 * @param countRequiredOnly
 *            if true count only the questions that are unanswered and also
 *            required
 * @return number of unanswered questions
 */
public static int countUnansweredQuestions(FormEntryModel model, boolean countRequiredOnly) {
    //ctsims - Made this list only count relevant questions
    int counter = 0;

    for(FormIndex index = model.incrementIndex(FormIndex.createBeginningOfFormIndex());!index.isEndOfFormIndex();index = model.incrementIndex(index)) {
        if(!model.isIndexRelevant(index)) {
            continue;
        }

        if(model.getEvent(index) == FormEntryController.EVENT_QUESTION) {
            FormEntryPrompt prompt = model.getQuestionPrompt(index);
            if(prompt.getAnswerValue() == null) {
                if(!countRequiredOnly || prompt.isRequired()) {
                    counter++;
                }
            }
        }
    }

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

示例2: getWidget

import org.javarosa.form.api.FormEntryModel; //导入方法依赖的package包/类
/**
 * NOTE: Only applicable for Questions right now, not any other kind of IFormElement
 * @param questionIndex
 * @param form
 * @param initViewState
 * @return
 */
public ChatterboxWidget getWidget (FormIndex questionIndex, FormEntryModel model, int initViewState) {
    IWidgetStyle collapsedStyle = null;
    IWidgetStyleEditable expandedStyle = null;

    FormEntryPrompt prompt = model.getQuestionPrompt(questionIndex);

    int controlType = prompt.getControlType();
    int dataType = prompt.getDataType();

    String appearanceAttr = prompt.getAppearanceHint();

    collapsedStyle = new CollapsedWidget();
    ((CollapsedWidget)collapsedStyle).setSeekable(this.readOnly);

    expandedStyle = widgetFactory.getWidget(controlType,dataType,appearanceAttr);

    if (collapsedStyle == null || expandedStyle == null) {
        throw new IllegalStateException("No appropriate widget to render question");
    }

    expandedStyle.registerMultimediaController(mediaController);
    ChatterboxWidget widget = new ChatterboxWidget(cbox, prompt, initViewState, collapsedStyle, expandedStyle);
    prompt.register(widget);
    return widget;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:33,代码来源:ChatterboxWidgetFactory.java

示例3: listQuestion

import org.javarosa.form.api.FormEntryModel; //导入方法依赖的package包/类
private static void listQuestion (FormDef f, QuestionDef q,FormEntryController fec, int indent, StringBuilder sb) {
	FormEntryModel femodel = fec.getModel();
	TreeElement instanceNode = getInstanceNode(f.getInstance(), q.getBind());
	String caption = "";
	FormEntryPrompt fep = femodel.getQuestionPrompt();
	caption = fep.getLongText();

	int type = instanceNode.getDataType();

	if (q.getControlType() != Constants.CONTROL_TRIGGER) {
		println(sb, indent, "Question: \"" + caption + "\"");
		println(sb, indent + 1, "Type: " + printType(type));
	} else {
		println(sb, indent, "Info: \"" + caption + "\"");
	}

	if (q.getControlType() == Constants.CONTROL_SELECT_ONE || q.getControlType() == Constants.CONTROL_SELECT_MULTI) {
		printChoices(f,q,fec, indent + 1, sb);
	}

	printProperty("relevant", f, instanceNode, indent + 1, sb);

	printProperty("required", f, instanceNode, indent + 1, sb);

	printProperty("readonly", f, instanceNode, indent + 1, sb);

	String defaultValue = printDefault(instanceNode);
	if (defaultValue != null) {
		println(sb, indent + 1, "Default: " + defaultValue);
	}

	if (instanceNode.getConstraint() != null) {
		println(sb, indent + 1, "Constraint: " + printCondition(instanceNode.getConstraint().constraint));
	}

	println(sb);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:38,代码来源:FormOverview.java

示例4: listQuestion

import org.javarosa.form.api.FormEntryModel; //导入方法依赖的package包/类
private static void listQuestion (FormDef f, QuestionDef q,FormEntryController fec, int indent, StringBuffer sb) {
    FormEntryModel femodel = fec.getModel();
    TreeElement instanceNode = getInstanceNode(f.getInstance(), q.getBind());
    String caption = "";
    FormEntryPrompt fep = femodel.getQuestionPrompt();
    caption = fep.getLongText();

    int type = instanceNode.getDataType();

    if (q.getControlType() != Constants.CONTROL_TRIGGER) {
        println(sb, indent, "Question: \"" + caption + "\"");
        println(sb, indent + 1, "Type: " + printType(type));
    } else {
        println(sb, indent, "Info: \"" + caption + "\"");
    }

    if (q.getControlType() == Constants.CONTROL_SELECT_ONE || q.getControlType() == Constants.CONTROL_SELECT_MULTI) {
        printChoices(f,q,fec, indent + 1, sb);
    }

    printProperty("relevant", f, instanceNode, indent + 1, sb);

    printProperty("required", f, instanceNode, indent + 1, sb);

    printProperty("readonly", f, instanceNode, indent + 1, sb);

    String defaultValue = printDefault(instanceNode);
    if (defaultValue != null) {
        println(sb, indent + 1, "Default: " + defaultValue);
    }

    if (instanceNode.getConstraint() != null) {
        println(sb, indent + 1, "Constraint: " + printCondition(instanceNode.getConstraint().constraint));
    }

    println(sb);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:38,代码来源:FormOverview.java

示例5: checkModel

import org.javarosa.form.api.FormEntryModel; //导入方法依赖的package包/类
private void checkModel(FormEntryModel model, StringBuilder fieldErrors)
{
	FormIndex index = model.getFormIndex();
	while(!index.isEndOfFormIndex())
	{
		int event = model.getEvent(index);
		if(event != FormEntryController.EVENT_QUESTION)
		{
			index = model.incrementIndex(index);
			continue;
		}
		FormEntryPrompt prompt = model.getQuestionPrompt(index);
		final int dataType = prompt.getDataType();
		switch(dataType)
		{
			case org.javarosa.core.model.Constants.DATATYPE_TEXT:
				case org.javarosa.core.model.Constants.DATATYPE_DATE:
				case org.javarosa.core.model.Constants.DATATYPE_CHOICE:
				case org.javarosa.core.model.Constants.DATATYPE_INTEGER:
				case org.javarosa.core.model.Constants.DATATYPE_DECIMAL:
			case org.javarosa.core.model.Constants.DATATYPE_LONG:
				case org.javarosa.core.model.Constants.DATATYPE_TIME:
				case org.javarosa.core.model.Constants.DATATYPE_BOOLEAN:
					break;

				//Unsupported DataType's below
				case org.javarosa.core.model.Constants.DATATYPE_BARCODE:
					addFieldTypeNotSupported("BARCODE", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_BINARY:
					addFieldTypeNotSupported("BINARY", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_CHOICE_LIST:
					addFieldTypeNotSupported("CHOICE_LIST", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_DATE_TIME:
					addFieldTypeNotSupported("DATE_TIME", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_GEOPOINT:
					addFieldTypeNotSupported("GEOPOINT", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_GEOSHAPE:
					addFieldTypeNotSupported("GEOSHAPE", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_GEOTRACE:
					addFieldTypeNotSupported("GEOTRACE", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_NULL:
					addFieldTypeNotSupported("NULL", fieldErrors, prompt);
					break;
				case org.javarosa.core.model.Constants.DATATYPE_UNSUPPORTED:
					addFieldTypeNotSupported("UNSUPPORTED", fieldErrors, prompt);
					break;
				default:
					addFieldTypeNotSupported("UNKNOWN", fieldErrors, prompt);
					break;
           	
		}
		index = model.incrementIndex(index);
	}
}
 
开发者ID:benetech,项目名称:Secure-App-Generator,代码行数:62,代码来源:ObtainXFormController.java

示例6: init

import org.javarosa.form.api.FormEntryModel; //导入方法依赖的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.FormEntryModel.getQuestionPrompt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。