/// <summary>
        /// Toggles all solution folders open temporarily to workaround searches not working inside
        /// solution folders that have never been expanded.
        /// </summary>
        /// <param name="parentItem">The parent item to inspect.</param>
        private void ToggleSolutionFoldersOpenTemporarily(UIHierarchyItem parentItem)
        {
            if (parentItem == null)
            {
                throw new ArgumentNullException("parentItem");
            }

            const string solutionFolderGuid = "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}";

            var project = parentItem.Object as Project;
            bool isCollapsedSolutionFolder = project != null && project.Kind == solutionFolderGuid && !parentItem.UIHierarchyItems.Expanded;

            // Expand the solution folder temporarily.
            if (isCollapsedSolutionFolder)
            {
                parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                Package.IDE.ToolWindows.SolutionExplorer.DoDefaultAction();
            }

            // Run recursively to children as well for nested solution folders.
            foreach (UIHierarchyItem childItem in parentItem.UIHierarchyItems)
            {
                ToggleSolutionFoldersOpenTemporarily(childItem);
            }

            // Collapse the solution folder.
            if (isCollapsedSolutionFolder)
            {
                parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                Package.IDE.ToolWindows.SolutionExplorer.DoDefaultAction();
            }
        }
예제 #2
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                    return false;

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                ProjectItem pi = (ProjectItem)hierItem.Object;
                if (pi.Object is DataSourceView)
                {
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)pi.ContainingProject;
                    return (projExt.Kind == BIDSProjectKinds.SSAS); //only show in an SSAS project, not in a report model or SSIS project (which also can have a DSV)
                }
                else if (pi.Object is Dimension)
                {
                    Dimension dim = pi.Object as Dimension;
                    if (dim != null && dim.IsParentChild)
                        return true;
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
예제 #3
0
파일: Helper.cs 프로젝트: nostlie/Sandbox
        private static void Collapse(UIHierarchyItem item, ref UIHierarchy solutionExplorer)
        {
            foreach (UIHierarchyItem innerItem in item.UIHierarchyItems)
            {
                if (innerItem.UIHierarchyItems.Count > 0)
                {

                    // Re-cursive call
                    Collapse(innerItem, ref solutionExplorer);

                    // Collapse
                    if (innerItem.UIHierarchyItems.Expanded)
                    {
                        innerItem.UIHierarchyItems.Expanded = false;
                        if (innerItem.UIHierarchyItems.Expanded == true)
                        {
                            // Bug in VS 2005
                            innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                            solutionExplorer.DoDefaultAction();
                        }

                    }
                }

            }
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                    return false;

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                Project p = hierItem.Object as Project;
                SolutionClass solution = hierItem.Object as SolutionClass;
                if (p != null)
                {
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                    return (projExt.Kind == BIDSProjectKinds.SSRS);
                }
                else if (solution != null)
                {
                    foreach (Project pp in solution.Projects)
                    {
                        Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)p;
                        if (projExt.Kind == BIDSProjectKinds.SSRS)
                            return true;
                    }
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
예제 #5
0
        internal static void CollapseRecursively(UIHierarchyItem parentItem)
        {
            if (parentItem == null)
            {
                throw new ArgumentNullException("parentItem");
            }

            if (!parentItem.UIHierarchyItems.Expanded) return;

            // Recurse to all children first.
            foreach (UIHierarchyItem childItem in parentItem.UIHierarchyItems)
            {
                CollapseRecursively(childItem);
            }

            if (ShouldCollapseItem(parentItem))
            {
                // Attempt the direct collapse first.
                parentItem.UIHierarchyItems.Expanded = false;

                // If failed, solution folder oddity may be at play.  Try an alternate path.
                if (parentItem.UIHierarchyItems.Expanded)
                {
                    parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                    ((DTE2)parentItem.DTE).ToolWindows.SolutionExplorer.DoDefaultAction();
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                    return false;

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                foreach (string extension in DTS_FILE_EXTENSIONS)
                {
                    if (sFileName.EndsWith(extension))
                        return true;
                }
                foreach (string extension in SSAS_FILE_EXTENSIONS)
                {
                    if (sFileName.EndsWith(extension))
                        return true;
                }
                foreach (string extension in SSRS_FILE_EXTENSIONS)
                {
                    if (sFileName.EndsWith(extension))
                        return true;
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
예제 #7
0
 private static void Collapse(UIHierarchyItem item) {
     foreach (UIHierarchyItem hierarchyItem in item.UIHierarchyItems) {
         if (hierarchyItem.UIHierarchyItems.Count > 0) {
             Collapse(hierarchyItem);
             if (hierarchyItem.UIHierarchyItems.Expanded)
                 hierarchyItem.UIHierarchyItems.Expanded = false;
         }
     }
 }
예제 #8
0
        internal static bool HasExpandedChildren(UIHierarchyItem parentItem)
        {
            if (parentItem == null)
            {
                throw new ArgumentNullException("parentItem");
            }

            return parentItem.UIHierarchyItems.Cast<UIHierarchyItem>().Any(
                childItem => childItem.UIHierarchyItems.Expanded || HasExpandedChildren(childItem));
        }
예제 #9
0
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
            if (((System.Array)solExplorer.SelectedItems).Length != 1) return false;

            UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));

            string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
            return (sFileName.EndsWith(".dtsx"));
        }
        private void ExpandCollapseNodes(UIHierarchyItem node, bool expanded, UIHierarchy tree)
        {
            foreach(UIHierarchyItem subNode in node.UIHierarchyItems)
              {
            ExpandCollapseNodes(subNode, expanded, tree);
              }

              if (node.Object is SolutionFolder)
              {
            node.UIHierarchyItems.Expanded = true;
              }
              else if (node.Object is Solution)
              {
            node.UIHierarchyItems.Expanded = true;
              }
              else if (node.Object is Project)
              {
            if (((Project)node.Object).Object is SolutionFolder)
            {
              //are there projects in the solution folder
              SolutionFolder f = ((Project)node.Object).Object as SolutionFolder;
              bool expandit = false;
              foreach (ProjectItem pi in f.Parent.ProjectItems)
              {
                if (pi.Object is Project)
                {
                  //solutionfolder contains a child project, dont close
                  expandit = true;
                }
              }
              node.UIHierarchyItems.Expanded = expandit;
            }
            else
            {
              node.UIHierarchyItems.Expanded = false;
            }
              }
              else
              {
            node.UIHierarchyItems.Expanded = false;
            //bug in VS
            //if still expanded
            if (node.UIHierarchyItems.Expanded == true)
            {
              node.Select(vsUISelectionType.vsUISelectionTypeSelect);
              tree.DoDefaultAction();
            }
              }
        }
예제 #11
0
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
            foreach (object selected in ((System.Array)solExplorer.SelectedItems))
            {
                UIHierarchyItem hierItem = (UIHierarchyItem)selected;
                ProjectItem projectItem = hierItem.Object as ProjectItem;
                if (projectItem == null || !projectItem.Name.ToLower().EndsWith(".biml")) 
                {
                    return false;
                }
            }

            return (((System.Array)solExplorer.SelectedItems).Length > 0);
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                    return false;

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                return (((ProjectItem)hierItem.Object).Object is Dimension);
            }
            catch
            {
                return false;
            }
        }
예제 #13
0
        private static bool ShouldCollapseItem(UIHierarchyItem parentItem)
        {
            if (parentItem.Object is Solution)
            {
                return false;
            }

            if (parentItem.Object is Project)
            {
                var solution = parentItem.DTE.Solution;
                if (solution != null && solution.Projects.Count <= 2)
                {
                    return false;
                }
            }

            return true;
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                    return false;

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                // this figures out if this is the dimensions node without using the name
                // by checking the type of the first child item. 
                return (hierItem.UIHierarchyItems.Count >= 1 
                    && ((ProjectItem)hierItem.UIHierarchyItems.Item(1).Object).Object is Dimension);
                //return (hierItem.Name == "Dimensions" && ((ProjectItem)hierItem.Object).Object == null);
            }
            catch
            {
                return false;
            }
        }
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
            if (((System.Array)solExplorer.SelectedItems).Length == 1)
            {
                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                Project project = hierItem.Object as Project;
                ProjectItem projectItem = hierItem.Object as ProjectItem;
                if (project != null)
                {
                    return (project.Kind == BIDSProjectKinds.SSIS);
                }
                else if (projectItem != null)
                {
                    return projectItem.ContainingProject.Kind == BIDSProjectKinds.SSIS;
                }
            }

            return false;
        }
