Пример #1
0
 /// <summary>
 /// Gets the root feature of a given feature model instance, searching up into the parent feature model files.
 /// </summary>
 /// <param name="featureModel">The feature model.</param>
 /// <returns>The feature model's root feature</returns>
 public static Feature GetCrossDiagramRootFeature(FeatureModel featureModel)
 {
     if (!string.IsNullOrEmpty(featureModel.ParentFeatureModelFile))
     {
         FeatureModel parentFeatureModel = Util.LoadFeatureModel(DTEHelper.GetFullProjectItemPath(featureModel.ParentFeatureModelFile));
         return(GetCrossDiagramRootFeature(parentFeatureModel));
     }
     else
     {
         return(featureModel.RootFeature);
     }
 }
Пример #2
0
        /// <summary>
        /// Navigates to the parent feature model.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void OnGoToParentFeatureModelClick(object sender, EventArgs e)
        {
            MenuCommand command = sender as MenuCommand;

            foreach (object selectedObject in this.CurrentSelection)
            {
                if (selectedObject is FeatureModelDSLDiagram)
                {
                    FeatureModel featureModel = (selectedObject as FeatureModelDSLDiagram).ModelElement as FeatureModel;
                    string       parentFeatureModelFilePath = DTEHelper.GetProjectItemPath(featureModel.ParentFeatureModelFile);
                    DTEHelper.OpenFile(parentFeatureModelFilePath);
                    break;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Loads a Feature Model from a .fm file
        /// </summary>
        /// <param name="fileName">Feature Model file (.fm)</param>
        /// <returns></returns>
        public static FeatureModel LoadFeatureModel(string fileName)
        {
            FeatureModel result = null;
            Store        store  = new Store();

            Type[] modelTypes = new Type[] {
                typeof(Microsoft.VisualStudio.Modeling.Diagrams.CoreDesignSurfaceDomainModel),
                typeof(UFPE.FeatureModelDSL.FeatureModelDSLDomainModel)
            };
            store.LoadDomainModels(modelTypes);
            using (Transaction t = store.TransactionManager.BeginTransaction("Load model", true))
            {
                result = FeatureModelDSLSerializationHelper.Instance.LoadModel(store, fileName, null, null, null);
                t.Commit();
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// Determines if the menu command to navigate to the parent feature model
        /// will be visible. This happens only if this feature model contains
        /// a reference for a parent feature model.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void OnGoToParentFeatureModelDisplayAction(object sender, EventArgs e)
        {
            MenuCommand command = sender as MenuCommand;

            command.Visible = false;
            command.Enabled = false;
            foreach (object selectedObject in this.CurrentSelection)
            {
                if (selectedObject is FeatureModelDSLDiagram)
                {
                    FeatureModel featureModel = (selectedObject as FeatureModelDSLDiagram).ModelElement as FeatureModel;
                    if (!string.IsNullOrEmpty(featureModel.ParentFeatureModelFile))
                    {
                        command.Visible = true;
                        command.Enabled = true;
                    }
                    break;
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Gets the root feature of a given feature model instance, searching up into the parent feature model files.
 /// </summary>
 /// <param name="featureModel">The feature model.</param>
 /// <returns>The feature model's root feature</returns>
 public static Feature GetCrossDiagramRootFeature(FeatureModel featureModel)
 {
     if (!string.IsNullOrEmpty(featureModel.ParentFeatureModelFile)) {
         FeatureModel parentFeatureModel = Util.LoadFeatureModel(DTEHelper.GetFullProjectItemPath(featureModel.ParentFeatureModelFile));
         return GetCrossDiagramRootFeature(parentFeatureModel);
     } else {
         return featureModel.RootFeature;
     }
 }