Beispiel #1
0
        public void GoToPimClass(PIMClass pimClass)
        {
            ElementDiagramDependencies dependentDiagrams = ElementDiagramDependencies.FindElementDiagramDependencies(MainWindow.CurrentProject, new[] { pimClass }, null);

            if (dependentDiagrams.Count == 1)
            {
                if (dependentDiagrams[pimClass].Count == 1)
                {
                    ActivateDiagramWithElement(dependentDiagrams[pimClass][0], pimClass);
                }
                else
                {
                    SelectItemsDialog d = new SelectItemsDialog();
                    d.ToStringAction = diagram => ((Diagram)diagram).Caption;
                    d.SetItems(dependentDiagrams[pimClass]);
                    if (d.ShowDialog() == true)
                    {
                        foreach (Diagram diagram in d.selectedObjects.Cast <Diagram>())
                        {
                            ActivateDiagramWithElement(diagram, pimClass);
                        }
                    }
                }
            }
            else if (dependentDiagrams.Count == 0)
            {
                XCaseYesNoBox.ShowOK("PIM class not used in diagrams", "PIM class is not used in any diagram. You can edit it via Navigator window. ");
            }
        }
Beispiel #2
0
 internal override void GenerateSubCommands()
 {
     report.Append("Fixing association interpretations" + newline);
     foreach (PSMAssociation a in Project.LatestVersion.PSMSchemas.SelectMany(s => s.PSMAssociations).Where(assoc => assoc.Interpretation != null && assoc.InterpretedAssociationEnd == null))
     {
         PIMAssociationEnd e;
         PIMAssociation    pimassoc = a.Interpretation as PIMAssociation;
         PSMClass          child    = a.Child as PSMClass;
         if (child == null)
         {
             report.Append("child not class: " + a.ToString() + newline);
             continue;
         }
         PIMClass childInterpretation = child.Interpretation as PIMClass;
         if (pimassoc.PIMAssociationEnds.Where(ae => ae.PIMClass == childInterpretation).Count() > 1)
         {
             report.Append("cannot fix - self reference detected: " + a.ToString() + newline);
             continue;
         }
         else
         {
             e = pimassoc.PIMAssociationEnds.Single(ae => ae.PIMClass == childInterpretation);
         }
         report.Append("fixed OK: " + a.ToString() + newline);
         Commands.Add(new acmdSetPSMAssociationInterpretation(Controller, a, e, a.Interpretation)
         {
             Propagate = false
         });
     }
 }
