Esempio n. 1
0
        public FormIndex decrementIndex(FormIndex index)
        {
            ArrayList indexes        = new ArrayList();
            ArrayList multiplicities = new ArrayList();
            ArrayList elements       = new ArrayList();

            if (index.isBeginningOfFormIndex())
            {
                return(index);
            }
            else if (index.isEndOfFormIndex())
            {
                if (form.Children == null || form.Children.Count == 0)
                {
                    return(FormIndex.createBeginningOfFormIndex());
                }
            }
            else
            {
                form.collapseIndex(index, indexes, multiplicities, elements);
            }

            decrementHelper(indexes, multiplicities, elements);

            if (indexes.Count == 0)
            {
                return(FormIndex.createBeginningOfFormIndex());
            }
            else
            {
                return(form.buildIndex(indexes, multiplicities, elements));
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 3
0
        /**
         * @param index
         * @return true if the element at the specified index is read only
         */
        public Boolean isIndexReadonly(FormIndex index)
        {
            if (index.isBeginningOfFormIndex() || index.isEndOfFormIndex())
            {
                return(true);
            }

            TreeReference ref_           = form.getChildInstanceRef(index);
            Boolean       isAskNewRepeat = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT ||
                                            getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);

            if (isAskNewRepeat)
            {
                return(false);
            }
            else
            {
                TreeElement node = form.Instance.resolveReference(ref_);
                return(!node.isEnabled());
            }
        }