예제 #16
0
 /// <summary>
 /// Determines if the command should be displayed or not.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override bool DisplayCommand(UIHierarchyItem item)
 {
     try
     {
         bool bFoundRightItem = false;
         UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
         foreach (UIHierarchyItem hierItem in ((System.Array)solExplorer.SelectedItems))
         {
             if (hierItem.Name.ToLower().EndsWith(".cube")) //checking the file extension is adequate because this feature is not needed for in online mode (when live connected to the server)
                 bFoundRightItem = true;
             else
                 return false;
         }
         return bFoundRightItem;
     }
     catch
     {
         return false;
     }
 }
        public string FindProject(EnvDTE.UIHierarchyItems h, Project p)
        {
            var xEnumerator = h.GetEnumerator();

            while (xEnumerator.MoveNext())
            {
                UIHierarchyItem xHierarchyItem = (UIHierarchyItem)xEnumerator.Current;
                if (xHierarchyItem.Name == p.Name)
                {
                    dynamic node    = xHierarchyItem.Object;
                    dynamic nodeArg = p.Object; // Cosmos.VS.Package.VSProjectNode

                    try {
                        if (node.Object.Project.ProjectIDGuid == nodeArg.ProjectIDGuid)
                        {
                            return(p.Name);
                        }
                    } catch {
                    }

                    try {
                        if (node.Project.ProjectIDGuid == nodeArg.ProjectIDGuid)
                        {
                            return(p.Name);
                        }
                    } catch {
                    }
                }
                var xPartOfName = FindProject(xHierarchyItem.UIHierarchyItems, p);
                if (xPartOfName.Length > 0)
                {
                    SolutionClass solution = xHierarchyItem.Object as SolutionClass;
                    if (solution != null)
                    {
                        return(xHierarchyItem.Name + "\\" + xPartOfName);
                    }
                    return(xHierarchyItem.Name + "\\" + xPartOfName);
                }
            }
            return(string.Empty);
        }
