Add much easier ConsoleDisplayTable AddColumn() and AddRow() methods.

Use these for new "show regions" command rather than old cumbersome stuff.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-06-26 00:40:46 +01:00
parent 005ca12a99
commit 19c2f08a8b
2 changed files with 20 additions and 6 deletions

View File

@ -79,6 +79,16 @@ namespace OpenSim.Framework.Console
return sb.ToString(); return sb.ToString();
} }
public void AddColumn(string name, int width)
{
Columns.Add(new ConsoleDisplayTableColumn(name, width));
}
public void AddRow(params string[] cells)
{
Rows.Add(new ConsoleDisplayTableRow(cells));
}
public void AddToStringBuilder(StringBuilder sb) public void AddToStringBuilder(StringBuilder sb)
{ {
string formatString = GetFormatString(); string formatString = GetFormatString();
@ -135,5 +145,10 @@ namespace OpenSim.Framework.Console
{ {
Cells = cells; Cells = cells;
} }
public ConsoleDisplayTableRow(params string[] cells) : this()
{
Cells = new List<string>(cells);
}
} }
} }

View File

@ -648,16 +648,15 @@ namespace OpenSim.Services.GridService
private void OutputRegionsToConsoleSummary(List<RegionData> regions) private void OutputRegionsToConsoleSummary(List<RegionData> regions)
{ {
ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
dispTable.Columns.Add(new ConsoleDisplayTableColumn("Name", 16)); dispTable.AddColumn("Name", 16);
dispTable.Columns.Add(new ConsoleDisplayTableColumn("ID", 36)); dispTable.AddColumn("ID", 36);
dispTable.Columns.Add(new ConsoleDisplayTableColumn("Owner ID", 36)); dispTable.AddColumn("Owner ID", 36);
dispTable.Columns.Add(new ConsoleDisplayTableColumn("Flags", 60)); dispTable.AddColumn("Flags", 60);
foreach (RegionData r in regions) foreach (RegionData r in regions)
{ {
OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
dispTable.Rows.Add( dispTable.AddRow(r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString());
new ConsoleDisplayTableRow(new List<string> { r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString() }));
} }
MainConsole.Instance.Output(dispTable.ToString()); MainConsole.Instance.Output(dispTable.ToString());