Beispiel #1
0
        private static List <Entity> ParseEntities(MapDetails Map)
        {
            List <Entity>      Entities = new List <Entity>();
            List <PathDetails> Paths    = new List <PathDetails>();

            foreach (XmlNode ObjectGroupNode in Map.MapElement.SelectNodes("objectgroup"))
            {
                foreach (XmlNode ObjectNode in ObjectGroupNode.SelectNodes("object"))
                {
                    ObjectType Type = ReadObjectType(ObjectNode);
                    if (Type == ObjectType.Path)
                    {
                        var Path = ParsePath(ObjectNode);
                        Paths.Add(Path);
                    }
                    else if (Type == ObjectType.Entity)
                    {
                        var Entity = ParseEntity(ObjectNode);
                        Entities.Add(Entity);
                    }
                    else
                    {
                        throw new ArgumentException("Unknown object type '" + Type + "'.");
                    }
                }
            }

            foreach (var Path in Paths)
            {
                var Entity = Entities.Where(c => c.Name.Equals(Path.EntityName, StringComparison.InvariantCultureIgnoreCase));
                foreach (var e in Entity)
                {
                    var PathComponent = e.GetComponent <PathComponent>();
                    if (PathComponent == null)
                    {
                        PathComponent = new PathComponent();
                        e.Components.Add(PathComponent);
                    }
                    if (PathComponent.Nodes != null)
                    {
                        PathComponent.Nodes.Clear();
                    }
                    foreach (var Node in Path.Nodes)
                    {
                        PathComponent.AddNode(Node);
                    }
                }
            }
            return(Entities);
        }
Beispiel #2
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            if (!g.IsObject())
            {
                return;
            }

            ObjectGroupNode og = (ObjectGroupNode)g;

            ConcreteInteractionObject cio = ui.Core.ObjectRegistry.ChooseWidget((ApplianceObject)og.Object);

            if (cio != null)
            {
                g.Decorations.Add(UnitDecision.DECISION_KEY, new UnitDecision(cio));
            }
        }
Beispiel #3
0
        protected void doNotRenderObject(ApplianceObject ao)
        {
            ObjectGroupNode objGrp = null;

            // find the object
            if (_specSnippet.IsObject() &&
                ((ObjectGroupNode)_specSnippet).Object == ao)
            {
                objGrp = (ObjectGroupNode)_specSnippet;
            }
            else
            {
                // find the object group that contains ao
                objGrp = findObjectGroup(_specSnippet, ao);
            }

            objGrp.Parent.Children.Remove(objGrp);
            _templateGroup.Children.Add(objGrp);
            objGrp.Parent = _templateGroup;
        }
