/// <summary> /// Return the actual collection of values we support /// </summary> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (selected == true) { SchemaModelItem targetitem = connection.SchemaModelItemTarget; SchemaModelItem sourceitem = connection.SchemaModelItemSource; if (targetitem.GetType() == typeof(Activity)) { return(new StandardValuesCollection(new string[] { "filters" })); } else if (targetitem.GetType() == typeof(Artifact) && sourceitem.GetType() == typeof(Activity)) { switch (((ArtifactType)((Artifact)targetitem).GetProperties()["Type"].GetValue(((Artifact)targetitem).GetProperties()["Type"]))) { case ArtifactType.Asset: return(new StandardValuesCollection(new string[] { "uses" })); case ArtifactType.Tool: return(new StandardValuesCollection(new string[] { "uses" })); case ArtifactType.WorkProduct: return(new StandardValuesCollection(new string[] { "reads", "writes" })); } } else if (targetitem.GetType() == typeof(Artifact) && sourceitem.GetType() == typeof(ViewPoint)) { return(new StandardValuesCollection(new string[] { "filters" })); } else if (targetitem.GetType() == typeof(ViewPoint)) { return(new StandardValuesCollection(new string[] { "reads", "writes" })); } else { return(null); } } return(null); }
/// <summary> /// Creates a relationship between SchemaModelItemSource and SchemaModelItemTarget /// </summary> /// <param name="source">SchemaModelItemSource to start the relationship at</param> /// <param name="target">SchemaModelItemTarget to end the relationship at</param> public override void CreateConnection(Shape sourceShape, Shape targetShape) { if (sourceShape == null) { throw new ArgumentNullException("sourceShape"); } if (targetShape == null) { throw new ArgumentNullException("targetShape"); } if (sourceShape != null && targetShape != null) { ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItem sourceElement = sourceShape.ModelElement as ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItem; ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItem targetElement = targetShape.ModelElement as ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItem; // Make MEL relationship - PEL relationship will be handled by ViewFixup mechanism if (sourceElement != null && targetElement != null) { targetElement.SchemaModelItemSource.Add(sourceElement); foreach (object o in targetElement.GetElementLinks()) { if (o.GetType() == typeof(ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)) { if (((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. GetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]).ToString().Equals("")) { if ((targetElement as Activity) != null) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "filters"); } else if ((targetElement as ISpySoft.SFSchemaLanguage.DomainModel.Artifact) != null) { if (((ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType)((ISpySoft.SFSchemaLanguage.DomainModel.Artifact)targetElement).GetProperties()["Type"]. GetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Type"])) == ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType.Asset) { if ((sourceElement as ViewPoint) != null) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "filters"); } else { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "uses"); } } else if (((ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType)((ISpySoft.SFSchemaLanguage.DomainModel.Artifact)targetElement).GetProperties()["Type"]. GetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Type"])) == ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType.Tool) { if ((sourceElement as ViewPoint) != null) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "filters"); } else { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "uses"); } } else { if ((sourceElement as ISpySoft.SFSchemaLanguage.DomainModel.ViewPoint) != null) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "filters"); } else { ConnectionTextSelector selector = new ConnectionTextSelector(); selector.ShowDialog(); ConnectionTextSelector.SelectionState state = selector.Selected; if (state == ConnectionTextSelector.SelectionState.reads) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "reads"); } // writes else if (state == ConnectionTextSelector.SelectionState.writes) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "writes"); } else { } } } } // Viewpoint else { ConnectionTextSelector selector = new ConnectionTextSelector(); selector.ShowDialog(); ConnectionTextSelector.SelectionState state = selector.Selected; if (state == ConnectionTextSelector.SelectionState.reads) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "reads"); } // writes else if (state == ConnectionTextSelector.SelectionState.writes) { ((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"]. SetValue(((ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)o).GetProperties()["Description"], "writes"); } else { } } } } } } } }