예제 #1
0
        protected BranchGroupNode findInTree(GroupNode g,
                                             ApplianceObject ao)
        {
            // if a unit has been found the represents this portion of the
            // group tree, then don't search for mutual exclusion within it
            // (any such relationships will presumably be handled by the
            //  the custom CIO)
            if (g.Decorations[UnitDecision.DECISION_KEY] != null)
            {
                return(null);
            }

            if (g.IsObject())
            {
                if (((ObjectGroupNode)g).Object == ao)
                {
                    return(g.Parent);
                }
            }
            else
            {
                IEnumerator e = ((BranchGroupNode)g).Children.GetEnumerator();
                while (e.MoveNext())
                {
                    BranchGroupNode br = findInTree((GroupNode)e.Current, ao);
                    if (br != null)
                    {
                        return(br);
                    }
                }
            }

            return(null);
        }
예제 #2
0
        /*
         * Member Methods
         */

        protected void extractStates(BranchGroupNode bg, bool levelOne)
        {
            IEnumerator e = bg.Children.GetEnumerator();

            while (e.MoveNext())
            {
                GroupNode ig = (GroupNode)e.Current;

                if (levelOne &&
                    (ig.Name == ListGroupNode.LIST_SELECTION_STATE ||
                     ig.Name == ListGroupNode.LIST_LENGTH_STATE))
                {
                    continue;
                }

                if (ig.IsObject() && ((ObjectGroupNode)ig).Object.State)
                {
                    _states.Add(((ObjectGroupNode)ig).Object);
                }

                if (!ig.IsObject())
                {
                    extractStates((BranchGroupNode)e.Current, false);
                }
            }
        }
예제 #3
0
        protected bool readonlyHelper(BranchGroupNode bg)
        {
            IEnumerator e = bg.Children.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Current is ObjectGroupNode)
                {
                    if (((ObjectGroupNode)e.Current).Object.State &&
                        !((ApplianceState)((ObjectGroupNode)e.Current).Object).ReadOnly)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!readonlyHelper((BranchGroupNode)e.Current))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #4
0
        protected void generateOrganization(GroupNode root, ArrayList dependedObjects)
        {
            IEnumerator e = dependedObjects.GetEnumerator();

            while (e.MoveNext())
            {
                ApplianceState state = (ApplianceState)e.Current;

                BranchGroupNode g = findInTree(root, state);

                if (g != null)
                {
                    generateOrganizationAtGroupNode(g, state);
                }
            }
        }
예제 #5
0
        public SmartCIO(Control control, GroupNode specSnippet)
            : base(control)
        {
            _specSnippet = specSnippet;

            // attempt to find labels
            if (!specSnippet.IsObject())
            {
                _labels = specSnippet.Labels;
            }
            else if (specSnippet.IsObject())
            {
                _labels = ((ObjectGroupNode)specSnippet).Object.Labels;
            }

            // create the Template group
            _templateGroup = new BranchGroupNode();


            // extract the objects that make up this type block
            _objects = new Hashtable();
            if (_specSnippet.IsObject())
            {
                _objects[SINGLE_STATE] = ((ObjectGroupNode)specSnippet).Object;

                // determine the location of this group in its parent
                int parentIdx = _specSnippet.Parent.Children.IndexOf(_specSnippet);
                if (parentIdx < 0)                   // this should never happen
                {
                    parentIdx = 0;
                }

                // make the template group
                _specSnippet.Parent.Children.Insert(parentIdx + 1, _templateGroup);
                _templateGroup.Parent = _specSnippet.Parent;
            }
            else
            {
                extractObjects(specSnippet);

                // make the template group
                ((BranchGroupNode)specSnippet).Children.Add(_templateGroup);
                _templateGroup.Parent = (BranchGroupNode)_specSnippet;
            }
        }
