Browse Source

ICSharpCode.Core: For <MenuItem type="CheckBox">, the checked attribute can now be specified. Doing so enables lazy loading by using that value as default (until the item is clicked). The value can depend on properties stored in the PropertyService.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1930 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
75ccdb10ea
  1. 18
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin
  2. 20
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageOptions.cs
  3. 5
      src/Libraries/NRefactory/Project/Src/Ast/Enums.cs
  4. 10
      src/Libraries/NRefactory/Project/Src/Ast/General/Statement.cs
  5. 4
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  6. 2
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
  7. 2
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  8. 29
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/Gui/MenuCheckBox.cs
  9. 34
      src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

18
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin

@ -3,7 +3,7 @@
url = "http://ncover.org" url = "http://ncover.org"
description = "Code Coverage AddIn for SharpDevelop using NCover"> description = "Code Coverage AddIn for SharpDevelop using NCover">
<Manifest> <Manifest>
<Identity name = "ICSharpCode.CodeCoverage"/> <Identity name = "ICSharpCode.CodeCoverage"/>
<Dependency addin = "ICSharpCode.UnitTesting"/> <Dependency addin = "ICSharpCode.UnitTesting"/>
</Manifest> </Manifest>
@ -17,7 +17,7 @@
</Runtime> </Runtime>
<Path name = "/SharpDevelop/Workbench/Pads"> <Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "CodeCoveragePad" <Pad id = "CodeCoveragePad"
category = "Tools" category = "Tools"
title = "${res:ICSharpCode.UnitTesting.CodeCoverage}" title = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "Bookmarks" insertafter = "Bookmarks"
@ -52,9 +52,9 @@
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions"> <Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<DialogPanel id = "CodeCoverageOptionsPanel" <DialogPanel id = "CodeCoverageOptionsPanel"
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}" label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "NAnt" insertafter = "NAnt"
class = "ICSharpCode.CodeCoverage.CodeCoverageOptionsPanel"/> class = "ICSharpCode.CodeCoverage.CodeCoverageOptionsPanel"/>
</Path> </Path>
<Path name = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"> <Path name = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands">
@ -72,20 +72,22 @@
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}" label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
class = "ICSharpCode.CodeCoverage.CodeCoverageProjectOptionsPanel"/> class = "ICSharpCode.CodeCoverage.CodeCoverageProjectOptionsPanel"/>
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Edit/Format"> <Path name = "/SharpDevelop/Workbench/MainMenu/Edit/Format">
<MenuItem id = "ShowCodeCoverage" <MenuItem id = "ShowCodeCoverage"
insertafter = "Indent" insertafter = "Indent"
label = "${res:ICSharpCode.CodeCoverage.ShowCoverage}" label = "${res:ICSharpCode.CodeCoverage.ShowCoverage}"
checked = "${property:CodeCoverage.Options/CodeCoverageHighlighted??False}"
type = "CheckBox" type = "CheckBox"
class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/> class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/>
</Path> </Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ContextMenu"> <Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ContextMenu">
<MenuItem id = "ShowCodeCoverage" <MenuItem id = "ShowCodeCoverage"
insertafter = "Indent" insertafter = "Indent"
insertbefore = "FileMode" insertbefore = "FileMode"
label = "${res:ICSharpCode.CodeCoverage.ShowCoverage}" label = "${res:ICSharpCode.CodeCoverage.ShowCoverage}"
checked = "${property:CodeCoverage.Options/CodeCoverageHighlighted??False}"
type = "CheckBox" type = "CheckBox"
class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/> class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/>
</Path> </Path>

20
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageOptions.cs

