summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2011-02-11 17:42:18 +0100
committerJose <jose@zeroc.com>2011-02-11 17:42:18 +0100
commitc70af1021be182ce1754549f85de85cdaef9ffe2 (patch)
treecf99a0848c686d02bc8e05ce609a80aee3891c60
parent5013 - VS add-in & Solution Navigator (diff)
downloadice-c70af1021be182ce1754549f85de85cdaef9ffe2.tar.bz2
ice-c70af1021be182ce1754549f85de85cdaef9ffe2.tar.xz
ice-c70af1021be182ce1754549f85de85cdaef9ffe2.zip
VS Add-In refresh solution explorer icons.
-rwxr-xr-x[-rw-r--r--]vsaddin/src/Builder.cs141
-rwxr-xr-x[-rw-r--r--]vsaddin/src/Util.cs26
2 files changed, 112 insertions, 55 deletions
diff --git a/vsaddin/src/Builder.cs b/vsaddin/src/Builder.cs
index 6c785fefc83..b57b301c6e5 100644..100755
--- a/vsaddin/src/Builder.cs
+++ b/vsaddin/src/Builder.cs
@@ -189,6 +189,10 @@ namespace Ice.VisualStudio
_debugStartNewInstance = application.Events.get_CommandEvents(c.Guid, c.ID);
_debugStartNewInstance.BeforeExecute +=
new _dispCommandEvents_BeforeExecuteEventHandler(setDotNetDebugEnvironment);
+ }
+ else if(c.Guid.Equals(Util.refreshCommandGUID) && c.ID == Util.refreshCommandID)
+ {
+ Util.setRefreshCommand(c);
}
}
}
@@ -311,7 +315,8 @@ namespace Ice.VisualStudio
public void buildDone(vsBuildScope Scope, vsBuildAction Action)
{
try
- {
+ {
+ Util.solutionExplorerRefresh();
_sliceBuild = false;
//
// If a Slice file has changed during the build, we rebuild that project's
@@ -421,7 +426,8 @@ namespace Ice.VisualStudio
public void afterBuildCancel(string Guid, int ID, object obj, object CustomOut)
{
try
- {
+ {
+ Util.solutionExplorerRefresh();
_sliceBuild = false;
//
@@ -884,59 +890,86 @@ namespace Ice.VisualStudio
// Ensure that generated items are opened in read only mode.
//
private void documentOpened(Document document)
- {
- if(fileTracker().hasGeneratedFile(document.ProjectItem.ContainingProject, document.FullName))
- {
- if(!document.ReadOnly)
- {
- document.ReadOnly = true;
- }
+ {
+ try
+ {
+ if(document == null || document.ProjectItem == null || document.ProjectItem.ContainingProject == null)
+ {
+ return;
+ }
+ if(!Util.isSliceBuilderEnabled(document.ProjectItem.ContainingProject))
+ {
+ return;
+ }
+ if(fileTracker().hasGeneratedFile(document.ProjectItem.ContainingProject, document.FullName))
+ {
+ if(!document.ReadOnly)
+ {
+ document.ReadOnly = true;
+ }
+ }
+ }
+ catch(Exception ex)
+ {
+ Util.write(null, Util.msgLevel.msgError, ex.ToString() + "\n");
+ Util.unexpectedExceptionWarning(ex);
+ throw;
}
}
public void documentSaved(Document document)
- {
- Project project = null;
- try
- {
- project = document.ProjectItem.ContainingProject;
- }
- catch(COMException)
- {
- //
- // Expected when documents are created during project initialization
- // and the ProjectItem is not yet available.
- //
- return;
- }
-
- if(!Util.isSliceBuilderEnabled(project))
- {
- return;
- }
- if(!Util.isSliceFilename(document.Name))
- {
- return;
+ {
+ try
+ {
+ Project project = null;
+ try
+ {
+ project = document.ProjectItem.ContainingProject;
+ }
+ catch(COMException)
+ {
+ //
+ // Expected when documents are created during project initialization
+ // and the ProjectItem is not yet available.
+ //
+ return;
+ }
+
+ if(!Util.isSliceBuilderEnabled(project))
+ {
+ return;
+ }
+ if(!Util.isSliceFilename(document.Name))
+ {
+ return;
+ }
+
+ //
+ // If build is in proccess, we don't run the slice compiler now, we append the document
+ // to a list of projects that have changes and return. The projects on this list
+ // will be rebuilt when the current build process is done or canceled, see
+ // "buildDone" and "afterBuildCancel" methods in this class.
+ //
+ if(isBuilding(project))
+ {
+ List<Project> rebuildProjects = getRebuildProjects();
+ if(!rebuildProjects.Contains(project))
+ {
+ rebuildProjects.Add(project);
+ }
+ return;
+ }
+
+ clearErrors(project);
+ buildProject(project, false, vsBuildScope.vsBuildScopeProject);
+ Util.solutionExplorerRefresh();
+ }
+ catch(Exception ex)
+ {
+ Util.write(null, Util.msgLevel.msgError, ex.ToString() + "\n");
+ Util.unexpectedExceptionWarning(ex);
+ throw;
}
-
- //
- // If build is in proccess, we don't run the slice compiler now, we append the document
- // to a list of projects that have changes and return. The projects on this list
- // will be rebuilt when the current build process is done or canceled, see
- // "buildDone" and "afterBuildCancel" methods in this class.
- //
- if(isBuilding(project))
- {
- List<Project> rebuildProjects = getRebuildProjects();
- if(!rebuildProjects.Contains(project))
- {
- rebuildProjects.Add(project);
- }
- return;
- }
-
- clearErrors(project);
- buildProject(project, false, vsBuildScope.vsBuildScopeProject);
}
public void projectAdded(Project project)
@@ -946,7 +979,8 @@ namespace Ice.VisualStudio
if(Util.isSliceBuilderEnabled(project))
{
Util.verifyProjectSettings(project);
- updateDependencies(project);
+ updateDependencies(project);
+ Util.solutionExplorerRefresh();
}
}
catch(Exception ex)
@@ -3328,10 +3362,10 @@ namespace Ice.VisualStudio
//
// True if build is in process, false otherwise.
//
- private bool _building;
+ private bool _building = false;
//
- // If build is in process, this contains the build scope.
+ // This contains the build scope of the last build command.
//
private vsBuildScope _buildScope = vsBuildScope.vsBuildScopeSolution;
@@ -3341,7 +3375,6 @@ namespace Ice.VisualStudio
//
private Project _buildProject;
-
private uint _dwCookie;
}
}
diff --git a/vsaddin/src/Util.cs b/vsaddin/src/Util.cs
index 8ab412217c1..0f6576c4187 100644..100755
--- a/vsaddin/src/Util.cs
+++ b/vsaddin/src/Util.cs
@@ -2971,6 +2971,10 @@ namespace Ice.VisualStudio
if(dp.Project.Equals(project))
{
System.Array requiredProjects = dp.RequiredProjects as System.Array;
+ if(requiredProjects == null)
+ {
+ continue;
+ }
foreach(Project p in requiredProjects)
{
Util.buildOrder(solution, p, ref projects);
@@ -2985,6 +2989,26 @@ namespace Ice.VisualStudio
{
projects.Add(project);
}
- }
+ }
+
+ public static void solutionExplorerRefresh()
+ {
+ if(_refreshCommand != null && _refreshCommand.IsAvailable)
+ {
+ DTE dte = getCurrentDTE();
+ object objIn = null;
+ object objOut = null;
+ dte.Commands.Raise(refreshCommandGUID, refreshCommandID, ref objIn, ref objOut);
+ }
+ }
+
+ public static void setRefreshCommand(Command command)
+ {
+ _refreshCommand = command;
+ }
+
+ private static Command _refreshCommand;
+ public const string refreshCommandGUID = "{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}";
+ public const int refreshCommandID = 222;
}
}