Chorus Send/Receive

August 24, 2009

Using Chorus to grab a project from a USB drive

Filed under: Chorus — hattonjohn @ 12:47 pm

(Chorus is an open-source version control porcelain (over Mercurial plumbing) designed to enable workflows appropriate for typical language development teams who are geographically distributed.  Chorus is designed to be integrated into other applications, and installed with their installers.  This blog is the second in which I describe what an application developer needs to do to incorporate Chorus.)

In Language Software, we are perhaps more keenly aware than many developers just how complicated computers are for folks who haven’t grown up driving them.  Even well-intentioned informational dialog boxes act as stumbling blocks to the people I consult with here in Papua New Guinea, expat and national alike.  And the worst thing we can do, of course, is to take for granted how challenging the “Open File” and “Choose Directory” dialog boxes are to many users.  So, we need an easier way to help users get a Chorus-enabled project off of a USB flash drive and onto the right place on their computer.  They’ll want to do this when they’re setting up a new computer, recovering from a broken hard drive, or just adding  a new person to the team.  (If they have a good internet connection, they could instead pull directly from a distant repository, and how to help them do that will be the subject of my next post.)   Chorus gives you an simple way to help these users rapidly grab the right thing and put it in the right place, without ever dealing with the file system.

Let’s walk through some sample client code (this sample taken from WeSay):

private void OnGetFromUsb(object sender, LinkLabelLinkClickedEventArgs e)
{
    using (var dlg = new Chorus.UI.Clone.GetCloneFromUsbDialog(WeSay.Project.WeSayWordsProject.NewProjectDirectory))
    {

The first line makes us the dialog and tells it where we put WeSay projects, by default.  That way we don’t have to bother asking our users, most of whom don’t care and shouldn’t be asked. The next line sets up a callback so that projects from other applications (or just raw Mercurial directories) won’t be listed:

dlg.Model.ProjectFilter = dir => GetLooksLikeWeSayProject(dir);

And finally, we fire off the dialog and, after a successful completion, we go ahead and open the newly-cloned project in WeSay:

        if (DialogResult.Cancel == dlg.ShowDialog())
            return;
        OpenSpecifiedProject(dlg.PathToNewProject);
    }
}

Here’s what the user sees:

If no USB drives are found, the dialog prompts the user with an icon and message:

2009-08-24_15-25-57-136

Once one or more USB drives are found, the dialog walks the devices (only to a level of 2 deep), and displays those Mercurial projects which pass our filter:

2009-08-24_15-29-48-895

 

Note, if the project already exists at the default location on the user’s computer, what should we do?  The answer is difficult, because there are several possible scenarios.  The user might be confused, and trying to synchronize. In that case, we had better NOT make it easy for him to make and start using a second copy. The user might not have realized that they already had the project. They might just want to have a parallel “branch” of the project. Or they may know they have it, but are trying to use this vector to replace what they have.  With all those choices, I’m giving up for now and just show this notification box.  Maybe we can do better in the future.

2009-08-24_15-41-42-952

 

A final note:  you don’t have to use this UI.  If you want, you can code against the underlying to the  CloneFromUsb class:

2009-08-24_15-54-34-383

 

Ok, next time, I’ll describe our first pass at a dialog for grabbing projects from internet-hosted repositories.

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.