예제 #6
0
        /*
         * Process Method
         */
        public override PanelNode Process(GroupNode g, PanelNode p)
        {
            if (g is BranchGroupNode)
            {
                BranchGroupNode bg = (BranchGroupNode)g;

                if (bg.Children.Count == 2 &&
                    !g.ContainsGroups())
                {
                    IEnumerator child = bg.Children.GetEnumerator();
                    while (child.MoveNext())
                    {
                        if (((ObjectGroupNode)child.Current).Decorations[UnitDecision.DECISION_KEY] == null ||
                            ((UnitDecision)((ObjectGroupNode)child.Current).Decorations[UnitDecision.DECISION_KEY]).Handled ||
                            ((UnitDecision)((ObjectGroupNode)child.Current).Decorations[UnitDecision.DECISION_KEY]).CIO.HasLabel())
                        {
                            return(p);
                        }
                    }

                    LabelCIO labelCIO = null;
                    if (g.Labels != null)
                    {
                        labelCIO = new LabelCIO(g.Labels);
                    }

                    UnitDecision d =
                        (UnitDecision)((ObjectGroupNode)bg.Children[0]).Decorations[UnitDecision.DECISION_KEY];
                    ConcreteInteractionObject cio1 = d.CIO;
                    d.Handled = true;

                    d = (UnitDecision)((ObjectGroupNode)bg.Children[1]).Decorations[UnitDecision.DECISION_KEY];
                    ConcreteInteractionObject cio2 = d.CIO;
                    d.Handled = true;

                    LabeledTwoCompRow r = new LabeledTwoCompRow(g, p, labelCIO, cio1, cio2);

                    p.AddRow(r);
                }
            }

            return(p);
        }
예제 #7
0
        protected void searchHelper(GroupNode g, Appliance a)
        {
            if (g.Decorations[UnitDecision.DECISION_KEY] != null)
            {
                return;
            }

            if (g.HasType())
            {
                SmartCIO cio = a.GetUIGenerator().Core.SmartCIOMgr.GetSmartCIO(g.HighlevelType, g);

                if (cio != null)
                {
                    cio.TemplateGroup.Decorations[UnitDecision.DECISION_KEY] = new UnitDecision(cio);
                }
            }

            if (g.IsObject() && ((ObjectGroupNode)g).Object.HighlevelType != null)
            {
                SmartCIO cio = a.GetUIGenerator().Core.SmartCIOMgr.GetSmartCIO(((ObjectGroupNode)g).Object.HighlevelType, g);

                if (cio != null)
                {
                    cio.TemplateGroup.Decorations[UnitDecision.DECISION_KEY] = new UnitDecision(cio);
                }
            }
            else if (!g.IsObject())
            {
                BranchGroupNode bg = (BranchGroupNode)g;

                if (bg.Count == 0)
                {
                    return;
                }

                for (int i = 0; i < bg.Children.Count; i++)
                {
                    searchHelper((GroupNode)bg.Children[i], a);
                }
            }
        }
예제 #8
0
        protected void processHelper(GroupNode g, UIGenerator ui, ListNode node)
        {
            if (g == null)
            {
                return;
            }

            node = invokeRules(g, ui, node);

            if (g is ObjectGroupNode)
            {
                return;
            }

            BranchGroupNode bg = (BranchGroupNode)g;

            for (int i = 0; i < bg.Count; i++)
            {
                processHelper((GroupNode)bg.Children[i], ui, node);
            }
        }
예제 #9
0
        protected Hashtable collectDependencies(GroupNode g,
                                                ApplianceState state)
        {
            Hashtable result = new Hashtable();

            BranchGroupNode bg = (BranchGroupNode)g;
            IEnumerator     e  = bg.Children.GetEnumerator();

            while (e.MoveNext())
            {
                GroupNode ng = (GroupNode)e.Current;

                ArrayList deps = collectDependency(ng, state);

                filterDependencies(deps);

                result[ng] = deps;
            }

            return(result);
        }
예제 #10
0
        protected void processHelper(GroupNode g, UIGenerator ui)
        {
            if (g == null)
            {
                return;
            }

            invokeRules(g, ui);

            if (g.IsObject())
            {
                return;
            }

            BranchGroupNode bg = (BranchGroupNode)g;

            for (int i = 0; i < bg.Children.Count; i++)
            {
                processHelper((GroupNode)bg.Children[i], ui);
            }
        }
