yourfanat wrote: I am using another tool for Oracle developers - dbForge Studio for Oracle. This IDE has lots of usefull features, among them: oracle designer, code competion and formatter, query builder, debugger, profiler, erxport/import, reports and many others. The latest version supports Oracle 12C. More information here.
Cloud Expo on Google News
Cloud Expo & Virtualization 2009 East
Smarter Business Solutions Through Dynamic Infrastructure
Smarter Insights: How the CIO Becomes a Hero Again
Windows Azure
Why VDI?
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun's Incubation Platform: Helping Startups Serve the Enterprise
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
Building a Search Plugin for Windows Live Writer
Microsoft has made it brain-dead simple to build a plugin and hook into their UI

So, a few weeks ago, Lori asked me if I’d be up for writing a plugin for Windows Live Writer to insert DevCentral related links into her blog posts.  For those that don’t know about Windows Live Writer and post to a blog regularly, you are doing yourselves a disservice by not checking it out (that is, if you are a Windows user).

I’ve messed around with some Live Writer plugins in the past and figured this wouldn’t be too big a task.  In fact, Microsoft has made it brain-dead simple to build a plugin and hook into their UI.  Here’s the steps I took to build ours in C# with Visual Studio 2010.

Create a Class Library Project
The first step is to create the project.  In Visual Studio, go into the New Project wizard and select a Class Library project.

You’ll then want to add a reference to the WindowsLive.Writer.Api.dll assembly that can be found in the Windows Live Writer installation directory.

The main class that is created will be the one that Live Writer hooks into.  You can tell Live Writer that this is the one you want to use by adding the following attributes before the class declaration

   1: [WriterPluginAttribute 
   3:     "DevCentral Related Links Plugin",
   4:     ImagePath = "DevCentralWLWPlugin.jpg",
   5:     HasEditableOptions = false,
   6:     PublisherUrl = "",
   7:     Description = "Insert Related Links from into your blog post.")]
   8: [InsertableContentSourceAttribute("DevCentral Links")]
   9: public class DevCentralWLWPlugin : ContentSource

You’ll want to add your own GUID in for the first attribute and replace the above descriptions with the ones specific to your project.  You’ll also want to make sure your class is derived from the ContentSource defined in the WindowsLive.Writer.Api namespace.

Create A Popup Form

DCWLWPluginForm You’ll likely want your plugin to do something and the easiest way to get input from the users is by building a Windows Form.  In my code, I created new Windows Form object and named it DCSearchLookupForm and added the appropriate search and filter fields to allow the user to query for search results and select the ones they want included in their post.  In my Form, I had the resulting links stored in a member variable named “outputHTML”.

The form consists of the following sections

  • Search Terms – Here you can enter different combinations of search terms.  Instead of making everyone figure out the special ways you can enter logical expressions with Google Search, the user just enters the fields and the search phrase will be build for you.  In case you want to see what the resulting phrase is, double click on the “All These Words” label and a dialog will popup with the generated phrase.
  • Search Engine – Right now this is only DevCentral but you can change this in a custom build by changing the Search Id (CSE_ID) value.
  • Refinement – Google Custom Search allows you to build refinements (or subsets) of the index of your search engine.  This drop down will be propulated by the refinements sent back from a simple search query when the dialog is loaded.
  • Number of Links – Google limits requests to 20 items but I’ve added the ability to go up to 100 by iterating through numerous requests.  So, if you can’t find the results you want in the first 10 items that are the default, you can bump this up to 100.
  • Related Links – This is the output of the most recent search.  All of the items are selected by default.  You can deselect the ones you do not wish included in your list.
  • Formatting Template – Instead of hard coding a output format, I opted to allow the user to customize it with a head, item, and footer template.  The head and footer are written at the beginning and end and the item template is printed once per search result item.  The substitution parameters are listed in the dialog box.  There are a few other hidden ones that you can use, but you will have to dig into the source to find them B-).
  • Reload Default Template – If you mucked up the template and want to start over, the “Reload Default Template” link will repopulate the fields with the default values.

Integrating With Live Writer
Once you have the form created and tested out, you’ll integrate it into Live Writer by implementing the CreateContent method.  This is the method that is called by Windows Live Writer when the user clicks on the link created by your plugins InsertableContentSourceAttribute value above.  In this method, I just create an instance of the form, let the user do his thing and if the OK button is pressed, insert the formatted search results into the newContent variable.

   1: public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent)
   2: {
   3:     try
   4:     {
   5:         DCSearchLookupForm f = new DCSearchLookupForm();
   6:         DialogResult dr = f.ShowDialog();
   7:         if (dr == DialogResult.OK)
   8:         {
   9:             newContent = f.outputHTML;
  10:         }
  11:     }
  12:     catch (Exception ex)
  13:     {
  14:         MessageBox.Show(ex.Message.ToString(), "Error", 
  15:             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  16:     }
  17:     return DialogResult.OK;
  18: }

Building A Test Application
I found it helpful when debugging to build a test application that had a button and WebBrowser control to create the form and display the returned values.  This took two minutes and saved me from having to debug Windows Live Writer each time through.  I included this in my project as an executable called WLWPluginTestApp and set that as the Startup Project in my solution so that I could debug right into it when making changes in the plugin.

Creating A Setup Program
Installing a Windows Live Writer plugin is as simple as copying it to the plugins directory under the Windows Live Writer installation directory but that may not be the easiest way to deliver your plugin to your users.  It’s very simple to create a setup project that copies the output from the plugin project into a specified directory.  Just create a simple setup program and add the “Primary Output”, “Content Files”, "and “Localized Resources” from the plugin project and change the “Application Folder” property to the Windows Live Writer plugin directory.  I used “[ProgramFilesFolder]Windows Live\Writer\Plugins” in my setup.

Project Downloads
So, if you are yearning to include some DevCentral related content in your blog posts, then go ahead and download the installation package and give it a go.  I’ve also made the source code available if you want to see how the plugin was made or if you want to build one of your own.  The source should give you everything you need to custom make a related links module for your own Google Custom Search Engine.


Related Articles on DevCentral


Read the original blog entry...

Latest Cloud Developer Stories
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online co...
Wooed by the promise of faster innovation, lower TCO, and greater agility, businesses of every shape and size have embraced the cloud at every layer of the IT stack – from apps to file sharing to infrastructure. The typical organization currently uses more than a dozen sanctioned...
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO and DXWorldEXPO are two of the most important technology events of the year. Since its launch over eight years ago, @CloudEXPO and DXWorldEXPO have presented a rock star faculty as w...
In this presentation, you will learn first hand what works and what doesn't while architecting and deploying OpenStack. Some of the topics will include:- best practices for creating repeatable deployments of OpenStack- multi-site considerations- how to customize OpenStack to inte...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)!

Advertise on this site! Contact advertising(at)! 201 802-3021

SYS-CON Featured Whitepapers