18 changed files with 300 additions and 67 deletions
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
// 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 ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser |
||||
{ |
||||
/// <summary>
|
||||
/// Tree node representing one single referenced assembly.
|
||||
/// </summary>
|
||||
public class AssemblyReferenceTreeNode : ModelCollectionTreeNode |
||||
{ |
||||
private IAssemblyReferenceModel model; |
||||
|
||||
public AssemblyReferenceTreeNode(IAssemblyReferenceModel model) |
||||
{ |
||||
if (model == null) |
||||
throw new ArgumentNullException("model"); |
||||
this.model = model; |
||||
} |
||||
|
||||
protected override object GetModel() |
||||
{ |
||||
return model; |
||||
} |
||||
|
||||
protected override IModelCollection<object> ModelChildren { |
||||
get { |
||||
// TODO Show assemblies referenced by this assembly?
|
||||
return ImmutableModelCollection<object>.Empty; |
||||
} |
||||
} |
||||
|
||||
protected override System.Collections.Generic.IComparer<ICSharpCode.TreeView.SharpTreeNode> NodeComparer { |
||||
get { |
||||
return NodeTextComparer; |
||||
} |
||||
} |
||||
|
||||
public override object Text { |
||||
get { |
||||
return model.AssemblyName.ShortName; |
||||
} |
||||
} |
||||
|
||||
public override object Icon { |
||||
get { |
||||
return SD.ResourceService.GetImageSource("Icons.16x16.Reference"); |
||||
} |
||||
} |
||||
|
||||
public override void ShowContextMenu() |
||||
{ |
||||
var assemblyReferenceModel = this.Model as IAssemblyReferenceModel; |
||||
if (assemblyReferenceModel != null) { |
||||
var ctx = MenuService.ShowContextMenu(null, assemblyReferenceModel, "/SharpDevelop/Pads/ClassBrowser/AssemblyReferenceContextMenu"); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// 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.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Base interface for a single assembly reference.
|
||||
/// </summary>
|
||||
public interface IAssemblyReferenceModel |
||||
{ |
||||
DomAssemblyName AssemblyName { get; } |
||||
IAssemblyModel ParentAssemblyModel { get; } |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// 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.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Base interface for list of assembly references.
|
||||
/// </summary>
|
||||
public interface IAssemblyReferencesModel |
||||
{ |
||||
IModelCollection<IAssemblyReferenceModel> AssemblyNames { get; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Implements an empty assembly references model.
|
||||
/// </summary>
|
||||
public class EmptyAssemblyReferencesModel : IAssemblyReferencesModel |
||||
{ |
||||
public static readonly IAssemblyReferencesModel Instance = new EmptyAssemblyReferencesModel(); |
||||
|
||||
private static readonly SimpleModelCollection<IAssemblyReferenceModel> EmptyReferenceCollection = |
||||
new SimpleModelCollection<IAssemblyReferenceModel>(); |
||||
|
||||
public IModelCollection<IAssemblyReferenceModel> AssemblyNames { |
||||
get { |
||||
return EmptyReferenceCollection; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// 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.Collections.Generic; |
||||
using System.Linq; |
||||
using ICSharpCode.SharpDevelop.Parser; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Model representing list of assembly references.
|
||||
/// </summary>
|
||||
public class AssemblyReferencesModel : IAssemblyReferencesModel |
||||
{ |
||||
IAssemblyModel parentAssemblyModel; |
||||
private NullSafeSimpleModelCollection<IAssemblyReferenceModel> assemblyNames; |
||||
|
||||
public AssemblyReferencesModel(IAssemblyModel parentAssemblyModel) |
||||
{ |
||||
if (parentAssemblyModel == null) |
||||
throw new ArgumentNullException("parentAssemblyModel"); |
||||
|
||||
assemblyNames = new NullSafeSimpleModelCollection<IAssemblyReferenceModel>(); |
||||
this.parentAssemblyModel = parentAssemblyModel; |
||||
} |
||||
|
||||
public IModelCollection<IAssemblyReferenceModel> AssemblyNames |
||||
{ |
||||
get { |
||||
return assemblyNames; |
||||
} |
||||
} |
||||
|
||||
public void Update(IReadOnlyList<DomAssemblyName> references) |
||||
{ |
||||
assemblyNames.Clear(); |
||||
if (references != null) { |
||||
assemblyNames.AddRange(references.Select(r => new AssemblyReferenceModel(parentAssemblyModel, r))); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Model representing an assembly reference.
|
||||
/// </summary>
|
||||
public class AssemblyReferenceModel : IAssemblyReferenceModel |
||||
{ |
||||
IAssemblyModel parentAssemblyModel; |
||||
DomAssemblyName assemblyName; |
||||
|
||||
public AssemblyReferenceModel(IAssemblyModel parentAssemblyModel, DomAssemblyName assemblyName) |
||||
{ |
||||
if (parentAssemblyModel == null) |
||||
throw new ArgumentNullException("parentAssemblyModel"); |
||||
if (assemblyName == null) |
||||
throw new ArgumentNullException("assemblyName"); |
||||
|
||||
this.parentAssemblyModel = parentAssemblyModel; |
||||
this.assemblyName = assemblyName; |
||||
} |
||||
|
||||
public DomAssemblyName AssemblyName { |
||||
get { |
||||
return assemblyName; |
||||
} |
||||
} |
||||
|
||||
public IAssemblyModel ParentAssemblyModel { |
||||
get { |
||||
return parentAssemblyModel; |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue