/// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            if (this.elementViewModel != null)
            {
                this.elementViewModel.Dispose();
            }

            this.elementViewModel = null;

            if (this.DiagramTreeNode != null)
            {
                if (this.presentationElementClassId != null)
                {
                    this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ShapeClassReferencesDomainClass.DomainClassId),
                                                                                          true, this.presentationElementClassId.Value, new Action <ElementAddedEventArgs>(OnShapeElementAdded));

                    this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ShapeClassReferencesDomainClass.DomainClassId),
                                                                                            true, this.presentationElementClassId.Value, new Action <ElementDeletedEventArgs>(OnShapeElementRemoved));

                    this.EventManager.GetEvent <ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(ShapeClassReferencesDomainClass.DomainClassDomainRoleId),
                                                                                           new Action <RolePlayerChangedEventArgs>(OnShapeElementChanged));

                    this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(RelationshipShapeClassReferencesReferenceRelationship.DomainClassId),
                                                                                          true, this.presentationElementClassId.Value, new Action <ElementAddedEventArgs>(OnRSShapeElementAdded));

                    this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(RelationshipShapeClassReferencesReferenceRelationship.DomainClassId),
                                                                                            true, this.presentationElementClassId.Value, new Action <ElementDeletedEventArgs>(OnRSShapeElementRemoved));

                    this.EventManager.GetEvent <ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(RelationshipShapeClassReferencesReferenceRelationship.DomainRelationshipDomainRoleId),
                                                                                           new Action <RolePlayerChangedEventArgs>(OnRSShapeElementChanged));
                }
            }

            base.OnDispose();
        }
Esempio n. 2
0
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            if (this.ReferenceVM != null)
            {
                this.ReferenceVM.Dispose();
            }

            if (this.DiagramClassView != null)
            {
                if (this.DiagramClassView.DiagramClass != null)
                {
                    this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ModalDiagramReferencesDomainClass.DomainClassId),
                                                                                          true, this.DiagramClassView.DiagramClass.Id, new Action <ElementAddedEventArgs>(OnReferenceAdded));

                    this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ModalDiagramReferencesDomainClass.DomainClassId),
                                                                                            true, this.DiagramClassView.DiagramClass.Id, new Action <ElementDeletedEventArgs>(OnReferenceRemoved));

                    this.EventManager.GetEvent <ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(ModalDiagramReferencesDomainClass.DomainClassId),
                                                                                           new Action <RolePlayerChangedEventArgs>(OnReferenceChanged));
                }
            }

            this.ReferenceVM = null;

            base.OnDispose();
        }
Esempio n. 3
0
        /// <summary>
        /// Finds a view model that is representing the given model element.
        /// </summary>
        /// <param name="element">Model element.</param>
        /// <returns>View model if found; Null otherwise.</returns>
        public override BaseModelElementViewModel FindViewModel(ModelElement element)
        {
            BaseModelElementViewModel m = base.FindViewModel(element);

            if (m != null)
            {
                return(m);
            }

            foreach (EmbeddingNodeViewModel vm in EmbeddingNodes)
            {
                if (vm.Element == element && vm.IsElementHolder)
                {
                    return(vm);
                }

                BaseModelElementViewModel retVm = vm.FindViewModel(element);
                if (retVm != null)
                {
                    return(retVm);
                }
            }

            return(null);
        }
        /// <summary>
        /// Deletes the view model that is hosting the given element.
        /// </summary>
        /// <param name="node">Element.</param>
        public void DeleteElement()
        {
            if (this.elementViewModel != null)
            {
                this.elementViewModel.Dispose();
            }

            this.elementViewModel = null;

            OnPropertyChanged("DiagramElementViewModel");
        }
        /// <summary>
        /// Navigate To Element Command executed.
        /// </summary>
        protected virtual void NavigateToElementCommand_Executed()
        {
            BaseModelElementViewModel selectedValue = GetPropertyValue() as BaseModelElementViewModel;

            if (selectedValue != null)
            {
                SelectedItemsCollection col = new SelectedItemsCollection();
                col.Add(selectedValue.Element);
                EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
            }
        }
        /// <summary>
        /// Initialization routine.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            if (this.modelElement != null)
            {
                this.modelElementVM = new BaseModelElementViewModel(this.ViewModelStore, this.modelElement, true);

                // if the hosted element is deleted, we have to close this
                this.EventManager.GetEvent <ModelElementDeletedEvent>().Subscribe(this.modelElement.Id, OnModelElementDeleted);
            }
        }
