Skip to content

Commit

Permalink
Refresh, delete queries. Also finished Add Queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Anirudh Sanjeev committed Feb 21, 2010
1 parent 8180655 commit e35314d
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 99 deletions.
26 changes: 23 additions & 3 deletions BugzillaInterface/QueryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public class BaseQuery
[XmlIgnore()]
public IBugAPI bugProxy{get;set;}

public string Title{get{
return "Random Query Name";}set{}}
public string Title{get;set;}

public List<BugReport> GetQueryResults()
{
Expand All @@ -70,7 +69,6 @@ public List<BugReport> GetQueryResults()
}
public BaseQuery()
{
Title = "Random query name";
queryParameters = new SearchParams();
}

Expand Down Expand Up @@ -136,6 +134,7 @@ public Query()
{
Bugs = new List<BugReport>();
BugIds = new List<int>();
Generator = new BaseQuery();
}

public Query(Repository source)
Expand All @@ -159,6 +158,27 @@ public void TestStuff()
}
}

/// <summary>
/// Runs the Query and returns the number of results
/// </summary>
/// <returns>
/// A <see cref="System.Int32"/>. -1 if failure, 0 - n if success
/// </returns>
public int Execute()
{
Source = SplatterCore.Instance.Sources[SourceID];
try
{
List<BugReport> results = Generator.GetQueryResults();
Bugs = results;
return Bugs.Count;
}
finally
{
}
return -1;
}

