Wiki

Case Status Kiln
Register Log In

Wiki

 
FogBugz Plugin Interfaces (All…»Implementing IPluginFilterView
  • RSS Feed

Last modified on 1/2/2015 1:53 PM by User.

Tags:

Implementing IPluginFilterView

Introduction

This article will demonstrate a simple FogBugz plugin that implements the IPluginFilterView interface contained in the FogCreek.FogBugz.Plugins.Interfaces class library.

Functionality

We return an array of ViewMenuItems that this plugin will provide views for (in this case, only one). We specify that it's a case list, and link to a static file in our plugin for its image.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
public CViewMenuItem[] ViewMenuItems()
{
	string sImgUrl = api.Url.PluginStaticFileUrl("IPluginFilterView_Example@fogcreek.com", "kiwi.png");
	return new CViewMenuItem[] {new CViewMenuItem(
		"Titles",
		"Display the case titles of all cases in the filter.",
		ViewMenuCategory.CaseList,
		"Case Titles Only",
		sImgUrl,
		sImgUrl)};
}

When the user selects a view provided by this plugin, it calls PresentFilter and passes the filter. In this case we are only providing one view. If we were providing several, we would check the CFilter.sView property to see which of our views is requested.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
public string PresentFilter(CFilter filter)
{
	StringBuilder sb = new StringBuilder();
	CSelectQuery q = filter.GetBugsQuery(false, true, false);
	q.IgnorePermissions = true;
	System.Data.DataSet data = q.GetDataSet();
	foreach (System.Data.DataRow row in data.Tables["Bug"].Rows)
	{
		sb.Append(System.Web.HttpUtility.HtmlEncode(row["sTitle"].ToString()) + "<br />"); 
	}
	return sb.ToString();
}

Compile and Install It On Your Own

Download the source file:  IPluginFilterView_Example.cs

Then follow these instructions to create a functioning plugin assembly: Compiling and Installing a FogBugz Plugin