@ -21,6 +21,8 @@ namespace ICSharpCode.CodeCoverage
public static readonly string NotVisitedColorProperty = "NotVisitedColor"; public static readonly string NotVisitedColorProperty = "NotVisitedColor";
public static readonly string NotVisitedForeColorProperty = "NotVisitedForeColor"; public static readonly string NotVisitedForeColorProperty = "NotVisitedForeColor";
public static readonly string NCoverFileNameProperty = "NCoverFileName"; public static readonly string NCoverFileNameProperty = "NCoverFileName";
// This name is also referenced by CodeCoverage.addin
public static readonly string CodeCoverageHighlightedProperty = "CodeCoverageHighlighted"; public static readonly string CodeCoverageHighlightedProperty = "CodeCoverageHighlighted";
public static readonly string ShowSourceCodePanelProperty = "ShowSourceCodePanel"; public static readonly string ShowSourceCodePanelProperty = "ShowSourceCodePanel";
public static readonly string ShowVisitCountPanelProperty = "ShowVisitCountPanel"; public static readonly string ShowVisitCountPanelProperty = "ShowVisitCountPanel";
@ -29,14 +31,14 @@ namespace ICSharpCode.CodeCoverage
static Properties properties; static Properties properties;
static CodeCoverageOptions() static CodeCoverageOptions()
{ {
properties = PropertyService.Get(OptionsProperty, new Properties()); properties = PropertyService.Get(OptionsProperty, new Properties());
} }
public static Properties Properties { public static Properties Properties {
get { get {
return properties; return properties;
} }
} }
/// <summary> /// <summary>
@ -99,10 +101,10 @@ namespace ICSharpCode.CodeCoverage
set { set {
Properties.Set<Color>(VisitedColorProperty, value); Properties.Set<Color>(VisitedColorProperty, value);
} }
} }
/// <summary> /// <summary>
/// Gets the foreground colour that will be used when highlighting /// Gets the foreground colour that will be used when highlighting
/// visited code. /// visited code.
/// </summary> /// </summary>
public static Color VisitedForeColor public static Color VisitedForeColor
@ -114,7 +116,7 @@ namespace ICSharpCode.CodeCoverage
set { set {
Properties.Set<Color>(VisitedForeColorProperty, value); Properties.Set<Color>(VisitedForeColorProperty, value);
} }
} }
/// <summary> /// <summary>
/// Gets the colour that will be used when highlighting code that has not /// Gets the colour that will be used when highlighting code that has not
@ -129,10 +131,10 @@ namespace ICSharpCode.CodeCoverage
set { set {
Properties.Set<Color>(NotVisitedColorProperty, value); Properties.Set<Color>(NotVisitedColorProperty, value);
} }
} }
/// <summary> /// <summary>
/// Gets the foreground colour that will be used when highlighting /// Gets the foreground colour that will be used when highlighting
/// code that has not been visited. /// code that has not been visited.
/// </summary> /// </summary>
public static Color NotVisitedForeColor public static Color NotVisitedForeColor
@ -144,6 +146,6 @@ namespace ICSharpCode.CodeCoverage
set { set {
Properties.Set<Color>(NotVisitedForeColorProperty, value); Properties.Set<Color>(NotVisitedForeColorProperty, value);
} }
} }
} }
} }

5
src/Libraries/NRefactory/Project/Src/Ast/Enums.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.Ast
Internal = 0x0002, Internal = 0x0002,
Protected = 0x0004, Protected = 0x0004,
Public = 0x0008, Public = 0x0008,
Dim = 0x0010, // VB.NET SPECIFIC Dim = 0x0010, // VB.NET SPECIFIC, for fields/local variables only
// Scope // Scope
Abstract = 0x0010, // == MustOverride/MustInherit Abstract = 0x0010, // == MustOverride/MustInherit
@ -45,6 +45,7 @@ namespace ICSharpCode.NRefactory.Ast
Default = 0x40000, // VB specific Default = 0x40000, // VB specific
Fixed = 0x80000, // C# specific (fixed size arrays in unsafe structs) Fixed = 0x80000, // C# specific (fixed size arrays in unsafe structs)
/// <summary>Generated code, not part of parsed code</summary>
Synthetic = 0x200000, Synthetic = 0x200000,
/// <summary>Only for VB properties.</summary> /// <summary>Only for VB properties.</summary>
WriteOnly = 0x400000, // VB specific WriteOnly = 0x400000, // VB specific
@ -236,7 +237,9 @@ namespace ICSharpCode.NRefactory.Ast
PostIncrement, PostIncrement,
PostDecrement, PostDecrement,
/// <summary>Dereferencing pointer</summary>
Star, Star,
/// <summary>Get address of</summary>
BitWiseAnd BitWiseAnd
} }

10
src/Libraries/NRefactory/Project/Src/Ast/General/Statement.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.NRefactory.Ast
public static Statement CheckNull(Statement statement) public static Statement CheckNull(Statement statement)
{ {
return statement == null ? NullStatement.Instance : statement; return statement ?? NullStatement.Instance;
} }
} }
@ -51,15 +51,11 @@ namespace ICSharpCode.NRefactory.Ast
static NullStatement nullStatement = new NullStatement(); static NullStatement nullStatement = new NullStatement();
public override bool IsNull { public override bool IsNull {
get { get { return true; }
return true;
}
} }
public static NullStatement Instance { public static NullStatement Instance {
get { get { return nullStatement; }
return nullStatement;
}
} }
NullStatement() NullStatement()

4
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

