Beispiel #1
0
        /// <summary>
        /// returns the path to the closest ancestor of <see cref="addedNode"/>
        /// that existed in the previous version.
        /// </summary>
        /// <param name="addedNode">The added node.</param>
        /// <param name="oldVersion">The old version.</param>
        /// <returns>xpath expression</returns>
        private static XPathExpr GetXPathForAddedNode(PSMElement addedNode, Version oldVersion)
        {
            PSMTreeIterator it = new PSMTreeIterator(addedNode);
            PSMElement      ancestorOldVersion = null;

            while (ancestorOldVersion == null)
            {
                if (it.CanGoToParent())
                {
                    it.GoToParent();
                }
                else
                {
                    return(null);
                }
                it.CurrentNode = it.GetSignificantAncestorOrSelf();
                if (it.CurrentNode != null)
                {
                    ancestorOldVersion = (PSMElement)it.CurrentNode.GetInVersion(oldVersion);
                }
                else
                {
                    break;
                }
            }
            return(ancestorOldVersion != null?ancestorOldVersion.XPathE() : null);
        }
Beispiel #2
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            Version version = cbBranches.SelectedValue as Version;

            if (version != null && versionManager != null && versionManager.Versions.Count > 1 &&
                XCaseYesNoBox.Show("Remove version", string.Format("Do you really want to remove version {0}?\r\nThis action can not be undone.", version)) == MessageBoxResult.Yes)
            {
                UnbindProject();
                versionManager.DeleteVersion(version);
                BindToProject(versionManager.LatestVersion);
                cbBranches.SelectedItem      = versionManager.LatestVersion.Version;
                MainWindow.HasUnsavedChanges = true;

                #if DEBUG
                Tests.ModelIntegrity.ModelConsistency.CheckEverything(project);
                //Tests.ModelIntegrity.ModelConsistency.CheckElementSchema(ElementWatcher.CreatedElements, project.Schema, null);

                Tests.ModelIntegrity.VersionsConsistency.CheckVersionsConsistency(versionManager);
                foreach (Element element in ElementWatcher.CreatedElements)
                {
                    if (element.Version == null && !(element is InstantiatedProperty) && !(element is StereotypeInstance))
                    {
                        System.Diagnostics.Debug.WriteLine(String.Format("{0} element without version", element));
                    }
                }
                #endif
            }
        }
Beispiel #3
0
 public EvolutionChangeSet(PSMDiagram diagram, IEnumerable <EvolutionChange> changes, Version oldVersion, Version newVersion)
 {
     Diagram = diagram;
     this.AddRange(changes);
     OldVersion = oldVersion;
     NewVersion = newVersion;
 }
Beispiel #4
0
        /// <summary>
        /// Gets the X path for a node. If the node existed in the previous version, the old
        /// path is returned. For new nodes it returns the path to the closest ancestor
        /// that existed in the previous version.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="oldVersion">The old version.</param>
        /// <returns>xpath expression</returns>
        public static XPathExpr GetXPathForNode(PSMElement node, Version oldVersion)
        {
            PSMElement nodeOldVersion = (PSMElement)node.GetInVersion(oldVersion);

            if (nodeOldVersion != null)
            {
                return(nodeOldVersion.XPathE());
            }
            else
            {
                return(GetXPathForAddedNode(node, oldVersion));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Gets path to a content grop
        /// </summary>
        /// <param name="containingClass">The containing class of the group.</param>
        /// <param name="oldVersion">The old version.</param>
        /// <returns>path to a content group</returns>
        private static XPathExpr GetXPathForContentGroup(PSMElement containingClass, Version oldVersion)
        {
            PSMElement groupElementOldVersion = (PSMElement)containingClass.GetInVersion(oldVersion);

            if (groupElementOldVersion != null)
            {
                return(groupElementOldVersion.XPathE());
            }
            else
            {
                return(GetXPathForAddedNode(containingClass, oldVersion).Append("/$cg"));
            }
        }
Beispiel #6
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMAttribute psmAttribute)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            if (((PSMAttribute)psmAttribute.GetInVersion(v1)).Name != ((PSMAttribute)psmAttribute.GetInVersion(v2)).Name)
            {
                AttributeNameChange c = new AttributeNameChange(psmAttribute)
                {
                    OldVersion = v1, NewVersion = v2
                };
                result.Add(c);
            }

            return(result);
        }
