/* * Organizer Method */ public override Hashtable AddOrganization(GroupNode group, InterfaceNode currentNode) { TabbedOverlappingPanelsNode tab = new TabbedOverlappingPanelsNode( _state ); MultiplePanelNode non = null; if ( _vertical ) non = new HorizontallyNonOverlappingPanelsNode( (PanelNode)currentNode, tab ); else { non = new VerticallyNonOverlappingPanelsNode(); currentNode.InsertAsParent( non ); non.AddPanel( tab ); } Hashtable deps = new Hashtable( _dependencies.Count ); Hashtable panels = new Hashtable( _dependencies.Count ); IEnumerator e = _dependencies.Keys.GetEnumerator(); PanelNode newP = null; while( e.MoveNext() ) { GroupNode g = (GroupNode)e.Current; ArrayList aryDeps = (ArrayList)_dependencies[ g ]; EqualsDependency eqDep = (EqualsDependency)aryDeps[ 0 ]; try { newP = (PanelNode)tab.GetNodeByValue( (int)eqDep.Value ).GetChildNode(); newP.Group = g; } catch( Exception ) { Globals.GetFrame( eqDep.State.Appliance ).AddLogLine( "Error in TabbedControlPanelOrganizer... Line 82" ); } deps[ aryDeps ] = newP; panels[ g ] = newP; } tab.InitGroupToTabMap(); _activePanel = newP; _dependencies = deps; _uiValid = true; this.ValueChanged( _state ); return panels; }
/* * 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); }
/* * 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; } } }