Browse Source

Add basic "View in browser" menu item.

pull/23/head
Eusebiu Marcu 14 years ago
parent
commit
4318102544
  1. 8
      data/resources/StringResources.resx
  2. BIN
      data/resources/image/BitmapResources/BitmapResources-data/Icons.22x22.Browser.png
  3. 1
      data/resources/image/BitmapResources/BitmapResources.res
  4. 58
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  5. 20
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  6. 2
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  7. 7
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
  8. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ProjectNodeCommands.cs
  9. 74
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SpecialFileNodeCommands.cs
  10. 32
      src/Main/Base/Project/Src/Internal/ConditionEvaluators/ViewInBrowserConditionEvaluator.cs
  11. 4
      src/Main/Base/Project/Src/Project/CompilableProject.cs
  12. 6
      src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
  13. BIN
      src/Main/StartUp/Project/Resources/BitmapResources.resources

8
data/resources/StringResources.resx

@ -5167,7 +5167,7 @@ Goto 'Options-&gt;Visual Style' and change the current language ambience.</value @@ -5167,7 +5167,7 @@ Goto 'Options-&gt;Visual Style' and change the current language ambience.</value
<value>ASP.NET/IIS (Express) worker process ({0}) was not found.</value>
</data>
<data name="ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction" xml:space="preserve">
<value>There's no Project Url specified or external program. Check the web server at Project Properties -&amp;gt; Debug tab.</value>
<value>There's no Project Url specified or external program. Check the web server at Project Properties - Debug tab.</value>
</data>
<data name="ICSharpCode.WepProjectOptionsPanel.Port" xml:space="preserve">
<value>Server port:</value>
@ -6550,6 +6550,12 @@ Removed the end part of the original message ", reason '${Message}'" since this @@ -6550,6 +6550,12 @@ Removed the end part of the original message ", reason '${Message}'" since this
<data name="ProjectComponent.ContextMenu.SetAsStartupProject" xml:space="preserve">
<value>Set as St&amp;artUp Project</value>
</data>
<data name="ProjectComponent.ContextMenu.ViewInBrowser" xml:space="preserve">
<value>View in browser</value>
</data>
<data name="ProjectComponent.ContextMenu.NotAWebProject" xml:space="preserve">
<value>The project is not a web project.</value>
</data>
<data name="ProjectComponent.NewFolderString" xml:space="preserve">
<value>New Folder</value>
</data>

BIN
data/resources/image/BitmapResources/BitmapResources-data/Icons.22x22.Browser.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

1
data/resources/image/BitmapResources/BitmapResources.res

@ -60,6 +60,7 @@ Icons.16x16.ClosedReferenceFolder = ProjectBrowserIcons\GhostFol @@ -60,6 +60,7 @@ Icons.16x16.ClosedReferenceFolder = ProjectBrowserIcons\GhostFol
Icons.16x16.OpenResourceFolder = ProjectBrowserIcons\PropertyFolder.Open.png
Icons.16x16.ClosedResourceFolder = ProjectBrowserIcons\PropertyFolder.Closed.png
Icons.22x22.Browser = BitmapResources-data\Icons.22x22.Browser.png
Icons.16x16.ArrowLeftRight = BitmapResources-data\Icons.16x16.ArrowLeftRight.png
Icons.16x16.ArrowDown = BitmapResources-data\Icons.16x16.ArrowDown.png

58
src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs

@ -161,25 +161,21 @@ namespace ICSharpCode.SharpDevelop.Services @@ -161,25 +161,21 @@ namespace ICSharpCode.SharpDevelop.Services
if (index > -1){
Attach(processes[index]);
} else {
try {
this.monitor = new ProcessMonitor(processName);
this.monitor.ProcessCreated += delegate {
WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(defaultAppProcess, options)));
};
this.monitor.Start();
}
catch (System.Exception ex) {
LoggingService.ErrorFormatted("Process Monitor exception: {0}", ex.Message);
}
}
if (options.Data.WebServer == WebServer.IISExpress) {
// start IIS express and attach to it
if (WebProjectService.IISVersion == IISVersion.IISExpress) {
System.Diagnostics.Process.Start(WebProjectService.IISExpressProcessLocation);
} else {
MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}");
return;
this.monitor = new ProcessMonitor(processName);
this.monitor.ProcessCreated += delegate {
WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(defaultAppProcess, options)));
};
this.monitor.Start();
if (options.Data.WebServer == WebServer.IISExpress) {
// start IIS express and attach to it
if (WebProjectService.IISVersion == IISVersion.IISExpress) {
System.Diagnostics.Process.Start(WebProjectService.IISExpressProcessLocation);
} else {
DisposeProcessMonitor();
MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}");
return;
}
}
}
@ -190,6 +186,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -190,6 +186,7 @@ namespace ICSharpCode.SharpDevelop.Services
defaultAppProcess = System.Diagnostics.Process.Start(options.Data.ProjectUrl);
} else {
MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}");
DisposeProcessMonitor();
return;
}
break;
@ -205,6 +202,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -205,6 +202,7 @@ namespace ICSharpCode.SharpDevelop.Services
defaultAppProcess = System.Diagnostics.Process.Start(url);
} else {
MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}");
DisposeProcessMonitor();
return;
}
}
@ -216,6 +214,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -216,6 +214,7 @@ namespace ICSharpCode.SharpDevelop.Services
string err = "Error: " + ex.Message;
MessageService.ShowError(err);
LoggingService.Error(err);
DisposeProcessMonitor();
return;
}
} else {
@ -268,7 +267,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -268,7 +267,7 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
}
public void ShowAttachDialog()
{
using (AttachToProcessForm attachForm = new AttachToProcessForm()) {
@ -409,11 +408,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -409,11 +408,7 @@ namespace ICSharpCode.SharpDevelop.Services
debuggedProcess.Terminate();
}
if (monitor != null) {
monitor.Stop();
monitor.Dispose();
monitor = null;
}
DisposeProcessMonitor();
}
bool CheckWebProjectStartInfo()
@ -449,6 +444,8 @@ namespace ICSharpCode.SharpDevelop.Services @@ -449,6 +444,8 @@ namespace ICSharpCode.SharpDevelop.Services
string processName = WebProjectService.WorkerProcessName;
var processes = System.Diagnostics.Process.GetProcesses();
int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));
if (index == -1)
return;
Attach(processes[index]);
if (!attached) {
@ -464,6 +461,15 @@ namespace ICSharpCode.SharpDevelop.Services @@ -464,6 +461,15 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
void DisposeProcessMonitor()
{
if (monitor != null) {
monitor.Stop();
monitor.Dispose();
monitor = null;
}
}
// ExecutionControl:
public void Break()
@ -688,7 +694,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -688,7 +694,7 @@ namespace ICSharpCode.SharpDevelop.Services
} catch (System.Exception ex) {
LoggingService.Error("Error on GetTooltipControl: " + ex.Message);
return null;
}
}
}
public ITreeNode GetNode(string variable, string currentImageName = null)

