Exemplo n.º 1
0
        private void  performAction(TreeElement node, int action)
        {
            switch (action)
            {
            case ACTION_NULL:  break;

            case ACTION_SHOW:  node.setRelevant(true); break;

            case ACTION_HIDE:  node.setRelevant(false); break;

            case ACTION_ENABLE:  node.setEnabled(true); break;

            case ACTION_DISABLE:  node.setEnabled(false); break;

            case ACTION_LOCK: /* not supported */; break;

            case ACTION_UNLOCK: /* not supported */; break;

            case ACTION_REQUIRE:  node.Required = true; break;

            case ACTION_DONT_REQUIRE:  node.Required = false; break;
            }
        }
Exemplo n.º 2
0
        /// <summary> recursively read in a node of the instance, by filling out the template instance</summary>
        /// <param name="e">
        /// </param>
        /// <param name="ref">
        /// </param>
        /// <param name="in">
        /// </param>
        /// <param name="pf">
        /// </param>
        /// <throws>  IOException </throws>
        /// <throws>  DeserializationException </throws>
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        private void  readTreeElement(TreeElement e, System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            TreeElement templ   = instance.getTemplatePath(e.Ref);
            bool        isGroup = !templ.Leaf;

            if (isGroup)
            {
                System.Collections.ArrayList childTypes = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
                for (int i = 0; i < templ.NumChildren; i++)
                {
                    System.String childName = templ.getChildAt(i).Name;
                    if (!childTypes.Contains(childName))
                    {
                        childTypes.Add(childName);
                    }
                }

                for (int i = 0; i < childTypes.Count; i++)
                {
                    System.String childName = (System.String)childTypes[i];

                    TreeReference childTemplRef = e.Ref.extendRef(childName, 0);
                    TreeElement   childTempl    = instance.getTemplatePath(childTemplRef);

                    bool repeatable = childTempl.Repeatable;
                    int  n          = ExtUtil.readInt(in_Renamed);

                    bool relevant = (n > 0);
                    if (!repeatable && n > 1)
                    {
                        throw new DeserializationException("Detected repeated instances of a non-repeatable node");
                    }

                    if (repeatable)
                    {
                        int mult = e.getChildMultiplicity(childName);
                        for (int j = mult - 1; j >= 0; j--)
                        {
                            e.removeChild(childName, j);
                        }

                        for (int j = 0; j < n; j++)
                        {
                            TreeReference dstRef = e.Ref.extendRef(childName, j);
                            try
                            {
                                instance.copyNode(childTempl, dstRef);
                            }
                            catch (InvalidReferenceException ire)
                            {
                                //If there is an invalid reference, this is a malformed instance,
                                //so we'll throw a Deserialization exception.
                                TreeReference r = ire.InvalidReference;
                                if (r == null)
                                {
                                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                                    throw new DeserializationException("Null Reference while attempting to deserialize! " + ire.Message);
                                }
                                else
                                {
                                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                                    throw new DeserializationException("Invalid Reference while attemtping to deserialize! Reference: " + r.toString(true) + " | " + ire.Message);
                                }
                            }

                            TreeElement child = e.getChild(childName, j);
                            child.setRelevant(true);
                            readTreeElement(child, in_Renamed, pf);
                        }
                    }
                    else
                    {
                        TreeElement child = e.getChild(childName, 0);
                        child.setRelevant(relevant);
                        if (relevant)
                        {
                            readTreeElement(child, in_Renamed, pf);
                        }
                    }
                }
            }
            else
            {
                e.Value = (IAnswerData)ExtUtil.read(in_Renamed, new ExtWrapAnswerData(this, e.DataType));
            }
        }