Beispiel #4
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            if (!g.IsList())
            {
                return;
            }

            ListGroupNode lg = (ListGroupNode)g;

            ConcreteInteractionObject cio =
                ui.Core.ObjectRegistry.ChooseWidget(lg);

            g.Decorations.Add(ListDecision.DECISION_KEY, new ListDecision());

            if (cio != null)
            {
                g.Decorations.Add(UnitDecision.DECISION_KEY, new UnitDecision(cio));
            }
            else
            {
                // add in some components to allow the user to scroll through elements
                // in the list and make selections (if relevant)

                ApplianceState  indexState = new ListIndexState(lg.Appliance, lg);
                ObjectGroupNode idxGrp     = new ObjectGroupNode(indexState);

                lg.Children.Add(idxGrp);
                idxGrp.Parent = lg;

                if (lg.SelectionType == SelectionType.One)
                {
                    lg.SelectionState.ValueChangedEvent += new PUC.ApplianceState.ValueChangedHandler(((ListIndexState)indexState).SelectionChanged);
                }

                // TODO: Implement multiple selections code
            }
        }
        /*
         * Process Method
         */

        public override ListNode Process(GroupNode g, ListNode list)
        {
            // look for MutualExclusionDecisions

            object o = g.Decorations[MutualExclusionDecision.DECISION_KEY];

            if (o != null && o is MutualExclusionDecision)
            {
                MutualExclusionDecision d = (MutualExclusionDecision)o;

                if (!d.Handled &&
                    d.State.Type.ValueSpace is EnumeratedSpace)
                {
                    EnumeratedSpace espc = (EnumeratedSpace)d.State.Type.ValueSpace;

                    if (espc.GetItemCount() == (d.DependencySets.Count - 1))
                    {
                        for (int i = 1; i < d.DependencySets.Count; i++)
                        {
                            ArrayList dep = (ArrayList)d.DependencySets[i];

                            if (dep.Count != 1)
                            {
                                // Globals.AddLogLine("size! " + dep.Count );
                                return(list);
                            }
                            if (!(dep[0] is EqualsDependency))
                            {
                                // Globals.AddLogLine("not equals!");
                                return(list);
                            }
                        }
                    }
                    else
                    {
                        return(list);
                    }

                    // we need a pointer to the GroupNode that contains the state
                    // variable that we are looking at (because tree manipulations
                    // will need to use it)

                    ObjectGroupNode stateGroup = null;

                    BranchGroupNode bg = (BranchGroupNode)g;
                    IEnumerator     e  = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (e.Current is ObjectGroupNode &&
                            ((ObjectGroupNode)e.Current).Object == d.State)
                        {
                            stateGroup = (ObjectGroupNode)e.Current;
                            break;
                        }
                    }

                    // re-order the tree

                    ArrayList childOrder = new ArrayList();

                    bg.Children.Remove(stateGroup);

                    BranchGroupNode midG = new BranchGroupNode();

                    midG.Children = bg.Children;
                    e             = midG.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        ((GroupNode)e.Current).Parent = midG;
                    }

                    bg.Children = new ArrayList();

                    ArrayList dset = (ArrayList)d.ChildSets[0];
                    if (dset.Count > 0)
                    {
                        e = dset.GetEnumerator();
                        while (e.MoveNext())
                        {
                            GroupNode c = (GroupNode)e.Current;

                            c.Parent = bg;

                            midG.Children.Remove(c);
                            bg.Children.Add(c);
                        }
                    }

                    bg.Children.Add(midG);
                    midG.Parent       = bg;
                    stateGroup.Parent = bg;

                    for (int i = 1; i < d.ChildSets.Count; i++)
                    {
                        dset = (ArrayList)d.ChildSets[i];

                        if (dset.Count > 1)
                        {
                            BranchGroupNode newG = new BranchGroupNode();

                            newG.Parent = midG;

                            e = dset.GetEnumerator();
                            while (e.MoveNext())
                            {
                                GroupNode c = (GroupNode)e.Current;

                                c.Parent = newG;

                                midG.Children.Remove(c);
                                newG.Children.Add(c);
                            }

                            childOrder.Insert(i - 1, newG);
                        }
                        else if (dset.Count == 0)
                        {
                            BranchGroupNode newG = new BranchGroupNode();

                            newG.Parent = midG;
                            midG.Children.Add(newG);

                            childOrder.Insert(i - 1, newG);
                        }
                        else
                        {
                            childOrder.Insert(i - 1, dset[0]);
                        }
                    }

                    d.DependencySets.RemoveAt(0);

                    // now create StateValueListNodes from the re-orged group tree
                    // these nodes will be picked up by an additional rule later
                    // in the generation process
                    StateValueListNode newList = null;
                    for (int i = 0; i < childOrder.Count; i++)
                    {
                        GroupNode group   = (GroupNode)childOrder[i];
                        ArrayList aryDeps = (ArrayList)d.DependencySets[i];

                        EqualsDependency eqDep = (EqualsDependency)aryDeps[0];

                        newList = new StateValueListNode(d.State, eqDep.Value);
                        list.Add(newList);

                        group.Decorations.Add(ListNodeDecision.DECISION_KEY, new ListNodeDecision(newList, d));
                    }

                    d.Handled = true;
                }
            }

            return(list);
        }
