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

Use these for new "show regions" command rather than old cumbersome stuff.
0.7.4.1
Justin Clark-Casey (justincc) 2012-06-26 00:40:46 +01:00
parent 5292b8b8be
commit 1f22b29ca3
2 changed files with 20 additions and 6 deletions

View File

@ -79,6 +79,16 @@ namespace OpenSim.Framework.Console
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)
{
string formatString = GetFormatString();
@ -135,5 +145,10 @@ namespace OpenSim.Framework.Console
{
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)
{
ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
dispTable.Columns.Add(new ConsoleDisplayTableColumn("Name", 16));
dispTable.Columns.Add(new ConsoleDisplayTableColumn("ID", 36));
dispTable.Columns.Add(new ConsoleDisplayTableColumn("Owner ID", 36));
dispTable.Columns.Add(new ConsoleDisplayTableColumn("Flags", 60));
dispTable.AddColumn("Name", 16);
dispTable.AddColumn("ID", 36);
dispTable.AddColumn("Owner ID", 36);
dispTable.AddColumn("Flags", 60);
foreach (RegionData r in regions)
{
OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
dispTable.Rows.Add(
new ConsoleDisplayTableRow(new List<string> { r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString() }));
dispTable.AddRow(r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString());
}
MainConsole.Instance.Output(dispTable.ToString());