Beispiel #3
0
        public override bool CanExecute()
        {
            ReadOnlyCollection <PIMAssociation> aX1 = Project.TranslateComponentCollection <PIMAssociation>(X1);
            ReadOnlyCollection <PIMAssociation> aX2 = Project.TranslateComponentCollection <PIMAssociation>(X2);

            if (aX1.Count == 0 || aX2.Count == 0)
            {
                return(false);
            }
            PIMClass pimClass1 = aX2[0].PIMClasses[0];
            PIMClass pimClass2 = aX2[0].PIMClasses[1];

            IEnumerable <PIMAssociation> intersect = pimClass1.PIMAssociationEnds.Select <PIMAssociationEnd, PIMAssociation>(e => e.PIMAssociation)
                                                     .Intersect <PIMAssociation>(
                pimClass2.PIMAssociationEnds.Select <PIMAssociationEnd, PIMAssociation>(e => e.PIMAssociation));

            if (
                !aX1.All <PIMAssociation>(a => intersect.Contains <PIMAssociation>(a))
                ||
                !aX2.All <PIMAssociation>(a => intersect.Contains <PIMAssociation>(a))
                )
            {
                ErrorDescription = CommandErrors.CMDERR_SYNCHRO_PIM_ASSOC_NOT_SUBSET;
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        internal override PropagationMacroCommand PrePropagation()
        {
            PIMClass        pimClass = Project.TranslateComponent <PIMClass>(classGuid);
            List <PSMClass> list     = pimClass.GetInterpretedComponents().Cast <PSMClass>().ToList <PSMClass>();

            if (list.Count == 0)
            {
                return(null);
            }

            PropagationMacroCommand command = new PropagationMacroCommand(Controller);

            command.Report = new CommandReport("Pre-propagation (update PIM class abstract property)");

            foreach (PSMClass psmClass in list)
            {
                acmdUpdatePSMClassAbstract cmd = new acmdUpdatePSMClassAbstract(Controller, psmClass, newAbstract)
                {
                    Propagate = false
                };
                command.Commands.Add(cmd);
            }

            return(command);
        }
Beispiel #5
0
        public override bool CanExecute()
        {
            if (!(PSMComponentGuid != Guid.Empty &&
                  PIMComponentGuid == Guid.Empty || (Project.VerifyComponentType <PSMAttribute>(PSMComponentGuid) && Project.VerifyComponentType <PIMAttribute>(PIMComponentGuid))
                  ))
            {
                ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH;
                return(false);
            }

            if (PIMComponentGuid == Guid.Empty)
            {
                return(true);
            }

            PIMClass pimClass1 = Project.TranslateComponent <PIMAttribute>(PIMComponentGuid).PIMClass;
            PSMClass niClass   = Project.TranslateComponent <PSMAttribute>(PSMComponentGuid).NearestInterpretedClass();

            if (niClass == null)
            {
                ErrorDescription = CommandErrors.CMDERR_CANNOT_SET_INTERPRETATION_NO_INTCLASS;
                return(false);
            }
            PIMClass pimClass2 = niClass.Interpretation as PIMClass;

            if (pimClass1 != pimClass2 && !pimClass2.GetGeneralClasses().Contains(pimClass1))
            {
                ErrorDescription = CommandErrors.CMDERR_CANNOT_SET_INTERPRETATION_CLASSES_DONT_MATCH;
                return(false);
            }
            return(true);
        }
Beispiel #6
0
        public PSMAttribute AddAttribute(Property attribute)
        {
            if (attribute == null)
            {
                return(AddAttribute());
            }

            PIMClass represented = RepresentedClass;

            if (attribute != null && !represented.MeAndAncestors.Contains(attribute.Class))
            {
                throw new ArgumentException("The given attribute is not owned by the represented class!");
            }

            PSMAttribute attr = new _PSMAttribute(attribute, Schema);

            attributes.Add(attr);
            attr.Diagram = this.Diagram;
            attribute.DerivedPSMAttributes.Add(attr);

            if (attribute.Class != represented)
            {
                List <Generalization> path = represented.GetPathToAncestor(attribute.Class);
                if (path != null)
                {
                    foreach (Generalization gen in path)
                    {
                        gen.ReferencingPSMAttributes.Add(attr);
                        attr.UsedGeneralizations.Add(gen);
                    }
                }
            }

            return(attr);
        }
Beispiel #7
0
        public override bool VerifyConsistency(object superordinateObject, object candidate)
        {
            PIMClass     pimClass     = (PIMClass)superordinateObject;
            PIMAttribute pimAttribute = (PIMAttribute)candidate;

            return(pimClass.PIMAttributes.Contains(pimAttribute));
        }
Beispiel #8
0
 void Current_SelectionChanged()
 {
     if (bApply.IsEnabled && !applyButtonPressed)
     {
         if (ExolutioYesNoBox.Show("Changes not applied", "Apply performed changes?") == MessageBoxResult.Yes)
         {
             bApply_Click(null, null);
         }
         bApply.IsEnabled = false;
     }
     if (Current.ActiveDiagramView is PIMDiagramView)
     {
         PIMClass newSelection = Current.ActiveDiagramView.GetSingleSelectedComponentOrNull() as PIMClass;
         if (newSelection != null)
         {
             Initialize(controller, newSelection);
         }
         else
         {
             PIMAttribute a = Current.ActiveDiagramView.GetSingleSelectedComponentOrNull() as PIMAttribute;
             if (a != null)
             {
                 Initialize(controller, a.PIMClass, a);
             }
         }
     }
     else
     {
         this.Close();
     }
 }
Beispiel #9
0
        public static bool VerifyAttributeClassPair(params object[] verifiedObjects)
        {
            PIMAttribute attribute = (PIMAttribute)verifiedObjects[1];
            PIMClass     @class    = (PIMClass)verifiedObjects[0];

            return(@class.PIMAttributes.Contains(attribute));
        }
Beispiel #10
0
        public void Initialize(Exolutio.Controller.Controller controller, PIMClass PIMClass, PIMAttribute initialSelectedAttribute = null)
        {
            this.controller = controller;
            this.PIMClass   = PIMClass;

            this.Title = string.Format(this.Title, PIMClass);

            tbName.Text = PIMClass.Name;
            //tbElementLabel.Text = PIMClass.ElementName;
            //cbAbstract.IsChecked = PIMClass.IsAbstract;
            //cbAnyAttribute.IsChecked = PIMClass.AllowAnyAttribute;

            typeColumn.ItemsSource = PIMClass.ProjectVersion.GetAvailablePIMTypes();

            fakeAttributesList = new ObservableCollection <FakePIMAttribute>();

            fakeAttributes = new FakeAttributeCollection(fakeAttributesList, PIMClass);
            fakeAttributesList.CollectionChanged += delegate { UpdateApplyEnabled(); };
            gridAttributes.ItemsSource            = fakeAttributesList;

            if (initialSelectedAttribute != null)
            {
                gridAttributes.SelectedItem = fakeAttributesList.SingleOrDefault(fa => fa.SourceAttribute == initialSelectedAttribute);
            }

            dialogReady      = true;
            bApply.IsEnabled = false;
        }
Beispiel #11
0
        internal override void GenerateSubCommands()
        {
            PIMClass pimClass = Project.TranslateComponent <PIMClass>(ClassGuid);

            foreach (PIMAttribute a in pimClass.PIMAttributes)
            {
                cmdDeletePIMAttribute da = new cmdDeletePIMAttribute(Controller);
                da.Set(a);
                Commands.Add(da);
            }

            List <PIMAssociation> associations =
                pimClass.PIMAssociationEnds
                .Select <PIMAssociationEnd, PIMAssociation>(e => e.PIMAssociation)
                .Distinct <PIMAssociation>()
                .ToList <PIMAssociation>();

            foreach (PIMAssociation a in associations)
            {
                cmdDeletePIMAssociation da = new cmdDeletePIMAssociation(Controller);
                da.Set(a);
                Commands.Add(da);
            }

            Commands.Add(new acmdRenameComponent(Controller, ClassGuid, ""));
            Commands.AddRange(acmdRemoveComponentFromDiagram.CreateCommandsToRemoveFromAllDiagrams(Controller, ClassGuid));
            Commands.Add(new acmdDeletePIMClass(Controller, ClassGuid));
        }
Beispiel #12
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PIMClass pimClass = Project.TranslateComponent <PIMClass>(classGuid);

            pimClass.Abstract = oldAbstract;
            return(OperationResult.OK);
        }
Beispiel #13
0
        internal override void CommandOperation()
        {
            PIMClass pimClass = Project.TranslateComponent <PIMClass>(classGuid);

            oldAbstract       = pimClass.Abstract;
            pimClass.Abstract = newAbstract;
            Report            = new CommandReport(CommandReports.PIM_CLASS_ABSTRACT_CHANGED, pimClass, oldAbstract, pimClass.Abstract);
        }
Beispiel #14
0
        public NestingJoin AddNestingJoin(PIMClass coreClass)
        {
            NestingJoin nj = new _NestingJoing(coreClass);

            nestingJoins.Add(nj);

            return(nj);
        }
Beispiel #15
0
        internal override void CommandOperation()
        {
            PIMClass pimClass = Project.TranslateComponent <PIMClass>(classGuid);

            oldFinal       = pimClass.Final;
            pimClass.Final = newFinal;
            Report         = new CommandReport(CommandReports.PIM_CLASS_FINAL_CHANGED, pimClass, oldFinal, pimClass.Final);
        }
Beispiel #16
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PIMClass c = Project.TranslateComponent <PIMClass>(ClassGuid);

            Project.TranslateComponent <PIMSchema>(schemaGuid).PIMClasses.Remove(c);
            Project.mappingDictionary.Remove(ClassGuid);
            return(OperationResult.OK);
        }
        public override bool VerifyConsistency(object superordinateObject, object candidate)
        {
            PIMAttribute pimAttribute = (PIMAttribute)superordinateObject;
            PIMClass     pimClass     = (PIMClass)candidate;

            return(pimAttribute.PIMClass != pimClass &&
                   pimAttribute.PIMClass.PIMAssociationEnds.Any(e => e.PIMAssociation.PIMClasses.Contains(pimClass)));
        }
