Skip to content

Commit

Permalink
Display first column of the first 30 records of the first table
Browse files Browse the repository at this point in the history
  • Loading branch information
psankar committed Dec 27, 2010
1 parent 51f6a7b commit 56ab179
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions Autobahn.cs
Expand Up @@ -55,10 +55,58 @@ public void Add (string s)

}

public class RecordsList : IListProvider
{
public List<string> items = new List<string> ();
public ListView view;

public void Render (int line, int col, int width, int item)
{
Curses.addstr (items[item]);
}

public bool AllowMark {
get {
return false;
}
}

public int Items {
get {
return items.Count;
}
}

public bool IsMarked (int item)
{
return false;
}

public bool ProcessKey (int ch)
{
return false;
}

public void SelectedChanged ()
{
return;
}

public void SetListView (ListView target)
{
view = target;
}

public void Add (string s)
{
items.Add (s);
}
}


public class Shell : Container
{
public Shell (TablesList tables) : base (0, 0, Application.Cols, Application.Lines)
public Shell (TablesList tables, RecordsList records) : base (0, 0, Application.Cols, Application.Lines)
{
Frame masterFrame = new Frame ("Autobahn - The SQLite Browser");
Add (masterFrame);
Expand All @@ -70,6 +118,10 @@ public Shell (TablesList tables) : base (0, 0, Application.Cols, Application.Lin

ListView tables_view = new ListView (1, 1, 1, tables.Items, tables);
masterFrame.Add (tables_view);

ListView records_view = new ListView (20, 1, 1, records.Items, records);
masterFrame.Add (records_view);

}

static void Main (String [] args)
Expand All @@ -96,13 +148,22 @@ static void Main (String [] args)
tables.Add (reader.GetString (0));
}

RecordsList records = new RecordsList ();
sql = "SELECT * FROM " + tables.items [0];
command.CommandText = sql;
reader = command.ExecuteReader ();
int n = 0;
while (reader.Read () && n++ < 30) {
records.Add (reader.GetString (0));
}

// clean up
reader.Close (); reader = null;
command.Dispose (); command = null;
dbConnection.Close (); dbConnection = null;

Application.Init (false);
Shell s = new Shell (tables);
Shell s = new Shell (tables, records);
Application.Run (s);
}
}
Expand Down

0 comments on commit 56ab179

Please sign in to comment.