Esempio n. 7
0
        public static List <DataTemplateViewModel> GetRelationshipShapeClassTemplate(BaseModelElementViewModel vm)
        {
            RelationshipShapeClass shapeClass = vm.GetHostedElement() as RelationshipShapeClass;
            MetaModel metaModel = shapeClass.GetMetaModel();

            List <DataTemplateViewModel> retVms = ParseFile(vm.ViewModelStore, "RelationshipShapeClassTemplate.xml",
                                                            new string[] {
                shapeClass.Name,                                // CustomString0
                metaModel.Namespace,                            // CustomString1
            });

            retVms.Add(CreateBindablePropertiesTemplate(vm));
            return(retVms);
        }
        /// <summary>
        /// Adds a new view model for the given element.
        /// </summary>
        /// <param name="node">Element.</param>
        public void AddRSShapeElement(DomainRelationship element)
        {
            if (this.elementViewModel != null)
            {
                this.elementViewModel.Dispose();
            }

            if (element != null)
            {
                this.elementViewModel = new BaseModelElementViewModel(this.ViewModelStore, element);
            }

            OnPropertyChanged("DiagramElementViewModel");
        }
        /// <summary>
        /// Reset.
        /// </summary>
        protected override void Reset()
        {
            if (this.HostedElement != null)
            {
                if (this.hostedElement.Element != null)
                {
                    this.EventManager.GetEvent <ModelElementDeletedEvent>().Unsubscribe(this.hostedElement.Element.Id, OnHostedElementDeleted);
                }

                this.hostedElement.Dispose();
                this.HostedElement = null;
            }

            base.Reset();
        }