Beispiel #18
0
        internal override void CommandOperation()
        {
            PIMClass c = Project.TranslateComponent <PIMClass>(deletedClassGuid);

            Report = new CommandReport(CommandReports.PIM_component_deleted, c);
            Project.TranslateComponent <PIMSchema>(schemaGuid).PIMClasses.Remove(c);
            Project.mappingDictionary.Remove(deletedClassGuid);
        }
Beispiel #19
0
 /// <summary>
 /// Creates instance which represents <paramref name="sourceClass"/> in OCL type system.
 /// </summary>
 /// <param name="tt">Destination OCL type system.</param>
 /// <param name="sourceClass">Source class</param>
 /// <param name="parent">Parent of <paramref name="sourceClass"/> in inheritance hierarchy (if it has any)</param>
 /// <param name="nameOverride">Use this parameter when the class in the OCL should be registered under a
 /// different name than <paramref name="sourceClass"/>.<see cref="PIMClass.Name"/></param>
 public PIMBridgeClass(TypesTable.TypesTable tt, Namespace ns, PIMClass sourceClass, PIMBridgeClass parent = null,
                       string nameOverride = null)
     : base(tt, ns, nameOverride ?? sourceClass.Name, parent ?? tt.Library.Any)
 {
     this.SourceClass = sourceClass;
     PIMAttribute     = new Dictionary <PIMAttribute, PIMBridgeAttribute>();
     PIMAssociations  = new Dictionary <PIMAssociationEnd, PIMBridgeAssociation>();
     PIMOperations    = new Dictionary <ModelOperation, Operation>();
 }
