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


Java FormIndex.isInForm方法代码示例

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


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

示例1: stepEvent

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * Moves the current FormIndex to the next/previous relevant position.
 *
 * @param forward
 * @return
 */
private int stepEvent(boolean forward) {
    FormIndex index = model.getFormIndex();

    do {
        if (forward) {
            index = model.incrementIndex(index);
        } else {
            index = model.decrementIndex(index);
        }
    } while (index.isInForm() && !model.isIndexRelevant(index));

    return jumpToIndex(index);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:FormEntryController.java

示例2: createModelIfNecessary

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * For the current index: Checks whether the index represents a node which
 * should exist given a non-interactive repeat, along with a count for that
 * repeat which is beneath the dynamic level specified.
 *
 * If this index does represent such a node, the new model for the repeat is
 * created behind the scenes and the index for the initial question is
 * returned.
 *
 * Note: This method will not prevent the addition of new repeat elements in
 * the interface, it will merely use the xforms repeat hint to create new
 * nodes that are assumed to exist
 *
 * @param index The index to be evaluated as to whether the underlying model is
 *        hinted to exist
 */
private void createModelIfNecessary(FormIndex index) {
    if (index.isInForm()) {
        IFormElement e = getForm().getChild(index);
        if (e instanceof GroupDef) {
            GroupDef g = (GroupDef) e;
            if (g.getRepeat() && g.getCountReference() != null) {
            	// Lu Gram: repeat count XPath needs to be contextualized for nested repeat groups
            	TreeReference countRef = FormInstance.unpackReference(g.getCountReference());
            	TreeReference contextualized = countRef.contextualize(index.getReference());
                IAnswerData count = getForm().getMainInstance().resolveReference(contextualized).getValue();
                if (count != null) {
                    long fullcount = ((Integer) count.getValue()).intValue();
                    TreeReference ref = getForm().getChildInstanceRef(index);
                    TreeElement element = getForm().getMainInstance().resolveReference(ref);
                    if (element == null) {
                        if (index.getTerminal().getInstanceIndex() < fullcount) {

                          try {
                            getForm().createNewRepeat(index);
                          } catch (InvalidReferenceException ire) {
                            ire.printStackTrace();
                            throw new RuntimeException("Invalid Reference while creting new repeat!" + ire.getMessage());
                          }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:medic,项目名称:javarosa,代码行数:47,代码来源:FormEntryModel.java

示例3: putQuestion

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
private void putQuestion (FormIndex questionIndex, boolean expanded, int qType) {
        ChatterboxWidget cw = null;

        if (!questionIndex.isInForm())
            return;

        if (expanded && qType != Q_NORMAL) {
            if (FormEntryModel.REPEAT_STRUCTURE_NON_LINEAR == model.getRepeatStructure()) {
                if (qType == Q_REPEAT_JUNCTURE) {
                    //TODO: make rollback work
//                    if (!forward && uncommittedRepeats.contains(questionIndex)) {
//                        controller.deleteRepeat(model.getForm().descendIntoRepeat(questionIndex, model.getRepetitions().size() - 1));
//                    }
                    uncommittedRepeats.removeElement(questionIndex);

                    cw = widgetFactory.getRepeatJunctureWidget(questionIndex, model, this);
                } else if (qType == Q_REPEAT_DELETE) {
                    cw = widgetFactory.getRepeatDeleteWidget(questionIndex, model, this);
                }
            } else {
                cw = widgetFactory.getNewRepeatWidget(questionIndex, model, this);
            }
            activeIsInterstitial = true;
        } else if (model.getForm().explodeIndex(questionIndex).lastElement() instanceof GroupDef) {
            //do nothing
        } else if (model.isIndexRelevant(questionIndex)) { //FIXME relevancy check
            cw = widgetFactory.getWidget(questionIndex, model,
                                          expanded ? ChatterboxWidget.VIEW_EXPANDED
                                                   : ChatterboxWidget.VIEW_COLLAPSED);
        }

        if (cw != null) {
            putFrame(cw, questionIndex);
        }
    }
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:36,代码来源:Chatterbox.java

示例4: getAdjacentIndex

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * Find a FormIndex next to the given one.
 *
 * NOTE: Leave public for Touchforms
 *
 * @param forward If true, get the next FormIndex, else get the previous one.
 */
public FormIndex getAdjacentIndex(FormIndex index, boolean forward, boolean expandRepeats) {
    boolean descend = true;
    boolean relevant;
    boolean inForm;

    do {
        if (forward) {
            index = model.incrementIndex(index, descend);
        } else {
            index = model.decrementIndex(index);
        }

        //reset all step rules
        descend = true;
        relevant = true;
        inForm = index.isInForm();
        if (inForm) {
            relevant = model.isIndexRelevant(index);

            //If this the current index is a group and it is not relevant
            //do _not_ dig into it.
            if (!relevant && model.getEvent(index) == FormEntryController.EVENT_GROUP) {
                descend = false;
            }
        }
    } while (inForm && !relevant);

    if (expandRepeats) {
        expandRepeats(index);
    }

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

示例5: createModelIfNecessary

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * For the current index: Checks whether the index represents a node which
 * should exist given a non-interactive repeat, along with a count for that
 * repeat which is beneath the dynamic level specified.
 *
 * If this index does represent such a node, the new model for the repeat is
 * created behind the scenes and the index for the initial question is
 * returned.
 *
 * Note: This method will not prevent the addition of new repeat elements in
 * the interface, it will merely use the xforms repeat hint to create new
 * nodes that are assumed to exist
 *
 * @param index To be evaluated as to whether the underlying model is
 *              hinted to exist
 */
public void createModelIfNecessary(FormIndex index) {
    if (index.isInForm()) {
        IFormElement e = getForm().getChild(index);
        if (e instanceof GroupDef) {
            GroupDef g = (GroupDef)e;
            if (g.getRepeat() && g.getCountReference() != null) {
                IAnswerData count = getForm().getMainInstance().resolveReference(g.getConextualizedCountReference(index.getReference())).getValue();
                if (count != null) {
                    int fullcount = -1;
                    try {
                        fullcount = ((Integer)new IntegerData().cast(count.uncast()).getValue()).intValue();
                    } catch (IllegalArgumentException iae) {
                        throw new RuntimeException("The repeat count value \"" + count.uncast().getString() + "\" at " + g.getConextualizedCountReference(index.getReference()).toString() + " must be a number!");
                    }
                    TreeReference ref = getForm().getChildInstanceRef(index);
                    TreeElement element = getForm().getMainInstance().resolveReference(ref);
                    if (element == null) {
                        if (index.getInstanceIndex() < fullcount) {
                            try {
                                getForm().createNewRepeat(index);
                            } catch (InvalidReferenceException ire) {
                                ire.printStackTrace();
                                throw new RuntimeException("Invalid Reference while creating new repeat!" + ire.getMessage());
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:48,代码来源:FormEntryModel.java

示例6: populateEntries

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
private void populateEntries() {
    Vector<Entry> entriesVec = new Vector<Entry>();
    FormIndex index = FormIndex.createBeginningOfFormIndex();
    FormDef form = model.getForm();

    int prevDepth = 0;

    while (!index.isEndOfFormIndex()) {
        if (index.isInForm() && model.isIndexRelevant(index)) {
            String text = "";
            boolean isHeader = false;
            Image img = null;
            if (model.getEvent(index) == FormEntryController.EVENT_QUESTION) {
                FormEntryPrompt prompt = model.getQuestionPrompt(index);
                text = getText(prompt);
            } else if (model.getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT) {
                FormEntryCaption[] hierachy = model.getCaptionHierarchy(index);
                text = "Add "
                        + (index.getElementMultiplicity() == 0 ? "a "
                                : "another ")
                        + hierachy[hierachy.length - 1].getLongText() + "?";
                try {
                    img = Image.createImage(Localization.get("plussign"));
                } catch (IOException ioe) {
                    img = null;
                    Logger.exception(ioe);
                }
            } else if ((model.getEvent(index) == FormEntryController.EVENT_GROUP)
                    || (model.getEvent(index) == FormEntryController.EVENT_REPEAT)) {
                text = getHeaderText(model.getCaptionHierarchy(index));
                isHeader = true;
            }
            if (!text.equals("")) {
                Style style = isHeader ? StyleSheet
                        .getStyle(Constants.STYLE_HEADER) : StyleSheet
                        .getStyle(Constants.STYLE_PROMPT);
                String spacer="";
                int i = isHeader?-1:0;
                while (i < index.getDepth() - 2) {
                    //ctsims : Huh?
                    //spacer = "――" + spacer;
                    spacer = "> > " + spacer;
                    i++;
                }
                text=img==null?spacer+text:text;
                entriesVec.addElement(new Entry(text, img, style, index));
            }
        }
        prevDepth = index.getDepth();
        index = model.incrementIndex(index);
    }
    entries = new Entry[entriesVec.size()];
    entriesVec.copyInto(entries);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:55,代码来源:FormSummaryView.java

示例7: createModelIfNecessary

import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
 * For the current index: Checks whether the index represents a node which
 * should exist given a non-interactive repeat, along with a count for that
 * repeat which is beneath the dynamic level specified.
 *
 * If this index does represent such a node, the new model for the repeat is
 * created behind the scenes and the index for the initial question is
 * returned.
 *
 * Note: This method will not prevent the addition of new repeat elements in
 * the interface, it will merely use the xforms repeat hint to create new
 * nodes that are assumed to exist
 *
 * @param index To be evaluated as to whether the underlying model is
 *              hinted to exist
 */
public void createModelIfNecessary(FormIndex index) {
    if (index.isInForm()) {
        IFormElement e = getForm().getChild(index);
        if (e instanceof GroupDef) {
            GroupDef g = (GroupDef)e;
            createModelForGroup(g, index, getForm());
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:26,代码来源:FormEntryModel.java


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