Esempio n. 10
0
        /// <summary>
        /// Do drag drop.
        /// </summary>
        public void DoDragDrop(IDataObject dataObject)
        {
            try
            {
                string[] formats = dataObject.GetFormats();
                foreach (string format in formats)
                {
                    object data = dataObject.GetData(format);
                    if (data is BaseModelElementViewModel)
                    {
                        BaseModelElementViewModel vm = data as BaseModelElementViewModel;
                        ModelElement m = vm.Element as ModelElement;

                        string targetName = "#" + KeyGenerator.Instance.ConvertGuidToVModellID(m.Id);
                        string targetText = "";

                        if (m is IDomainModelOwnable)
                        {
                            if ((m as IDomainModelOwnable).DomainElementHasName)
                            {
                                targetText = (m as IDomainModelOwnable).DomainElementName;
                            }
                            else
                            {
                                targetText = (m as IDomainModelOwnable).DomainElementTypeDisplayName;
                            }
                        }

                        /*if (this.ViewModelStore.GetDomainModelServices(m).ElementNameProvider.HasName(m))
                         *  targetText = this.ViewModelStore.GetDomainModelServices(m).ElementNameProvider.GetName(m);
                         * else
                         *  targetText = this.ViewModelStore.GetDomainModelServices(m).ElementTypeProvider.GetTypeDisplayName(m);
                         */

                        if (this.HtmlRichTextEditor != null)
                        {
                            this.HtmlRichTextEditor.InsertHyperlink(targetText, targetName);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                IMessageBoxService messageBox = this.GlobalServiceProvider.Resolve <IMessageBoxService>();
                messageBox.ShowError(ex.Message);
            }
        }
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            if (this.modelElement != null)
            {
                this.EventManager.GetEvent <ModelElementDeletedEvent>().Unsubscribe(this.modelElement.Id, OnModelElementDeleted);

                BaseModelElementViewModel v = this.modelElementVM;
                this.modelElementVM = null;

                OnPropertyChanged("HostedElementVM");
                v.Dispose();

                this.modelElement = null;
            }

            base.OnDispose();
        }
        /// <summary>
        /// Sets the reference.
        /// </summary>
        /// <param name="node">Node.</param>
        public void AddReference(DomainClass node)
        {
            // verify that element has not been added yet
            foreach (BaseModelElementViewModel viewModel in this.referenceVMs)
            {
                if (viewModel.Element.Id == node.Id)
                {
                    return;
                }
            }

            BaseModelElementViewModel vm = new BaseModelElementViewModel(this.ViewModelStore, node, true);

            this.referenceVMs.Add(vm);

            OnPropertyChanged("ReferenceVMs");
        }
        public static List<DataTemplateViewModel> GetTemplates(BaseModelElementViewModel vm)
        {
            List<DataTemplateViewModel> templates = new List<DataTemplateViewModel>();
            if (vm is BaseAttributeElementViewModel)
            {
                templates.AddRange(ModelTreeDataTemplates.GetDomainElementViewModelTemplates(vm as BaseAttributeElementViewModel));
            }

            if (vm is TreeNodeViewModel)
            {
                List<DataTemplateViewModel> temp = ModelTreeDataTemplates.GetDomainClassPropertyGridViewModelTemplates(vm as TreeNodeViewModel);
                if( temp != null )
                    templates.AddRange(temp);
            }

            return templates;
        }
        private void DeleteCommand_Executed(BaseModelElementViewModel vm)
        {
            DomainClass d = vm.Element as DomainClass;
            if (d != null)
            {
                SpecificElementsDiagram diagram = this.DiagramClassView.DiagramClass as SpecificElementsDiagram;
                if (diagram.DomainClasses.Contains(d))
                {
                    using (Transaction t = this.Store.TransactionManager.BeginTransaction() )
                    {
                        diagram.DomainClasses.Remove(d);
                        t.Commit();
                    }
                }

                this.RemoveReference(d);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Finds a view model that is representing the given model element.
        /// </summary>
        /// <param name="element">Model element.</param>
        /// <returns>View model if found; Null otherwise.</returns>
        public BaseModelElementViewModel FindViewModel(ModelElement element)
        {
            foreach (EmbeddingDiagramNodeViewModel vm in EmbeddingNodes)
            {
                if (vm.Element == element)
                {
                    return(vm);
                }

                BaseModelElementViewModel retVm = vm.FindViewModel(element);
                if (retVm != null)
                {
                    return(retVm);
                }
            }

            return(null);
        }
        private void DeleteCommand_Executed(BaseModelElementViewModel vm)
        {
            DomainClass d = vm.Element as DomainClass;

            if (d != null)
            {
                SpecificElementsDiagram diagram = this.DiagramClassView.DiagramClass as SpecificElementsDiagram;
                if (diagram.DomainClasses.Contains(d))
                {
                    using (Transaction t = this.Store.TransactionManager.BeginTransaction())
                    {
                        diagram.DomainClasses.Remove(d);
                        t.Commit();
                    }
                }

                this.RemoveReference(d);
            }
        }
        public static List <DataTemplateViewModel> GetTemplates(BaseModelElementViewModel vm)
        {
            List <DataTemplateViewModel> templates = new List <DataTemplateViewModel>();

            if (vm is BaseAttributeElementViewModel)
            {
                templates.AddRange(ModelTreeDataTemplates.GetDomainElementViewModelTemplates(vm as BaseAttributeElementViewModel));
            }

            if (vm is TreeNodeViewModel)
            {
                List <DataTemplateViewModel> temp = ModelTreeDataTemplates.GetDomainClassPropertyGridViewModelTemplates(vm as TreeNodeViewModel);
                if (temp != null)
                {
                    templates.AddRange(temp);
                }
            }

            return(templates);
        }
Esempio n. 18
0
        /// <summary>
        /// Constuctor.
        /// </summary>
        /// <param name="viewModelStore">The store this view model belongs to.</param>
        /// <param name="domainProperty">Domain property.</param>
        /// <param name="parent">Parent node.</param>
        public DomainPropertyViewModel(ViewModelStore viewModelStore, DomainProperty domainProperty, BaseModelElementViewModel parent)
            : base(viewModelStore, parent.Element)
        {
            this.domainProperty = domainProperty;
            this.parentElement  = parent;

            if (domainProperty != null)
            {
                this.EventManager.GetEvent <ModelElementPropertyChangedEvent>().Subscribe(domainProperty.Id,
                                                                                          new System.Action <ElementPropertyChangedEventArgs>(OnPropertyChanged));

                this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(DomainPropertyReferencesType.DomainClassId),
                                                                                    true, this.DomainProperty.Id, new Action <ElementAddedEventArgs>(OnTypeAdded));

                this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(DomainPropertyReferencesType.DomainClassId),
                                                                                      true, this.DomainProperty.Id, new Action <ElementDeletedEventArgs>(OnTypeRemoved));

                this.EventManager.GetEvent <ModelRolePlayerChangedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRole(DomainPropertyReferencesType.DomainTypeDomainRoleId),
                                                                                     new Action <RolePlayerChangedEventArgs>(OnTypeChanged));
            }
        }
Esempio n. 19
0
        public static List <DataTemplateViewModel> GetTemplates(BaseModelElementViewModel vm)
        {
            if (vm is SpecificDependencyDiagramViewModel)
            {
                return(DataTemplates.GetSpecificDependencyDiagramTemplate(vm as SpecificDependencyDiagramViewModel));
            }
            else if (vm is DependencyDiagramViewModel)
            {
                return(DataTemplates.GetDependencyDiagramTemplate(vm as DependencyDiagramViewModel));
            }
            else if (vm is SpecificElementsDiagramViewModel)
            {
                return(DataTemplates.GetSpecificElementsDiagramTemplate(vm as SpecificElementsDiagramViewModel));
            }
            else if (vm is ModalDiagramViewModel)
            {
                return(DataTemplates.GetModalDiagramTemplate(vm as ModalDiagramViewModel));
            }
            else if (vm is DiagramClassViewModel)
            {
                return(DataTemplates.GetDiagramClassTemplate(vm as DiagramClassViewModel));
            }
            else if (vm.GetHostedElement() is ShapeClass)
            {
                return(DataTemplates.GetShapeClassTemplate(vm));
            }
            else if (vm.GetHostedElement() is RelationshipShapeClass)
            {
                return(DataTemplates.GetRelationshipShapeClassTemplate(vm));
            }
            else if (vm.GetHostedElement() is MappingRelationshipShapeClass)
            {
                return(DataTemplates.GetMappingRelationshipShapeClassTemplate(vm));
            }

            return(new List <DataTemplateViewModel>());
        }
        public static List<DataTemplateViewModel> GetTemplates(BaseModelElementViewModel vm)
        {
            if (vm is SpecificDependencyDiagramViewModel)
            {
                return DataTemplates.GetSpecificDependencyDiagramTemplate(vm as SpecificDependencyDiagramViewModel);
            }
            else if (vm is DependencyDiagramViewModel)
            {
                return DataTemplates.GetDependencyDiagramTemplate(vm as DependencyDiagramViewModel);
            }
            else if (vm is SpecificElementsDiagramViewModel)
            {
                return DataTemplates.GetSpecificElementsDiagramTemplate(vm as SpecificElementsDiagramViewModel);
            }
            else if (vm is ModalDiagramViewModel)
            {
                return DataTemplates.GetModalDiagramTemplate(vm as ModalDiagramViewModel);
            }
            else if (vm is DiagramClassViewModel)
            {
                return DataTemplates.GetDiagramClassTemplate(vm as DiagramClassViewModel);
            }
            else if (vm.GetHostedElement() is ShapeClass)
            {
                return DataTemplates.GetShapeClassTemplate(vm);
            }
            else if (vm.GetHostedElement() is RelationshipShapeClass)
            {
                return DataTemplates.GetRelationshipShapeClassTemplate(vm);
            }
            else if (vm.GetHostedElement() is MappingRelationshipShapeClass)
            {
                return DataTemplates.GetMappingRelationshipShapeClassTemplate(vm);
            }

            return new List<DataTemplateViewModel>();
        }
 /// <summary>
 /// Removes the reference.
 /// </summary>
 /// <param name="node">Node.</param>
 public void RemoveReference(DomainClass node)
 {
     this.ReferenceVM = null;
 }
Esempio n. 22
0
        public static DataTemplateViewModel CreateBindablePropertiesTemplate(BaseModelElementViewModel vm)
        {
            ModelElement            modelElement      = vm.GetHostedElement();
            AttributedDomainElement attrDomainElement = null;

            string specificProperties = "";

            if (modelElement is ShapeClass)
            {
                attrDomainElement = ((modelElement) as ShapeClass).DomainClass;

                specificProperties  = "*** Specific properties: *** " + "\r\n";
                specificProperties += "   AbsoluteLeft (double)" + "\r\n";
                specificProperties += "   AbsoluteTop (double)" + "\r\n";
                specificProperties += "   AbsoluteLocation (PointD(double, double))" + "\r\n";
                specificProperties += "   Bounds (RectangleD(double, double, double, double))" + "\r\n";
                specificProperties += "   CanHaveNestedChildren (bool)" + "\r\n";
                specificProperties += "   CanHaveRelativeChildren (bool)" + "\r\n";
                specificProperties += "   Height (double)" + "\r\n";
                specificProperties += "   IsHeightFixed (bool)" + "\r\n";
                specificProperties += "   IsRelativeChildShape (bool)" + "\r\n";
                specificProperties += "   IsWidthFixed (bool)" + "\r\n";
                specificProperties += "   Left (double)" + "\r\n";
                specificProperties += "   Location (PointD(double, double))" + "\r\n";
                specificProperties += "   Size (SizeD(double, double))" + "\r\n";
                specificProperties += "   TakesPartInRelationship (bool)" + "\r\n";
                specificProperties += "   Top (double)" + "\r\n";
                specificProperties += "   Width (double)" + "\r\n";
                specificProperties += "\r\n";
            }
            else if (modelElement is RelationshipShapeClass || modelElement is MappingRelationshipShapeClass)
            {
                if (modelElement is RelationshipShapeClass)
                {
                    attrDomainElement = ((modelElement) as RelationshipShapeClass).ReferenceRelationship;
                }
                else
                {
                    attrDomainElement = ((modelElement) as MappingRelationshipShapeClass).DomainClass;
                }

                specificProperties  = "*** Specific properties: *** " + "\r\n";
                specificProperties += "   EdgePoints (EdgePointViewModel(X,Y, ...))" + "\r\n";
                specificProperties += "   StartEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n";
                specificProperties += "   MiddleEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n";
                specificProperties += "   EndEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n";
                specificProperties += "   Geometry (PathGeometry)" + "\r\n";
                specificProperties += "   FromAnchorAngle (double)" + "\r\n";
                specificProperties += "   ToAnchorAngle (double)" + "\r\n";
                specificProperties += "   RoutingMode (RoutingMode(Orthogonal, Straight))" + "\r\n";
                specificProperties += "\r\n";
            }

            bool   hasSpecificDomainProperties = false;
            string specificDomainProperties    = "*** Specific domain properties: *** " + "\r\n";

            if (attrDomainElement != null)
            {
                foreach (DomainProperty p in attrDomainElement.Properties)
                {
                    if (p.Type == null)
                    {
                        continue;
                    }

                    hasSpecificDomainProperties = true;
                    specificDomainProperties   += "   Element_" + p.Name + "(" + p.Type.Name + ")" + "\r\n";
                }
            }

            if (!hasSpecificDomainProperties)
            {
                specificDomainProperties = "";
            }
            else
            {
                specificDomainProperties += "\r\n";
            }

            DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore,
                                                                       "Bindable Properties",

                                                                       specificProperties +

                                                                       specificDomainProperties +

                                                                       "*** General properties: *** " + "\r\n" +
                                                                       "   DomainElementName (string)" + "\r\n" +
                                                                       "   DomainElementFullName (string)" + "\r\n" +
                                                                       "   DomainElementHasName (bool)" + "\r\n" +
                                                                       "   DomainElementType (string)" + "\r\n" +
                                                                       "   DomainElementTypeDisplayName (string)" + "\r\n" +
                                                                       "   DomainElementParentHasName (bool)" + "\r\n" +
                                                                       "   DomainElementParentName (string)" + "\r\n" +
                                                                       "   DomainElementParentFullName (string)" + "\r\n" +
                                                                       "   DomainElementParentHasFirstExistingName (bool)" + "\r\n" +
                                                                       "   DomainElementParentFirstExistingName (string)" + "\r\n" +
                                                                       "   DomainElementHasParentFullPath (bool)" + "\r\n" +
                                                                       "   DomainElementParentFullPath (string)");

            template.ImageUri           = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-32x32.png";
            template.Description        = "These are bindable properties you can utilize in your data templates. ";
            template.SyntaxHighlighting = "C#";

            return(template);
        }