Beispiel #6
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            // look for MutualExclusionDecisions

            object o = g.Decorations[MutualExclusionDecision.DECISION_KEY];

            if (o != null && o is MutualExclusionDecision)
            {
                MutualExclusionDecision d = (MutualExclusionDecision)o;

                if (!d.Handled &&
                    d.State.Type.ValueSpace is EnumeratedSpace)
                {
                    object          stateval = d.State.Value;
                    EnumeratedSpace espc     = (EnumeratedSpace)d.State.Type.ValueSpace;

                    if (espc.GetItemCount() == (d.DependencySets.Count - 1))
                    {
                        for (int i = 1; i < d.DependencySets.Count; i++)
                        {
                            ArrayList dep = (ArrayList)d.DependencySets[i];

                            if (dep.Count != 1)
                            {
                                // Globals.AddLogLine("size! " + dep.Count );
                                return;
                            }
                            if (!(dep[0] is EqualsDependency))
                            {
                                // Globals.AddLogLine("not equals!");
                                return;
                            }
                        }
                    }
                    else
                    {
                        return;
                    }

                    // we need a pointer to the GroupNode that contains the state
                    // variable that we are looking at (because tree manipulations
                    // will need to use it)

                    ObjectGroupNode stateGroup = null;
                    BranchGroupNode bg         = (BranchGroupNode)g;

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).IsObject() &&
                            ((ObjectGroupNode)e.Current).Object == d.State)
                        {
                            stateGroup = (ObjectGroupNode)e.Current;
                            break;
                        }
                    }

                    // re-order the tree

                    ArrayList childOrder = new ArrayList();

                    bg.Children.Remove(stateGroup);

                    BranchGroupNode midG = new BranchGroupNode();

                    midG.Children = bg.Children;
                    e             = midG.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        ((GroupNode)e.Current).Parent = midG;
                    }

                    bg.Children = new ArrayList();

                    ArrayList dset = (ArrayList)d.ChildSets[0];
                    if (dset.Count > 0)
                    {
                        e = dset.GetEnumerator();
                        while (e.MoveNext())
                        {
                            GroupNode c = (GroupNode)e.Current;

                            c.Parent = bg;

                            midG.Children.Remove(c);
                            bg.Children.Add(c);
                        }
                    }

                    bg.Children.Add(midG);
                    midG.Parent       = bg;
                    stateGroup.Parent = bg;

                    for (int i = 1; i < d.ChildSets.Count; i++)
                    {
                        dset = (ArrayList)d.ChildSets[i];

                        if (dset.Count > 1)
                        {
                            BranchGroupNode newG = new BranchGroupNode();
                            newG.Parent = midG;

                            e = dset.GetEnumerator();
                            while (e.MoveNext())
                            {
                                GroupNode c = (GroupNode)e.Current;

                                c.Parent = newG;

                                midG.Children.Remove(c);
                                newG.Children.Add(c);
                            }

                            childOrder.Insert(i - 1, newG);
                        }
                        else if (dset.Count == 0)
                        {
                            BranchGroupNode newG = new BranchGroupNode();

                            newG.Parent   = midG;
                            newG.Children = new ArrayList();

                            midG.Children.Add(newG);

                            childOrder.Insert(i - 1, newG);
                        }
                        else
                        {
                            childOrder.Insert(i - 1, dset[0]);
                        }
                    }

                    d.DependencySets.RemoveAt(0);

                    OrganizationDecision newDecision = new TabbedOverlapOrgDecision(d, ui, d.State, childOrder, d.DependencySets, true);
                    midG.Decorations.Add(OrganizationDecision.DECISION_KEY, newDecision);

                    d.Handled = true;
                }
            }
        }
