Beispiel #1
0
        /// <summary>
        /// Creates a new attribute container.
        /// It is an UML Class with XSem.PSMAttributeContainer stereotype.
        /// </summary>
        /// <param name="_parent">
        /// Reference to a component that is the parent of this container.
        /// </param>
        /// <param name="_schema">
        /// Reference to the Schema instance that is the top
        /// of this model hierarchy.
        /// </param>
        public _PSMAttributeContainer(PSMSuperordinateComponent _parent, Schema _schema)
            : base(_schema, StereotypeTarget.Class)
        {
            parent     = _parent;
            attributes = new ObservableCollection <PSMAttribute>();
            attributes.CollectionChanged += OnAttributesChanged;

            adaptedElement = NUml.Uml2.Create.Class();

            // Get the XSem.PSMAttributeContainer stereotype and apply it
            // The stereotype instance is then removed from the collection to hide it from the user.
            try
            {
                Stereotype xsem = Schema.Profiles.Get("XSem").Stereotypes.Get("PSMAttributeContainer");
                xsemStereotype = xsem.ApplyTo(this);
                AppliedStereotypes.Remove(xsemStereotype);
            }
            catch (NullReferenceException)
            {
                throw new Exception("Fatal error! Cannot find the XSem profile or " +
                                    "the XSem.PSMAttributeContainer stereotype!");
            }

            // Initialize the stereotype instance
            xsemStereotype.Attributes.Get("Parent").Value = new ValueSpecification(parent);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new PSM class representing the given PIM class.
        /// </summary>
        /// <param name="applyXSem">
        /// If true, XSem.PSMClass stereotype is applied to the represented class,
        /// otherwise the class is not extended.
        /// </param>
        /// <param name="representedPIMClass">Reference to the represented PIM class</param>
        /// <param name="_schema">
        /// Reference to the Schema instance that is the top
        /// of this model hierarchy.
        /// </param>
        /// <exception cref="ArgumentException">Given class is not a PIM class</exception>
        public _PSMClass(bool applyXSem, PIMClass representedPIMClass, Schema _schema)
            : base(_schema)
        {
            // Initialize the adapter
            psmAttributes = new ObservableCollection <PSMAttribute>();
            psmAttributes.CollectionChanged += OnPSMAttributesChanged;
            components = new ObservableCollection <PSMSubordinateComponent>();
            components.CollectionChanged += OnComponentsChanged;

            if (applyXSem)
            {
                // Get the XSem.PSMClass stereotype and apply it to this class
                // The stereotype instance is then removed from the collection to hide it from the user.
                try
                {
                    Stereotype stPSMClass = Schema.Profiles.Get("XSem").Stereotypes.Get("PSMClass");
                    xsemStereotype = stPSMClass.ApplyTo(this);
                    AppliedStereotypes.Remove(xsemStereotype);
                }
                catch (NullReferenceException)
                {
                    throw new Exception("Fatal error! Cannot find the XSem profile or XSem.PSMClass stereotype!");
                }

                // Initialize the stereotype instance
                xsemStereotype.Attributes.Get("RepresentedClass").Value = new ValueSpecification(representedPIMClass);
                xsemStereotype.Attributes.Get("ElementName").Value      = new ValueSpecification(representedPIMClass.Name);
            }

            this.representedClass = representedPIMClass;
            this.representedClass.PropertyChanged +=
                delegate(object sender, System.ComponentModel.PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Name")
                {
                    NotifyPropertyChanged("RepresentedClassName");
                }
            };
            this.representedClass.DerivedPSMClasses.CollectionChanged +=
                delegate(object sender, NotifyCollectionChangedEventArgs e)
            {
                NotifyPropertyChanged("RepresentedClassRepresentants");
            };

            // Initialize the class
            Package    = representedClass.Package;
            Visibility = representedClass.Visibility;
            Name       = representedClass.Name;

            representedClass.PropertyChanged += OnRepresentedClassChanged;
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new PSM Class union.
        /// </summary>
        /// <param name="_schema">
        /// Reference to the Schema instance that is the top
        /// of this model hierarchy.
        /// </param>
        public _PSMClassUnion(Schema _schema) : base(_schema, StereotypeTarget.Class)
        {
            adaptedElement = NUml.Uml2.Create.Class();
            components     = new ObservableCollection <PSMAssociationChild>();

            components.CollectionChanged += OnComponentsChanged;

            // Get the XSem.PSMClassUnion stereotype and apply it to this class
            try
            {
                Stereotype xsem = Schema.Profiles.Get("XSem").Stereotypes.Get("PSMClassUnion");
                xsemStereotype = xsem.ApplyTo(this);
                AppliedStereotypes.Remove(xsemStereotype);
            }
            catch (NullReferenceException)
            {
                throw new Exception("Fatal error! XSem profile or XSem.PSMClassUnion stereotype cannot be found!");
            }
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new PSM Content choice component.
        /// It is an UML class with XSem.PSMContentChoice stereotype.
        /// </summary>
        /// <param name="_parent">
        /// Reference to a component that is the parent of this one
        /// </param>
        /// <param name="_schema">
        /// Reference to the Schema instance that is the top
        /// of this model hierarchy.
        /// </param>
        public _PSMContentChoice(PSMSuperordinateComponent _parent, Schema _schema) : base(_schema)
        {
            parent = _parent;

            // Get the PSMContentChoice stereotype and apply it to this class
            try
            {
                Stereotype xsem = Schema.Profiles.Get("XSem").Stereotypes.Get("PSMContentChoice");
                xsemStereotype = xsem.ApplyTo(this);
                AppliedStereotypes.Remove(xsemStereotype);
            }
            catch (NullReferenceException)
            {
                throw new Exception("Fatal error! Cannot find the XSem profile or " +
                                    "the XSem.PSMContentChoice stereotype!");
            }

            // Initialize the stereotype instance
            xsemStereotype.Attributes.Get("Parent").Value = new ValueSpecification(parent);
        }
Beispiel #5
0
        /// <summary>
        /// Creates a new PSM Association with the parent set.
        /// </summary>
        /// <param name="parent">
        /// References the parent component (the one the association starts in).
        /// </param>
        /// <param name="schema">
        /// Reference to the Schema instance that is the top
        /// of this model hierarchy.
        /// </param>
        /// <exception cref="ArgumentException">
        /// The parent component was not created in the model library
        /// </exception>
        public _PSMAssociation(PSMSuperordinateComponent parent, Schema schema)
            : base(schema, StereotypeTarget.Association)
        {
            nestingJoins = new ObservableCollection <NestingJoin>();
            nestingJoins.CollectionChanged += OnNestingJoinsChanged;
            this.parent = parent;

            adaptedElement = NUml.Uml2.Create.Association();
            parentEnd      = NUml.Uml2.Create.Property();
            childEnd       = NUml.Uml2.Create.Property();

            if (!(parent is _ImplPSMSuperordinateComponent))
            {
                throw new ArgumentException("The parent component was not created in the model library!");
            }

            parentEnd.Class       = ((_ImplPSMSuperordinateComponent)parent).AdaptedClass;
            parentEnd.Association = adaptedElement;
            childEnd.Association  = adaptedElement;

            adaptedElement.OwnedEnd.Add(parentEnd);
            adaptedElement.OwnedEnd.Add(childEnd);

            lower = 1;

            try
            {
                Stereotype stPSMAssoc = schema.Profiles.Get("XSem").Stereotypes.Get("PSMAssociation");
                xsemStereotype = stPSMAssoc.ApplyTo(this);
                AppliedStereotypes.Remove(xsemStereotype);
            }
            catch (NullReferenceException)
            {
                throw new Exception("Fatal error! Cannot find the XSem profile or XSem.PSMClass stereotype!");
            }

            referencedGeneralizations = new ObservableCollection <Generalization>();
        }
Beispiel #6
0
        /// <summary>
        /// Creates a PSM attribute representing the given PIM attribute.
        /// </summary>
        /// <param name="representedAttribute">
        /// Reference to the represented PIM attribute
        /// </param>
        /// <param name="_schema">
        /// Reference to the Schema instance that is the top
        /// of this model hierarchy.
        /// </param>
        /// <exception cref="ArgumentException">
        /// If the given property reference is not a PIM attribute.
        /// </exception>
        public _PSMAttribute(Property representedAttribute, Schema _schema) : base(_schema)
        {
            if (representedAttribute != null &&
                ((representedAttribute is AssociationEnd) || (representedAttribute is PSMAttribute))
                )
            {
                throw new ArgumentException("The PSM attribute can only represent a PIM attribute");
            }

            this.representedAttribute = representedAttribute;
            if (representedAttribute != null)
            {
                representedAttribute.PropertyChanged += OnRepresentedAttributeChanged;
            }

            // Get the XSem.PSMAttribute stereotype and apply it
            try
            {
                Stereotype xsemSt = Schema.Profiles.Get("XSem").Stereotypes.Get("PSMAttribute");
                xsemStereotype = xsemSt.ApplyTo(this);
                AppliedStereotypes.Remove(xsemStereotype);
            }
            catch (NullReferenceException)
            {
                throw new Exception("Fatal error! Cannot find the XSem profile or the XSem.PSMAttribute stereotype!");
            }

            // Initialize the stereotype instance
            Property ra;
            string   elname;

            if (representedAttribute != null)
            {
                elname = representedAttribute.Name;
                ra     = representedAttribute;

                // Initialize the attribute properties
                Name         = representedAttribute.Name;
                Aggregation  = representedAttribute.Aggregation;
                Default      = representedAttribute.Default;
                DefaultValue = representedAttribute.DefaultValue;
                IsComposite  = representedAttribute.IsComposite;
                IsDerived    = representedAttribute.IsDerived;
                IsOrdered    = representedAttribute.IsOrdered;
                IsReadOnly   = representedAttribute.IsReadOnly;
                IsUnique     = representedAttribute.IsUnique;
                Lower        = representedAttribute.Lower;
                Type         = representedAttribute.Type;
                Upper        = representedAttribute.Upper;
                Visibility   = representedAttribute.Visibility;
            }
            else
            {
                elname = Name;
                ra     = null;
            }

            xsemStereotype.Attributes.Get("RepresentedAttribute").Value = new ValueSpecification(ra);
            xsemStereotype.Attributes.Get("Alias").Value = new ValueSpecification(elname);

            referencedGeneralizations = new ObservableCollection <Generalization>();
        }