本文整理汇总了Java中org.javarosa.core.model.FormIndex.getNextLevel方法的典型用法代码示例。如果您正苦于以下问题:Java FormIndex.getNextLevel方法的具体用法?Java FormIndex.getNextLevel怎么用?Java FormIndex.getNextLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.FormIndex
的用法示例。
在下文中一共展示了FormIndex.getNextLevel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCaptionHierarchy
import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
* Returns a hierarchical list of FormEntryCaption objects for the given
* FormIndex
*
* @param index
* @return list of FormEntryCaptions in hierarchical order
*/
public FormEntryCaption[] getCaptionHierarchy(FormIndex index) {
List<FormEntryCaption> captions = new ArrayList<FormEntryCaption>();
FormIndex remaining = index;
while (remaining != null) {
remaining = remaining.getNextLevel();
FormIndex localIndex = index.diff(remaining);
IFormElement element = form.getChild(localIndex);
if (element != null) {
FormEntryCaption caption = null;
if (element instanceof GroupDef)
caption = new FormEntryCaption(getForm(), localIndex);
else if (element instanceof QuestionDef)
caption = new FormEntryPrompt(getForm(), localIndex);
if (caption != null) {
captions.add(caption);
}
}
}
FormEntryCaption[] captionArray = new FormEntryCaption[captions.size()];
return captions.toArray(captionArray);
}
示例2: getCaptionHierarchy
import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
* Returns a hierarchical list of FormEntryCaption objects for the given
* FormIndex
*
* @return list of FormEntryCaptions in hierarchical order
*/
public FormEntryCaption[] getCaptionHierarchy(FormIndex index) {
Vector<FormEntryCaption> captions = new Vector<FormEntryCaption>();
FormIndex remaining = index;
while (remaining != null) {
remaining = remaining.getNextLevel();
FormIndex localIndex = index.diff(remaining);
IFormElement element = form.getChild(localIndex);
if (element != null) {
FormEntryCaption caption = null;
if (element instanceof GroupDef)
caption = new FormEntryCaption(getForm(), localIndex);
else if (element instanceof QuestionDef)
caption = new FormEntryPrompt(getForm(), localIndex);
if (caption != null) {
captions.addElement(caption);
}
}
}
FormEntryCaption[] captionArray = new FormEntryCaption[captions.size()];
captions.copyInto(captionArray);
return captionArray;
}
示例3: getCaptionHierarchy
import org.javarosa.core.model.FormIndex; //导入方法依赖的package包/类
/**
* Returns a hierarchical list of FormEntryCaption objects for the given
* FormIndex
*
* @return list of FormEntryCaptions in hierarchical order
*/
public FormEntryCaption[] getCaptionHierarchy(FormIndex index) {
Vector<FormEntryCaption> captions = new Vector<>();
FormIndex remaining = index;
while (remaining != null) {
remaining = remaining.getNextLevel();
FormIndex localIndex = index.diff(remaining);
IFormElement element = form.getChild(localIndex);
if (element != null) {
FormEntryCaption caption = null;
if (element instanceof GroupDef)
caption = new FormEntryCaption(getForm(), localIndex);
else if (element instanceof QuestionDef)
caption = new FormEntryPrompt(getForm(), localIndex);
if (caption != null) {
captions.addElement(caption);
}
}
}
FormEntryCaption[] captionArray = new FormEntryCaption[captions.size()];
captions.copyInto(captionArray);
return captionArray;
}
示例4: 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;
}
示例5: 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));
}
示例6: 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;
}