Esempio n. 23
0
 /// <summary>
 /// Sets the reference.
 /// </summary>
 /// <param name="node">Node.</param>
 public void SetReference(DomainClass node)
 {
     this.ReferenceVM = new BaseModelElementViewModel(this.ViewModelStore, node);
 }
Esempio n. 24
0
 /// <summary>
 /// Removes the reference.
 /// </summary>
 /// <param name="node">Node.</param>
 public void RemoveReference(DomainClass node)
 {
     this.ReferenceVM = null;
 }
 /// <summary>
 /// Called if the hosted element was deleted.
 /// </summary>
 /// <param name="args">Data</param>
 protected virtual void OnHostedElementDeleted(ElementDeletedEventArgs args)
 {
     this.HostedElement = null;
 }
 /// <summary>
 /// Called if the hosted element was deleted.
 /// </summary>
 /// <param name="args">Data</param>
 protected virtual void OnHostedElementDeleted(ElementDeletedEventArgs args)
 {
     this.HostedElement = null;
 }
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            if (this.modelElement != null)
            {
                this.EventManager.GetEvent<ModelElementDeletedEvent>().Unsubscribe(this.modelElement.Id, OnModelElementDeleted);

                BaseModelElementViewModel v = this.modelElementVM;
                this.modelElementVM = null;
                
                OnPropertyChanged("HostedElementVM");
                v.Dispose();
              
                this.modelElement = null;
            }

            base.OnDispose();
        }
        /// <summary>
        /// Sets the reference.
        /// </summary>
        /// <param name="node">Node.</param>
        public void AddReference(DomainClass node)
        { 
            // verify that element has not been added yet
            foreach (BaseModelElementViewModel viewModel in this.referenceVMs)
                if (viewModel.Element.Id == node.Id)
                    return;

            BaseModelElementViewModel vm = new BaseModelElementViewModel(this.ViewModelStore, node, true);
            this.referenceVMs.Add(vm);

            OnPropertyChanged("ReferenceVMs");
        }
        public static List<DataTemplateViewModel> GetMappingRelationshipShapeClassTemplate(BaseModelElementViewModel vm)
        {
            MappingRelationshipShapeClass shapeClass = vm.GetHostedElement() as MappingRelationshipShapeClass;
            MetaModel metaModel = shapeClass.GetMetaModel();

            List<DataTemplateViewModel> retVms = ParseFile(vm.ViewModelStore, "MappingRelationshipShapeClassTemplate.xml",
                new string[]{
                    shapeClass.Name,                            // CustomString0
                    metaModel.Namespace,                        // CustomString1
                });

            retVms.Add(CreateBindablePropertiesTemplate(vm));
            return retVms;
        }