Beispiel #20
0
        public void AddAssociationEnd(Association association, PIMClass newClass)
        {
            AddAnotherAssociationEndCommand addAnotherAssociationEndCommand =
                (AddAnotherAssociationEndCommand)AddAnotherAssociationEndCommandFactory.Factory().Create(DiagramController.ModelController);

            addAnotherAssociationEndCommand.Association = association;
            addAnotherAssociationEndCommand.Class       = newClass;
            addAnotherAssociationEndCommand.Execute();
        }
Beispiel #21
0
 private void OnClassEditClick(object sender, RoutedEventArgs e)
 {
     if (((MenuItem)sender).DataContext is PIMClass)
     {
         PIMClass aClass      = ((MenuItem)sender).DataContext as PIMClass;
         var      classDialog = new ClassDialog(
             new ClassController(aClass, new DiagramController(null, project.GetModelController())), project.GetModelController());
         classDialog.ShowDialog();
     }
 }
Beispiel #22
0
        internal override void CommandOperation()
        {
            if (ClassGuid == Guid.Empty)
            {
                ClassGuid = Guid.NewGuid();
            }
            PIMClass pimClass = new PIMClass(Project, ClassGuid, Project.TranslateComponent <PIMSchema>(schemaGuid));

            Report = new CommandReport(CommandReports.PIM_component_added, pimClass);
        }
Beispiel #23
0
        void PPSMtoPSM(P_PSMDiagram D)
        {
            NewModelClassCommand addPIMClass = NewModelClassCommandFactory.Factory().Create(DiagramController.ModelController) as NewModelClassCommand;

            addPIMClass.Package = DiagramController.Project.Schema.Model;
            addPIMClass.Execute();
            tempPIMClass = addPIMClass.CreatedClass.Element;

            X.p.Maximum    = X.ClassesCount;
            X.p.Value      = 0;
            X.p.Visibility = Visibility.Visible;
            X.l.Visibility = Visibility.Visible;
            if (!Layout)
            {
                TreeLayout.SwitchOff();
            }
            Stopwatch S = new Stopwatch();

            S.Start();
            if (UseCommands)
            {
                GeneratePSM(D);
            }
            else
            {
                DiagramController.getUndoStack().Invalidate();
                DiagramController.getRedoStack().Invalidate();
                GeneratePSM2(D);
            }
            S.Stop();
            X.t.Text += "Generated PSM in " + S.ElapsedMilliseconds.ToString() + "ms" + Environment.NewLine;

            S = new Stopwatch();
            S.Start();
            if (UseCommands)
            {
                LinkSRs(D);
            }
            else
            {
                LinkSRs2(D);
            }
            S.Stop();
            X.t.Text += "Linked SRs in " + S.ElapsedMilliseconds.ToString() + "ms" + Environment.NewLine;
            if (!Layout)
            {
                TreeLayout.SwitchOn();
            }

            //Only to refresh GUI, which normally happens after each command
            ActivateDiagramCommand A = ActivateDiagramCommandFactory.Factory().Create(DiagramController.ModelController) as ActivateDiagramCommand;

            A.Set(DiagramController.Diagram);
            A.Execute();
        }