예제 #11
0
        protected void phaseHelper(GroupNode g, PanelNode p)
        {
            PanelNode panel = p;

            if (g == null)
            {
                return;
            }

            panel = invokeRules(g, panel);

            if (g.IsObject())
            {
                return;
            }

            BranchGroupNode bg = (BranchGroupNode)g;

            for (int i = 0; i < bg.Children.Count; i++)
            {
                phaseHelper((GroupNode)bg.Children[i], panel);
            }
        }
예제 #12
0
        public TabbedOverlappingPanelsNode(BranchGroupNode g)
        {
            _tabbedPanel = new TabbedPanelsCIO();
            _tabNodes    = new ArrayList();

            _groupToTabMap = new Hashtable();

            IEnumerator e = g.Children.GetEnumerator();

            while (e.MoveNext())
            {
                TabbedPanelCIO p = new TabbedPanelCIO(((GroupNode)e.Current).Labels);
                ((TabbedPanelsCIO)_tabbedPanel).AddTab(p);

                TabPanelNode tp = new TabPanelNode(p, (GroupNode)e.Current);
                _groupToTabMap[e.Current] = tp;
                _tabNodes.Add(tp);
                AddPanel(tp);

                ((GroupNode)e.Current).Decorations[PanelDecision.DECISION_KEY] =
                    new PanelDecision((PanelNode)tp.GetChildNode());
            }
        }
예제 #13
0
        protected void generateOrganizationAtGroupNode(BranchGroupNode g, ApplianceState state)
        {
            /*
             * Step #1: Extract and combine dependencies from each group
             * at this level of the tree, ignoring repeated states.
             *
             * Need to create a data structure here.  It will be a Hashtable
             * of ArrayLists, hashed on the GroupNode ref.
             */

            Hashtable groupDeps = collectDependencies(g, state);

            /*
             * Step #2: For every group & object that depends on the
             * state, check for mutual exclusion.
             */

            ArrayList mutexSets = findMutualExclusion(g, state, groupDeps);

            ArrayList childSets = (ArrayList)mutexSets[0];
            ArrayList depSets   = (ArrayList)mutexSets[1];

            /*
             * Step #3: Save the relevent information into a Decision and
             * store it in the root node of the tree.
             */

            Decision d = new MutualExclusionDecision(state, childSets, depSets);

            // TODO: Allow multiple Multiple MutualExclusionDecisions to be
            // associated with a particular group
            if (g.Decorations[MutualExclusionDecision.DECISION_KEY] == null)
            {
                g.Decorations.Add(MutualExclusionDecision.DECISION_KEY, d);
            }
        }
예제 #14
0
        protected int searchHelper(GroupNode g, bool listBelow, Appliance a)
        {
            if (g.IsObject())
            {
                return(0);
            }

            BranchGroupNode bg = (BranchGroupNode)g;

            if (bg.Count == 0)
            {
                return(0);
            }

            ListDecision d = null;

            if (bg.IsList())
            {
                d = new ListDecision(!listBelow);
                bg.Decorations[ListDecision.DECISION_KEY] = d;
            }

            int dim = 0;

            for (int i = 0; i < bg.Children.Count; i++)
            {
                dim = Math.Max(dim, searchHelper((GroupNode)bg.Children[i], d != null, a));
            }

            if (d != null)
            {
                return(d.Dimensions = dim + 1);
            }

            return(dim);
        }
예제 #15
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;
                }
            }
        }
