コード例 #1
0
 public static IList <EvolutionChange> Detect(Version v1, Version v2, IHasPSMAttributes hasAttributes)
 {
     return((from psmAttribute in ((IHasPSMAttributes)hasAttributes.GetInVersion(v1)).PSMAttributes
             where psmAttribute.GetInVersion(v1) != null && psmAttribute.GetInVersion(v2) == null
             select new HasAttributesAttributeRemovedChange(hasAttributes, psmAttribute)
     {
         OldVersion = v1, NewVersion = v2
     }).Cast <EvolutionChange>().ToList());
 }
コード例 #2
0
        public override void Execute(object parameter)
        {
            IHasPSMAttributes hasAttributes = (IHasPSMAttributes)GetElement();

            SelectItemsDialog selectVersion = new SelectItemsDialog();
            List <Version>    _versions     = new List <Version>(CurrentProject.VersionManager.Versions.Where(ver => ver.Number < hasAttributes.Version.Number));
            Version           v;

            if (_versions.Count > 1)
            {
                selectVersion.UseRadioButtons = true;
                selectVersion.SetItems(_versions);
                selectVersion.ShortMessage = "Select version";
                selectVersion.LongMessage  = "Select version to map to.";
                selectVersion.Title        = "Select version";

                if (selectVersion.ShowDialog() != true || selectVersion.selectedObjects.Count != 1)
                {
                    return;
                }
                v = (Version)selectVersion.selectedObjects[0];
            }
            else
            {
                v = _versions[0];
            }

            SelectItemsDialog selectAttributes = new SelectItemsDialog();

            selectAttributes.UseRadioButtons = true;
            selectAttributes.SetItems(hasAttributes.PSMAttributes);
            selectAttributes.ShortMessage = "Select attribute";
            selectAttributes.LongMessage  = "Select attribute for mapping.";
            selectAttributes.Title        = "Select attribute";
            selectAttributes.SelectItem(hasAttributes.PSMAttributes.FirstOrDefault(a => a.GetInVersion(v) == null));
            if (selectAttributes.ShowDialog() != true || selectAttributes.selectedObjects.Count != 1)
            {
                return;
            }

            IVersionedElement selectedAttribute = (IVersionedElement)selectAttributes.selectedObjects[0];
            Version           currentVersion    = selectedAttribute.Version;

            Diagram diagram = (Diagram)ActiveDiagramView.Diagram.GetInVersion(v);

            if (diagram == null)
            {
                XCaseYesNoBox.ShowOK("Diagram not present", "Diagram does not exist in this version. ");
                return;
            }


            List <Element> _candidates = new List <Element>();

            foreach (var element in ((IHasPSMAttributes)hasAttributes.GetInVersion(v)).PSMAttributes.Where
                         (e => e.GetType() == selectedAttribute.GetType() && e.IsFirstVersion && e.GetInVersion(currentVersion) == null))
            {
                _candidates.Add(element);
            }

            if (_candidates.Count == 0)
            {
                XCaseYesNoBox.ShowOK("Not found", "No possible elements found for this item. ");
                return;
            }

            SelectItemsDialog selectElement = new SelectItemsDialog();

            selectElement.UseRadioButtons = true;
            selectElement.SetItems(_candidates);
            Element guess = _candidates.FirstOrDefault(c => c.ToString() == selectedAttribute.ToString());

            selectElement.SelectItem(guess);
            selectElement.ShortMessage = "Select element";
            selectElement.LongMessage  = "Select element to map to.";
            selectElement.Title        = "Select element";

            if (selectElement.ShowDialog() != true || selectElement.selectedObjects.Count != 1)
            {
                return;
            }

            Element el = (Element)selectElement.selectedObjects[0];

            CurrentProject.VersionManager.RegisterBranch(el, selectedAttribute, currentVersion, true, el.Version);
        }