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


Java FormIndex.isTerminal方法代码示例

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


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

示例1: isIndexRelevant

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * Determine if the current FormIndex is relevant. Only relevant indexes
 * should be returned when filling out a form.
 *
 * @param index
 * @return true if current element at FormIndex is relevant
 */
public boolean isIndexRelevant(FormIndex index) {
    TreeReference ref = form.getChildInstanceRef(index);
    boolean isAskNewRepeat = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT);
    boolean isRepeatJuncture = (getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);

    boolean relevant;
    if (isAskNewRepeat) {
        relevant = form.isRepeatRelevant(ref) && form.canCreateRepeat(ref, index);
        //repeat junctures are still relevant if no new repeat can be created; that option
        //is simply missing from the menu
    } else if (isRepeatJuncture) {
    	relevant = form.isRepeatRelevant(ref);
    } else {
        TreeElement node = form.getMainInstance().resolveReference(ref);
        relevant = node.isRelevant(); // check instance flag first
    }

    if (relevant) { // if instance flag/condition says relevant, we still
        // have to check the <group>/<repeat> hierarchy

        FormIndex ancestorIndex = index;
        while (!ancestorIndex.isTerminal()) {
            // This should be safe now that the TreeReference is contained
            // in the ancestor index itself
            TreeElement ancestorNode =
                    form.getMainInstance().resolveReference(ancestorIndex.getLocalReference());

            if (!ancestorNode.isRelevant()) {
                relevant = false;
                break;
            }
            ancestorIndex = ancestorIndex.getNextLevel();
        }
    }

    return relevant;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:45,代码来源:FormEntryModel.java

示例2: getNewRepeatWidget

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
public ChatterboxWidget getNewRepeatWidget (FormIndex index, FormEntryModel model, Chatterbox cbox) {
    //GroupDef repeat = (GroupDef)f.explodeIndex(index).lastElement();

    //damn linked lists...
    FormIndex end = index;
    while (!end.isTerminal()) {
        end = end.getNextLevel();
    }
    int multiplicity = end.getInstanceIndex();

    FormEntryCaption p = model.getCaptionPrompt(index);

    String label; //decide what text form to use.

    label = p.getLongText();
    if(label == null){
        label = p.getShortText();
    }

    String labelInner = (label == null || label.length() == 0 ? Localization.get("repeat.repitition") : label);

    String promptLabel = Localization.get((multiplicity > 0 ? "repeat.message.multiple" : "repeat.message.single"), new String[] {labelInner});

    FakedFormEntryPrompt prompt = new FakedFormEntryPrompt(promptLabel,
                                        Constants.CONTROL_SELECT_ONE, Constants.DATATYPE_TEXT);
    prompt.addSelectChoice(new SelectChoice(null,Localization.get("yes"), "y", false));
    prompt.addSelectChoice(new SelectChoice(null,Localization.get("no"), "n", false));

    return new ChatterboxWidget(cbox, prompt, ChatterboxWidget.VIEW_EXPANDED, new CollapsedWidget(), new SelectOneEntryWidget(ChoiceGroup.EXCLUSIVE));
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:31,代码来源:ChatterboxWidgetFactory.java

示例3: isIndexRelevant

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * Determine if the current FormIndex is relevant. Only relevant indexes
 * should be returned when filling out a form.
 *
 * @return true if current element at FormIndex is relevant
 */
public boolean isIndexRelevant(FormIndex index) {
    TreeReference ref = form.getChildInstanceRef(index);
    boolean isAskNewRepeat = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT);
    boolean isRepeatJuncture = (getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);

    boolean relevant;
    if (isAskNewRepeat) {
        relevant = form.isRepeatRelevant(ref) && form.canCreateRepeat(ref, index);
        //repeat junctures are still relevant if no new repeat can be created; that option
        //is simply missing from the menu
    } else if (isRepeatJuncture) {
        relevant = form.isRepeatRelevant(ref);
    } else {
        TreeElement node = form.getMainInstance().resolveReference(ref);
        relevant = (node != null) && node.isRelevant();
    }

    if (relevant) { // if instance flag/condition says relevant, we still
        // have to check the <group>/<repeat> hierarchy

        FormIndex ancestorIndex = index;
        while (!ancestorIndex.isTerminal()) {
            // This should be safe now that the TreeReference is contained
            // in the ancestor index itself
            TreeElement ancestorNode =
                    form.getMainInstance().resolveReference(ancestorIndex.getLocalReference());

            if (!ancestorNode.isRelevant()) {
                relevant = false;
                break;
            }
            ancestorIndex = ancestorIndex.getNextLevel();
        }
    }

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

示例4: stepIndexOut

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * used to go up one level in the formIndex. That is, if you're at 5_0, 1 (the second question
 * in a repeating group), this method will return a FormInex of 5_0 (the start of the repeating
 * group). If your at index 16 or 5_0, this will return null;
 */
public static FormIndex stepIndexOut(FormIndex index) {
    if (index.isTerminal()) {
        return null;
    } else {
        return new FormIndex(stepIndexOut(index.getNextLevel()), index);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:13,代码来源:FormHierarchyActivity.java

示例5: stepIndexOut

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * used to go up one level in the formIndex. That is, if you're at 5_0, 1 (the second question
 * in a repeating group), this method will return a FormInex of 5_0 (the start of the repeating
 * group). If your at index 16 or 5_0, this will return null;
 *
 * @param index
 * @return index
 */
public FormIndex stepIndexOut(FormIndex index) {
    if (index.isTerminal()) {
        return null;
    } else {
        return new FormIndex(stepIndexOut(index.getNextLevel()), index);
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:16,代码来源:FormController.java


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