예제 #18
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null)
                {
                    return(false);
                }

                ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem;
                if (pi.Object is Cube)
                {
                    return(true);
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
예제 #19
0
        public static void CollapseAll(this DTE2 dte, IEnumerable <string> exlusionList = null)
        {
            UIHierarchy solutionExplorer = dte.ToolWindows.SolutionExplorer;

            // Check if there is any open solution
            if (solutionExplorer.UIHierarchyItems.Count == 0)
            {
                return;
            }

            // Get the top node (the name of the solution)
            UIHierarchyItem rootNode = solutionExplorer.UIHierarchyItems.Item(1);

            rootNode.DTE.SuppressUI = true;

            // Collapse each project node
            Collapse(rootNode, solutionExplorer, exlusionList);

            rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect);
            rootNode.DTE.SuppressUI = false;
        }
        public void FindInSelectedItemsSolution()
        {
            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = solution
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            string[] results = TsconfigLocations.FindPathsFromSelectedItems(selectedItems, out Dictionary <string, string> fileToProjectMap);

            string expectedConfig1 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfig.json");
            string expectedConfig2 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/tsconfig.json");
            string expectedConfig3 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/b/tsconfig.json");

            Assert.AreEqual(3, results.Length);
            Assert.IsTrue(results.Contains(expectedConfig1));
            Assert.IsTrue(results.Contains(expectedConfig2));
            Assert.IsTrue(results.Contains(expectedConfig3));
            Assert.AreEqual(0, fileToProjectMap.Keys.Count);
        }
예제 #21
0
        private UIHierarchyItem Find(UIHierarchyItem hierarchyItem, ProjectItem pi)
        {
            UIHierarchyItem retVal = null;

            foreach (UIHierarchyItem childItem in hierarchyItem.UIHierarchyItems)
            {
                if (childItem.Object == pi)
                {
                    retVal = hierarchyItem;
                }
                else
                {
                    retVal = Find(childItem, pi);
                }
                if (retVal != null)
                {
                    break;
                }
            }
            return(retVal);
        }
