Exemplo n.º 1
0
        protected override void OnCopy(Microsoft.VisualStudio.Modeling.ModelElement sourceElement)
        {
            base.OnCopy(sourceElement);

            StructureProperty sourceProperty = (StructureProperty)sourceElement;

            this.Type = sourceProperty.Type;
        }
Exemplo n.º 2
0
        private void OnElementDeleted(object source, Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs e)
        {
            Microsoft.VisualStudio.Modeling.ModelElement m = e.ModelElement;

            // remove key
            if (m is IDomainModelOwnable)
            {
                this.GetDomainModelServices(m as IDomainModelOwnable).ElementIdProvider.RemoveKey(m);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Validates the given model element.
        /// </summary>
        /// <param name="element">ModelElement to be validated.</param>
        public List <IValidationMessage> Validate(Microsoft.VisualStudio.Modeling.ModelElement element)
        {
            this.CurrentValidationController.ClearMessages();
            this.CurrentValidationController.Validate(element, ModelValidationCategories.Menu);

            List <IValidationMessage> messages = new List <IValidationMessage>();

            messages.AddRange(this.CurrentValidationController.FatalMessages);
            messages.AddRange(this.CurrentValidationController.ErrorMessages);
            messages.AddRange(this.CurrentValidationController.WarningMessages);
            messages.AddRange(this.CurrentValidationController.InformationalMessages);

            this.validationResult = messages;

            return(messages);
        }
Exemplo n.º 4
0
        protected override ShapeElement CreateChildShape(Microsoft.VisualStudio.Modeling.ModelElement element)
        {
            var shape = base.CreateChildShape(element);

            var model = this.ModelElement as nHydrate.Dsl.nHydrateModel;

            if (model != null)
            {
                if (shape is StoredProcedureShape)
                {
                    if ((model.DiagramVisibility & VisibilityTypeConstants.StoredProcedure) == VisibilityTypeConstants.StoredProcedure)
                    {
                        shape.Show();
                    }
                    else
                    {
                        shape.Hide();
                    }
                }
                else if (shape is ViewShape)
                {
                    if ((model.DiagramVisibility & VisibilityTypeConstants.View) == VisibilityTypeConstants.View)
                    {
                        shape.Show();
                    }
                    else
                    {
                        shape.Hide();
                    }
                }
                else if (shape is FunctionShape)
                {
                    if ((model.DiagramVisibility & VisibilityTypeConstants.Function) == VisibilityTypeConstants.Function)
                    {
                        shape.Show();
                    }
                    else
                    {
                        shape.Hide();
                    }
                }
            }

            return(shape);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Resets the current document data.
        /// </summary>
        public override void Reset()
        {
            bool bSendClosedEvent = false;

            if (this.RootElement != null)
            {
                OnDocumentClosing(new EventArgs());
                bSendClosedEvent = true;
            }

            this.rootModelElement = null;

            if (bSendClosedEvent)
            {
                OnDocumentClosed(new EventArgs());
            }

            this.bIsDirty = false;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Given a model element this will select it on the explorer tree
        /// </summary>
        /// <param name="modelElement"></param>
        public virtual void SelectElement(Microsoft.VisualStudio.Modeling.ModelElement modelElement, bool highlight)
        {
            if (modelElement != null && modelElement is Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement)
            {
                modelElement = (modelElement as Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement).ModelElement;
            }

            var treeView = this.TreeContainer.Controls[1] as System.Windows.Forms.TreeView;
            var element  = GetModelElementNode(treeView.Nodes, modelElement);

            if (element != null)
            {
                treeView.SelectedNode = element;
                if (highlight)
                {
                    this.Show();
                }
            }
        }
Exemplo n.º 7
0
        private DomainEnumPropertyDescriptor CreateDomainEnumPropertyDescriptor(Microsoft.VisualStudio.Modeling.ModelElement requestor, Microsoft.VisualStudio.Modeling.DomainPropertyInfo domainPropertyInfo, System.Attribute[] attributes)
        {
            DomainProperty domainProperty = requestor as DomainProperty;

            if (domainProperty == null)
            {
                return(null);
            }
            if (domainPropertyInfo.Id != DomainProperty.DefaultValueDomainPropertyId)
            {
                return(null);
            }
            DomainEnumeration domainEnumeration = domainProperty.Type as DomainEnumeration;

            if (domainEnumeration == null)
            {
                return(null);
            }
            return(new DomainEnumPropertyDescriptor(this, requestor, domainPropertyInfo, domainEnumeration, attributes));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Loads the document from a given file name. This will not replace the currently loaded domain model neither will it send events.
        /// </summary>
        /// <param name="fileName">Filename from which to load the document data.</param>
        public virtual Microsoft.VisualStudio.Modeling.ModelElement LoadInternal(string fileName)
        {
            Microsoft.VisualStudio.Modeling.Transaction transaction = this.ModelData.Store.TransactionManager.BeginTransaction("Load Model Internal", true);

            try
            {
                Microsoft.VisualStudio.Modeling.ModelElement modelElement = LoadDocumentInternal(fileName);
                transaction.Commit();

                return(modelElement);
            }
            catch (Exception ex)
            {
                transaction.Rollback();

                this.SerializationResult.AddMessage(new SerializationMessage(ModelValidationMessageIds.SerializationLoadErrorId, ModelValidationViolationType.Error,
                                                                             ex.Message, fileName, 0, 0));

                return(null);
            }
        }
Exemplo n.º 9
0
        private TreeNode GetModelElementNode(TreeNodeCollection nodes, Microsoft.VisualStudio.Modeling.ModelElement modelElement)
        {
            foreach (TreeNode node in nodes)
            {
                if (node is Microsoft.VisualStudio.Modeling.Shell.ModelElementTreeNode)
                {
                    if ((node as Microsoft.VisualStudio.Modeling.Shell.ModelElementTreeNode).ModelElement == modelElement)
                    {
                        return(node);
                    }
                }

                var subNode = GetModelElementNode(node.Nodes, modelElement);
                if (subNode != null)
                {
                    return(subNode);
                }
            }

            return(null);
        }
Exemplo n.º 10
0
        private void DisplaySubObjects()
        {
            if (lvwMain.SelectedItems.Count != 1)
            {
                lvwSubItem.Items.Clear();
                return;
            }

            Microsoft.VisualStudio.Modeling.ModelElement selectedObject = null;
            if (lvwSubItem.SelectedItems.Count > 0)
            {
                selectedObject = lvwSubItem.SelectedItems[0].Tag as Microsoft.VisualStudio.Modeling.ModelElement;
            }

            lvwSubItem.Items.Clear();

            var si = lvwMain.SelectedItems[0].Tag as Microsoft.VisualStudio.Modeling.ModelElement;

            if (si != null)
            {
                if (si is nHydrate.Dsl.Entity)
                {
                    LoadSubItems((nHydrate.Dsl.Entity)si);
                }
                else if (si is nHydrate.Dsl.View)
                {
                    LoadSubItems((nHydrate.Dsl.View)si);
                }
            }

            //Re-select
            if (selectedObject != null)
            {
                var sel = lvwSubItem.Items.ToList().FirstOrDefault(x => x.Tag == selectedObject);
                if (sel != null)
                {
                    sel.Selected = true;
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Resets the current document data.
        /// </summary>
        public override void Reset()
        {
            bool bSendClosedEvent = false;
            if (this.RootElement != null)
            {
                OnDocumentClosing(new EventArgs());
                bSendClosedEvent = true;
            }

            this.rootModelElement = null;

            if (bSendClosedEvent)
                OnDocumentClosed(new EventArgs());

            this.bIsDirty = false;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Called for each element in the traversal.
 /// </summary>
 public bool Visit(Microsoft.VisualStudio.Modeling.ElementWalker walker, Microsoft.VisualStudio.Modeling.ModelElement element)
 {
     this.validationList.Add(element);
     return(true);
 }
Exemplo n.º 13
0
        public void SelectElement(Microsoft.VisualStudio.Modeling.ModelElement element)
        {
            txtSummary.DataBindings.Clear();
            txtSummary.Text = string.Empty;
            _modelElement   = null;

            //If this is a shape then get the actual inner model element
            if ((element != null) && (element is Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement))
            {
                element = (element as Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement).ModelElement;
            }

            if (element == null || element.IsDeleted || element.IsDeleting)
            {
                pnlSummary.Visible   = false;
                _noSelection.Visible = true;
                return;
            }

            if ((!nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Name")) &&
                (!nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Key")))
            {
                pnlSummary.Visible   = false;
                _noSelection.Visible = true;
                return;
            }

            if (!nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Summary"))
            {
                pnlSummary.Visible   = false;
                _noSelection.Visible = true;
                return;
            }

            if (nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Name"))
            {
                lblObjectName.Text = nHydrate.DslPackage.Objects.Utils.GetPropertyValue <string>(element, "Name");
            }
            else if (nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Key"))
            {
                lblObjectName.Text = nHydrate.DslPackage.Objects.Utils.GetPropertyValue <string>(element, "Key");
            }
            else
            {
                throw new Exception("Unknown Name");
            }

            if (string.IsNullOrEmpty(lblObjectName.Text))
            {
                lblObjectName.Text = "(Not Set)";
            }

            //Preface sub-objects
            if (element is nHydrate.Dsl.Field)
            {
                lblObjectName.Text = ((nHydrate.Dsl.Field)element).Entity.Name + "." + lblObjectName.Text;
            }
            else if (element is nHydrate.Dsl.ViewField)
            {
                lblObjectName.Text = ((nHydrate.Dsl.ViewField)element).View.Name + "." + lblObjectName.Text;
            }
            else if (element is nHydrate.Dsl.StoredProcedureField)
            {
                lblObjectName.Text = ((nHydrate.Dsl.StoredProcedureField)element).StoredProcedure.Name + "." + lblObjectName.Text;
            }
            else if (element is nHydrate.Dsl.FunctionField)
            {
                lblObjectName.Text = ((nHydrate.Dsl.FunctionField)element).Function.Name + "." + lblObjectName.Text;
            }
            else if (element is nHydrate.Dsl.StoredProcedureParameter)
            {
                lblObjectName.Text = ((nHydrate.Dsl.StoredProcedureParameter)element).StoredProcedure.Name + "." + lblObjectName.Text;
            }
            else if (element is nHydrate.Dsl.FunctionParameter)
            {
                lblObjectName.Text = ((nHydrate.Dsl.FunctionParameter)element).Function.Name + "." + lblObjectName.Text;
            }

            _modelElement = element;
            txtSummary.DataBindings.Add("Text", element, "Summary", false, DataSourceUpdateMode.OnPropertyChanged);
            _noSelection.Visible = false;
            pnlSummary.Visible   = true;
        }
Exemplo n.º 14
0
        protected override Microsoft.VisualStudio.Modeling.Design.ElementPropertyDescriptor CreatePropertyDescriptor(Microsoft.VisualStudio.Modeling.ModelElement requestor, Microsoft.VisualStudio.Modeling.DomainPropertyInfo domainPropertyInfo, Attribute[] attributes)
        {
            DomainEnumPropertyDescriptor domainEnumPropertyDescriptor = CreateDomainEnumPropertyDescriptor(requestor, domainPropertyInfo, attributes);

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

            return(base.CreatePropertyDescriptor(requestor, domainPropertyInfo, attributes));
        }
Exemplo n.º 15
0
 public override Microsoft.VisualStudio.Modeling.Shell.ModelElementTreeNode CreateModelElementTreeNode(Microsoft.VisualStudio.Modeling.ModelElement modelElement)
 {
     return(base.CreateModelElementTreeNode(modelElement));
 }
Exemplo n.º 16
0
        private void DisplayObjects()
        {
            Microsoft.VisualStudio.Modeling.ModelElement selectedObject = null;
            if (lvwMain.SelectedItems.Count > 0)
            {
                selectedObject = lvwMain.SelectedItems[0].Tag as Microsoft.VisualStudio.Modeling.ModelElement;
            }

            lvwMain.Items.Clear();

            foreach (var modelObject in _modelElements)
            {
                //Add Entities
                if (modelObject is nHydrate.Dsl.Entity && _settings.AllowEntity)
                {
                    var item   = modelObject as nHydrate.Dsl.Entity;
                    var marked = false;
                    if (IsSearchMatch(item.Name))
                    {
                        marked = true;
                    }
                    else if (_settings.AllowField && item.Fields.Any(x => IsSearchMatch(x.Name)))
                    {
                        marked = true;
                    }

                    if (marked)
                    {
                        var li = new ListViewItem();
                        _mainColumns.Where(x => x.Visible).ToList().ForEach(x => li.SubItems.Add(string.Empty));
                        lvwMain.Items.Add(li);
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.DataType), "Entity");
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.CodeFacade), item.CodeFacade);
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.TypedEntity), item.TypedEntity.ToString());
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.Schema), item.Schema);
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.IsAssociative), item.IsAssociative.ToString().ToLower());
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.Immutable), item.Immutable.ToString().ToLower());
                        li.ImageIndex = 0;
                        li.Text       = item.Name;
                        li.Tag        = item;
                    }
                }

                //Add Views
                if (modelObject is nHydrate.Dsl.View && _settings.AllowView)
                {
                    var item   = modelObject as nHydrate.Dsl.View;
                    var marked = false;
                    if (IsSearchMatch(item.Name))
                    {
                        marked = true;
                    }
                    else if (_settings.AllowField && item.Fields.Any(x => IsSearchMatch(x.Name)))
                    {
                        marked = true;
                    }

                    if (marked)
                    {
                        var li = new ListViewItem();
                        _mainColumns.Where(x => x.Visible).ToList().ForEach(x => li.SubItems.Add(string.Empty));
                        lvwMain.Items.Add(li);
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.DataType), "View");
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.CodeFacade), item.CodeFacade);
                        SetListItemValue(li, _mainColumns.FirstOrDefault(x => x.Type == FindWindowColumnTypeConstants.Schema), item.Schema);
                        li.ImageIndex = 1;
                        li.Text       = item.Name;
                        li.Tag        = item;
                    }
                }
            }

            //Re-select
            if (selectedObject != null)
            {
                var sel = lvwMain.Items.ToList().FirstOrDefault(x => x.Tag == selectedObject);
                if (sel != null)
                {
                    sel.Selected = true;
                }
            }

            DisplaySubObjects();
        }
 protected override Microsoft.VisualStudio.Modeling.Design.RolePlayerPropertyDescriptor CreateRolePlayerPropertyDescriptor(Microsoft.VisualStudio.Modeling.ModelElement sourceRolePlayer, Microsoft.VisualStudio.Modeling.DomainRoleInfo targetRoleInfo, Attribute[] sourceDomainRoleInfoAttributes)
 {
     System.Type type = targetRoleInfo.DomainRelationship.ImplementationClass;
     if ((sourceRolePlayer is DomainRole) && (type == typeof(DomainRoleReferencesCustomPropertyGridEditor)))
     {
         return(new DomainRoleReferencesCustomPropertyGridEditorDescriptor(sourceRolePlayer, targetRoleInfo, sourceDomainRoleInfoAttributes));
     }
     return(base.CreateRolePlayerPropertyDescriptor(sourceRolePlayer, targetRoleInfo, sourceDomainRoleInfoAttributes));
 }
 public DomainRoleReferencesCustomPropertyGridEditorDescriptor(Microsoft.VisualStudio.Modeling.ModelElement sourcePlayer, Microsoft.VisualStudio.Modeling.DomainRoleInfo domainRole, System.Attribute[] sourceDomainRoleInfoAttributes)
     : base(sourcePlayer, domainRole, sourceDomainRoleInfoAttributes)
 {
 }
        protected override void WriteElements(Microsoft.VisualStudio.Modeling.SerializationContext serializationContext, Microsoft.VisualStudio.Modeling.ModelElement element, System.Xml.XmlWriter writer)
        {
            base.WriteElements(serializationContext, element, writer);

            //  writer.WriteStartElement("custom");
            //  writer.WriteCData("my custom stuff here!");
            //  writer.WriteEndElement();
        }