Beispiel #7
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMContentContainer contentContainer)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            if (((PSMContentContainer)contentContainer.GetInVersion(v1)).Name != ((PSMContentContainer)contentContainer.GetInVersion(v2)).Name)
            {
                ContentContainerRenamedChange c = new ContentContainerRenamedChange(contentContainer)
                {
                    OldVersion = v1, NewVersion = v2
                };
                result.Add(c);
            }

            return(result);
        }
Beispiel #8
0
        private void bLocatePrev_Click(object sender, RoutedEventArgs ea)
        {
            if (MainWindow.ActiveDiagram != null && MainWindow.ActiveDiagram.SelectedItems.Count > 0)
            {
                ISelectable i = MainWindow.ActiveDiagram.SelectedItems[0];
                if (i is IModelElementRepresentant)
                {
                    Element e = MainWindow.ActiveDiagram.ElementRepresentations.GetElementRepresentedBy((IModelElementRepresentant)i);
                    Version v = MainWindow.ActiveDiagram.Diagram.Project.VersionManager.Versions[0];

                    if (e.ExistsInVersion(v) && MainWindow.DiagramTabManager.GetDiagramView((Diagram)MainWindow.ActiveDiagram.Diagram.GetInVersion(v)) != null)
                    {
                        MainWindow.DiagramTabManager.GetDiagramView((Diagram)MainWindow.ActiveDiagram.Diagram.GetInVersion(v)).SelectElement((Element)e.GetInVersion(v));
                    }
                }
            }
        }
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMAttribute psmAttribute)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMAttribute attributeV1 = (PSMAttribute)psmAttribute.GetInVersion(v1);
            PSMAttribute attributeV2 = (PSMAttribute)psmAttribute.GetInVersion(v2);

            if (attributeV1.AttributeContainer != null && attributeV2.AttributeContainer == null)
            {
                AttributeReturnedFromAtributeContainerChange c = new AttributeReturnedFromAtributeContainerChange(psmAttribute)
                {
                    OldVersion = v1, NewVersion = v2
                };
                result.Add(c);
            }

            return(result);
        }
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMSubordinateComponent subordinateComponent)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMSubordinateComponent subordinateOldVersion = (PSMSubordinateComponent)subordinateComponent.GetInVersion(v1);

            if (subordinateComponent.Parent.GetInVersion(v1) == subordinateOldVersion.Parent &&
                subordinateComponent.ComponentIndex() != subordinateOldVersion.ComponentIndex())
            {
                SubordinateComponentComponentIndexChange change = new SubordinateComponentComponentIndexChange(subordinateComponent)
                {
                    OldVersion = v1, NewVersion = v2
                };
                result.Add(change);
            }

            return(result);
        }