Beispiel #24
0
 private void TextBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (representedClassBox.DataContext is PSMClass)
     {
         PIMClass representedClass = ((PSMClass)representedClassBox.DataContext).RepresentedClass;
         if (representedClass != null)
         {
             GoToPIMClass(representedClass);
         }
     }
 }
Beispiel #25
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PIMAssociationEnd pimAssociationEnd = Project.TranslateComponent <PIMAssociationEnd>(associationEndGuid);
            PIMClass          generalClass      = Project.TranslateComponent <PIMClass>(generalClassGuid);
            PIMClass          specialClass      = Project.TranslateComponent <PIMClass>(specialClassGuid);

            specialClass.PIMAssociationEnds.Remove(pimAssociationEnd);
            pimAssociationEnd.PIMClass = generalClass;
            generalClass.PIMAssociationEnds.Insert(pimAssociationEnd, index);
            return(OperationResult.OK);
        }
Beispiel #26
0
        /// <summary>
        /// Creates a new PIM step begining in start, ending in end and using association.
        /// </summary>
        /// <param name="start">Reference to the starting PIM class</param>
        /// <param name="end">Reference to the ending PIM class</param>
        /// <param name="association">Association used to get from start to end.</param>
        public _PIMStep(PIMClass start, PIMClass end, Association association)
        {
            if ((start == null) || (end == null) || (association == null))
            {
                throw new ArgumentException("All the members of the step have to be set to non-null values!");
            }

            this.start       = start;
            this.end         = end;
            this.association = association;
        }
Beispiel #27
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PIMGeneralization pimGeneralization = Project.TranslateComponent <PIMGeneralization>(generalizationGuid);
            PIMClass          oldClass          = Project.TranslateComponent <PIMClass>(oldClassGuid);
            PIMClass          newClass          = oldClass.GeneralizationAsSpecific.General;

            newClass.GeneralizationsAsGeneral.Remove(pimGeneralization);
            pimGeneralization.General = oldClass;
            oldClass.GeneralizationsAsGeneral.Insert(pimGeneralization, index);
            return(OperationResult.OK);
        }
        internal override CommandBase.OperationResult UndoOperation()
        {
            PIMGeneralization pimGeneralization = Project.TranslateComponent <PIMGeneralization>(generalizationGuid);
            PIMClass          generalClass      = Project.TranslateComponent <PIMClass>(generalClassGuid);
            PIMClass          specialClass      = Project.TranslateComponent <PIMClass>(specialClassGuid);

            specialClass.GeneralizationsAsGeneral.Remove(pimGeneralization);
            pimGeneralization.General = generalClass;
            generalClass.GeneralizationsAsGeneral.Insert(pimGeneralization, index);
            return(OperationResult.OK);
        }
Beispiel #29
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PIMAttribute pimAttribute = Project.TranslateComponent <PIMAttribute>(attributeGuid);
            PIMClass     oldClass     = Project.TranslateComponent <PIMClass>(oldClassGuid);
            PIMClass     newClass     = Project.TranslateComponent <PIMClass>(newClassGuid);

            newClass.PIMAttributes.Remove(pimAttribute);
            pimAttribute.PIMClass = oldClass;
            oldClass.PIMAttributes.Insert(pimAttribute, index);
            return(OperationResult.OK);
        }
        internal override CommandBase.OperationResult UndoOperation()
        {
            PIMAttribute pimAttribute = Project.TranslateComponent <PIMAttribute>(attributeGuid);
            PIMClass     generalClass = Project.TranslateComponent <PIMClass>(generalClassGuid);
            PIMClass     specialClass = Project.TranslateComponent <PIMClass>(specialClassGuid);

            specialClass.PIMAttributes.Remove(pimAttribute);
            pimAttribute.PIMClass = generalClass;
            generalClass.PIMAttributes.Insert(pimAttribute, index);
            return(OperationResult.OK);
        }