示例#1
0
        private String getRepetitionText(String type, FormIndex index, Boolean newrep)
        {
            if (element is GroupDef && ((GroupDef)element).Repeat && index.getElementMultiplicity() >= 0)
            {
                GroupDef g = (GroupDef)element;

                String title = getLongText();
                int    ix    = index.getElementMultiplicity() + 1;
                int    count = getNumRepetitions();

                String caption = null;
                if ("header".Equals(type))
                {
                    caption = g.entryHeader;
                }
                else if ("choose".Equals(type))
                {
                    caption = g.chooseCaption;
                    if (caption == null)
                    {
                        caption = g.entryHeader;
                    }
                }
                if (caption == null)
                {
                    return(title + " " + ix + "/" + count);
                }

                IDictionary <String, Object> vars = new Dictionary <String, Object>();
                vars.Add("name", title);
                vars.Add("i", ix);
                vars.Add("n", count);
                vars.Add("new", newrep);
                return(form.fillTemplateString(caption, index.getReference(), vars));
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /**
         * Given a FormIndex, returns the event this FormIndex represents.
         *
         * @see FormEntryController
         */
        public int getEvent(FormIndex index)
        {
            if (index.isBeginningOfFormIndex())
            {
                return(FormEntryController.EVENT_BEGINNING_OF_FORM);
            }
            else if (index.isEndOfFormIndex())
            {
                return(FormEntryController.EVENT_END_OF_FORM);
            }

            // This came from chatterbox, and is unclear how correct it is,
            // commented out for now.
            // DELETEME: If things work fine
            // Vector defs = form.explodeIndex(index);
            // IFormElement last = (defs.size() == 0 ? null : (IFormElement)
            // defs.lastElement());
            IFormElement element = form.getChild(index);

            if (element is GroupDef)
            {
                if (((GroupDef)element).Repeat)
                {
                    if (repeatStructure != REPEAT_STRUCTURE_NON_LINEAR && form.Instance.resolveReference(form.getChildInstanceRef(index)) == null)
                    {
                        return(FormEntryController.EVENT_PROMPT_NEW_REPEAT);
                    }
                    else if (repeatStructure == REPEAT_STRUCTURE_NON_LINEAR && index.getElementMultiplicity() == TreeReference.INDEX_REPEAT_JUNCTURE)
                    {
                        return(FormEntryController.EVENT_REPEAT_JUNCTURE);
                    }
                    else
                    {
                        return(FormEntryController.EVENT_REPEAT);
                    }
                }
                else
                {
                    return(FormEntryController.EVENT_GROUP);
                }
            }
            else
            {
                return(FormEntryController.EVENT_QUESTION);
            }
        }
示例#3
0
 public int getMultiplicity()
 {
     return(index.getElementMultiplicity());
 }