Exemplo n.º 20
0
 public override ShapeElement FixUpChildShapes(Microsoft.VisualStudio.Modeling.ModelElement childElement)
 {
     return(base.FixUpChildShapes(childElement));
 }
Exemplo n.º 21
0
 public override Microsoft.VisualStudio.Modeling.Shell.ExplorerTreeNode FindNodeForElement(Microsoft.VisualStudio.Modeling.ModelElement element)
 {
     return(base.FindNodeForElement(element));
 }
Exemplo n.º 22
0
        public override Microsoft.VisualStudio.Modeling.Shell.ModelElementTreeNode CreateModelElementTreeNode(Microsoft.VisualStudio.Modeling.ModelElement modelElement)
        {
            var n = base.CreateModelElementTreeNode(modelElement);

            //n.ContextMenu = new System.Windows.Forms.ContextMenu();
            //n.ContextMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("qqqq"));
            return(n);
        }
Exemplo n.º 23
0
		public void SelectElement(Microsoft.VisualStudio.Modeling.ModelElement element)
		{
			txtSummary.DataBindings.Clear();
			txtSummary.Text = string.Empty;
			_modelElement = null;

			//If this is a shape then get the actual inner model element
			if ((element != null) && (element is Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement))
			{
				element = (element as Microsoft.VisualStudio.Modeling.Diagrams.ShapeElement).ModelElement;
			}

			if (element == null || element.IsDeleted || element.IsDeleting)
			{
				pnlSummary.Visible = false;
				_noSelection.Visible = true;
				return;
			}

			if ((!nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Name")) &&
				(!nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Key")))
			{
				pnlSummary.Visible = false;
				_noSelection.Visible = true;
				return;
			}

			if (!nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Summary"))
			{
				pnlSummary.Visible = false;
				_noSelection.Visible = true;
				return;
			}

			if (nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Name"))
				lblObjectName.Text = nHydrate.DslPackage.Objects.Utils.GetPropertyValue<string>(element, "Name");
			else if (nHydrate.DslPackage.Objects.Utils.PropertyExists(element, "Key"))
				lblObjectName.Text = nHydrate.DslPackage.Objects.Utils.GetPropertyValue<string>(element, "Key");
			else
				throw new Exception("Unknown Name");

			if (string.IsNullOrEmpty(lblObjectName.Text))
				lblObjectName.Text = "(Not Set)";

			//Preface sub-objects
			if (element is nHydrate.Dsl.Field)
				lblObjectName.Text = ((nHydrate.Dsl.Field)element).Entity.Name + "." + lblObjectName.Text;
			else if (element is nHydrate.Dsl.ViewField)
				lblObjectName.Text = ((nHydrate.Dsl.ViewField)element).View.Name + "." + lblObjectName.Text;
			else if (element is nHydrate.Dsl.StoredProcedureField)
				lblObjectName.Text = ((nHydrate.Dsl.StoredProcedureField)element).StoredProcedure.Name + "." + lblObjectName.Text;
			else if (element is nHydrate.Dsl.FunctionField)
				lblObjectName.Text = ((nHydrate.Dsl.FunctionField)element).Function.Name + "." + lblObjectName.Text;
			else if (element is nHydrate.Dsl.StoredProcedureParameter)
				lblObjectName.Text = ((nHydrate.Dsl.StoredProcedureParameter)element).StoredProcedure.Name + "." + lblObjectName.Text;
			else if (element is nHydrate.Dsl.FunctionParameter)
				lblObjectName.Text = ((nHydrate.Dsl.FunctionParameter)element).Function.Name + "." + lblObjectName.Text;

			_modelElement = element;
			txtSummary.DataBindings.Add("Text", element, "Summary", false, DataSourceUpdateMode.OnPropertyChanged);
			_noSelection.Visible = false;
			pnlSummary.Visible = true;
		}
Exemplo n.º 24
0
 public override System.Collections.ICollection GetChildElements(Microsoft.VisualStudio.Modeling.ModelElement parentElement)
 {
     return(base.GetChildElements(parentElement));
 }
Exemplo n.º 25
0
 public BaseModelContextRolePlayerPropertyDescriptor(Microsoft.VisualStudio.Modeling.ModelElement sourcePlayer, Microsoft.VisualStudio.Modeling.DomainRoleInfo domainRole, System.Attribute[] sourceDomainRoleInfoAttributes)
     : base(sourcePlayer, domainRole, sourceDomainRoleInfoAttributes)
 {
 }