Beispiel #11
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMAttribute psmAttribute)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            bool inClass = psmAttribute.AttributeContainer == null;
            IHasPSMAttributes containerV1, containerV2;

            PSMAttribute attributeV1 = (PSMAttribute)psmAttribute.GetInVersion(v1);
            PSMAttribute attributeV2 = (PSMAttribute)psmAttribute.GetInVersion(v2);

            if (attributeV1.AttributeContainer != null && attributeV2.AttributeContainer == null ||
                attributeV1.AttributeContainer == null && attributeV2.AttributeContainer != null ||
                attributeV1.AttributeContainer != null && attributeV2.AttributeContainer != null && attributeV2.AttributeContainer.GetInVersion(v1) != attributeV1.AttributeContainer)
            {
                // moved to different class/container
                return(result);
            }


            if (inClass)
            {
                Debug.Assert(psmAttribute.AttributeContainer == null);
                containerV1 = attributeV1.Class;
                containerV2 = attributeV2.Class;
            }
            else
            {
                containerV1 = attributeV1.AttributeContainer;
                containerV2 = attributeV2.AttributeContainer;
            }

            if (containerV1 != null && containerV2 != null &&
                containerV1.PSMAttributes.IndexOf(attributeV1) != containerV2.PSMAttributes.IndexOf(attributeV2))
            {
                AttributePositionChange c = new AttributePositionChange(psmAttribute)
                {
                    OldVersion = v1, NewVersion = v2
                };
                result.Add(c);
            }

            return(result);
        }
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMAssociationChild associationChild)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMAssociationChild associationChildOldVersion = (PSMAssociationChild)associationChild.GetInVersion(v2);

            Debug.Assert(associationChildOldVersion != null);

            if ((associationChild.ParentAssociation != null ||
                 (associationChild.ParentAssociation == null && associationChild.ParentUnion == null)) &&
                associationChildOldVersion.ParentUnion != null)
            {
                result.Add(new AssociationChildReturnedFromUnionChange(associationChild)
                {
                    OldVersion = v1, NewVersion = v2
                });
            }

            return(result);
        }
Beispiel #13
0
        internal XPathExpr NodeToProcessedPath(PSMElement node)
        {
            Version oldVersion = ChangeSet.OldVersion;

            if (!InGroup)
            {
                return(XPathHelper.GetXPathForNode(node, oldVersion));
            }
            else
            {
                XPathExpr path = XPathHelper.GetXPathForNode(node, oldVersion).Append("/$cg");
                //if (InGroup/* && ProcessedPath.HasPrefix(ContentGroupPath)*/)
                {
                    Debug.Assert(path.HasPrefix(ContentGroupPath));
                    Debug.Assert(path == (!ContentGroupPath.ToString().EndsWith("/$cg") ? ContentGroupPath.Append("/$cg") : ContentGroupPath));
                    //path = path.InsertAfterPrefix(ContentGroupPath, "/$cg");
                }
                return(path);
            }
        }
Beispiel #14
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMAttribute psmAttribute)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMAttribute attributeV1 = (PSMAttribute)psmAttribute.GetInVersion(v1);
            PSMAttribute attributeV2 = (PSMAttribute)psmAttribute.GetInVersion(v2);

            if ((attributeV1.AttributeContainer == null && attributeV2.AttributeContainer != null) || // moved from class
                (attributeV1.AttributeContainer != null && attributeV2.AttributeContainer != null &&
                 attributeV1.AttributeContainer != attributeV2.AttributeContainer.GetInVersion(v1)))
            // moved from another AC
            {
                AttributeMovedToAtributeContainerChange c = new AttributeMovedToAtributeContainerChange(psmAttribute)
                {
                    OldVersion = v1, NewVersion = v2
                };
                result.Add(c);
            }

            return(result);
        }
Beispiel #15
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMAttribute psmAttribute)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMAttribute psmAttributeOldVersion = (PSMAttribute)psmAttribute.GetInVersion(v1);
            PSMAttribute psmAttributeNewVersion = ((PSMAttribute)psmAttribute.GetInVersion(v2));



            if ((psmAttributeOldVersion.Type != null && psmAttributeNewVersion.Type == null) ||
                (psmAttributeOldVersion.Type == null && psmAttributeNewVersion.Type != null) ||
                (psmAttributeNewVersion.Type != null && psmAttributeOldVersion.Type != null &&
                 psmAttributeOldVersion.Type != psmAttributeNewVersion.Type.GetInVersion(v1)))
            {
                AttributeTypeChange c = new AttributeTypeChange(psmAttribute)
                {
                    OldVersion = v1, NewVersion = v2
                };
                result.Add(c);
            }

            return(result);
        }