Beispiel #7
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            // look for MutualExclusionDecisions

            object o = g.Decorations[MutualExclusionDecision.DECISION_KEY];

            if (o != null && o is MutualExclusionDecision)
            {
                MutualExclusionDecision d = (MutualExclusionDecision)o;

                if (!d.Handled)
                {
                    // this will never occur on an ObjectGroupNode
                    BranchGroupNode bg = (BranchGroupNode)g;

                    // we need a pointer to the GroupNode that contains the state
                    // variable that we are looking at (because tree manipulations
                    // will need to use it)

                    ObjectGroupNode stateGroup = null;

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).IsObject() &&
                            ((ObjectGroupNode)e.Current).Object == d.State)
                        {
                            stateGroup = (ObjectGroupNode)e.Current;
                            break;
                        }
                    }

                    // re-order the tree

                    ArrayList childOrder = new ArrayList();

                    bg.Children.Remove(stateGroup);

                    BranchGroupNode midG = new BranchGroupNode();

                    midG.Children = bg.Children;
                    e             = midG.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        ((GroupNode)e.Current).Parent = midG;
                    }

                    bg.Children = new ArrayList();

                    ArrayList dset = (ArrayList)d.ChildSets[0];
                    if (dset.Count > 0)
                    {
                        e = dset.GetEnumerator();
                        while (e.MoveNext())
                        {
                            GroupNode c = (GroupNode)e.Current;

                            c.Parent = bg;

                            midG.Children.Remove(c);
                            bg.Children.Add(c);
                        }
                    }

                    bg.Children.Add(stateGroup);
                    bg.Children.Add(midG);
                    midG.Parent       = bg;
                    stateGroup.Parent = bg;

                    for (int i = 1; i < d.ChildSets.Count; i++)
                    {
                        dset = (ArrayList)d.ChildSets[i];

                        if (dset.Count > 1)
                        {
                            BranchGroupNode newG = new BranchGroupNode();
                            newG.Parent = midG;

                            e = dset.GetEnumerator();
                            while (e.MoveNext())
                            {
                                GroupNode c = (GroupNode)e.Current;

                                c.Parent = newG;

                                midG.Children.Remove(c);
                                newG.Children.Add(c);
                            }

                            childOrder.Insert(i - 1, newG);
                        }
                        else if (dset.Count == 0)
                        {
                            BranchGroupNode newG = new BranchGroupNode();

                            newG.Parent   = midG;
                            newG.Children = new ArrayList();

                            midG.Children.Add(newG);

                            childOrder.Insert(i - 1, newG);
                        }
                        else
                        {
                            childOrder.Insert(i - 1, dset[0]);
                        }
                    }

                    d.DependencySets.RemoveAt(0);

                    OrganizationDecision newDecision = new ExternalOverlapOrgDecision(d, d.State, childOrder, d.DependencySets);
                    midG.Decorations.Add(OrganizationDecision.DECISION_KEY, newDecision);

                    d.Handled = true;
                }
            }
        }
Beispiel #8
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            // look for MutualExclusionDecisions

            object o = g.Decorations[MutualExclusionDecision.DECISION_KEY];

            if (o != null && o is MutualExclusionDecision)
            {
                MutualExclusionDecision d = (MutualExclusionDecision)o;

                if (!d.Handled &&
                    d.State.Type.ValueSpace is BooleanSpace &&
                    ((ArrayList)d.ChildSets[0]).Count == 0)
                {
                    // we need a pointer to the GroupNode that contains the state
                    // variable that we are looking at (because tree manipulations
                    // will need to use it)

                    BranchGroupNode bg         = (BranchGroupNode)g;
                    ObjectGroupNode stateGroup = null;

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).IsObject() &&
                            ((ObjectGroupNode)e.Current).Object == d.State)
                        {
                            stateGroup = (ObjectGroupNode)e.Current;
                            break;
                        }
                    }

                    // now we modify the tree to incluce a power panel

                    BranchGroupNode newG = new BranchGroupNode();

                    newG.Parent   = bg;
                    newG.Children = bg.Children;

                    bg.Children = new ArrayList();

                    // make two groups under the common group
                    bg.Children.Add(stateGroup);
                    bg.Children.Add(newG);

                    d.State.InternalController = true;

                    e = newG.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        ((GroupNode)e.Current).Parent = newG;
                    }

                    ArrayList n = (ArrayList)d.DependencySets[0];
                    ArrayList i = (ArrayList)d.DependencySets[1];

                    EqualsDependency equalDep = (EqualsDependency)i[0];
                    if ((bool)equalDep.Value)
                    {
                        n.Add(new EqualsDependency(equalDep.State, "false"));
                    }
                    else
                    {
                        n.Add(new EqualsDependency(equalDep.State, "true"));
                    }

                    OrganizationDecision newDecision = new InternalOverlapOrgDecision(d, d.State, bg.Children, d.DependencySets);
                    g.Decorations.Add(OrganizationDecision.DECISION_KEY, newDecision);

                    // make sure that other rules don't try to reorganize this node
                    d.Handled = true;
                }
            }
        }