@ -18,7 +18,7 @@ using ICSharpCode.NRefactory.Ast;
namespace ICSharpCode.NRefactory.PrettyPrinter namespace ICSharpCode.NRefactory.PrettyPrinter
{ {
public class CSharpOutputVisitor : IOutputAstVisitor public sealed class CSharpOutputVisitor : IOutputAstVisitor
{ {
Errors errors = new Errors(); Errors errors = new Errors();
CSharpOutputFormatter outputFormatter; CSharpOutputFormatter outputFormatter;
@ -1077,7 +1077,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return null; return null;
} }
public virtual object VisitYieldStatement(YieldStatement yieldStatement, object data) public object VisitYieldStatement(YieldStatement yieldStatement, object data)
{ {
Debug.Assert(yieldStatement != null); Debug.Assert(yieldStatement != null);
Debug.Assert(yieldStatement.Statement != null); Debug.Assert(yieldStatement.Statement != null);

2
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -41,12 +41,14 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
// TODO: Debug statements only, remove me // TODO: Debug statements only, remove me
#if DEBUG
if (dockPanel.ActiveDocument != null && !(dockPanel.ActiveDocument is IWorkbenchWindow)) { if (dockPanel.ActiveDocument != null && !(dockPanel.ActiveDocument is IWorkbenchWindow)) {
if (firstTimeError) { if (firstTimeError) {
MessageBox.Show("ActiveDocument was " + dockPanel.ActiveDocument.GetType().FullName); MessageBox.Show("ActiveDocument was " + dockPanel.ActiveDocument.GetType().FullName);
firstTimeError = false; firstTimeError = false;
} }
} }
#endif
IWorkbenchWindow window = dockPanel.ActiveDocument as IWorkbenchWindow; IWorkbenchWindow window = dockPanel.ActiveDocument as IWorkbenchWindow;
if (window == null || window.IsDisposed) { if (window == null || window.IsDisposed) {

2
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -344,6 +344,8 @@ namespace ICSharpCode.SharpDevelop
static void ParserUpdateThread() static void ParserUpdateThread()
{ {
LoggingService.Info("ParserUpdateThread started"); LoggingService.Info("ParserUpdateThread started");
Thread.Sleep(750);
// preload mscorlib, we're going to need it probably // preload mscorlib, we're going to need it probably
IProjectContent dummyVar = defaultProjectContentRegistry.Mscorlib; IProjectContent dummyVar = defaultProjectContentRegistry.Mscorlib;

29
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/Gui/MenuCheckBox.cs

@ -21,15 +21,20 @@ namespace ICSharpCode.Core
string description = String.Empty; string description = String.Empty;
ICheckableMenuCommand menuCommand = null; ICheckableMenuCommand menuCommand = null;
void CreateMenuCommand()
{
if (menuCommand == null) {
try {
menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
} catch (Exception e) {
MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
}
}
}
public ICheckableMenuCommand MenuCommand { public ICheckableMenuCommand MenuCommand {
get { get {
if (menuCommand == null) { CreateMenuCommand();
try {
menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
} catch (Exception e) {
MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
}
}
return menuCommand; return menuCommand;
} }
} }
@ -80,8 +85,14 @@ namespace ICSharpCode.Core
if (codon != null) { if (codon != null) {
ConditionFailedAction failedAction = codon.GetFailedAction(caller); ConditionFailedAction failedAction = codon.GetFailedAction(caller);
this.Visible = failedAction != ConditionFailedAction.Exclude; this.Visible = failedAction != ConditionFailedAction.Exclude;
if (MenuCommand != null) { if (menuCommand == null && !string.IsNullOrEmpty(codon.Properties["checked"])) {
Checked = MenuCommand.IsChecked; Checked = string.Equals(StringParser.Parse(codon.Properties["checked"]),
bool.TrueString, StringComparison.OrdinalIgnoreCase);
} else {
CreateMenuCommand();
if (menuCommand != null) {
Checked = menuCommand.IsChecked;
}
} }
} }
} }

34
src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

@ -226,7 +226,7 @@ namespace ICSharpCode.Core
return null; return null;
} }
case "PROPERTY": case "PROPERTY":
return PropertyService.Get(propertyName); return GetProperty(propertyName);
default: default:
if (propertyObjects.ContainsKey(prefix)) { if (propertyObjects.ContainsKey(prefix)) {
return Get(propertyObjects[prefix], propertyName); return Get(propertyObjects[prefix], propertyName);
@ -236,6 +236,38 @@ namespace ICSharpCode.Core
} }
} }
/// <summary>
/// Allow special syntax to retrieve property values:
/// ${property:PropertyName}
/// ${property:PropertyName??DefaultValue}
/// ${property:ContainerName/PropertyName}
/// ${property:ContainerName/PropertyName??DefaultValue}
/// A container is a Properties instance stored in the PropertyService. This is
/// used by many AddIns to group all their properties into one container.
/// </summary>
static string GetProperty(string propertyName)
{
string defaultValue = "";
int pos = propertyName.LastIndexOf("??");
if (pos >= 0) {
defaultValue = propertyName.Substring(pos + 2);
propertyName = propertyName.Substring(0, pos);
}
pos = propertyName.IndexOf('/');
if (pos >= 0) {
Properties properties = PropertyService.Get(propertyName.Substring(0, pos), new Properties());
propertyName = propertyName.Substring(pos + 1);
pos = propertyName.IndexOf('/');
while (pos >= 0) {
properties = properties.Get(propertyName.Substring(0, pos), new Properties());
propertyName = propertyName.Substring(pos + 1);
}
return properties.Get(propertyName, defaultValue);
} else {
return PropertyService.Get(propertyName, defaultValue);
}
}
static string Get(object obj, string name) static string Get(object obj, string name)
{ {
Type type = obj.GetType(); Type type = obj.GetType();

Loading…
Cancel
Save