Beispiel #16
0
        public void TestValidationOnRandomFiles(string filename)
        {
            Console.WriteLine("Testing file {0}.", filename);
            //string filename = "Attributes\\Attributes5.XCase";
            XmlDeserializatorVersions deserializator = new XmlDeserializatorVersions();
            VersionManager            versionManager = deserializator.RestoreVersionedProject(TEST_BASE_DIR + filename);

            Assert.IsTrue(versionManager != null && versionManager.VersionedProjects.Count == 2 &&
                          versionManager.Versions.Count == 2);

            Version    oldVersion        = versionManager.Versions[0];
            Version    newVersion        = versionManager.Versions[1];
            PSMDiagram diagramNewVersion = versionManager.VersionedProjects[newVersion].PSMDiagrams[0];
            PSMDiagram diagramOldVersion = versionManager.VersionedProjects[oldVersion].PSMDiagrams[0];

            ChangesDetector        detector         = new ChangesDetector();
            List <EvolutionChange> evolutionChanges = detector.Translate(diagramOldVersion, diagramNewVersion);

            XsltTemplateGenerator xsltGenerator = new XsltTemplateGenerator(diagramNewVersion);
            string xsltTransformation           = xsltGenerator.Generate(evolutionChanges, oldVersion, newVersion);

            SampleDataGenerator g         = new SampleDataGenerator();
            DocumentValidator   validator = new DocumentValidator {
                SilentMode = true
            };

            string outputFileDir = TEST_BASE_DIR + Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + "-error";

            int fails = 0;

            for (int i = 0; i < RANDOM_FILE_COUNT; i++)
            {
                string input = g.Translate(diagramOldVersion);
                if (!validator.ValidateDocument(diagramOldVersion, input))
                {
                    if (!Directory.Exists(outputFileDir))
                    {
                        Directory.CreateDirectory(outputFileDir);
                    }
                    File.WriteAllText(string.Format("{0}\\i{1}.xml", outputFileDir, i), input);
                    Console.WriteLine("Input document INVALID: " + validator.ErrorMessage);
                    fails++;
                    continue;
                }
                string result = XsltProcessing.Transform(input, xsltTransformation, TEST_BASE_DIR);
                if (!validator.ValidateDocument(diagramNewVersion, result))
                {
                    if (!Directory.Exists(outputFileDir))
                    {
                        Directory.CreateDirectory(outputFileDir);
                    }
                    File.WriteAllText(string.Format("{0}\\i{1}.xml", outputFileDir, i), input);
                    File.WriteAllText(string.Format("{0}\\o{1}.xml", outputFileDir, i), result);
                    Console.WriteLine("Result document INVALID: " + validator.ErrorMessage);
                    fails++;
                    continue;
                }
                Console.WriteLine("Test passed on file {0}/{1}", i, RANDOM_FILE_COUNT);
            }
            Console.WriteLine("Altogether tested on {0} random files. ", RANDOM_FILE_COUNT);
            if (fails != 0)
            {
                Console.WriteLine("{0} out of {1} files failed to pass. ", fails, RANDOM_FILE_COUNT);
                Assert.Fail("{0} out of {1} files failed to pass. ", fails, RANDOM_FILE_COUNT);
            }
            else
            {
                Console.WriteLine("All {0} files passed. ", RANDOM_FILE_COUNT);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Converts path to <paramref name="psmElementNewVersion"/>
        /// into a path relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ProcessedPath"/>.
        /// (and also relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ContentGroupPath"/> if it is used).
        /// If context is in group (<see cref="XsltGeneratorContext"/>.<see cref="XsltGeneratorContext.InGroup"/>) which
        /// has group attributes and <paramref name="psmElementNewVersion"/> is one of these attributes, the returned path
        /// is modified to use the '$attributes' variable.
        /// </summary>
        /// <param name="context">current generator context</param>
        /// <param name="psmElementNewVersion">element for which the path is projected</param>
        /// <param name="oldVersion">old version, used to determine the path to <paramref name="psmElementNewVersion"/> in the
        /// old version of the diagram</param>
        /// <returns>relative xpath expression</returns>
        public static XPathExpr GroupAwareProjectXPath(XsltGeneratorContext context, PSMElement psmElementNewVersion, Version oldVersion)
        {
            XPathExpr oldPath = ((PSMElement)psmElementNewVersion.GetInVersion(oldVersion)).XPathE();

            if (context.InGroup && oldPath.HasPrefix(context.ContentGroupPath))
            {
                oldPath = oldPath.InsertAfterPrefix(context.ContentGroupPath, "/$cg");
            }
            XPathExpr tmp = ProjectXPath(context.ProcessedPath, oldPath, context.InGroup);

            if (context.InGroup && context.ContentGroupAttributes != null && psmElementNewVersion is PSMAttribute &&
                context.ContentGroupAttributes.Contains((PSMAttribute)psmElementNewVersion))
            {
                if (tmp.ToString().StartsWith(XPathExpr.CurrentGroupVariableExpr))
                {
                    tmp = new XPathExpr(tmp.ToString().Replace(XPathExpr.CurrentGroupVariableExpr, "$attributes"));
                }
            }

            return(tmp);
        }
Beispiel #18
0
 public void SwitchToVersion(Version version)
 {
     BindToProject(versionManager.VersionedProjects[version]);
 }
Beispiel #19
0
 /// <summary>
 /// Gets path to a content grop
 /// </summary>
 /// <param name="contentGroup">The content group.</param>
 /// <param name="oldVersion">The old version.</param>
 /// <returns>path to a content group</returns>
 public static XPathExpr GetXPathForContentGroup(ContentGroup contentGroup, Version oldVersion)
 {
     return(GetXPathForContentGroup(contentGroup.ContainingClass, oldVersion));
 }
Beispiel #20
0
        public static List <PSMAttribute> GetAttributesForGroup(this PSMClass groupNode, Version oldVersion)
        {
            // take elements in the group that used to be attributes
            List <PSMAttribute>       result            = new List <PSMAttribute>();
            List <NodeElementWrapper> contentComponents = groupNode.GetSubtreeElements();

            foreach (NodeElementWrapper contentComponent in contentComponents)
            {
                if (contentComponent is SimpleNodeElement)
                {
                    SimpleNodeElement simpleNodeElement = ((SimpleNodeElement)contentComponent);
                    if (simpleNodeElement.Element is PSMAttribute)
                    {
                        PSMAttribute attribute           = (PSMAttribute)simpleNodeElement.Element;
                        PSMAttribute attributeOldVersion = (PSMAttribute)attribute.GetInVersion(oldVersion);
                        if (attributeOldVersion != null)
                        {
                            PSMElement parent = (attributeOldVersion).Class;
                            if (parent is PSMClass && ((PSMClass)parent).HasElementLabel)
                            {
                                continue;
                            }

                            if (attribute.AttributeContainer != null && attributeOldVersion.AttributeContainer == null)
                            {
                                result.Add(attribute);
                            }
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #21
0
        public void TestByCompare(string filename)
        {
            //string filename = "Attributes\\Attributes5.XCase";
            XmlDeserializatorVersions deserializator = new XmlDeserializatorVersions();
            VersionManager            versionManager = deserializator.RestoreVersionedProject(TEST_BASE_DIR + filename);

            Assert.IsTrue(versionManager != null && versionManager.VersionedProjects.Count == 2 &&
                          versionManager.Versions.Count == 2);

            Version    oldVersion        = versionManager.Versions[0];
            Version    newVersion        = versionManager.Versions[1];
            PSMDiagram diagramNewVersion = versionManager.VersionedProjects[newVersion].PSMDiagrams[0];
            PSMDiagram diagramOldVersion = versionManager.VersionedProjects[oldVersion].PSMDiagrams[0];

            ChangesDetector        detector         = new ChangesDetector();
            List <EvolutionChange> evolutionChanges = detector.Translate(diagramOldVersion, diagramNewVersion);

            XsltTemplateGenerator xsltGenerator = new XsltTemplateGenerator(diagramNewVersion);
            string xsltTransformation           = xsltGenerator.Generate(evolutionChanges, oldVersion, newVersion);

            string inputFileDir  = TEST_BASE_DIR + Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + "-in";
            string outputFileDir = TEST_BASE_DIR + Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + "-out";

            if (!Directory.Exists(inputFileDir))
            {
                Console.WriteLine("No input files. ");
                Assert.Inconclusive(string.Format("Input file directory does not exist : {0}", inputFileDir));
            }
            if (!Directory.Exists(outputFileDir))
            {
                Console.WriteLine("No reference files. ");
                Assert.Inconclusive(string.Format("Output file directory does not exist: {0}", outputFileDir));
            }

            DirectoryInfo dir = new DirectoryInfo(inputFileDir);

            FileInfo[] files       = dir.GetFiles("*.xml");
            bool       fail        = false;
            int        failedFiles = 0;

            foreach (FileInfo fileInfo in files)
            {
                Console.WriteLine(string.Format("File: {0}", fileInfo.Name));
                string input = File.ReadAllText(fileInfo.FullName);

                string result = XsltProcessing.Transform(input, xsltTransformation, TEST_BASE_DIR);
                File.WriteAllText(outputFileDir + "//" + fileInfo, result);

                DocumentValidator validator = new DocumentValidator {
                    SilentMode = true
                };

                bool inputInvalid  = false;
                bool resultInvalid = false;
                bool compareFail   = false;
                if (!validator.ValidateDocument(diagramOldVersion, input))
                {
                    inputInvalid = true;
                }

                if (!validator.ValidateDocument(diagramNewVersion, result))
                {
                    Console.WriteLine("Result document INVALID: " + validator.ErrorMessage);
                    resultInvalid = true;
                }

                string referenceFile = outputFileDir + "//" + Path.GetFileNameWithoutExtension(fileInfo.Name) + "-reference.xml";
                Assert.IsTrue(File.Exists(referenceFile), "Reference output file does not exist for: " + fileInfo.Name);
                string referenceOutput = File.ReadAllText(referenceFile);

                File.WriteAllText(outputFileDir + "//" + "last-stylesheet.xslt", xsltTransformation);

                if ((!inputInvalid && !resultInvalid) && result != referenceOutput)
                {
                    Console.WriteLine("Output and REFERENCE output DIFFERS for: " + fileInfo.Name);
                    compareFail = true;
                    Console.WriteLine("Input file: ");
                    Console.WriteLine(input);
                    Console.WriteLine("Result file: ");
                    Console.WriteLine(result);
                    Console.WriteLine("Reference file: ");
                    Console.WriteLine(referenceOutput);
                }
                else if (!inputInvalid && !resultInvalid && result == referenceOutput)
                {
                    Console.WriteLine("Comparison succeeded.");
                    File.WriteAllText(outputFileDir + "//" + "last-working-stylesheet.xslt", xsltTransformation);
                }

                if (inputInvalid)
                {
                    Console.WriteLine("Input document INVALID: " + validator.ErrorMessage);
                    Console.WriteLine("Input file: ");
                    Console.WriteLine(input);
                    fail = true;
                    failedFiles++;
                }

                if (resultInvalid)
                {
                    Console.WriteLine("Result document INVALID: " + validator.ErrorMessage);
                    Console.WriteLine("Result file: ");
                    Console.WriteLine(result);
                    fail = true;
                    failedFiles++;
                }

                if (compareFail)
                {
                    Console.WriteLine("Result of {0} DIFFERS from expected result.", fileInfo.Name);
                    fail = true;
                    failedFiles++;
                }
            }
            if (files.Length == 0)
            {
                Console.WriteLine("No input files. ");
                Assert.Inconclusive("No input files. ");
            }
            if (fail)
            {
                Console.WriteLine("{0} out of {1} files FAILED. ", failedFiles, files.Length);
                Assert.Fail("{0} out of {1} files FAILED. ", failedFiles, files.Length);
            }
            Console.WriteLine("Altogether tested on {0} files.", files.Length);
        }
Beispiel #22
0
        public void OpenProjectDiagrams()
        {
#if DEBUG
            if (Environment.MachineName.Contains("TRUPIK"))
            {
                string        currentFile = CurrentProject.FilePath;
                List <string> recentFiles;
                if (File.Exists(lastFilePath))
                {
                    recentFiles = File.ReadAllLines(lastFilePath).ToList();
                }
                else
                {
                    recentFiles = new List <string>();
                }
                if (!String.IsNullOrEmpty(currentFile))
                {
                    if (recentFiles.Contains(currentFile))
                    {
                        recentFiles.Remove(currentFile);
                    }
                    recentFiles.Insert(0, currentFile);
                }
                bOpenProject.ContextMenu = new ContextMenu();
                foreach (string recentFile in recentFiles)
                {
                    if (!string.IsNullOrEmpty(recentFile))
                    {
                        string          name = Path.GetFileNameWithoutExtension(recentFile);
                        ContextMenuItem cmi  = new ContextMenuItem(name);
                        cmi.DataContext = recentFile;
                        cmi.Click      += delegate { OpenProject((string)cmi.DataContext); };
                        bOpenProject.ContextMenu.Items.Add(cmi);
                    }
                }
                File.WriteAllLines(lastFilePath, recentFiles.Take(15).ToArray());
                if (System.Windows.Forms.Screen.AllScreens.Length > 1)
                {
                    this.WindowState = WindowState.Normal;
                    this.Left        = System.Windows.Forms.Screen.AllScreens[0].Bounds.X;
                    this.Top         = System.Windows.Forms.Screen.AllScreens[0].Bounds.Y;
                    this.Width       = System.Windows.Forms.Screen.AllScreens[0].Bounds.Width;
                    this.Height      = System.Windows.Forms.Screen.AllScreens[0].Bounds.Height;
                }
            }
#endif
            if (CurrentProject != null)
            {
                VersionManager versionManager = CurrentProject.VersionManager;
                // HACK - TRUPIK: added for simplier debugging, only on my machine..
                if (Environment.MachineName.Contains("TRUPIK") && versionManager != null && versionManager.Versions.Count == 2)
                {
                    Version v1 = versionManager.Versions[0];
                    Version v2 = versionManager.Versions[1];

                    ObservableCollection <PSMDiagram> diagramsV1 = versionManager.VersionedProjects[v1].PSMDiagrams;
                    ObservableCollection <PSMDiagram> diagramsV2 = versionManager.VersionedProjects[v2].PSMDiagrams;
                    if (diagramsV1.Count > 0)
                    {
                        DiagramTabManager.AddTab(diagramsV1.Last());
                        propertiesWindow.BindDiagram(ref dockManager);
                    }
                    if (diagramsV2.Count > 0)
                    {
                        DiagramTabManager.AddTab(diagramsV2.Last());
                        propertiesWindow.BindDiagram(ref dockManager);
                    }

                    if (diagramsV1.Count == 0 && diagramsV2.Count == 0)
                    {
                        ObservableCollection <PIMDiagram> pimDiagramsV1 = versionManager.VersionedProjects[v1].PIMDiagrams;
                        ObservableCollection <PIMDiagram> pimDiagramsV2 = versionManager.VersionedProjects[v2].PIMDiagrams;

                        if (pimDiagramsV1.Count > 0)
                        {
                            DiagramTabManager.AddTab(pimDiagramsV1.Last());
                            propertiesWindow.BindDiagram(ref dockManager);
                        }
                        if (pimDiagramsV2.Count > 0)
                        {
                            DiagramTabManager.AddTab(pimDiagramsV2.Last());
                            propertiesWindow.BindDiagram(ref dockManager);
                        }
                    }

                    //DocumentPane.NewVerticalTabGroupCommand.Execute(null, DiagramTabManager.ActivePane);
                    DiagramTabManager.ActivePane.CreateNewVerticalTabGroup();
                    if (diagramsV2.Count > 0)
                    {
                        DiagramTabManager.ActivateDiagram(diagramsV2.Last());
                    }
                }
                else
                {
                    for (int i = 0; i < Math.Min(CurrentProject.Diagrams.Count, 8); i++)
                    {
                        DiagramTabManager.AddTab(CurrentProject.Diagrams[i]);
                        propertiesWindow.BindDiagram(ref dockManager);
                    }
                }
            }
        }