예제 #16
0
        /*
         * 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);
        }
예제 #17
0
        /// <summary>
        /// This rule looks for InsufficientHeight layout problems, and attempts
        /// to fix them by splitting controls onto multiple tabbed panels.
        /// </summary>
        /// <param name="problem">the layout problem to fix</param>
        /// <param name="node">the root of the interface tree</param>
        /// <param name="ui">the UIGenerator object, which contains global variables to the layout process</param>
        public override InterfaceNode Process(LayoutProblem problem, InterfaceNode root, UIGenerator ui)
        {
            if (problem is InsufficientHeight)
            {
                InsufficientHeight prob = (InsufficientHeight)problem;

                // we will use tabs if the group associated with this panel
                // has only BranchGroupNodes as children, and each of those
                // groups has labels

                // Step #1: check if the above criteria are true

                if (prob.Panel.Group is BranchGroupNode)
                {
                    BranchGroupNode bg = (BranchGroupNode)prob.Panel.Group;

                    if (!bg.ContainsOnlyGroups())
                    {
                        return(root);
                    }

                    while (bg.Count == 1)
                    {
                        bg = (BranchGroupNode)bg.Children[0];

                        if (!bg.ContainsOnlyGroups())
                        {
                            return(root);
                        }
                    }

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).Labels == null)
                        {
                            return(root);
                        }
                    }

                    // If we get here, all of the criteria have been met.

                    // Now we insert our tabbed panel.
                    TabbedOverlappingPanelsNode tabs = new TabbedOverlappingPanelsNode(bg);
                    prob.Panel.Container.GetControl().Controls.Remove(prob.Panel.GetContainerCIO().GetControl());

                    if (prob.Panel.GetParent() != null)
                    {
                        prob.Panel.GetParent().AddPanel(tabs);
                        prob.Panel.GetParent().RemovePanel(prob.Panel);
                    }
                    else
                    {
                        root = tabs;
                    }

                    // now we need to distribute the rows from the panel into the new tabbed panels
                    IEnumerator row = prob.Panel.Rows.GetEnumerator();
                    while (row.MoveNext())
                    {
                        Row       r = (Row)row.Current;
                        GroupNode g = r.Group;
                        while (tabs[g] == null)
                        {
                            g = g.Parent;
                        }

                        ((PanelNode)tabs[g].GetChildNode()).AddRow(r);
                    }

                    // finally, add the components and the do the layout for the tabs
                    tabs.SetLocation(prob.Panel.GetBounds().X, prob.Panel.GetBounds().Y);
                    tabs.SetSize(prob.Panel.GetBounds().Width, prob.Panel.GetBounds().Height);
                    tabs.AddComponents(prob.Panel.Container, ui.LayoutVars);
                    tabs.DoLayout(ui.LayoutVars);
                }
            }

            return(root);
        }
예제 #18
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;
                }
            }
        }
예제 #19
0
        protected ArrayList findMutualExclusion(GroupNode g,
                                                ApplianceState state,
                                                Hashtable groupDeps)
        {
            ArrayList childSets = new ArrayList();
            ArrayList depSets   = new ArrayList();

            // The first element in childSet is that set of all children
            // that do not depend on this state at all (there aren't
            // necessarily any)

            ArrayList noDepChildren = new ArrayList();
            ArrayList noDeps        = new ArrayList();

            childSets.Add(noDepChildren);
            depSets.Add(noDeps);

            BranchGroupNode bg = (BranchGroupNode)g;

            IEnumerator e = bg.Children.GetEnumerator();

            while (e.MoveNext())
            {
                bool      cont = false;
                GroupNode c    = (GroupNode)e.Current;

                if (c.IsObject() && ((ObjectGroupNode)c).Object == state)
                {
                    continue;                                                                         // don't consider the
                }
                // depended child

                // if deps is null, then something is wrong
                ArrayList deps = (ArrayList)groupDeps[c];

                if (deps.Count == 0)
                {
                    noDepChildren.Add(c);
                    continue;
                }

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

                    // check if this element is mutex with sets[ i ]
                    ArrayList merge = mergeTwoVectors(deps, dset);

                    if (merge.Count != (deps.Count + dset.Count))
                    {
                        depSets[i] = merge;
                        dset       = (ArrayList)childSets[i];
                        dset.Add(c);

                        cont = true;
                        break;
                    }
                }

                if (cont)
                {
                    continue;
                }

                depSets.Add(deps);
                dset = new ArrayList();
                dset.Add(c);
                childSets.Add(dset);
            }

            ArrayList array = new ArrayList();

            array.Add(childSets);
            array.Add(depSets);
            return(array);
        }
예제 #20
0
        protected void gridSetupHelper(BranchGroupNode group,
                                       ArrayList listTables,
                                       DataTable current,
                                       DataGridTableStyle style)
        {
            IEnumerator e = group.Children.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Current is ListGroupNode)
                {
                    ListGroupNode lg = (ListGroupNode)e.Current;

                    // create a new table
                    DataTable table = new DataTable(lg.FullPath);
                    // create array for storing primary keys
                    DataColumn[] keys = new DataColumn[listTables.Count + 1];
                    // add the table to the DataSet
                    _dataSet.Tables.Add(table);

                    IEnumerator list = listTables.GetEnumerator();
                    for (int i = 0; list.MoveNext(); i++)
                    {
                        DataTable parentTable    = (DataTable)list.Current;
                        string    parentIndexCol = parentTable.TableName + "." + INDEX_COL_NAME;

                        // add a column to reference the parent table index
                        table.Columns.Add(parentIndexCol, Type.GetType("System.Int32"));

                        // add column to primary key array
                        keys[i] = table.Columns[parentIndexCol];
                    }

                    // add the special column with an integer type
                    table.Columns.Add(INDEX_COL_NAME, Type.GetType("System.Int32"));
                    table.Columns[INDEX_COL_NAME].Unique = true;
                    keys[listTables.Count] = table.Columns[INDEX_COL_NAME];

                    // set primary keys
                    table.PrimaryKey = keys;

                    // determine relation name
                    string relationName = lg.Name;
                    if (lg.Labels != null)
                    {
                        relationName = lg.Labels.GetShortestLabel();
                    }
                    // make the parent/child DataRelation to the DataSet
                    DataRelation r = new DataRelation(relationName,
                                                      current.Columns[INDEX_COL_NAME],
                                                      table.Columns[current.TableName + "." + INDEX_COL_NAME]);
                    // add relation to the DataSet
                    _dataSet.Relations.Add(r);

                    // create the DataGridTableStyle
                    DataGridTableStyle tableStyle = new DataGridTableStyle();
                    tableStyle.MappingName = table.TableName;
                    tableStyle.ReadOnly    = true;

                    listTables.Add(table);

                    gridSetupHelper(lg, listTables, table, tableStyle);

                    listTables.RemoveAt(listTables.Count - 1);

                    // add TableStyle after all columns have been found
                    _listGrid.TableStyles.Add(tableStyle);
                }
                else if (e.Current is BranchGroupNode)
                {
                    gridSetupHelper((BranchGroupNode)e.Current, listTables, current, style);
                }
                else if (e.Current is ObjectGroupNode)
                {
                    ApplianceObject ao = ((ObjectGroupNode)e.Current).Object;

                    string name = ao.FullName.Substring(current.TableName.Length + 1);
                    if (ao.State)
                    {
                        DataGridColumnStyle columnStyle;
                        Type type;

                        if (((ApplianceState)ao).Type.ValueSpace.Space ==
                            PUC.Types.ValueSpace.BOOLEAN_SPACE)
                        {
                            type        = true.GetType();
                            columnStyle = new DataGridBoolColumn();
                        }
                        else
                        {
                            type        = "".GetType();
                            columnStyle = new DataGridTextBoxColumn();
                        }
                        columnStyle.MappingName = name;

                        columnStyle.HeaderText = ao.Labels.GetShortestLabel();
                        columnStyle.ReadOnly   = ((ApplianceState)ao).ReadOnly;

                        if (!columnStyle.ReadOnly)
                        {
                            style.ReadOnly = false;
                        }

                        if (((ApplianceState)ao).Type.ValueSpace.Space ==
                            PUC.Types.ValueSpace.BINARY_SPACE)
                        {
                            columnStyle.ReadOnly = true;
                        }

                        DataColumn col = new DataColumn(name, type);
                        _columnToStateMap[col] = ao;
                        current.Columns.Add(col);
                        style.GridColumnStyles.Add(columnStyle);
                    }
                    else if (ao is ApplianceCommand)
                    {
                        DataGridBoolColumn columnStyle = new DataGridBoolColumn();
                        columnStyle.MappingName = name;
                        columnStyle.ReadOnly    = style.ReadOnly = false;

                        DataColumn col = new DataColumn(name, true.GetType());
                        _columnToStateMap[col] = ao;
                        current.Columns.Add(col);
                        style.GridColumnStyles.Add(columnStyle);
                    }
                }
            }
        }
예제 #21
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;
                }
            }
        }