Browse Source

StyleCop -> AnalysisProjectOptionsPanel

pull/30/head
PeterForstmeier 13 years ago
parent
commit
775356bcd4
  1. 4
      src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.addin
  2. 17
      src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.csproj
  3. 39
      src/AddIns/Analysis/SourceAnalysis/Src/AnalysisOptionsPanelXaml.xaml
  4. 129
      src/AddIns/Analysis/SourceAnalysis/Src/AnalysisOptionsPanelXaml.xaml.cs
  5. 3
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml.cs
  6. 11
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/OptionsHelper.cs

4
src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.addin

@ -21,6 +21,9 @@ @@ -21,6 +21,9 @@
<OptionPanel id = "SourceAnalysis"
label = "${res:AddIns.SourceAnalysis.Title}"
class = "MattEverson.SourceAnalysis.AnalysisProjectOptionsPanel"/>
<OptionPanel id = "SourceAnalysis"
label = "${res:AddIns.SourceAnalysis.Title}"
class = "MattEverson.SourceAnalysis.AnalysisProjectOptionsPanelXaml"/>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions">
@ -45,5 +48,6 @@ @@ -45,5 +48,6 @@
<OptionPanel id = "SourceAnalysisOptionPanel"
label = "${res:AddIns.SourceAnalysis.Title}"
class = "MattEverson.SourceAnalysis.AnalysisIdeOptionsPanel"/>
</Path>
</AddIn>

17
src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.csproj

@ -40,11 +40,17 @@ @@ -40,11 +40,17 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs">
@ -60,6 +66,10 @@ @@ -60,6 +66,10 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AnalysisOptionsPanelXaml.xaml.cs">
<DependentUpon>AnalysisOptionsPanelXaml.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\AnalysisProjectOptionsPanel.cs" />
<Compile Include="Src\AnalysisProjectOptions.Designer.cs">
<DependentUpon>AnalysisProjectOptions.cs</DependentUpon>
@ -90,11 +100,18 @@ @@ -90,11 +100,18 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj">
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project>
<Name>ICSharpCode.Core.Presentation</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\AnalysisOptionsPanelXaml.xaml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

39
src/AddIns/Analysis/SourceAnalysis/Src/AnalysisOptionsPanelXaml.xaml

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
<optionpanels:ProjectOptionPanel
x:Class="MattEverson.SourceAnalysis.AnalysisProjectOptionsPanelXaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels;assembly=ICSharpCode.SharpDevelop"
xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project;assembly=ICSharpCode.SharpDevelop"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:tv="http://icsharpcode.net/sharpdevelop/treeview"
xmlns:core="http://icsharpcode.net/sharpdevelop/core">
<Grid Margin="0,10,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="10"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="30"></ColumnDefinition>
</Grid.ColumnDefinitions>
<optionpanels:StorageLocationPicker Location="{Binding SourceAnalysisOverrideSettingsFile.Location}" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="3,0,3,0"
x:Name="settingsFileTextBox"
Text="{Binding SourceAnalysisOverrideSettingsFile.Value, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Button Grid.Column="3" Content="..." VerticalAlignment="Center"
Click="BrowseButton_Click" ></Button>
<Button Grid.Row="2" Grid.ColumnSpan="2" VerticalAlignment="Center"
Content="Modify StyleCop Settings" Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="ModifyStyleCopSettings_Click"></Button>
</Grid>
</optionpanels:ProjectOptionPanel>

129
src/AddIns/Analysis/SourceAnalysis/Src/AnalysisOptionsPanelXaml.xaml.cs

