Example #1
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMDiagram diagram)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMDiagram diagramOldVersion = (PSMDiagram)diagram.GetInVersion(v1);

            foreach (PSMSuperordinateComponent root in diagram.Roots)
            {
                PSMSuperordinateComponent rootOldVersion = (PSMSuperordinateComponent)root.GetInVersion(v1);

                IList <PSMSuperordinateComponent> oldRoots = diagramOldVersion.Roots.ToList();
                if (rootOldVersion != null &&
                    oldRoots.Contains(rootOldVersion) &&
                    oldRoots.IndexOf(rootOldVersion) != diagram.Roots.ToList().IndexOf(root)
                    )
                {
                    result.Add(new DiagramRootIndexChange(root)
                    {
                        OldVersion = v1, NewVersion = v2
                    });
                }
            }

            return(result);
        }
Example #2
0
        public override void Execute(object parameter)
        {
            if (CanExecute(parameter))
            {
                ChangesDetector detector = new ChangesDetector();

                PSMDiagram diagramNewVersion = (PSMDiagram)ActiveDiagramView.Diagram;

                PSMDiagram diagramOldVersion = null;

                if (previousVersions.Count == 1)
                {
                    diagramOldVersion = (PSMDiagram)diagramNewVersion.GetInVersion(previousVersions.First());
                }
                else
                {
                    SelectItemsDialog d = new SelectItemsDialog();
                    d.ShortMessage    = "Select previous version of the diagram. ";
                    d.Title           = "Select version";
                    d.UseRadioButtons = true;
                    d.SetItems(previousVersions);
                    d.SelectItem(previousVersions.FirstOrDefault(v => v.Number == previousVersions.Max(vm => vm.Number)));
                    if (d.ShowDialog() == true && d.selectedObjects.Count == 1)
                    {
                        diagramOldVersion = (PSMDiagram)d.selectedObjects[0];
                    }
                }

                if (diagramOldVersion != null)
                {
                    List <EvolutionChange> evolutionChanges = detector.Translate(diagramOldVersion, diagramNewVersion);
                    EvolutionChangesWindow.Show(evolutionChanges, MainWindow, diagramOldVersion, diagramNewVersion);
                }
            }
        }
Example #3
0
        public override bool CanExecute(object parameter)
        {
            if (ActiveDiagramView != null && ActiveDiagramView.Diagram != null && ActiveDiagramView.Diagram is PSMDiagram)
            {
                PSMDiagram psmDiagram = (PSMDiagram)ActiveDiagramView.Diagram;
                if (psmDiagram.VersionManager != null && psmDiagram.VersionManager.Versions.Count > 0)
                {
                    Version newVersion = psmDiagram.Version;

                    previousVersions = new List <Version>();

                    foreach (Version version in psmDiagram.VersionManager.Versions)
                    {
                        if (/*version.Number < newVersion.Number && */ psmDiagram.GetInVersion(version) != null &&
                            version != psmDiagram.Version)
                        {
                            previousVersions.Add(version);
                        }
                    }
                    if (previousVersions.Count > 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #4
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMDiagram diagram)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMDiagram diagramOldVersion = (PSMDiagram)diagram.GetInVersion(v1);

            foreach (PSMSuperordinateComponent root in diagramOldVersion.Roots)
            {
                if (root.GetInVersion(v2) == null)
                {
                    result.Add(new DiagramRootRemovedChange(root)
                    {
                        OldVersion = v1, NewVersion = v2
                    });
                }
            }

            return(result);
        }