Esempio n. 30
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="elementVM"></param>
 /// <param name="relationshipType"></param>
 /// <param name="relationshipDomainClassId"></param>
 public SearchElementWithRSTypeStruct(BaseModelElementViewModel elementVM, string relationshipType, Guid relationshipDomainClassId)
 {
     this.elementViewModel          = elementVM;
     this.relationshipType          = relationshipType;
     this.relationshipDomainClassId = relationshipDomainClassId;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="elementVM"></param>
 /// <param name="relationshipType"></param>
 /// <param name="relationshipDomainClassId"></param>
 public SearchElementWithRSTypeStruct(BaseModelElementViewModel elementVM, string relationshipType, Guid relationshipDomainClassId)
 {
     this.elementViewModel = elementVM;
     this.relationshipType = relationshipType;
     this.relationshipDomainClassId = relationshipDomainClassId;
 }
        /// <summary>
        /// Adds a new view model for the given element.
        /// </summary>
        /// <param name="node">Element.</param>
        public void AddRSShapeElement(DomainRelationship element)
        {
            if (this.elementViewModel != null)
                this.elementViewModel.Dispose();

            if (element != null)
                this.elementViewModel = new BaseModelElementViewModel(this.ViewModelStore, element);

            OnPropertyChanged("DiagramElementViewModel");
        }
 /// <summary>
 /// Sets the reference.
 /// </summary>
 /// <param name="node">Node.</param>
 public void SetReference(DomainClass node)
 {
     this.ReferenceVM = new BaseModelElementViewModel(this.ViewModelStore, node);
 }
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            if (this.ReferenceVM != null)
            {
                this.ReferenceVM.Dispose();
            }

            if( this.DiagramClassView != null )
                if (this.DiagramClassView.DiagramClass != null)
                {
                    this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ModalDiagramReferencesDomainClass.DomainClassId),
                        true, this.DiagramClassView.DiagramClass.Id, new Action<ElementAddedEventArgs>(OnReferenceAdded));

                    this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ModalDiagramReferencesDomainClass.DomainClassId),
                        true, this.DiagramClassView.DiagramClass.Id, new Action<ElementDeletedEventArgs>(OnReferenceRemoved));

                    this.EventManager.GetEvent<ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(ModalDiagramReferencesDomainClass.DomainClassId),
                        new Action<RolePlayerChangedEventArgs>(OnReferenceChanged));
                }

            this.ReferenceVM = null;

            base.OnDispose();
        }
        /// <summary>
        /// Initialization routine.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            if (this.modelElement != null)
            {
                this.modelElementVM = new BaseModelElementViewModel(this.ViewModelStore, this.modelElement, true);

                // if the hosted element is deleted, we have to close this
                this.EventManager.GetEvent<ModelElementDeletedEvent>().Subscribe(this.modelElement.Id, OnModelElementDeleted);
            }
        }
        /// <summary>
        /// Deletes the view model that is hosting the given element.
        /// </summary>
        /// <param name="node">Element.</param>
        public void DeleteElement()
        {
            if (this.elementViewModel != null)
                this.elementViewModel.Dispose();

            this.elementViewModel = null;

            OnPropertyChanged("DiagramElementViewModel");
        }
        public static DataTemplateViewModel CreateBindablePropertiesTemplate(BaseModelElementViewModel vm)
        {
            ModelElement modelElement = vm.GetHostedElement();
            AttributedDomainElement attrDomainElement = null;

            string specificProperties = "";
            if (modelElement is ShapeClass)
            {
                attrDomainElement = ((modelElement) as ShapeClass).DomainClass;

                specificProperties =  "*** Specific properties: *** " + "\r\n";
                specificProperties += "   AbsoluteLeft (double)" + "\r\n";
                specificProperties += "   AbsoluteTop (double)" + "\r\n";
                specificProperties += "   AbsoluteLocation (PointD(double, double))" + "\r\n";
                specificProperties += "   Bounds (RectangleD(double, double, double, double))" + "\r\n";
                specificProperties += "   CanHaveNestedChildren (bool)" + "\r\n";
                specificProperties += "   CanHaveRelativeChildren (bool)" + "\r\n";
                specificProperties += "   Height (double)" + "\r\n";
                specificProperties += "   IsHeightFixed (bool)" + "\r\n";
                specificProperties += "   IsRelativeChildShape (bool)" + "\r\n";
                specificProperties += "   IsWidthFixed (bool)" + "\r\n";
                specificProperties += "   Left (double)" + "\r\n";
                specificProperties += "   Location (PointD(double, double))" + "\r\n";
                specificProperties += "   Size (SizeD(double, double))" + "\r\n";
                specificProperties += "   TakesPartInRelationship (bool)" + "\r\n";
                specificProperties += "   Top (double)" + "\r\n";
                specificProperties += "   Width (double)" + "\r\n";
                specificProperties += "\r\n";
            }
            else if (modelElement is RelationshipShapeClass || modelElement is MappingRelationshipShapeClass)
            {
                if (modelElement is RelationshipShapeClass )
                    attrDomainElement = ((modelElement) as RelationshipShapeClass).ReferenceRelationship;
                else
                    attrDomainElement = ((modelElement) as MappingRelationshipShapeClass).DomainClass;

                specificProperties = "*** Specific properties: *** " + "\r\n";
                specificProperties += "   EdgePoints (EdgePointViewModel(X,Y, ...))" + "\r\n";
                specificProperties += "   StartEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n";
                specificProperties += "   MiddleEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n";
                specificProperties += "   EndEdgePoint (IEdgePointViewModel(X,Y,...))" + "\r\n";
                specificProperties += "   Geometry (PathGeometry)" + "\r\n";
                specificProperties += "   FromAnchorAngle (double)" + "\r\n";
                specificProperties += "   ToAnchorAngle (double)" + "\r\n";
                specificProperties += "   RoutingMode (RoutingMode(Orthogonal, Straight))" + "\r\n";
                specificProperties += "\r\n";
            }

            bool hasSpecificDomainProperties = false;
            string specificDomainProperties = "*** Specific domain properties: *** " + "\r\n";

            if (attrDomainElement != null)
            {
                foreach (DomainProperty p in attrDomainElement.Properties)
                {
                    if( p.Type == null )
                        continue;

                    hasSpecificDomainProperties = true;
                    specificDomainProperties += "   Element_" + p.Name + "(" + p.Type.Name + ")" + "\r\n";
                }
            }

            if (!hasSpecificDomainProperties)
                specificDomainProperties = "";
            else
                specificDomainProperties += "\r\n";

            DataTemplateViewModel template = new DataTemplateViewModel(vm.ViewModelStore,
                    "Bindable Properties",

                    specificProperties +
                    
                    specificDomainProperties + 

                    "*** General properties: *** " + "\r\n" +
                    "   DomainElementName (string)" + "\r\n" +
                    "   DomainElementFullName (string)" + "\r\n" +
                    "   DomainElementHasName (bool)" + "\r\n" +
                    "   DomainElementType (string)" + "\r\n" +
                    "   DomainElementTypeDisplayName (string)" + "\r\n" +
                    "   DomainElementParentHasName (bool)" + "\r\n" +
                    "   DomainElementParentName (string)" + "\r\n" +
                    "   DomainElementParentFullName (string)" + "\r\n" +
                    "   DomainElementParentHasFirstExistingName (bool)" + "\r\n" +
                    "   DomainElementParentFirstExistingName (string)" + "\r\n" +
                    "   DomainElementHasParentFullPath (bool)" + "\r\n" +
                    "   DomainElementParentFullPath (string)");
            template.ImageUri = "/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Properties-32x32.png";
            template.Description = "These are bindable properties you can utilize in your data templates. ";
            template.SyntaxHighlighting = "C#";

            return template;
        }
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            if (this.HostedElement != null)
            {
                if (this.hostedElement.Element != null)
                    this.EventManager.GetEvent<ModelElementDeletedEvent>().Unsubscribe(this.hostedElement.Element.Id, OnHostedElementDeleted);

                this.hostedElement.Dispose();
                this.HostedElement = null;
            }

            base.OnDispose();
        }
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            if (this.elementViewModel != null)
                this.elementViewModel.Dispose();

            this.elementViewModel = null;

            if (this.DiagramTreeNode != null)
                if (this.presentationElementClassId != null)
                {
                    this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ShapeClassReferencesDomainClass.DomainClassId),
                        true, this.presentationElementClassId.Value, new Action<ElementAddedEventArgs>(OnShapeElementAdded));

                    this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(ShapeClassReferencesDomainClass.DomainClassId),
                        true, this.presentationElementClassId.Value, new Action<ElementDeletedEventArgs>(OnShapeElementRemoved));

                    this.EventManager.GetEvent<ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(ShapeClassReferencesDomainClass.DomainClassDomainRoleId),
                        new Action<RolePlayerChangedEventArgs>(OnShapeElementChanged));

                    this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(RelationshipShapeClassReferencesReferenceRelationship.DomainClassId),
                        true, this.presentationElementClassId.Value, new Action<ElementAddedEventArgs>(OnRSShapeElementAdded));

                    this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(RelationshipShapeClassReferencesReferenceRelationship.DomainClassId),
                        true, this.presentationElementClassId.Value, new Action<ElementDeletedEventArgs>(OnRSShapeElementRemoved));

                    this.EventManager.GetEvent<ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(RelationshipShapeClassReferencesReferenceRelationship.DomainRelationshipDomainRoleId),
                        new Action<RolePlayerChangedEventArgs>(OnRSShapeElementChanged));
                }

            base.OnDispose();
        }