예제 #22
0
 public override void Exec()
 {
     try
     {
         UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
         UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
         ProjectItem     pi          = (ProjectItem)hierItem.Object;
         if (pi.Object is DataSourceView)
         {
             ExecDSV(pi);
         }
         else if (pi.Object is Dimension)
         {
             ExecDimension(pi);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
     }
 }
        public override void Exec()
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                //#if DENALI || SQL2014
                //Microsoft.AnalysisServices.BackEnd.DataModelingSandbox _sandbox = TabularHelpers.GetTabularSandboxFromBimFile(this, true);
                var _sandbox = new DataModelingSandboxWrapper(this);
                //#else
                //                var _sandbox = TabularHelpers.GetTabularSandboxAmoFromBimFile(this, true);
                //#endif
                var conn = _sandbox.GetSandbox().AdomdConnection;

                ExecSandbox(_sandbox);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
예제 #24
0
파일: PlugIn1.cs 프로젝트: xwagner2/eXpand
        Project FindProject(UIHierarchyItem uiHierarchyItem, Project project = null)
        {
            var proj = project;

            foreach (UIHierarchyItem hierarchyItem in uiHierarchyItem.UIHierarchyItems)
            {
                var findProject = proj ?? hierarchyItem.Object as Project;
                if (hierarchyItem.UIHierarchyItems.Count > 0)
                {
                    if (hierarchyItem.UIHierarchyItems.Expanded && FindProject(hierarchyItem, findProject) != null)
                    {
                        return(findProject);
                    }
                }
                else if (hierarchyItem.IsSelected)
                {
                    return(findProject);
                }
            }
            throw new NotImplementedException();
        }
예제 #25
0
        /// <summary>
        /// Gets the file path relative.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
        //public static string GetFilePathRelative(ProjectItem item)
        //{
        //    //Guard.ArgumentNotNull(item, "item");

        //    return GetFilePathRelative(item.DTE, item.get_FileNames(1));
        //}



        ///// <summary>
        ///// Gets the relative path.
        ///// </summary>
        ///// <param name="project">The project.</param>
        ///// <param name="projectItem">The project item.</param>
        ///// <returns></returns>
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
        //public static string GetRelativePath(Project project, ProjectItem projectItem)
        //{
        //    Guard.ArgumentNotNull(project, "project");
        //    Guard.ArgumentNotNull(projectItem, "projectItem");

        //    return GetRelativePath(project, projectItem.Properties.Item("FullPath").Value.ToString());
        //}

        ///// <summary>
        ///// Gets the relative path.
        ///// </summary>
        ///// <param name="project">The project.</param>
        ///// <param name="filePath">The file path.</param>
        ///// <returns></returns>
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
        //public static string GetRelativePath(Project project, string filePath)
        //{
        //    Guard.ArgumentNotNull(project, "project");
        //    Guard.ArgumentNotNullOrEmptyString(filePath, "filePath");

        //    string solutionRelativePath = GetFilePathRelative(project.DTE, filePath);

        //    string projectRelativePath = solutionRelativePath.Replace(project.Name + "\\", "");

        //    return projectRelativePath;
        //}

        ///// <summary>
        ///// Determines whether [is web project] [the specified project].
        ///// </summary>
        ///// <param name="project">The project.</param>
        ///// <returns>
        /////   <c>true</c> if [is web project] [the specified project]; otherwise, <c>false</c>.
        ///// </returns>
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
        //public static bool IsWebProject(Project project)
        //{
        //    Guard.ArgumentNotNull(project, "project");

        //    return (project.Kind.Equals(VsWebSite.PrjKind.prjKindVenusProject));
        //}
        #endregion

        #region Private Implementation
        private static UIHierarchyItem FindItemByName <TKind>(UIHierarchyItems items, string itemName)
        {
            foreach (UIHierarchyItem item in items)
            {
                if (item.Name == itemName)
                {
                    return(item);
                }
                else
                {
                    UIHierarchyItem item2 = FindItemByName <TKind>(item.UIHierarchyItems, itemName);

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

            return(null);
        }
예제 #26
0
        public void GetLintFilesForSingleItem()
        {
            string      projectItemFullName = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/file1.ts");
            string      projectFullName     = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfigTest.csproj");
            Project     project             = TsconfigLocationsTest.FindProject(projectFullName, solution);
            ProjectItem projectItem         = TsconfigLocationsTest.FindProjectItemInProject(projectItemFullName, project);

            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = projectItem
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            string[] results = LintFileLocations.FindPathsFromSelectedItems(selectedItems, out Dictionary <string, string> fileToProjectMap);

            Assert.AreEqual(1, results.Length);
            Assert.AreEqual(projectItemFullName, results[0]);
            //string expected1 = Path.GetFullPath(@"../../artifacts/tsconfig/none/b/file5.ts");
            //Assert.IsTrue(results.Contains(expected1));
        }
        public void FindInSelectedItemsTsconfig()
        {
            string              mainProjectFullName         = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfigTest.csproj");
            Project             mainProject                 = FindProject(mainProjectFullName, solution);
            string              mainProjectTsconfigFullName = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfig.json");
            ProjectItem         tsconfig = FindProjectItemInProject(mainProjectTsconfigFullName, mainProject);
            MockUIHierarchyItem mockTsconfigHierarchyItem = new MockUIHierarchyItem()
            {
                Object = tsconfig
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockTsconfigHierarchyItem };

            string[] results = TsconfigLocations.FindPathsFromSelectedItems(selectedItems, out Dictionary <string, string> fileToProjectMap);

            string expected = mainProjectTsconfigFullName;

            Assert.AreEqual(1, results.Length);
            Assert.IsTrue(results.Contains(expected));
            Assert.AreEqual(0, fileToProjectMap.Keys.Count);
        }
예제 #28
0
        public UIHierarchyItem Find(ProjectItem pi)
        {
            UIHierarchyItem retVal = null;

            foreach (UIHierarchyItem hierarchyItem in SolutionHierarchy.UIHierarchyItems)
            {
                if (hierarchyItem.Object == pi)
                {
                    retVal = hierarchyItem;
                }
                else
                {
                    retVal = Find(hierarchyItem, pi);
                }
                if (retVal != null)
                {
                    break;
                }
            }
            return(retVal);
        }
예제 #29
0
 public override bool DisplayCommand(UIHierarchyItem item)
 {
     UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
     if (((System.Array)solExplorer.SelectedItems).Length == 1)
     {
         UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
         //Project proj = hierItem.Object as Project;
         Project proj = this.GetSelectedProjectReference();
         SolutionClass solution = hierItem.Object as SolutionClass;
         if (proj != null)
         {
             return (proj.Kind == BIDSProjectKinds.SSIS && IsLegacyDeploymentMode(proj));
         }
         else if (solution != null)
         {
             foreach (Project p in solution.Projects)
             {
                 if (p.Kind != BIDSProjectKinds.SSIS || !IsLegacyDeploymentMode(proj)) return false;
             }
             return (solution.Projects.Count > 0);
         }
         else
         {
             proj = ((ProjectItem)hierItem.Object).ContainingProject;
             string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
             return (sFileName.EndsWith(".dtsx") && IsLegacyDeploymentMode(proj));
         }
     }
     else
     {
         foreach (object selected in ((System.Array)solExplorer.SelectedItems))
         {
             UIHierarchyItem hierItem = (UIHierarchyItem)selected;
             Project proj = ((ProjectItem)hierItem.Object).ContainingProject;
             string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
             if (!sFileName.EndsWith(".dtsx") || !IsLegacyDeploymentMode(proj)) return false;
         }
         return (((System.Array)solExplorer.SelectedItems).Length > 0);
     }
 }
예제 #30
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return(false);
                }

                UIHierarchyItem hierItem  = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                string          sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                foreach (string extension in DTS_FILE_EXTENSIONS)
                {
                    if (sFileName.EndsWith(extension))
                    {
                        return(true);
                    }
                }
                foreach (string extension in SSAS_FILE_EXTENSIONS)
                {
                    if (sFileName.EndsWith(extension))
                    {
                        return(true);
                    }
                }
                foreach (string extension in SSRS_FILE_EXTENSIONS)
                {
                    if (sFileName.EndsWith(extension))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
예제 #31
0
        /// <summary>
        /// Finds the hierarchy item.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        private UIHierarchyItem FindHierarchyItem(UIHierarchyItems items, object item)
        {
            // Enumerating children recursive would work, but it may be slow on large solution.
            // This tries to be smarter and faster
            Stack itemStack = new Stack();

            CreateItemsStack(itemStack, item);

            UIHierarchyItem last = null;

            while (itemStack.Count != 0)
            {
                if (!items.Expanded)
                {
                    items.Expanded = true;
                }
                if (!items.Expanded)
                {
                    // Workaround: expand dont always work...
                    UIHierarchyItem parent = (UIHierarchyItem)items.Parent;
                    parent.Select(vsUISelectionType.vsUISelectionTypeSelect);
                    this.application.ToolWindows.SolutionExplorer.DoDefaultAction();
                }

                object o = itemStack.Pop();

                last = null;
                foreach (UIHierarchyItem child in items)
                {
                    if (child.Object == o)
                    {
                        last  = child;
                        items = child.UIHierarchyItems;
                        break;
                    }
                }
            }

            return(last);
        }
        public void GetBuildFilesForSingleItem()
        {
            string      projectItemFullName = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/file1.ts");
            string      projectFullName     = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/tsconfigTest.csproj");
            Project     project             = TsconfigLocationsTest.FindProject(projectFullName, solution);
            ProjectItem projectItem         = TsconfigLocationsTest.FindProjectItemInProject(projectItemFullName, project);

            MockUIHierarchyItem mockSolutionHierarchyItem = new MockUIHierarchyItem()
            {
                Object = projectItem
            };

            UIHierarchyItem[] selectedItems = new UIHierarchyItem[] { mockSolutionHierarchyItem };

            List <string> results = BuildFileLocations.GetBuildFilesToLint(isBuildingSolution: false,
                                                                           selectedItems: selectedItems, useTsConfig: false).ToList();

            // We're going to build the project that the individual file is in (tsconfigTest) and so need to lint
            // all the files in said project before the build.  Note NOT using tsconfig.json (useTsConfig: false above).
            Assert.AreEqual(8, results.Count);

            string expected1 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/react-dom.d.ts");
            string expected2 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/react.d.ts");
            string expected3 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/test.ts");
            string expected4 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/file1.ts");
            string expected5 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/c/file4.ts");
            string expected6 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/b/file3.ts");
            string expected7 = Path.GetFullPath(@"../../artifacts/tsconfig/multiple/a/c/file6.tsx");
            string expected8 = Path.GetFullPath(@"../../artifacts/tsconfig/file9.ts"); // Linked file

            Assert.IsTrue(results.Contains(expected1));
            Assert.IsTrue(results.Contains(expected2));
            Assert.IsTrue(results.Contains(expected3));
            Assert.IsTrue(results.Contains(expected4));
            Assert.IsTrue(results.Contains(expected5));
            Assert.IsTrue(results.Contains(expected6));
            Assert.IsTrue(results.Contains(expected7));
            Assert.IsTrue(results.Contains(expected8));
        }
예제 #33
0
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                    return false;

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                if (!(hierItem.Object is ProjectItem)) return false;
                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                if (sFileName.EndsWith(".bim"))
                {
                    currentDB = (Database) (((Project) hierItem.Object).Object);
                    return true;
                }
            }
            catch
            {
            }
            return false;
        }
예제 #34
0
        static private UIHierarchyItem Find(UIHierarchyItem hierarchyItem, Project pi)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            UIHierarchyItem retVal = null;

            foreach (UIHierarchyItem childItem in hierarchyItem.UIHierarchyItems)
            {
                if (childItem.Object == pi)
                {
                    retVal = childItem;
                }
                else
                {
                    retVal = Find(childItem, pi);
                }
                if (retVal != null)
                {
                    break;
                }
            }
            return(retVal);
        }
        private static IEnumerable <UIHierarchyItem> GetSelectedItemProjectUIHierarchyItems(UIHierarchyItem[] selectedItems)
        {
            // Note that you can build a single project from the build menu, but your options are limited
            // to the project you have selected in Solution Explorer.  Here 'project you have selected' can
            // mean the project a selected item is in.  If you ctrl-click items in two projects the menu option
            // changes to 'Build Selection', meaning build both.  This logic replicates that.
            HashSet <string> seenPaths = new HashSet <string>();

            foreach (UIHierarchyItem selectedItem in selectedItems)
            {
                if (selectedItem.Object is ProjectItem projectItem &&
                    projectItem.ContainingProject?.GetRootFolder() is string projectItemRootFolder &&
                    !seenPaths.Contains(projectItemRootFolder))
                {
                    seenPaths.Add(projectItemRootFolder);
                    UIHierarchyItems uiHierarchyItems = WebLinterPackage.Dte.ToolWindows.SolutionExplorer.UIHierarchyItems;
                    UIHierarchyItem  containingProjectHierarchyItem = GetHierarchyItemForProject(projectItemRootFolder, uiHierarchyItems);
                    if (containingProjectHierarchyItem != null)
                    {
                        yield return(containingProjectHierarchyItem);
                    }
                }
 static private void FindProjectsIn(UIHierarchyItem item, List <Project> results)
 {
     if (item.Object is Project)
     {
         var proj = (Project)item.Object;
         if (new Guid(proj.Kind) != Guid.Parse("66A26720-8FB5-11D2-AA7E-00C04F688DDE"))
         {
             results.Add((Project)item.Object);
         }
         else
         {
             foreach (ProjectItem innerItem in proj.ProjectItems)
             {
                 FindProjectsIn(innerItem, results);
             }
         }
     }
     foreach (UIHierarchyItem innerItem in item.UIHierarchyItems)
     {
         FindProjectsIn(innerItem, results);
     }
 }
 internal static void CollapseFolder(VSProject2 hsa2, VSProject2 asa2, UIHierarchyItem folder)
 {
     foreach (UIHierarchyItem project in folder.UIHierarchyItems)
     {
         foreach (UIHierarchyItem projectItem in project.UIHierarchyItems)
         {
             if (projectItem.Name.Equals("References"))
             {
                 projectItem.UIHierarchyItems.Expanded = false;
             }
             else if (projectItem.Name.Equals("Generated Files") && (project.Name.Equals(hsa2.Project.Name) || project.Name.Equals(asa2.Project.Name)))
             {
                 projectItem.UIHierarchyItems.Expanded = false;
             }
             CollapseFolder(hsa2, asa2, projectItem);
         }
         if (project.Name.Equals(hsa2.Project.Name) || project.Name.Equals(asa2.Project.Name))
         {
             project.UIHierarchyItems.Expanded = false;
         }
     }
 }
예제 #38
0
파일: FileGrouper.cs 프로젝트: radtek/csql
        /// <summary>
        /// Gets the name of a project item that referes to file
        /// </summary>
        /// <param name="item">The project item.</param>
        /// <returns>The name of the file or <c>null</c> if the item does not represent a single file.</returns>
        private static string GetItemFileName(UIHierarchyItem item)
        {
            if (!(item.Object is EnvDTE.ProjectItem))
            {
                return(null);
            }

            EnvDTE.ProjectItem prjItem = (EnvDTE.ProjectItem)item.Object;
            if (prjItem.FileCount != 1)
            {
                return(null);
            }

            string fileName = prjItem.get_FileNames(1);

            if (String.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            return(fileName);
        }
        /// <summary>
        ///   Selects item in the Solution Explorer that corresponds to the
        ///   file containing version information.
        /// </summary>
        /// <param name="projectName">
        ///   Name of the project in which item must be searched for.
        /// </param>
        /// <param name="filenames">
        ///   Array of filenames to select. If array is empty or <c>null</c> then
        ///   the root (i.e. node corresponding to the project is selected.
        /// </param>
        public void SelectItem(ProjectInfo projectInfo, string[] filenames)
        {
            Debug.Assert(m_rootItem != null);
            Debug.Assert(projectInfo.UIPath.Length > 0);
            string[]        pathToProjectRoot = projectInfo.UIPath.Split('\\');
            UIHierarchyItem projectRoot       = m_rootItem;

            foreach (string pathComponent in pathToProjectRoot)
            {
                projectRoot = projectRoot.UIHierarchyItems.Item(pathComponent);
                Debug.Assert(projectRoot != null);
            }
            if (filenames == null || filenames.Length == 0)
            {
                SelectUIHierarchyItem(projectRoot);
                return;
            }
            foreach (string filename in filenames)
            {
                RecurseProjectTree(projectRoot, filename);
            }
        }
예제 #40
0
        public EnvDTE.Project Get()
        {
            Array           selectedItems = (Array)_solutionExplorer.SelectedItems;
            UIHierarchyItem selectedItem  = (UIHierarchyItem)selectedItems.GetValue(0);

            EnvDTE.Project selectedProject = selectedItem.Object as EnvDTE.Project;

            if (selectedProject == null)
            {
                return(((ProjectItem)selectedItem.Object).ContainingProject);
            }

            foreach (EnvDTE.Project project in _solution.Projects)
            {
                if (selectedProject.UniqueName == project.UniqueName)
                {
                    return(project);
                }
            }

            return(null);
        }
예제 #41
0
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;

            if (((System.Array)solExplorer.SelectedItems).Length == 1)
            {
                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                Project         project  = GetSelectedProjectReference();

                ProjectItem projectItem = hierItem.Object as ProjectItem;
                if (project != null)
                {
                    return(project.Kind == BIDSProjectKinds.SSIS);
                }
                else if (projectItem != null)
                {
                    return(projectItem.ContainingProject.Kind == BIDSProjectKinds.SSIS);
                }
            }

            return(false);
        }
예제 #42
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        //public override bool DisplayCommand(UIHierarchyItem item)
        //{
        //    try
        //    {
        //        UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
        //        if (((System.Array)solExplorer.SelectedItems).Length != 1)
        //            return false;

        //        UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
        //        if (!(hierItem.Object is ProjectItem)) return false;
        //        string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
        //        return (sFileName.EndsWith(".bim"));
        //    }
        //    catch
        //    {
        //    }
        //    return false;
        //}


        public override void Exec()
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));

                var sandbox = TabularHelpers.GetTabularSandboxFromBimFile(this, true);
                if (sandbox == null)
                {
                    throw new Exception("Can't get Sandbox!");
                }

                ProjectItem projItem = (ProjectItem)hierItem.Object;

                ExecInternal(projItem, sandbox);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool ShouldDisplayCommand()
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return(false);
                }

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                // this figures out if this is the dimensions node without using the name
                // by checking the type of the first child item.
                return(hierItem.UIHierarchyItems.Count >= 1 &&
                       ((ProjectItem)hierItem.UIHierarchyItems.Item(1).Object).Object is Dimension);
                //return (hierItem.Name == "Dimensions" && ((ProjectItem)hierItem.Object).Object == null);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                SolutionClass   solution    = hierItem.Object as SolutionClass;

                // test if this is a Multi-Dim project
                if (hierItem.Object is EnvDTE.Project)
                {
                    EnvDTE.Project p = (EnvDTE.Project)hierItem.Object;
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = p as Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt;
                    if (p == null)
                    {
                        return(false);
                    }

                    if (projExt.Kind == BIDSProjectKinds.SSAS)
                    {
                        return(true);
                        //Database db = (Database)p.Object;
                        //ScanAnalysisServicesProperties(db);
                    }
                }
                // else test if this is a tabular .bim file
                if (!(hierItem.Object is ProjectItem))
                {
                    return(false);
                }
                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                return(sFileName.EndsWith(".bim"));
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return(false);
                }

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                SolutionClass   solution = hierItem.Object as SolutionClass;
                EnvDTE.Project  proj     = GetSelectedProjectReference();

                if (proj != null)
                {
                    if (!(proj.Object is Database))
                    {
                        return(false);
                    }
                    Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)proj;
                    return(projExt.Kind == BIDSProjectKinds.SSIS);
                }
                else if (solution != null)
                {
                    foreach (EnvDTE.Project p in solution.Projects)
                    {
                        if (p.Kind != BIDSProjectKinds.SSIS)
                        {
                            return(false);
                        }
                    }
                    return(solution.Projects.Count > 0);
                }
            }
            catch { }
            return(false);
        }
        public override void Exec()
        {
            if (Biml.BimlUtility.ShowDisabledMessage())
            {
                return;
            }

            UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
            UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
            Project         project     = GetSelectedProjectReference();
            ProjectItem     projectItem = hierItem.Object as ProjectItem;

            if (project == null && projectItem != null)
            {
                project = projectItem.ContainingProject;
            }

            string projectDirectory = Path.GetDirectoryName(project.FullName);

            try
            {
                int    index           = 0;
                string fileRoot        = Path.Combine(projectDirectory, "BimlScript");
                string currentFileName = fileRoot + ".biml";
                while (File.Exists(currentFileName))
                {
                    ++index;
                    currentFileName = fileRoot + index + ".biml";
                }

                File.WriteAllText(currentFileName, NewBimlFileContents);
                project.ProjectItems.AddFromFile(currentFileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Toggles all solution folders open temporarily to workaround searches not working inside
        /// solution folders that have never been expanded.
        /// </summary>
        /// <param name="parentItem">The parent item to inspect.</param>
        private void ToggleSolutionFoldersOpenTemporarily(UIHierarchyItem parentItem)
        {
            if (parentItem == null)
            {
                throw new ArgumentNullException("parentItem");
            }

            const string solutionFolderGuid = "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}";

            var  project = parentItem.Object as Project;
            bool isCollapsedSolutionFolder = project != null && project.Kind == solutionFolderGuid && !parentItem.UIHierarchyItems.Expanded;

            // Expand the solution folder temporarily.
            if (isCollapsedSolutionFolder)
            {
                OutputWindowHelper.DiagnosticWriteLine(
                    string.Format("FindInSolutionExplorerCommand.ToggleSolutionFoldersOpenTemporarily expanding '{0}'", parentItem.Name));

                parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                Package.IDE.ToolWindows.SolutionExplorer.DoDefaultAction();
            }

            // Run recursively to children as well for nested solution folders.
            foreach (UIHierarchyItem childItem in parentItem.UIHierarchyItems)
            {
                ToggleSolutionFoldersOpenTemporarily(childItem);
            }

            // Collapse the solution folder.
            if (isCollapsedSolutionFolder)
            {
                OutputWindowHelper.DiagnosticWriteLine(
                    string.Format("FindInSolutionExplorerCommand.ToggleSolutionFoldersOpenTemporarily collapsing '{0}'", parentItem.Name));

                parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                Package.IDE.ToolWindows.SolutionExplorer.DoDefaultAction();
            }
        }
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool ShouldDisplayCommand()
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return(false);
                }

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                SolutionClass   solution = hierItem.Object as SolutionClass;
                EnvDTE.Project  proj     = GetSelectedProjectReference();

                if (proj != null)
                {
                    if (proj.Object == null || proj.Object.GetType().FullName != "Microsoft.AnalysisServices.Database")
                    {
                        return(false);                                                                                                //this should be a reference to Microsoft.AnalysisServices.AppLocal.dll
                    }
                    //Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)proj;
                    return(proj.Kind == BIDSProjectKinds.SSIS);
                }
                else if (solution != null)
                {
                    foreach (EnvDTE.Project p in solution.Projects)
                    {
                        if (p.Kind != BIDSProjectKinds.SSIS)
                        {
                            return(false);
                        }
                    }
                    return(solution.Projects.Count > 0);
                }
            }
            catch { }
            return(false);
        }
