Ejemplo n.º 1
0
        /// <summary>
        /// Returns a list of toolbox items for use with this DSL.
        /// </summary>
        /// Les items sont tous créés dans le designer et sont distingués par le nom du TabName qui correspond
        /// au diagramme associé.
        public override global::System.Collections.Generic.IList <DslDesign::ModelingToolboxItem> CreateToolboxItems()
        {
            IList <DslDesign::ModelingToolboxItem> toolboxItems = base.CreateToolboxItems();

            // Create store and load domain models.
            using (DslModeling::Store store = new DslModeling::Store(this.ServiceProvider))
            {
                store.LoadDomainModels(typeof(DslDiagrams::CoreDesignSurfaceDomainModel),
                                       typeof(global::DSLFactory.Candle.SystemModel.CandleDomainModel));

                global::System.Resources.ResourceManager resourceManager = global::DSLFactory.Candle.SystemModel.CandleDomainModel.SingletonResourceManager;
                global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture;

                // Parcours des toolbox items les associer au bon diagramme
                using (DslModeling::Transaction t = store.TransactionManager.BeginTransaction("CreateToolboxItems for modelsLayer"))
                {
                    foreach (DslDesign::ModelingToolboxItem item in toolboxItems)
                    {
                        global::System.ComponentModel.ToolboxItemFilterAttribute[] filters = (global::System.ComponentModel.ToolboxItemFilterAttribute[])item.Filter;
                        if (item.TabName == "Models")
                        {
                            filters[0] = new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxModelsFilterString);
                        }

                        if (item.TabName == "UILayer")
                        {
                            filters[0] = new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxUIFilterString);
                        }
                    }

                    t.Rollback();
                }
            }

            return(toolboxItems);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the domain model from a specified file.
        /// </summary>
        /// <param name="fileName">Filename to load the domain model from.</param>
        /// <param name="isReload"></param>
        protected override void LoadDocument(string fileName, bool isReload)
        {
            this.rootModelElement = null;

            serializationResult = new DslEditorModeling::SerializationResult();
            DslModeling::SerializationResult result = new DslModeling.SerializationResult();

            global::Tum.PDE.VSPluginDSL.DomainModel modelRoot = null;

            // reset post process info
            VSPluginDSLSerializationPostProcessor.Instance.Reset();

            DslModeling::Transaction transaction = this.ModelData.Store.TransactionManager.BeginTransaction("Load model", true);

            try
            {
                modelRoot = global::Tum.PDE.VSPluginDSL.VSPluginDSLSerializationHelper.Instance.LoadModelDomainModel(result, this.ModelData.GetModelPartition(), fileName, null, null, null);

                // post process
                if (modelRoot != null && !serializationResult.Failed)
                {
                    VSPluginDSLSerializationPostProcessor.Instance.DoPostProcess(new System.Collections.Generic.List <string>(), result, modelRoot.Store);
                }


                if (!serializationResult.Failed)
                {
                    // start validation because UseLoad=true
                    ValidateAll();
                }

                // load diagramsModel
                string diagramsFileName = GetDiagramsFileName(fileName);
                if (System.IO.File.Exists(diagramsFileName))
                {
                    diagramsModel = VSPluginDSLDiagramsDSLSerializationHelper.Instance.LoadModel(result, this.ModelData.GetModelPartition(), GetDiagramsFileName(fileName), null, null, null);
                }

                if (diagramsModel == null)
                {
                    diagramsModel = new DslEditorDiagrams::DiagramsModel(this.ModelData.Store);
                }

                if (!diagramsModel.ContainsDiagram("DesignerDiagram"))
                {
                    DesignerDiagram diagramDesignerDiagram = new DesignerDiagram(this.ModelData.Store);
                    diagramDesignerDiagram.Name = "DesignerDiagram";

                    diagramsModel.Diagrams.Add(diagramDesignerDiagram);
                }
                diagramsModel.GetDiagram("DesignerDiagram").Initialize();
                OnPropertyChanged("DesignerDiagram");
                if (!diagramsModel.ContainsDiagram("SpecificElementsDiagramTemplate"))
                {
                    SpecificElementsDiagramTemplate diagramSpecificElementsDiagramTemplate = new SpecificElementsDiagramTemplate(this.ModelData.Store);
                    diagramSpecificElementsDiagramTemplate.Name = "SpecificElementsDiagramTemplate";

                    diagramsModel.Diagrams.Add(diagramSpecificElementsDiagramTemplate);
                }
                diagramsModel.GetDiagram("SpecificElementsDiagramTemplate").Initialize();
                OnPropertyChanged("SpecificElementsDiagramTemplate");

                if (result.Failed)
                {
                    transaction.Rollback();
                }
                else
                {
                    transaction.Commit();
                }
            }
            catch (System.Exception ex)
            {
                serializationResult.AddMessage(new DslEditorModeling::SerializationMessage(
                                                   VSPluginDSLValidationMessageIds.SerializationLoadErrorId, DslEditorModeling::ModelValidationViolationType.Error,
                                                   ex.Message, fileName, 0, 0));
                transaction.Rollback();
            }
            // copy messages
            bool bHasMessages = false;

            foreach (DslModeling::SerializationMessage m in result)
            {
                bHasMessages = true;

                DslEditorModeling.ModelValidationViolationType kind = DslEditorModeling.ModelValidationViolationType.Error;
                if (m.Kind == DslModeling.SerializationMessageKind.Info)
                {
                    kind = DslEditorModeling.ModelValidationViolationType.Message;
                }
                else if (m.Kind == DslModeling.SerializationMessageKind.Warning)
                {
                    kind = DslEditorModeling.ModelValidationViolationType.Warning;
                }

                DslEditorModeling::SerializationMessage message = new DslEditorModeling.SerializationMessage(
                    VSPluginDSLValidationMessageIds.SerializationMessageId, kind, m.Message, m.Location, m.Line, m.Column);
                serializationResult.AddMessage(message);
            }
            serializationResult.Failed = result.Failed;

            if (serializationResult.Failed)
            {
                // Load failed, can't open the file.
                serializationResult.AddMessage(new DslEditorModeling::SerializationMessage(VSPluginDSLValidationMessageIds.SerializationLoadErrorId, DslEditorModeling::ModelValidationViolationType.Error,
                                                                                           VSPluginDSLDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"), fileName, 0, 0));
            }
            else
            {
                this.rootModelElement = modelRoot;
            }

            if (!serializationResult.Failed && !bHasMessages)
            {
                // start validation because UseOpen=true
                ValidateAll();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns a list of toolbox items for use with this DSL.
        /// </summary>
        public virtual global::System.Collections.Generic.IList <DslDesign::ModelingToolboxItem> CreateToolboxItems()
        {
            global::System.Collections.Generic.List <DslDesign::ModelingToolboxItem> toolboxItems = new global::System.Collections.Generic.List <DslDesign::ModelingToolboxItem>();

            // Create store and load domain models.
            using (DslModeling::Store store = new DslModeling::Store(this.ServiceProvider))
            {
                store.LoadDomainModels(typeof(DslDiagrams::CoreDesignSurfaceDomainModel),
                                       typeof(global::ConfigurationSectionDesigner.ConfigurationSectionDesignerDomainModel));
                global::System.Resources.ResourceManager resourceManager = global::ConfigurationSectionDesigner.ConfigurationSectionDesignerDomainModel.SingletonResourceManager;
                global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture;

                // Open transaction so we can create model elements corresponding to toolbox items.
                using (DslModeling::Transaction t = store.TransactionManager.BeginTransaction("CreateToolboxItems"))
                {
                    // Add ConfigurationSection shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "ConfigurationSectionToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         1,                                                                                                                                                 // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("ConfigurationSectionToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("ConfigurationSectionToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Configuration Section DesignerToolboxTab",                                                                                                        // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Configuration Section DesignerToolboxTab", resourceCulture),                                                            // Localized display name for the toolbox tab.
                                         "ConfigurationSection",                                                                                                                            // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("ConfigurationSectionToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::ConfigurationSectionDesigner.ConfigurationSection.DomainClassId),                                        // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                   // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add ConfigurationElement shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "ConfigurationElementToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         2,                                                                                                                                                 // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("ConfigurationElementToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("ConfigurationElementToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Configuration Section DesignerToolboxTab",                                                                                                        // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Configuration Section DesignerToolboxTab", resourceCulture),                                                            // Localized display name for the toolbox tab.
                                         "ConfigurationElement",                                                                                                                            // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("ConfigurationElementToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::ConfigurationSectionDesigner.ConfigurationElement.DomainClassId),                                        // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                   // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add ConfigurationElementCollection shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "ConfigurationElementCollectionToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         3,                                                                                                                                                           // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("ConfigurationElementCollectionToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("ConfigurationElementCollectionToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Configuration Section DesignerToolboxTab",                                                                                                                  // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Configuration Section DesignerToolboxTab", resourceCulture),                                                                      // Localized display name for the toolbox tab.
                                         "ConfigurationElementCollection",                                                                                                                            // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("ConfigurationElementCollectionToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::ConfigurationSectionDesigner.ConfigurationElementCollection.DomainClassId),                                        // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                             // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add CollectionItemType connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "CollectionItemTypeToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         4,                                                                                                                                               // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("CollectionItemTypeToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("CollectionItemTypeToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Configuration Section DesignerToolboxTab",                                                                                                      // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Configuration Section DesignerToolboxTab", resourceCulture),                                                          // Localized display name for the toolbox tab.
                                         "CollectionItemType",                                                                                                                            // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("CollectionItemTypeToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                            // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                 // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(CollectionItemTypeFilterString)
                    }));

                    // Add ConfigurationSectionGroup shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "ConfigurationSectionGroupToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         5,                                                                                                                                                      // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("ConfigurationSectionGroupToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("ConfigurationSectionGroupToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Configuration Section DesignerToolboxTab",                                                                                                             // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Configuration Section DesignerToolboxTab", resourceCulture),                                                                 // Localized display name for the toolbox tab.
                                         "ConfigurationSectionGroup",                                                                                                                            // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("ConfigurationSectionGroupToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::ConfigurationSectionDesigner.ConfigurationSectionGroup.DomainClassId),                                        // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                        // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    t.Rollback();
                }
            }

            return(toolboxItems);
        }
        // private void OnPostLoadModelAndDiagram(DslModeling::SerializationResult serializationResult, DslModeling::Partition modelPartition, string modelFileName, DslModeling::Partition diagramPartition, string diagramFileName, ModelRoot modelRoot, EFModelDiagram diagram)
        // private DslDiagrams::Diagram LoadDiagram(DslModeling::SerializationResult serializationResult, DslModeling::ModelElement modelRoot, DslModeling::Partition diagramPartition, global::System.IO.Stream diagramStream, DslModeling::ISchemaResolver schemaResolver, DslValidation::ValidationController validationController, DslModeling::ISerializerLocator serializerLocator)
        private DslDiagrams::Diagram LoadDiagram(DslModeling::SerializationResult serializationResult, DslModeling::Partition modelPartition, string modelFileName, string diagramFileName, DslModeling::ModelElement modelRoot, DslModeling::Partition diagramPartition, global::System.IO.Stream diagramStream, DslModeling::ISchemaResolver schemaResolver, DslValidation::ValidationController validationController, DslModeling::ISerializerLocator serializerLocator)
        {
            #region Check Parameters
            if (serializationResult == null)
            {
                throw new global::System.ArgumentNullException("serializationResult");
            }
            if (modelRoot == null)
            {
                throw new global::System.ArgumentNullException("modelRoot");
            }
            if (diagramPartition == null)
            {
                throw new global::System.ArgumentNullException("diagramPartition");
            }
            #endregion

            DslDiagrams::Diagram diagram = null;
            var diagramName = string.Empty;

            // Ensure there is an outer transaction spanning both model and diagram load, so moniker resolution works properly.
            if (!diagramPartition.Store.TransactionActive)
            {
                throw new global::System.InvalidOperationException(EFModelDomainModel.SingletonResourceManager.GetString("MissingTransaction"));
            }

            if (diagramStream == null || diagramStream == global::System.IO.Stream.Null || !diagramStream.CanRead || diagramStream.Length < 6)
            {
                // missing diagram file indicates we should create a new diagram.
                diagram = this.CreateDiagramHelper(diagramPartition, modelRoot);
            }
            else
            {
                var directory     = this.GetDirectory(diagramPartition.Store);
                var localName     = string.Empty;
                var localSettings = EFModelSerializationHelper.Instance.CreateXmlReaderSettings(null, false);
                try
                {
                    using (var reader = global::System.Xml.XmlReader.Create(diagramStream, localSettings))
                    {
                        reader.MoveToContent();
                        localName = reader.LocalName;
                        global::System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(reader.GetAttribute("name")), "One of diagram streams is not well-formed");
                        diagramName = reader.GetAttribute("name");
                    }
                    diagramStream.Seek(0, global::System.IO.SeekOrigin.Begin);
                }
                catch (global::System.Xml.XmlException xEx)
                {
                    DslModeling::SerializationUtilities.AddMessage(
                        new DslModeling::SerializationContext(directory),
                        DslModeling::SerializationMessageKind.Error,
                        xEx
                        );
                }

                var diagramSerializer = directory.GetSerializer(EFModelDiagram.DomainClassId) ?? this.GetSerializer(diagramPartition.Store, localName);
                global::System.Diagnostics.Debug.Assert(diagramSerializer != null, "Cannot find serializer for " + diagramName);

                if (diagramSerializer != null)
                {
                    DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, diagramName, serializationResult);
                    this.InitializeSerializationContext(diagramPartition, serializationContext, true);
                    DslModeling::TransactionContext transactionContext = new DslModeling::TransactionContext();
                    transactionContext.Add(DslModeling::SerializationContext.TransactionContextKey, serializationContext);


                    using (DslModeling::Transaction postT = diagramPartition.Store.TransactionManager.BeginTransaction("PostLoad Model and Diagram", true, transactionContext))
                    {
                        using (DslModeling::Transaction t = diagramPartition.Store.TransactionManager.BeginTransaction("LoadDiagram", true, transactionContext))
                        {
                            // Ensure there is some content in the file. Blank (or almost blank, to account for encoding header bytes, etc.)
                            // files will cause a new diagram to be created and returned
                            if (diagramStream.Length > 5)
                            {
                                global::System.Xml.XmlReaderSettings settings = EFModelSerializationHelper.Instance.CreateXmlReaderSettings(serializationContext, false);
                                try
                                {
                                    using (global::System.Xml.XmlReader reader = global::System.Xml.XmlReader.Create(diagramStream, settings))
                                    {
                                        reader.MoveToContent();
                                        diagram = diagramSerializer.TryCreateInstance(serializationContext, reader, diagramPartition) as DslDiagrams::Diagram;
                                        if (diagram != null)
                                        {
                                            this.ReadRootElement(serializationContext, diagramSerializer, diagram, reader, schemaResolver);
                                        }
                                    }
                                }
                                catch (global::System.Xml.XmlException xEx)
                                {
                                    DslModeling::SerializationUtilities.AddMessage(
                                        serializationContext,
                                        DslModeling::SerializationMessageKind.Error,
                                        xEx
                                        );
                                }
                                if (serializationResult.Failed)
                                {
                                    // Serialization error encountered, rollback the transaction.
                                    diagram = null;
                                    t.Rollback();
                                }
                            }

                            if (diagram == null && !serializationResult.Failed)
                            {
                                // Create diagram if it doesn't exist
                                diagram = this.CreateDiagramHelper(diagramPartition, modelRoot);
                            }

                            if (t.IsActive)
                            {
                                t.Commit();
                            }
                        }     // End inner Tx


                        // Fire PostLoad customization code whether Load succeeded or not
                        // Provide a method in a partial class with the following signature:

                        ///// <summary>
                        ///// Customize Model and Diagram Loading.
                        ///// </summary>
                        ///// <param name="serializationResult">Stores serialization result from the load operation.</param>
                        ///// <param name="modelPartition">Partition in which the new DslLibrary instance will be created.</param>
                        ///// <param name="modelFileName">Name of the file from which the DslLibrary instance will be deserialized.</param>
                        ///// <param name="diagramPartition">Partition in which the new DslDesignerDiagram instance will be created.</param>
                        ///// <param name="diagramFileName">Name of the file from which the DslDesignerDiagram instance will be deserialized.</param>
                        ///// <param name="modelRoot">The root of the file that was loaded.</param>
                        ///// <param name="diagram">The diagram matching the modelRoot.</param>
                        // private void OnPostLoadModelAndDiagram(DslModeling::SerializationResult serializationResult, DslModeling::Partition modelPartition, string modelFileName, DslModeling::Partition diagramPartition, string diagramFileName, ModelRoot modelRoot, EFModelDiagram diagram)

                        this.OnPostLoadModelAndDiagram(serializationResult, modelPartition, modelFileName, diagramPartition, diagramFileName, (ModelRoot)modelRoot, (EFModelDiagram)diagram);
                        if (serializationResult.Failed)
                        {       // Serialization error encountered, rollback the middle transaction.
                            modelRoot = null;
                            postT.Rollback();
                        }
                        if (postT.IsActive)
                        {
                            postT.Commit();
                        }
                    }    // End MiddleTx
                    // Do load-time validation if a ValidationController is provided.
                    if (!serializationResult.Failed && validationController != null)
                    {
                        using (new SerializationValidationObserver(serializationResult, validationController))
                        {
                            validationController.Validate(diagramPartition, DslValidation::ValidationCategories.Load);
                        }
                    }
                }
            }

            if (diagram != null)
            {
                if (!serializationResult.Failed)
                {       // Succeeded.
                    diagram.ModelElement = diagram.ModelElement ?? modelRoot;
                    diagram.PostDeserialization(true);
                    this.CheckForOrphanedShapes(diagram, serializationResult);
                }
                else
                {       // Failed.
                    diagram.PostDeserialization(false);
                }
            }

            return(diagram);
        }
        /// <summary>
        /// Loads the diagram.
        /// </summary>
        /// <typeparam name="TModel">The type of the model.</typeparam>
        /// <typeparam name="TDiagram">The type of the diagram.</typeparam>
        /// <param name="serializationResult">The serialization result.</param>
        /// <param name="modelRoot">The model root.</param>
        /// <param name="diagramFileName">Name of the diagram file.</param>
        /// <param name="schemaResolver">The schema resolver.</param>
        /// <param name="diagramDomainId">The diagram domain id.</param>
        /// <param name="callback">The callback.</param>
        public void LoadDiagram <TModel, TDiagram>(DslModeling::SerializationResult serializationResult, TModel modelRoot, string diagramFileName, DslModeling::ISchemaResolver schemaResolver, System.Guid diagramDomainId, CreateDiagramHandler callback)
            where TModel : ModelElement
            where TDiagram : ComponentModelDiagram
        {
            Partition diagramPartition = modelRoot.Store.DefaultPartition;

            // Ensure there is an outer transaction spanning both model and diagram load, so moniker resolution works properly.
            if (!diagramPartition.Store.TransactionActive)
            {
                throw new global::System.InvalidOperationException(global::DSLFactory.Candle.SystemModel.CandleDomainModel.SingletonResourceManager.GetString("MissingTransaction"));
            }

            ComponentModelDiagram diagram = null;
            DslModeling::DomainClassXmlSerializer diagramSerializer = this.Directory.GetSerializer(diagramDomainId);

            global::System.Diagnostics.Debug.Assert(diagramSerializer != null, "Cannot find serializer for SystemModelDiagram");
            if (diagramSerializer != null)
            {
                if (!global::System.IO.File.Exists(diagramFileName))
                {
                    // missing diagram file indicates we should create a new diagram.
                    diagram = callback(diagramPartition);
                }
                else
                {
                    using (global::System.IO.FileStream fileStream = global::System.IO.File.OpenRead(diagramFileName))
                    {
                        DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(this.Directory, fileStream.Name, serializationResult);

                        using (DslModeling::Transaction t = diagramPartition.Store.TransactionManager.BeginTransaction("LoadDiagram", true))
                        {
                            // Ensure there is some content in the file. Blank (or almost blank, to account for encoding header bytes, etc.)
                            // files will cause a new diagram to be created and returned
                            if (fileStream.Length > 5)
                            {
                                global::System.Xml.XmlReaderSettings settings = new global::System.Xml.XmlReaderSettings();
                                try
                                {
                                    using (global::System.Xml.XmlReader reader = global::System.Xml.XmlReader.Create(fileStream, settings))
                                    {
                                        reader.MoveToContent();
                                        diagram = diagramSerializer.TryCreateInstance(serializationContext, reader, diagramPartition) as ComponentModelDiagram;
                                        if (diagram != null)
                                        {
                                            // Note: the actual instance we get back from TryCreateInstance() can be of a derived type of SystemModelDiagram,
                                            // so we need to find the correct serializer instance to deserialize the element properly.
                                            DslModeling::DomainClassXmlSerializer instanceSerializer = this.Directory.GetSerializer(diagram.GetDomainClass().Id);
                                            global::System.Diagnostics.Debug.Assert(instanceSerializer != null, "Cannot find serializer for " + diagram.GetDomainClass().Name + "!");
                                            instanceSerializer.ReadRootElement(serializationContext, diagram, reader, schemaResolver);
                                        }
                                    }
                                }
                                catch (global::System.Xml.XmlException xEx)
                                {
                                    DslModeling::SerializationUtilities.AddMessage(
                                        serializationContext,
                                        DslModeling::SerializationMessageKind.Error,
                                        xEx
                                        );
                                }
                                if (serializationResult.Failed)
                                {
                                    // Serialization error encountered, rollback the transaction.
                                    diagram = null;
                                    t.Rollback();
                                }
                            }

                            if (diagram == null && !serializationResult.Failed)
                            {
                                // Create diagram if it doesn't exist
                                diagram = CreateDiagramHelper(diagramPartition, modelRoot);
                            }

                            if (t.IsActive)
                            {
                                t.Commit();
                            }
                        } // End inner Tx
                    }
                }

                if (diagram != null)
                {
                    diagram.ModelElement = modelRoot;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a list of toolbox items for use with this DSL.
        /// </summary>
        public virtual global::System.Collections.Generic.IList <DslDesign::ModelingToolboxItem> CreateToolboxItems()
        {
            global::System.Collections.Generic.List <DslDesign::ModelingToolboxItem> toolboxItems = new global::System.Collections.Generic.List <DslDesign::ModelingToolboxItem>();

            // Create store and load domain models.
            using (DslModeling::Store store = new DslModeling::Store(this.ServiceProvider))
            {
                store.LoadDomainModels(typeof(DslDiagrams::CoreDesignSurfaceDomainModel),
                                       typeof(global::pelsoft.FWK_Dsl.FWK_DslDomainModel));
                global::System.Resources.ResourceManager resourceManager = global::pelsoft.FWK_Dsl.FWK_DslDomainModel.SingletonResourceManager;
                global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture;

                // Open transaction so we can create model elements corresponding to toolbox items.
                using (DslModeling::Transaction t = store.TransactionManager.BeginTransaction("CreateToolboxItems"))
                {
                    // Add ModelClass shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "ModelClassToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         1,                                                                                                                                       // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("ModelClassToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("ModelClassToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                              // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                  // Localized display name for the toolbox tab.
                                         "ModelClassF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("ModelClassToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::pelsoft.FWK_Dsl.ModelClass.DomainClassId),                                                     // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                         // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add Attribute shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "AttributeToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         2,                                                                                                                                      // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("AttributeToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("AttributeToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                             // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                 // Localized display name for the toolbox tab.
                                         "AttributeF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("AttributeToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::pelsoft.FWK_Dsl.ModelAttribute.DomainClassId),                                                // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                        // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add ClassOperation shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "ClassOperationToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         3,                                                                                                                                           // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("ClassOperationToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("ClassOperationToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                  // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                      // Localized display name for the toolbox tab.
                                         "ClassOperationF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("ClassOperationToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::pelsoft.FWK_Dsl.ClassOperation.DomainClassId),                                                     // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                             // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add ModelInterface shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "ModelInterfaceToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         4,                                                                                                                                           // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("ModelInterfaceToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("ModelInterfaceToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                  // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                      // Localized display name for the toolbox tab.
                                         "ModelInterfaceF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("ModelInterfaceToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::pelsoft.FWK_Dsl.ModelInterface.DomainClassId),                                                     // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                             // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add InterfaceOperation shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "InterfaceOperationToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         5,                                                                                                                                               // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("InterfaceOperationToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("InterfaceOperationToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                      // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                          // Localized display name for the toolbox tab.
                                         "InterfaceOperationF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("InterfaceOperationToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::pelsoft.FWK_Dsl.InterfaceOperation.DomainClassId),                                                     // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                 // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add UnidirectionalAssociation connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "UnidirectionalAssociationToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         6,                                                                                                                                                      // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("UnidirectionalAssociationToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("UnidirectionalAssociationToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                             // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                                 // Localized display name for the toolbox tab.
                                         "ConnectUnidirectionalAssociationF1Keyword",                                                                                                            // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("UnidirectionalAssociationToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                                   // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                        // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(UnidirectionalAssociationFilterString)
                    }));

                    // Add BidirectionalAssociation connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "BidirectionalAssociationToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         7,                                                                                                                                                     // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("BidirectionalAssociationToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("BidirectionalAssociationToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                            // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                                // Localized display name for the toolbox tab.
                                         "ConnectBidirectionalAssociationF1Keyword",                                                                                                            // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("BidirectionalAssociationToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                                  // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                       // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(BidirectionalAssociationFilterString)
                    }));

                    // Add Aggregation connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "AggregationToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         8,                                                                                                                                        // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("AggregationToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("AggregationToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                               // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                   // Localized display name for the toolbox tab.
                                         "AggregationF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("AggregationToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                     // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                          // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(AggregationFilterString)
                    }));

                    // Add Composition connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "CompositionToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         9,                                                                                                                                        // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("CompositionToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("CompositionToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                               // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                   // Localized display name for the toolbox tab.
                                         "CompositionF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("CompositionToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                     // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                          // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(CompositionFilterString)
                    }));

                    // Add Generalization connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "GeneralizationToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         10,                                                                                                                                          // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("GeneralizationToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("GeneralizationToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                  // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                      // Localized display name for the toolbox tab.
                                         "GeneralizationF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("GeneralizationToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                        // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                             // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(GeneralizationFilterString)
                    }));

                    // Add MultipleAssociation shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "MultipleAssociationToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         11,                                                                                                                                               // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("MultipleAssociationToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("MultipleAssociationToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                       // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                           // Localized display name for the toolbox tab.
                                         "MultipleAssociationF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("MultipleAssociationToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::pelsoft.FWK_Dsl.MultipleAssociation.DomainClassId),                                                     // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                  // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add MultipleAssociationRole connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "MultipleAssociationRoleToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         12,                                                                                                                                                   // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("MultipleAssociationRoleToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("MultipleAssociationRoleToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                           // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                               // Localized display name for the toolbox tab.
                                         "MultipleAssociationRoleF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("MultipleAssociationRoleToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                                 // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                      // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(MultipleAssociationRoleFilterString)
                    }));

                    // Add AssociationClassRelationship connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "AssociationClassRelationshipToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         13,                                                                                                                                                        // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("AssociationClassRelationshipToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("AssociationClassRelationshipToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                                // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                                    // Localized display name for the toolbox tab.
                                         "AssociationClassRelationshipF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("AssociationClassRelationshipToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                                      // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                           // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(AssociationClassRelationshipFilterString)
                    }));

                    // Add Comment shape tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "CommentToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         14,                                                                                                                                   // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("CommentToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("CommentToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                           // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                               // Localized display name for the toolbox tab.
                                         "CommentF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("CommentToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         CreateElementToolPrototype(store, global::pelsoft.FWK_Dsl.Comment.DomainClassId),                                                     // ElementGroupPrototype (data object) representing model element on the toolbox.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                      // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require)
                    }));

                    // Add CommentsReferenceTypes connector tool.
                    toolboxItems.Add(new DslDesign::ModelingToolboxItem(
                                         "CommentsReferenceTypesToolboxItem",                                                                                                                 // Unique identifier (non-localized) for the toolbox item.
                                         15,                                                                                                                                                  // Position relative to other items in the same toolbox tab.
                                         resourceManager.GetString("CommentsReferenceTypesToolboxItem", resourceCulture),                                                                     // Localized display name for the item.
                                         (global::System.Drawing.Bitmap)DslDiagrams::ImageHelper.GetImage(resourceManager.GetObject("CommentsReferenceTypesToolboxBitmap", resourceCulture)), // Image displayed next to the toolbox item.
                                         "Class DiagramsToolboxTab",                                                                                                                          // Unique identifier (non-localized) for the toolbox item tab.
                                         resourceManager.GetString("Class DiagramsToolboxTab", resourceCulture),                                                                              // Localized display name for the toolbox tab.
                                         "CommentsReferenceTypesF1Keyword",                                                                                                                   // F1 help keyword for the toolbox item.
                                         resourceManager.GetString("CommentsReferenceTypesToolboxTooltip", resourceCulture),                                                                  // Localized tooltip text for the toolbox item.
                                         null,                                                                                                                                                // Connector toolbox items do not have an underlying data object.
                                         new global::System.ComponentModel.ToolboxItemFilterAttribute[] {                                                                                     // Collection of ToolboxItemFilterAttribute objects that determine visibility of the toolbox item.
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require),
                        new global::System.ComponentModel.ToolboxItemFilterAttribute(CommentsReferenceTypesFilterString)
                    }));

                    t.Rollback();
                }
            }

            return(toolboxItems);
        }