20
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
<ConditionEvaluator name="CompareProjectProperty" class="ICSharpCode.SharpDevelop.CompareProjectPropertyConditionEvaluator"/>
<ConditionEvaluator name="ProjectItem" class="ICSharpCode.SharpDevelop.Project.ProjectItemConditionEvaluator"/>
<ConditionEvaluator name="IsTextSelected" class="ICSharpCode.SharpDevelop.Editor.AvalonEdit.TextSelectedCondition"/>
<ConditionEvaluator name="ViewInBrowser" class="ICSharpCode.SharpDevelop.ViewInBrowserConditionEvaluator"/>
<Doozer name="CustomTool" class="ICSharpCode.SharpDevelop.Project.CustomToolDoozer"/>
<Doozer name="CustomProperty" class="ICSharpCode.SharpDevelop.Project.CustomPropertyDoozer"/>
@ -457,9 +458,26 @@ @@ -457,9 +458,26 @@
label = "${res:ProjectComponent.ContextMenu.IncludeFileInProject}"
class = "ICSharpCode.SharpDevelop.Project.Commands.IncludeFileInProject"/>
</Condition>
<MenuItem id = "ExcludeSeparator" type = "Separator" />
</ComplexCondition>
<ComplexCondition>
<And>
<Condition name = "Ownerstate" ownerstate = "InProject"/>
<Not>
<Condition name = "Ownerstate" ownerstate = "BehindFile"/>
</Not>
<Condition name="IsProcessRunning" isprocessrunning="False" isdebugging="False"/>
<Condition name = "ViewInBrowser" extensions="aspx,asmx,html,htm,svc"/>
</And>
<MenuItem id = "ViewInBrowser"
label = "${res:ProjectComponent.ContextMenu.ViewInBrowser}"
icon = "Icons.22x22.Browser"
class = "ICSharpCode.SharpDevelop.Project.Commands.ViewInBrowser"/>
<MenuItem id = "ExcludeSeparator_ViewInBrowser" type = "Separator" />
</ComplexCondition>
<Include id="CutCopyPasteDeleteRename" path="/SharpDevelop/Pads/ProjectBrowser/ContextMenu/CutCopyPasteDeleteRename"/>
<MenuItem id = "RenameSeparator" type = "Separator" />
<MenuItem id = "Properties"

2
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -268,6 +268,7 @@ @@ -268,6 +268,7 @@
<Compile Include="Src\Gui\Pads\AbstractConsolePad.cs" />
<Compile Include="Src\Gui\Pads\BaseWatchBox.cs" />
<Compile Include="Src\Gui\Pads\OutlinePad.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\Commands\SpecialFileNodeCommands.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\TreeNodes\DirectoryNodeFactory.cs" />
<Compile Include="Src\Gui\Pads\TaskList\TaskListPadCommands.cs" />
<Compile Include="Src\Gui\Pads\ToolsPad.cs" />
@ -279,6 +280,7 @@ @@ -279,6 +280,7 @@
<Compile Include="Src\Gui\Workbench\Layouts\AvalonWorkbenchWindow.cs" />
<Compile Include="Src\Gui\Workbench\SingleInstanceHelper.cs" />
<Compile Include="Src\Gui\Workbench\WpfWorkbench.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ViewInBrowserConditionEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\WriteableProjectEvaluator.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\WriteableSolutionEvaluator.cs" />
<Compile Include="Src\Internal\Doozers\IOptionPanel.cs" />

7
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs

@ -140,10 +140,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -140,10 +140,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
ProjectUrl.Text = string.Empty;
data.WebServer = WebServer.None;
UseLocalIIS.IsChecked = false;
}
else {
} else {
StatusLabel.Text = string.Empty;
ProjectUrl.Text = @"http://localhost/" + ProjectService.CurrentProject.Name;
ProjectUrl.Text = string.Format("{0}/{1}", CompilableProject.LocalHost, ProjectService.CurrentProject.Name);
}
data.ProjectUrl = ProjectUrl.Text;
@ -197,7 +196,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -197,7 +196,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
WebProjectDebugData data = new WebProjectDebugData();
data.WebServer = WebServer.IISExpress;
data.Port = PortTextBox.Text;
data.ProjectUrl = string.Format(@"http://localhost:{0}/" + ProjectService.CurrentProject.Name, PortTextBox.Text);
data.ProjectUrl = string.Format(@"{0}:{1}/{2}", CompilableProject.LocalHost, PortTextBox.Text, ProjectService.CurrentProject.Name);
CurrentProjectDebugData = data;
}
}

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ProjectNodeCommands.cs