예제 #49
0
        /// <summary>
        ///     Determines if the specified parent item should be collapsed.
        /// </summary>
        /// <param name="parentItem">The parent item.</param>
        /// <returns>True if the item should be collapsed, otherwise false.</returns>
        private static bool ShouldCollapseItem(UIHierarchyItem parentItem)
        {
            // Make sure not to collapse the solution, causes odd behavior.
            if (parentItem.Object is Solution)
            {
                return(false);
            }

            // Conditionally skip collapsing the only project in a solution.
            // Note: Visual Studio automatically creates a second invisible project called
            //       "Miscellaneous files".
            if (parentItem.Object is Project)
            {
                var solution = parentItem.DTE.Solution;

                if (solution != null && solution.Projects.OfType <Project>().All(x => x == parentItem.Object || x.Name == "Miscellaneous Files"))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #50
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                    return false;

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                string sFileName = ((ProjectItem)hierItem.Object).Name.ToLower();
                if (sFileName.EndsWith(".bim") && !(this is UsedColumnsPlugin)) return true; //show the menu if this is the .bim file of a Tabular model, but don't show the Used Columns Report for Tabular since the data source view isn't really something a Tabular developer manages

                ProjectItem pi = (ProjectItem)hierItem.Object;
                if (!(pi.Object is DataSourceView)) return false;
                Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt projExt = (Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt)pi.ContainingProject;

                return (projExt.Kind == BIDSProjectKinds.SSAS); //only show in an SSAS project, not in a report model or SSIS project (which also can have a DSV)
            }
            catch
            {
                return false;
            }
        }
