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


Java Selection.attachChoice方法代码示例

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


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

示例1: getSelectItemText

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
/**
 * Attempts to return the specified Item (from a select or 1select) text.
 * Will check for text in the following order:<br/>
 * Localized Text (long form) -> Localized Text (no special form) <br />
 * If no textID is available, method will return this item's labelInnerText.
 * @param sel the selection (item), if <code>null</code> will throw a IllegalArgumentException
 * @return Question Text.  <code>null</code> if no text for this element exists (after all fallbacks).
 * @throws RunTimeException if this method is called on an element that is NOT a QuestionDef
 * @throws IllegalArgumentException if Selection is <code>null</code>
 */
public String getSelectItemText(Selection sel){
	//throw tantrum if this method is called when it shouldn't be or sel==null
	if(!(getFormElement() instanceof QuestionDef)) throw new RuntimeException("Can't retrieve question text for non-QuestionDef form elements!");
	if(sel == null) throw new IllegalArgumentException("Cannot use null as an argument!");

	//Just in case the selection hasn't had a chance to be initialized yet.
	if(sel.index == -1) { sel.attachChoice(this.getQuestion()); }

	//check for the null id case and return labelInnerText if it is so.
	String tid = sel.choice.getTextID();
	if(tid == null || tid == "") return substituteStringArgs(sel.choice.getLabelInnerText());

	//otherwise check for 'long' form of the textID, then for the default form and return
	String returnText;
	returnText = getIText(tid, "long");
	if(returnText == null) returnText = getIText(tid,null);

	return substituteStringArgs(returnText);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:30,代码来源:FormEntryPrompt.java

示例2: getSelectItemText

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
/**
 * Attempts to return the specified Item (from a select or 1select) text.
 * Will check for text in the following order:<br/>
 * Localized Text (long form) -> Localized Text (no special form) <br />
 * If no textID is available, method will return this item's labelInnerText.
 *
 * @param sel the selection (item), if <code>null</code> will throw a IllegalArgumentException
 * @return Question Text.  <code>null</code> if no text for this element exists (after all fallbacks).
 * @throws IllegalArgumentException if Selection is <code>null</code>
 */
public String getSelectItemText(Selection sel) {
    //throw tantrum if this method is called when it shouldn't be or sel==null
    if (!(getFormElement() instanceof QuestionDef))
        throw new RuntimeException("Can't retrieve question text for non-QuestionDef form elements!");
    if (sel == null) throw new IllegalArgumentException("Cannot use null as an argument!");

    //Just in case the selection hasn't had a chance to be initialized yet.
    if (sel.index == -1) {
        sel.attachChoice(this.getQuestion());
    }

    //check for the null id case and return labelInnerText if it is so.
    String tid = sel.choice.getTextID();
    if (tid == null || "".equals(tid)) {
        return substituteStringArgs(sel.choice.getLabelInnerText());
    }

    //otherwise check for 'long' form of the textID, then for the default form and return
    String returnText;
    returnText = getIText(tid, "long");
    if (returnText == null) returnText = getIText(tid, null);

    return substituteStringArgs(returnText);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:35,代码来源:FormEntryPrompt.java

示例3: setUp

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() {
    question = new QuestionDef();
    question.setID(57);

    OrderedHashtable oh = new OrderedHashtable();
    Vector v = new Vector();
    for (int i = 0; i < 3; i++) {
        question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection" + i, false));
    }

    one = new Selection("Selection1");
    one.attachChoice(question);
    two = new Selection("Selection2");
    two.attachChoice(question);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:SelectOneDataTests.java

示例4: attachControlsToInstanceData

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
private void attachControlsToInstanceData(TreeElement node) {
   for (int i = 0; i < node.getNumChildren(); i++) {
      attachControlsToInstanceData(node.getChildAt(i));
   }

   IAnswerData val = node.getValue();
   List<Selection> selections = null;
   if (val instanceof SelectOneData) {
      selections = new ArrayList<Selection>();
      selections.add((Selection) val.getValue());
   } else if (val instanceof SelectMultiData) {
      selections = (List<Selection>) val.getValue();
   }

   if (selections != null) {
      QuestionDef q = findQuestionByRef(node.getRef(), this);
      if (q == null) {
         throw new RuntimeException(
                 "FormDef.attachControlsToInstanceData: can't find question to link");
      }

      if (q.getDynamicChoices() != null) {
         // droos: i think we should do something like initializing the
         // itemset here, so that default answers
         // can be linked to the selectchoices. however, there are
         // complications. for example, the itemset might
         // not be ready to be evaluated at form initialization; it may
         // require certain questions to be answered
         // first. e.g., if we evaluate an itemset and it has no choices, the
         // xform engine will throw an error
         // itemset TODO
      }

      for (int i = 0; i < selections.size(); i++) {
         Selection s = selections.get(i);
         s.attachChoice(q);
      }
   }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:40,代码来源:FormDef.java

示例5: setUp

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
public void setUp() throws Exception {
	super.setUp();
	
	question = new QuestionDef();
	question.setID(57);
	
	for (int i = 0; i < 3; i++) {
		question.addSelectChoice(new SelectChoice("","Selection" + i, "Selection" + i, false));
	}	
	
	one = new Selection("Selection1");
	one.attachChoice(question);
	two = new Selection("Selection2");
	two.attachChoice(question);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:16,代码来源:SelectOneDataTests.java

示例6: setUp

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
public void setUp() throws Exception {
	super.setUp();
	
	question = new QuestionDef();
	
	for (int i = 0; i < 4; i++) {
		question.addSelectChoice(new SelectChoice("","Selection" + i, "Selection " + i, false));
	}	
			
	one = new Selection("Selection 1");
	one.attachChoice(question);
	two = new Selection("Selection 2");
	two.attachChoice(question);
	three = new Selection("Selection 3");
	three.attachChoice(question);
	
	firstTwo = new ArrayList<Selection>();
	firstTwo.add(one);
	firstTwo.add(two);
	
	lastTwo = new ArrayList<Selection>();
	lastTwo.add(two);
	lastTwo.add(three);
	
	invalid = new ArrayList<Object>();
	invalid.add(three);
	invalid.add(new Integer(12));
	invalid.add(one);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:30,代码来源:SelectMultiDataTests.java

示例7: setWidgetValue

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
protected void setWidgetValue (Object o) {
    Vector vs = (Vector)o;
    for (int i = 0; i < vs.size(); i++) {
        Selection s = (Selection)vs.elementAt(i);
        if(s.index == -1) {
            s.attachChoice(prompt.getQuestion());
        }
        choiceGroup().setSelectedIndex(s.index, true);
        choiceGroup().touch();
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:12,代码来源:SelectMultiEntryWidget.java

示例8: setWidgetValue

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
protected void setWidgetValue (Object o) {
    Selection s = (Selection)o;
    if(s.index == -1) {
        s.attachChoice(prompt.getQuestion());
    }
    //To prevent audio from being played over if appropriate
    choiceGroup().setLastSelected(s.index);
    choiceGroup().setSelectedIndex(s.index, true);
    choiceGroup().touch();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:11,代码来源:SelectOneEntryWidget.java

示例9: attachControlsToInstanceData

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
private void attachControlsToInstanceData(TreeElement node) {
    for (int i = 0; i < node.getNumChildren(); i++) {
        attachControlsToInstanceData(node.getChildAt(i));
    }

    IAnswerData val = node.getValue();
    Vector selections = null;
    if (val instanceof SelectOneData) {
        selections = new Vector();
        selections.addElement(val.getValue());
    } else if (val instanceof SelectMultiData) {
        selections = (Vector)val.getValue();
    }

    if (selections != null) {
        QuestionDef q = findQuestionByRef(node.getRef(), this);
        if (q == null) {
            throw new RuntimeException("FormDef.attachControlsToInstanceData: can't find question to link");
        }

        if (q.getDynamicChoices() != null) {
            //droos: i think we should do something like initializing the itemset here, so that default answers
            //can be linked to the selectchoices. however, there are complications. for example, the itemset might
            //not be ready to be evaluated at form initialization; it may require certain questions to be answered
            //first. e.g., if we evaluate an itemset and it has no choices, the xform engine will throw an error
            //itemset TODO
        }

        for (int i = 0; i < selections.size(); i++) {
            Selection s = (Selection)selections.elementAt(i);
            s.attachChoice(q);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:35,代码来源:FormDef.java

示例10: setUp

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() {

    question = new QuestionDef();

    for (int i = 0; i < 4; i++) {
        question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection " + i, false));
    }

    one = new Selection("Selection 1");
    one.attachChoice(question);
    two = new Selection("Selection 2");
    two.attachChoice(question);
    three = new Selection("Selection 3");
    three.attachChoice(question);

    firstTwo = new Vector();
    firstTwo.addElement(one);
    firstTwo.addElement(two);

    lastTwo = new Vector();
    lastTwo.addElement(two);
    lastTwo.addElement(three);

    invalid = new Vector();
    invalid.addElement(three);
    invalid.addElement(new Integer(12));
    invalid.addElement(one);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:30,代码来源:SelectMultiDataTests.java

示例11: attachControlsToInstanceData

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
private void attachControlsToInstanceData(TreeElement node) {
    for (int i = 0; i < node.getNumChildren(); i++) {
        attachControlsToInstanceData(node.getChildAt(i));
    }

    IAnswerData val = node.getValue();
    Vector<Object> selections = null;
    if (val instanceof SelectOneData) {
        selections = new Vector<>();
        selections.addElement(val.getValue());
    } else if (val instanceof SelectMultiData) {
        selections = (Vector<Object>)val.getValue();
    }

    if (selections != null) {
        QuestionDef q = findQuestionByRef(node.getRef(), this);
        if (q == null) {
            throw new RuntimeException("FormDef.attachControlsToInstanceData: can't find question to link");
        }

        if (q.getDynamicChoices() != null) {
            //droos: i think we should do something like initializing the itemset here, so that default answers
            //can be linked to the selectchoices. however, there are complications. for example, the itemset might
            //not be ready to be evaluated at form initialization; it may require certain questions to be answered
            //first. e.g., if we evaluate an itemset and it has no choices, the xform engine will throw an error
            //itemset TODO
        }

        for (int i = 0; i < selections.size(); i++) {
            Selection s = (Selection)selections.elementAt(i);
            s.attachChoice(q);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:35,代码来源:FormDef.java

示例12: setUp

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() {
    question = new QuestionDef();

    for (int i = 0; i < 4; i++) {
        question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection " + i, false));
    }

    one = new Selection("Selection 1");
    one.attachChoice(question);
    two = new Selection("Selection 2");
    two.attachChoice(question);
    three = new Selection("Selection 3");
    three.attachChoice(question);

    firstTwo = new Vector<>();
    firstTwo.addElement(one);
    firstTwo.addElement(two);

    lastTwo = new Vector<>();
    lastTwo.addElement(two);
    lastTwo.addElement(three);

    invalid = new Vector();
    invalid.addElement(three);
    invalid.addElement(12);
    invalid.addElement(one);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:29,代码来源:SelectMultiDataTests.java

示例13: getSpecialFormSelectItemText

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
/**
 * This method is generally used to retrieve special forms for a
 * (select or 1select) item, e.g. "audio", "video", etc.
 *
 * @param sel  - The Item whose text you're trying to retrieve.
 * @param form - Special text form of Item you're trying to retrieve.
 * @return Special Form Text. <code>null</code> if no text for this element exists (with the specified special form).
 * @throws IllegalArgumentException if <code>sel == null</code>
 */
public String getSpecialFormSelectItemText(Selection sel, String form) {
    if (sel == null)
        throw new IllegalArgumentException("Cannot use null as an argument for Selection!");

    //Just in case the selection hasn't had a chance to be initialized yet.
    if (sel.index == -1) {
        sel.attachChoice(this.getQuestion());
    }

    String textID = sel.choice.getTextID();
    if (textID == null || textID.equals("")) return null;

    String returnText = getIText(textID, form);

    return substituteStringArgs(returnText);


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

示例14: getSpecialFormSelectItemText

import org.javarosa.core.model.data.helper.Selection; //导入方法依赖的package包/类
/**
 * This method is generally used to retrieve special forms for a
 * (select or 1select) item, e.g. "audio", "video", etc.
 *
 * @param sel - The Item whose text you're trying to retrieve.
 * @param form - Special text form of Item you're trying to retrieve.
 * @return Special Form Text. <code>null</code> if no text for this element exists (with the specified special form).
 * @throws RunTimeException if this method is called on an element that is NOT a QuestionDef
 * @throws IllegalArgumentException if <code>sel == null</code>
 */
public String getSpecialFormSelectItemText(Selection sel,String form){
	if(sel == null) throw new IllegalArgumentException("Cannot use null as an argument for Selection!");

	//Just in case the selection hasn't had a chance to be initialized yet.
	if(sel.index == -1) { sel.attachChoice(this.getQuestion()); }

	String textID = sel.choice.getTextID();
	if(textID == null || textID.equals("")) return null;

	String returnText = getIText(textID, form);

	return substituteStringArgs(returnText);

}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:FormEntryPrompt.java


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