本文整理汇总了Java中org.javarosa.core.model.QuestionDef.getControlType方法的典型用法代码示例。如果您正苦于以下问题:Java QuestionDef.getControlType方法的具体用法?Java QuestionDef.getControlType怎么用?Java QuestionDef.getControlType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.QuestionDef
的用法示例。
在下文中一共展示了QuestionDef.getControlType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGroupRelevancyInsideRepeat
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
* Ensures that the relevancy condition for a group insided of a repeat is
* properly accounted for when building the triggerables DAG
*/
@Test
public void testGroupRelevancyInsideRepeat() throws XPathSyntaxException {
FormParseInit fpi = new FormParseInit("/xform_tests/group_relevancy_in_repeat.xml");
FormEntryController fec = initFormEntry(fpi);
do {
QuestionDef q = fpi.getCurrentQuestion();
if (q != null && q.getControlType() == Constants.CONTROL_SELECT_ONE) {
IAnswerData ans = new SelectOneData(new Selection("yes"));
fec.answerQuestion(ans);
// test that a value that should be updated has been updated
ExprEvalUtils.testEval("/data/some_group/repeat_sum",
fpi.getFormDef().getInstance(), null, 25.0);
}
} while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
示例2: listQuestion
import org.javarosa.core.model.QuestionDef; //导入方法依赖的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);
}
示例3: processSelectChoices
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
private static void processSelectChoices (Element e, IFormElement fe, FormDef form) {
if (fe instanceof QuestionDef) {
QuestionDef q = (QuestionDef)fe;
int controlType = q.getControlType();
TreeReference ref = (TreeReference)q.getBind().getReference();
if (controlType == Constants.CONTROL_SELECT_ONE || controlType == Constants.CONTROL_SELECT_MULTI) {
String choiceTypeName = getChoiceTypeName(ref);
List<SelectChoice> choices;
//Figure out the choices involved if they are complex
ItemsetBinding itemset = q.getDynamicChoices();
if (itemset != null) {
form.populateDynamicChoices(itemset, ref);
choices = itemset.getChoices();
} else { //static choices
choices = q.getChoices();
}
writeChoices(e, choiceTypeName, choices);
if (controlType == Constants.CONTROL_SELECT_MULTI) {
writeListType(e, choiceTypeName);
}
choiceTypeMapping.put(form.getInstance().getTemplatePath(ref),
(controlType == Constants.CONTROL_SELECT_MULTI ? "list." : "") + choiceTypeName);
}
} else {
for (int i = 0; i < fe.getChildren().size(); i++) {
processSelectChoices(e, fe.getChild(i), form);
}
}
}
示例4: testAccessorsModifiers
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void testAccessorsModifiers () {
QuestionDef q = new QuestionDef();
q.setID(45);
if (q.getID() != 45) {
fail("ID getter/setter broken");
}
testSerialize(q, "c");
IDataReference ref = newRef("/data");
q.setBind(ref);
if (q.getBind() != ref) {
fail("Ref getter/setter broken");
}
testSerialize(q, "e");
q.setControlType(Constants.CONTROL_SELECT_ONE);
if (q.getControlType() != Constants.CONTROL_SELECT_ONE) {
fail("Control type getter/setter broken");
}
testSerialize(q, "g");
q.setAppearanceAttr("minimal");
if (!"minimal".equals(q.getAppearanceAttr())) {
fail("Appearance getter/setter broken");
}
testSerialize(q, "h");
}
示例5: listQuestion
import org.javarosa.core.model.QuestionDef; //导入方法依赖的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);
}
示例6: testAccessorsModifiers
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testAccessorsModifiers() {
QuestionDef q = new QuestionDef();
q.setID(45);
if (q.getID() != 45) {
fail("ID getter/setter broken");
}
testSerialize(q, "c");
XPathReference ref = newRef("/data");
q.setBind(ref);
if (q.getBind() != ref) {
fail("Ref getter/setter broken");
}
testSerialize(q, "e");
q.setControlType(Constants.CONTROL_SELECT_ONE);
if (q.getControlType() != Constants.CONTROL_SELECT_ONE) {
fail("Control type getter/setter broken");
}
testSerialize(q, "g");
q.setAppearanceAttr("minimal");
if (!"minimal".equals(q.getAppearanceAttr())) {
fail("Appearance getter/setter broken");
}
testSerialize(q, "h");
}
示例7: recursivelyInspectFields
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
private void recursivelyInspectFields(List<IFormElement> children, StringBuilder fieldErrors, boolean inGroup)
{
for (IFormElement child : children)
{
if (child instanceof GroupDef)
{
GroupDef groupDef = (GroupDef) child;
if(inGroup)
{
addGroupNotSupported("xform_group_inside_group", fieldErrors, groupDef);
return;
}
List<IFormElement> groupChildren = groupDef.getChildren();
if(groupChildren.isEmpty())
{
addGroupNotSupported("xform_group_empty", fieldErrors, groupDef);
inGroup = false;
return;
}
recursivelyInspectFields(groupChildren, fieldErrors, true);
inGroup = false;
}
if (child instanceof QuestionDef)
{
QuestionDef questionDef = (QuestionDef) child;
final int controlType = questionDef.getControlType();
switch(controlType)
{
case org.javarosa.core.model.Constants.CONTROL_INPUT:
case org.javarosa.core.model.Constants.CONTROL_SELECT_ONE:
case org.javarosa.core.model.Constants.CONTROL_LABEL:
case org.javarosa.core.model.Constants.CONTROL_TEXTAREA:
break;
//Unsupported Control types below
case org.javarosa.core.model.Constants.CONTROL_SELECT_MULTI:
addFieldControlNotSupported("SELECT_MULTI", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_AUDIO_CAPTURE:
addFieldControlNotSupported("AUDIO_CAPTURE", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_IMAGE_CHOOSE:
addFieldControlNotSupported("IMAGE_CHOOSE", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_RANGE:
addFieldControlNotSupported("RANGE", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_SECRET:
addFieldControlNotSupported("SECRET", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_SUBMIT:
addFieldControlNotSupported("SUBMIT", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_UNTYPED:
addFieldControlNotSupported("UNTYPED", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_UPLOAD:
addFieldControlNotSupported("UPLOAD", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_VIDEO_CAPTURE:
addFieldControlNotSupported("VIDEO_CAPTURE", fieldErrors, questionDef);
break;
case org.javarosa.core.model.Constants.CONTROL_TRIGGER:
addFieldControlNotSupported("TRIGGER", fieldErrors, questionDef);
break;
default:
addFieldControlNotSupported("UNKNOWN", fieldErrors, questionDef);
break;
}
}
}
}
示例8: processSelectChoices
import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
private static void processSelectChoices (Element e, IFormElement fe, FormDef form) {
if (fe instanceof QuestionDef) {
QuestionDef q = (QuestionDef)fe;
int controlType = q.getControlType();
TreeReference ref = q.getBind().getReference();
if (controlType == Constants.CONTROL_SELECT_ONE || controlType == Constants.CONTROL_SELECT_MULTI) {
String choiceTypeName = getChoiceTypeName(ref);
Vector<SelectChoice> choices;
//Figure out the choices involved if they are complex
ItemsetBinding itemset = q.getDynamicChoices();
if (itemset != null) {
if(itemset.nodesetRef.getInstanceName() != null) {
//CTS: We can't really do this right for external instance references right now.
choices = new Vector();
} else {
form.populateDynamicChoices(itemset, ref);
choices = itemset.getChoices();
}
} else { //static choices
choices = q.getChoices();
}
writeChoices(e, choiceTypeName, choices);
if (controlType == Constants.CONTROL_SELECT_MULTI) {
writeListType(e, choiceTypeName);
}
choiceTypeMapping.put(form.getInstance().getTemplatePath(ref),
(controlType == Constants.CONTROL_SELECT_MULTI ? "list." : "") + choiceTypeName);
}
} else {
for (int i = 0; i < fe.getChildren().size(); i++) {
processSelectChoices(e, fe.getChild(i), form);
}
}
}