예제 #51
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length == 0)
                    return false;

                foreach (object selectedItem in ((System.Array)solExplorer.SelectedItems))
                {
                    UIHierarchyItem hierItem = ((UIHierarchyItem)selectedItem);
                    if (!(((ProjectItem)hierItem.Object).Object is Dimension))
                    {
                        return false;
                    }
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
예제 #52
0
        private UIHierarchyItem FindProjectHierarchyItem(UIHierarchyItem root)
        {
            UIHierarchyItem projectItem = null;
            try
            {
                if (root.Name == envPro.Name)
                    return root;

            #if VS2005
                bool expansionState = root.UIHierarchyItems.Expanded;
            #endif
                foreach (UIHierarchyItem childItem in root.UIHierarchyItems)
                {
                    projectItem = FindProjectHierarchyItem(childItem);
                    if (projectItem != null)
                        break;
                }
            #if VS2005
                root.UIHierarchyItems.Expanded = expansionState;
            #endif
            }
            catch
            {
            }
            return projectItem;
        }
예제 #53
0
 public override bool DisplayCommand(UIHierarchyItem item)
 {
     return false;
 }
예제 #54
0
        /// <summary>
        /// Determines if the command should be displayed or not.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool DisplayCommand(UIHierarchyItem item)
        {
            try
            {
                if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null)
                    return false;

                ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem;
                if (pi.Object is Cube)
                {
                    return true;
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
예제 #55
0
 public override bool DisplayCommand(UIHierarchyItem item)
 {
     UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
     if (((System.Array)solExplorer.SelectedItems).Length == 1)
     {
         UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
         EnvDTE.Project proj = GetSelectedProjectReference();
         if (proj != null)
         {
             return (proj.Kind == BIDSProjectKinds.SSIS);
         }
     }
     return false;
 }
예제 #56
0
 Project FindProject(UIHierarchyItem uiHierarchyItem, Project project=null) {
     var proj = project;
     foreach (UIHierarchyItem hierarchyItem in uiHierarchyItem.UIHierarchyItems) {
         var findProject = proj ?? hierarchyItem.Object as Project;
         if (hierarchyItem.UIHierarchyItems.Count > 0) {
             if (hierarchyItem.UIHierarchyItems.Expanded&&FindProject(hierarchyItem, findProject)!=null)
                 return findProject;
         }
         else if (hierarchyItem.IsSelected)
             return findProject;
     }
     throw new NotImplementedException();
 }
예제 #57
0
 public static void collapse(UIHierarchyItem item, string projectName)
 {
     foreach(UIHierarchyItem subitem in item.UIHierarchyItems)
     {
         if(subitem.UIHierarchyItems.Expanded && subitem.UIHierarchyItems.Count > 0)
         {
             collapse(subitem, projectName);
         }
     }
     if (item.Name != projectName)
     {
         item.UIHierarchyItems.Expanded = false;
     }
 }
예제 #58
0
        public static void CollapseFilter(UIHierarchyItem item, UIHierarchy hierarchy)
        {
            UIHierarchyItems subItems = item.UIHierarchyItems;
            if (subItems != null)
            {
                foreach (UIHierarchyItem innerItem in subItems)
                {
                    if (innerItem.UIHierarchyItems.Count > 0)
                    {
                        CollapseFilter(innerItem, hierarchy);

                        if (innerItem.UIHierarchyItems.Expanded)
                        {
                            innerItem.UIHierarchyItems.Expanded = false;
                            if (innerItem.UIHierarchyItems.Expanded == true)
                            {
                                innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                                hierarchy.DoDefaultAction();
                            }
                        }
                    }
                }
            }
            if (item.UIHierarchyItems.Expanded)
            {
                item.UIHierarchyItems.Expanded = false;
                if (item.UIHierarchyItems.Expanded == true)
                {
                    item.Select(vsUISelectionType.vsUISelectionTypeSelect);
                    hierarchy.DoDefaultAction();
                }
            }
        }
 public override bool DisplayCommand(UIHierarchyItem item)
 {
     string sDataFlowGUID;
     return IsContextMenuLocationValid(out sDataFlowGUID);
 }
 /// <summary>
 /// Determines if the command should be displayed or not.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public override bool DisplayCommand(UIHierarchyItem item)
 {
     try
     {
         if (toolWindow.Visible) return true;
         if (this.ApplicationObject.Solution == null) return false;
         foreach (EnvDTE.Project p in this.ApplicationObject.Solution.Projects)
         {
             if (p.Kind == BIDSProjectKinds.SSIS) return true;
         }
         return false;
     }
     catch
     {
         return false;
     }
 }