Browse Source

Sort sub list in Groups by any Column,

see src\AddIns\Analysis\CodeQuality\Reporting\DependencyReport.cs for example
reports
Peter Forstmeier 12 years ago
parent
commit
a3775b6ff8
  1. 7
      src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs
  2. 10
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs
  3. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs
  4. 34
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs

7
src/AddIns/Analysis/CodeQuality/Reporting/DependencyReport.cs

@ -19,10 +19,12 @@ @@ -19,10 +19,12 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Reflection;
using ICSharpCode.Reporting;
using ICSharpCode.Reporting.Interfaces;
using ICSharpCode.Reporting.Items;
using ICSharpCode.CodeQuality.Engine.Dom;
namespace ICSharpCode.CodeQuality.Reporting
@ -46,6 +48,11 @@ namespace ICSharpCode.CodeQuality.Reporting @@ -46,6 +48,11 @@ namespace ICSharpCode.CodeQuality.Reporting
var reportingFactory = new ReportingFactory();
var reportCreator = reportingFactory.ReportCreator (stream,newList);
ReportSettings = reportingFactory.ReportModel.ReportSettings;
var groupColumn = (GroupColumn)ReportSettings.GroupColumnsCollection[0];
groupColumn.GroupSortColumn = new SortColumn() {
ColumnName = "ReferenceCount",
SortDirection = ListSortDirection.Ascending
};
reportCreator.BuildExportList();
return reportCreator;
}

10
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs

@ -143,8 +143,13 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -143,8 +143,13 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
IEnumerable<IGrouping<object, object>> GroupInternal () {
PropertyDescriptor sortProperty = null;
var groupProperty = listProperties.Find(reportSettings.GroupColumnsCollection[0].ColumnName,true);
var sortProperty = listProperties.Find("Randomint",true);
var groupColumn = (GroupColumn)reportSettings.GroupColumnsCollection[0];
if (groupColumn.GroupSortColumn != null) {
sortProperty = listProperties.Find(groupColumn.GroupSortColumn.ColumnName,true);
}
IEnumerable<IGrouping<object, object>> groupedList;
if (sortProperty == null) {
groupedList = baseList.GroupBy(a => a.GetType().GetProperty(groupProperty.Name).GetValue(a, null)).OrderBy(c => c.Key);
@ -155,7 +160,6 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -155,7 +160,6 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
return groupedList;
}
#endregion
public void Bind()
@ -167,8 +171,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -167,8 +171,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
}
}
#region Fill
#region Fill
public void Fill (List<IPrintableObject> collection, object current) {
Current = current;

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs

@ -43,6 +43,6 @@ namespace ICSharpCode.Reporting.Items @@ -43,6 +43,6 @@ namespace ICSharpCode.Reporting.Items
public int GroupLevel {get;private set;}
public SortColumn GroupSortColumn {get;set;}
}
}

34
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs

@ -46,6 +46,34 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -46,6 +46,34 @@ namespace ICSharpCode.Reporting.Test.DataSource
}
[Test]
public void GroupbyOneColumnSortSubList () {
var rs = new ReportSettings();
var gc = new GroupColumn() {
ColumnName ="GroupItem",
SortDirection = ListSortDirection.Ascending,
GroupSortColumn = new SortColumn() {
ColumnName = "Randomint",
SortDirection = ListSortDirection.Ascending
}
};
rs.GroupColumnsCollection.Add(gc);
var collectionSource = new CollectionDataSource (list,rs);
collectionSource.Bind();
var testKey = String.Empty;
var testSubKey = -1;
var groupedList = collectionSource.GroupedList;
foreach (var element in groupedList) {
Assert.That(element.Key,Is.GreaterThan(testKey));
testKey = element.Key.ToString();
foreach (Contributor sub in element) {
Assert.That(sub.RandomInt,Is.GreaterThanOrEqualTo(testSubKey));
testSubKey = sub.RandomInt;
}
testSubKey = -1;
}
}
[Test]
public void GroupbyOneColumn () {
@ -53,6 +81,12 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -53,6 +81,12 @@ namespace ICSharpCode.Reporting.Test.DataSource
rs.GroupColumnsCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending));
var collectionSource = new CollectionDataSource (list,rs);
collectionSource.Bind();
var testKey = String.Empty;
var groupedList = collectionSource.GroupedList;
foreach (var element in groupedList) {
Assert.That(element.Key,Is.GreaterThan(testKey));
testKey = element.Key.ToString();
}
}

Loading…
Cancel
Save