@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
namespace ICSharpCode.SharpDevelop.Project.Commands
{

74
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SpecialFileNodeCommands.cs

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
namespace ICSharpCode.SharpDevelop.Project.Commands
{
public class ViewInBrowser : AbstractMenuCommand
{
public override void Run()
{
var node = ProjectBrowserPad.Instance.SelectedNode as FileNode;
if (node == null) {
return;
}
var project = ProjectService.CurrentProject as CompilableProject;
if (project == null) {
return;
}
if (!project.IsWebProject) {
MessageService.ShowError("${res:ProjectComponent.ContextMenu.NotAWebProject}");
return;
}
if (!WebProjectService.IsIISInstalled) {
MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.IISNotFound}");
return;
}
string fileName = node.FileName;
// set project options
project.StartAction = StartAction.StartURL;
string directoryName = Path.GetDirectoryName(project.FileName) + "\\";
project.StartUrl = fileName.Replace(directoryName, "/").Replace("\\", "/");
// set web server options
string projectName = project.Name;
var existingOptions = WebProjectsOptions.Instance.GetWebProjectOptions(projectName);
var options = new WebProjectOptions {
Data = new WebProjectDebugData {
WebServer = WebProjectService.IISVersion == IISVersion.IISExpress ? WebServer.IISExpress : WebServer.IIS,
Port = (existingOptions != null && existingOptions.Data != null) ? existingOptions.Data.Port : "8080", //TODO: port collision detection
ProjectUrl = string.Format("{0}/{1}", CompilableProject.LocalHost, project.Name)
},
ProjectName = projectName
};
if (options.Data.WebServer == WebServer.IISExpress) {
options.Data.ProjectUrl = string.Format(
@"{0}:{1}/{2}", CompilableProject.LocalHost, options.Data.Port, projectName);
}
WebProjectsOptions.Instance.SetWebProjectOptions(projectName, options);
// create virtual directory
string error = WebProjectService.CreateVirtualDirectory(
projectName,
Path.GetDirectoryName(ProjectService.CurrentProject.FileName));
LoggingService.Info(error ?? string.Empty);
// RunProject
new RunProject().Run();
}
}
}

32
src/Main/Base/Project/Src/Internal/ConditionEvaluators/ViewInBrowserConditionEvaluator.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop
{
public class ViewInBrowserConditionEvaluator : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
var node = ProjectBrowserPad.Instance.SelectedNode;
if (node == null) {
return false;
}
string fileName = Path.GetFileName(node.FullPath);
string[] extensions = condition["extensions"].Split(',');
if (!extensions.Any(e => fileName.EndsWith(e))) {
return false;
}
return true;
}
}
}

4
src/Main/Base/Project/Src/Project/CompilableProject.cs

@ -31,6 +31,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -31,6 +31,8 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary>
public abstract class CompilableProject : MSBuildBasedProject, IUpgradableProject
{
public const string LocalHost = "http://localhost";
#region Static methods
/// <summary>
/// Gets the file extension of the assembly created when building a project
@ -284,7 +286,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -284,7 +286,7 @@ namespace ICSharpCode.SharpDevelop.Project
switch (this.StartAction) {
case StartAction.Project:
if (IsWebProject)
return new ProcessStartInfo("http://localhost");
return new ProcessStartInfo(LocalHost);
return CreateStartInfo(this.OutputAssemblyFullPath);
case StartAction.Program:

6
src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs

@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Project
public enum IISVersion
{
None = 0,
IISExpress,
IISExpress = 4,
IIS5 = 5,
IIS6,
IIS7,
@ -157,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -157,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary>
public static bool IsIISInstalled {
get {
return (int)IISVersion > 4;
return (int)IISVersion >= 4;
}
}
@ -191,7 +191,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -191,7 +191,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary>
/// <param name="virtualDirectoryName">Virtual directory name.</param>
/// <param name="virtualDirectoryPath">Physical path.</param>
/// <returns></returns>
/// <returns>Error string or string null = no errors.</returns>
public static string CreateVirtualDirectory(string virtualDirectoryName, string physicalDirectoryPath)
{
try {

BIN
src/Main/StartUp/Project/Resources/BitmapResources.resources

Binary file not shown.
Loading…
Cancel
Save