public void TestLoggedInStuff()
{
foreach (BugReport bug in Bugs) {
Expand Down
78 changes: 78 additions & 0 deletions Frontend/AddQueryDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ public AddQueryDialog ()
foreach(Widget filter in filterWidgets)
{
filter.HideAll();
filter.Visible = false;
filterContainer.PackStart(filter, false, false, 0);
}
filterContainer.Visible = false;
filterContainer.HideAll();
}


Expand Down Expand Up @@ -128,6 +131,8 @@ protected virtual void FilterActivated (object o, Gtk.RowActivatedArgs args)
{
int index = args.Path.Indices[0];
Console.WriteLine ("Activating filter number{0}", index);
filterContainer.Show();
filterContainer.Visible = true;
foreach(Widget child in filterContainer.Children)
{
child.HideAll();
Expand Down Expand Up @@ -155,6 +160,79 @@ protected virtual void ComboBoxChanged (object sender, System.EventArgs e)
}
}

// The candidate query that will be added to the master list
Query Candidate;

protected virtual void TestQueryButtonClicked (object sender, System.EventArgs e)
{
// we're assuming that the source is a valid one.
buttonOk.Sensitive = false;
Candidate = null; // Erase any previous successful query candidate
Query target = new Query();

// Set the global source ID of the target's source
target.SourceID = sourceSelector.Active - 1;

// Start setting the parameters that will be set via the filters
SearchParams queryParams = new SearchParams();

// iterate over all the filters and get the filters
foreach(Widget filterWidget in filterWidgets)
{
IFilterWidget filter = (IFilterWidget)filterWidget;
if(filter != null)
{
// modify the query parameters
filter.SetFilterParams(ref queryParams);
}
}

target.Generator.queryParameters = queryParams;
target.Generator.Title = bugTitleEntry.Text;

// now try to run the query
testQueryButton.Sensitive = false;
int output = target.Execute();
if(output == -1)
{
// the connection failed or something
testQueryOutputLabel.Text = "The request to the server failed. Please try later";
testQueryButton.Sensitive = true;
}
else
{
testQueryOutputLabel.Text = String.Format("The query returned {0} results", output);

// Allow user to press OK button
buttonOk.Sensitive = true;

// Set the new candidate
Candidate = target;

testQueryButton.Sensitive = true;

}
}

public MainWindow parentWindow{get;set;}
protected virtual void OKButtonClicked (object sender, System.EventArgs e)
{
if(Candidate!=null)
{
// add the candidate query to the list of queries
SplatterCore.Instance.Queries.Add(Candidate);

// Force a save to disk
SplatterCore.Instance.SaveState();

// Tell GUI To sync
parentWindow.SyncTreeviewWithBugs();

this.Visible = false;
this.Dispose();
}
}


}
}
Expand Down
40 changes: 36 additions & 4 deletions Frontend/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,35 @@ public MainWindow () : base(Gtk.WindowType.Toplevel)
{
Build ();
TreeViewColumn idColumn = new TreeViewColumn();
idColumn.Title = "ID";
CellRendererText idColumnCell = new CellRendererText();
idColumn.PackStart(idColumnCell, true);
idColumn.AddAttribute(idColumnCell, "text", 0);


TreeViewColumn productColumn = new TreeViewColumn();
productColumn.Title = "Product";
CellRendererText productColumnCell = new CellRendererText();
productColumn.PackStart(productColumnCell, true);
productColumn.AddAttribute(productColumnCell, "text", 1);


TreeViewColumn severityColumn = new TreeViewColumn();
severityColumn.Title = "Severity";
CellRendererText severityColumnCell = new CellRendererText();
severityColumn.PackStart(severityColumnCell, true);
severityColumn.AddAttribute(severityColumnCell, "text", 2);


TreeViewColumn statusColumn = new TreeViewColumn();
statusColumn.Title = "Status";
CellRendererText statusColumnCell = new CellRendererText();
statusColumn.PackStart(statusColumnCell, true);
statusColumn.AddAttribute(statusColumnCell, "text", 3);


TreeViewColumn summaryColumn = new TreeViewColumn();
summaryColumn.Title = "Summary";
CellRendererText summaryColumnCell = new CellRendererText();
summaryColumn.PackStart(summaryColumnCell, true);
summaryColumn.AddAttribute(summaryColumnCell, "text", 4);
Expand Down Expand Up @@ -91,21 +96,40 @@ protected void OnDeleteEvent (object sender, DeleteEventArgs a)
protected virtual void AddNewQueryClicked (object sender, System.EventArgs e)
{
AddQueryDialog addQuery = new AddQueryDialog ();
addQuery.ShowAll();
addQuery.parentWindow = this;
}

protected virtual void RefreshQueriesBuggonClicked (object sender, System.EventArgs e)
{
int TotalQueries = SplatterCore.Instance.Queries.Count;
if(TotalQueries > 0)
{
int index = 0;
foreach (Query query in SplatterCore.Instance.Queries) {
statusLabel.Text = "Refreshing query " + query.Generator.Title;
progressbar1.Fraction = (double)(index + 1) / (double)(TotalQueries + 1);
query.Execute();
}
progressbar1.Fraction = 1;
statusLabel.Text = "Refresh complete!";

// Save and sync
SplatterCore.Instance.SaveState();
SyncTreeviewWithBugs();
}
}

/// <summary>
/// Updates the entire treeview with the latest bugs
/// </summary>
protected void SyncTreeviewWithBugs ()
public void SyncTreeviewWithBugs ()
{
Console.WriteLine ("Syncing treeview with bugs " + SplatterCore.Instance.Queries.Count);
// Clear all the items in the store
bugStore.Clear();
foreach(Query q in SplatterCore.Instance.Queries)
{
Console.WriteLine ("Adding new Query ");
TreeIter queryIter = bugStore.AppendValues(q.Generator.Title);
foreach(BugReport bug in q.Bugs)
{
Expand All @@ -114,7 +138,15 @@ protected void SyncTreeviewWithBugs ()
}
}



protected virtual void DeleteQuery (object sender, System.EventArgs e)
{
TreePath[] selectedQueries = treeview1.Selection.GetSelectedRows();

foreach(TreePath selected in selectedQueries)
{
int index = selected.Indices[0];
Console.WriteLine ("Deleting query with index {0}", index);
}
}
}
}
Loading

0 comments on commit e35314d

Please sign in to comment.