public void SetCheckedPotentialBbie(CheckableItem checkableItem)
        {
            CandidateAbie abie = FindSelectedAbie(rootElement.CandidateAbies);

            foreach (PotentialBbie potentialBbie in abie.PotentialBbies)
            {
                if (potentialBbie.Name.Equals(checkableItem.Text))
                {
                    potentialBbie.Checked = checkableItem.Checked;
                }
            }
        }
        public void SetCheckedPotentialAsbie(IOConnectionItem checkedAsbie)
        {
            CandidateAbie abie = FindSelectedAbie(rootElement.CandidateAbies);

            foreach (PotentialAsbie potentialAsbie in abie.PotentialAsbies)
            {
                if (potentialAsbie.Name.Equals(checkedAsbie.Text))
                {
                    potentialAsbie.Checked = checkedAsbie.Checked;
                }
            }
        }
        private static CandidateAbie findAbie(string selectedAbie, IEnumerable <CandidateAbie> abies)
        {
            CandidateAbie returnAbie = null;

            if (abies != null)
            {
                foreach (CandidateAbie abie in abies)
                {
                    if (abie.Name.Equals(selectedAbie))
                    {
                        return(abie);
                    }
                    returnAbie = findAbie(selectedAbie, abie.PotentialAbies);
                    if (returnAbie != null)
                    {
                        return(returnAbie);
                    }
                }
            }
            return(returnAbie);
        }
        public void SetSelectedCandidateAbie(CheckableTreeViewItem checkableTreeViewItem)
        {
            mPotentialBbieItems = new List <CheckableItem>();
            CandidateAbie abie = findAbie(checkableTreeViewItem.Text, rootElement.CandidateAbies);

            if (abie != null)
            {
                if (abie.PotentialBbies == null)
                {
                    var bbies = new List <IBbie>(abie.OriginalAbie.Bbies);
                    abie.PotentialBbies =
                        new List <PotentialBbie>(
                            bbies.ConvertAll(potBbie => new PotentialBbie(potBbie.Name)));
                }
                if (abie.PotentialAsbies == null)
                {
                    var asbies = new List <IAsbie>(abie.OriginalAbie.Asbies);
                    abie.PotentialAsbies =
                        new List <PotentialAsbie>(
                            asbies.ConvertAll(
                                potAsbie =>
                                new PotentialAsbie(potAsbie.Name, (potAsbie.AssociatingAbie.Equals(potAsbie)))));
                }
                mPotentialBbieItems =
                    new List <CheckableItem>(
                        abie.PotentialBbies.ConvertAll(
                            potBbie => new CheckableItem(potBbie.Checked, potBbie.Name, true, false, Cursors.Arrow)));

                mPotentialAsbieItems =
                    new List <IOConnectionItem>(
                        abie.PotentialAsbies.ConvertAll(
                            potAsbie => new IOConnectionItem(potAsbie.Name, potAsbie.Incoming, potAsbie.Checked)));

                abie.Selected = true;
                UnSelectAllButAbie(abie.Name, rootElement.CandidateAbies);
            }
            PotentialBbieItems  = mPotentialBbieItems;
            PotentialAsbieItems = mPotentialAsbieItems;
        }
        public void SetCheckedCandidateAbie(CheckableTreeViewItem checkableTreeViewItem)
        {
            if (checkableTreeViewItem != null)
            {
                CandidateAbie abie = findAbie(checkableTreeViewItem.Text, rootElement.CandidateAbies);
                if (abie == null)
                {
                    return; // it's ok.. we found an MA
                }
                //check all related Nodes from tree if checked is true
                if (checkableTreeViewItem.Checked)
                {
                    checkAllParents(checkableTreeViewItem);
                }
                else
                {
                    checkChildren(checkableTreeViewItem);
                }
                //checkChildren(result, checkedValue); change from 08.04.2010 => only uncheck children

                if (abie.PotentialBbies == null)
                {
                    var bbies = new List <IBbie>(abie.OriginalAbie.Bbies);
                    abie.PotentialBbies =
                        new List <PotentialBbie>(bbies.ConvertAll(potBbie => new PotentialBbie(potBbie.Name)));
                }

                foreach (PotentialBbie bbie in abie.PotentialBbies)
                {
                    bbie.Checked = checkableTreeViewItem.Checked;
                }

                abie.Checked       = checkableTreeViewItem.Checked;
                CandidateAbieItems = new ObservableCollection <CheckableTreeViewItem>(mCandidateAbieItems);
            }
        }
        private static CandidateAbie FindSelectedAbie(IEnumerable <CandidateAbie> abies)
        {
            CandidateAbie returnAbie = null;

            if (abies != null)
            {
                foreach (CandidateAbie abie in abies)
                {
                    if (abie.Selected)
                    {
                        return(abie);
                    }
                    returnAbie = FindSelectedAbie(abie.PotentialAbies);
                    if (returnAbie != null)
                    {
                        if (returnAbie.Selected)
                        {
                            return(returnAbie);
                        }
                    }
                }
            }
            return(returnAbie);
        }
        public void createSubSet()
        {
            var abiesToRemove  = new List <String>();
            var bbiesToRemove  = new Dictionary <String, List <String> >();
            var asbiesToRemove = new Dictionary <String, List <String> >();

            followAsmasAndRemoveUnused(rootElement.OriginalMa);
            foreach (IBieLibrary bieLibrary in ccCache.GetBieLibraries())
            {
                var abies = new List <IAbie>(bieLibrary.Abies);
                foreach (IAbie abie in abies)
                {
                    List <CheckableTreeViewItem> result = findCheckableTreeViewItems(abie.Name, mCandidateAbieItems);
                    if (result.Count == 0)
                    {
                        abiesToRemove.Add(abie.Name);
                        bieLibrary.RemoveAbie(abie);
                    }
                    else
                    {
                        if (testIfAllCheckableTreeViewItemsAreUnchecked(result))
                        {
                            abiesToRemove.Add(abie.Name);
                            bieLibrary.RemoveAbie(abie);
                        }
                        else
                        {
                            CandidateAbie candidateAbie = findAbie(abie.Name, rootElement.CandidateAbies);
                            //update asbies
                            if (candidateAbie.PotentialAsbies != null)
                            //if the potentialAsbies are null the user hasn't even looked at them.. nothing to do!
                            {
                                if (candidateAbie.PotentialAsbies.Count == 0)
                                //for now this is almost always 0.. so we will examine children also!
                                {
                                    foreach (CheckableTreeViewItem checkableTreeViewItem in result)
                                    {
                                        if (checkableTreeViewItem.Checked)
                                        {
                                            //remove unchecked Bbies, only if the item is not unchecked!
                                            var actualBbies = new List <IBbie>(abie.Bbies);
                                            var tempBbies   = new List <String>();
                                            if (candidateAbie.PotentialBbies != null)
                                            {
                                                foreach (IBbie bbie in actualBbies)
                                                {
                                                    foreach (PotentialBbie potentialBbie in candidateAbie.PotentialBbies)
                                                    {
                                                        if (bbie.Name.Equals(potentialBbie.Name))
                                                        {
                                                            if (!potentialBbie.Checked)
                                                            {
                                                                tempBbies.Add(bbie.Name + bbie.Bdt.Name);
                                                                abie.RemoveBbie(bbie);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            bbiesToRemove.Add(abie.Name, tempBbies);
                                        }
                                        //examine children to find obsolete asbies
                                        foreach (CheckableTreeViewItem child in checkableTreeViewItem.Children)
                                        {
                                            if (!child.Checked)
                                            {
                                                var tmpAsbies = new List <String>();
                                                foreach (IAsbie asbie in candidateAbie.OriginalAbie.Asbies)
                                                {
                                                    if (asbie.AssociatedAbie.Name.Equals(child.Text))
                                                    {
                                                        tmpAsbies.Add(asbie.Name);
                                                        candidateAbie.OriginalAbie.RemoveAsbie(asbie);
                                                    }
                                                }
                                                asbiesToRemove.Add(abie.Name, tmpAsbies);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    IEnumerable <IAsbie> originalAsbies = candidateAbie.OriginalAbie.Asbies;
                                    var tmpAsbies = new List <String>();
                                    foreach (IAsbie asbie in originalAsbies)
                                    {
                                        foreach (PotentialAsbie potentialAsbie in candidateAbie.PotentialAsbies)
                                        {
                                            if (potentialAsbie.Name.Equals(asbie.Name))
                                            {
                                                if (!potentialAsbie.Checked)
                                                {
                                                    tmpAsbies.Add(asbie.Name);
                                                    candidateAbie.OriginalAbie.RemoveAsbie(asbie);
                                                }
                                            }
                                        }
                                    }
                                    asbiesToRemove.Add(abie.Name, tmpAsbies);
                                }
                            }
                        }
                    }
                }
            }
            if (!namespacePrefix.Equals(String.Empty) && !targetNamespace.Equals(String.Empty))
            {
                writeSchematronRules(abiesToRemove, bbiesToRemove, asbiesToRemove);
            }
        }