@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 21.07.2012
* Time: 18:51
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using ICSharpCode.SharpDevelop.Project;
namespace MattEverson.SourceAnalysis
{
/// <summary>
/// Interaction logic for AnalysisIdeOptionsPanelXaml.xaml
/// </summary>
public partial class AnalysisProjectOptionsPanelXaml : ProjectOptionPanel
{
public AnalysisProjectOptionsPanelXaml()
{
InitializeComponent();
}
public ProjectProperty<string> SourceAnalysisOverrideSettingsFile {
get { return GetProperty("SourceAnalysisOverrideSettingsFile", "", TextBoxEditMode.EditRawProperty); }
}
protected override void Load(MSBuildBasedProject project, string configuration, string platform)
{
base.Load(project, configuration, platform);
if (String.IsNullOrEmpty(SourceAnalysisOverrideSettingsFile.Value)) {
SourceAnalysisOverrideSettingsFile.Value = StyleCopWrapper.GetMasterSettingsFile();
SourceAnalysisOverrideSettingsFile.Location = PropertyStorageLocations.Base;
}
}
void BrowseButton_Click(object sender, RoutedEventArgs e)
{
var fn = OptionsHelper.OpenFile(String.Empty);
if (!String.IsNullOrEmpty(fn)) {
settingsFileTextBox.Text = fn;
}
}
void ModifyStyleCopSettings_Click(object sender, RoutedEventArgs e)
{
var settingsFile = SourceAnalysisOverrideSettingsFile.Value;
if (settingsFile == StyleCopWrapper.GetMasterSettingsFile()) {
if (ConfirmSwitchFromMaster()) {
settingsFile = CopyFromMaster();
}
}
if (!System.IO.File.Exists(settingsFile)) {
if (ConfirmReplaceMissingFile()) {
settingsFile = CopyFromMaster();
}
else {
MessageService.ShowWarning("No settings file found to modify.");
return;
}
}
string styleCopPath = StyleCopWrapper.FindStyleCopPath();
string executable;
if (styleCopPath != null)
executable = Path.Combine(Path.GetDirectoryName(styleCopPath), "StyleCopSettingsEditor.exe");
else
executable = null;
string parameters = "\"" + settingsFile + "\"";
if (!File.Exists(executable)) {
LoggingService.Debug("StyleCopSettingsEditor.exe: " + executable);
MessageService.ShowWarning("Unable to find the StyleCop Settings editor. Please specify the StyleCop location in Tools Options.");
return;
}
using(Process p = Process.Start("\"" + executable + "\"", parameters)) {
// No need to wait for the settings dialog to close - we can leave it open.
}
}
private bool ConfirmReplaceMissingFile()
{
return MessageService.AskQuestion("A settings file is not present. Would you like to copy the master into the " +
"project folder?",
"Missing Settings File");
}
private bool ConfirmSwitchFromMaster()
{
return MessageService.AskQuestion("You are currently using the master settings file. Do you want to make a "
+ "copy in the project folder instead?",
"Using Master Settings File");
}
private string CopyFromMaster()
{
var newSettingsFile = Project.Directory + "\\Settings.SourceAnalysis";
System.IO.File.Copy(
StyleCopWrapper.GetMasterSettingsFile(),
newSettingsFile,
true
);
SourceAnalysisOverrideSettingsFile.Value = newSettingsFile;
SourceAnalysisOverrideSettingsFile.Location = PropertyStorageLocations.Base;
return newSettingsFile;
}
}
}

3
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/ApplicationSettings.xaml.cs

@ -17,8 +17,6 @@ using ICSharpCode.Core; @@ -17,8 +17,6 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
using Microsoft.Win32;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
@ -30,7 +28,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -30,7 +28,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
private const string iconsfilter = "${res:SharpDevelop.FileFilter.Icons}|*.ico|${res:SharpDevelop.FileFilter.AllFiles}|*.*";
private const string manifestFilter = "${res:Dialog.ProjectOptions.ApplicationSettings.Manifest.ManifestFiles}|*.manifest|${res:SharpDevelop.FileFilter.AllFiles}|*.*";
private const string win32filter = "Win32 Resource files|*.res|${res:SharpDevelop.FileFilter.AllFiles}|*.*";
// MSBuildBasedProject project;
public ApplicationSettings()
{

11
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/OptionsHelper.cs

@ -73,11 +73,18 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -73,11 +73,18 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
}
*/
/// <summary>
/// Open File
/// </summary>
/// <param name="filter" or String.Empty></param>
/// <returns FileName></returns>
public static string OpenFile (string filter)
{
var dialog = new OpenFileDialog();
dialog.Filter = StringParser.Parse(filter);
if (String.IsNullOrEmpty(filter)) {
dialog.Filter = StringParser.Parse(filter);
}
if (dialog.ShowDialog() ?? false) {
return dialog.FileName;
}

Loading…
Cancel
Save