About the Author
Riyad Kalla is a contributing editor to the EclipseZone site along with the legendary R.J. Lorimer. When he's not posting great content at EZ and JL he can usually be found in front of his new XBox.
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

Java, the OLPC, and community responsibility

The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!

Introduction to Mylar


Mylar is a project that I would best describe as an intelligent scoping work filter. To clarify that buzzword-laden description I will describe it in laymen's terms: Mylar intelligently filters down what you see in Eclipse, in real time, to present only information and metrics that are pertinent to your current situation. As an example, say you are part of the Eclipse platform team and you have been given the job of fixing Bug #67384 (The SWT_AWT bridge not working on Mac OS). Think of all the plugins, files, descriptors, methods, classes, subclasses, internal classes and more that fixing that bug involves? What would your Java Perspective look like while you were working on this? Imagine having "Link with Editor" turned on in your Package Explorer view.

Link with Editor button
Figure 1. Link with Editor button

Imagine switching between all your editors that are open and seeing your Package Explorer jump up and down through all the many projects you are touching as you work on this issue, constantly getting lost in the deep package hierarchies and file listings. What about all the views that are changing, updating and confusing you while you do all this? Now enter Mylar.

Mylar is based around the idea of tasks and contexts. The way I understand this organization so far is that each task has a context that relates to the work required for that task. A context is a recording (by Mylar) of all the files you touched, how long it took you, what views you used and so on in order to complete the task. You can add tasks and remove tasks from your Mylar task list since each one will have a context associated with it. You can quickly activate or deactivate the context for each task, immediately transforming Eclipse's editors and views to the state required to work on that task.

At EclipseCon this year I spoke with some developers who have used Mylar and they informed me that you can attach your context to bug reports and send them to other developers who can open your context and be presented only with the pertinent information required to fix or work on that bug. How amazingly cool is that?

Example of Mylar

I was looking for some good screenshots of an example of what Mylar does to simplify your workbench so you see only relevant things. While the EclipseCon presentation that Mik gave is really a fantastic way to get to know Mylar, I did run across a screenshot from Sun's Kirill Grouchnikov's blog about using Mylar when working on his Substance LNF project:

Mylar on Substance LNF
Figure 2. Mylar display of working on Substance LNF

It might be hard to see from the screenshot, but based on the task that is currently selected (Improve the theme resizable icon) you'll notice how the Package Explorer is being filtered down to only show you the packages, classes and methods that have been recorded in that context for that task.

Installing and Using Mylar

After installing Mylar for the first time and starting Eclipse, you will be prompted with the following popup:

Initial Mylar setup
Figure 3. Initial Mylar setup screen

Here you are essentially telling Mylar what you want it to care about while you are working. For example, you can have it ignore your editor state while you are working on a task by unselecting the 3rd option. Additionally you might notice (from the 2nd option) that Mylar's ability to monitor your working state (or context) is actually quite detailed: it will even save/restore your editor folds if you'd like it to. After you have figured out what options you want on and off hit Finish. Mylar will now ask you about setting up your initial context:

Create initial context
Figure 4. Initial context creation

I left everything the default and just hit Finish. From there I was taken to my normal Eclipse workbench screen with the addition of the new Mylar Task List:

Mylar view
Figure 5. The Mylar task list

The Mylar task list is where you will do most of your work with Mylar. It is where you define, enable/disable, modify and delete your tasks. You might notice there are two kinds of task buttons. One for "Repository Task" and one for "Local Task". The difference is that local tasks are simply stored in your local workspace while repository tasks are actually checked into and managed via a repository. Right now Mylar supports Bugzilla and JIRA for task repositories. You can have a look at the supported repository connectors here.

Now for the purpose of this article let's simply create a local task. Notice "New task" task listed in your Task List view. If you right click on the task you'll see a listing of some of the functions you can perform:

Task context menu
Figure 6. Task context menu

Here you are free to activate, deactivate, remove, delete, rename, categorize and style this task. Also note that if you "activate" a task, then go nuts editing in Eclipse and trail off this task, each time you "activate" this task, Mylar opens up a bunch of editors and views. If you don't want these, you can always run the "Clear Context" action to have the task forget what it thinks it knows about your working state while you are working on this task.

I don't know how tasks behave differently if they are checked into a repository or if the action of "Completing" a task actually "Resolves" a bug in say Bugzilla, but from what I understand of Mylar, it's fairly tightly integrated with the whole issue tracking paradigm.

Now let's say you are using Mylar and have activated a task that you are building the context for but don't want it to be so restrictive with your Package Explorer view just yet (because you need to open more files). You can quickly apply or unapply Mylar at any time to your Project Explorer by clicking the Mylar button at the top right of your explorer view:

Enable/Disable Mylar
Figure 7. Apply or unapply Mylar

In my small sample project this grayed out and hid uninteresting parts of my project that were not part of my Test task's context and toggling this button restored the explorer to it's normal state.

Another thing about Mylar that a lot of developers, especially contractors, find helpful is it's ability to track task metrics, such as how long it took you to complete a task. You can dig more into this functionality by opening up and playing with some of the other views that Mylar provides:

Other Mylar views
Figure 8. Other Mylar views

Conclusion

Before EclipseCon I had heard or read the name "Mylar" once or twice and paid no attention to it. It wasn't easy to explain in one sentence, and I didn't see the blogosphere full of information about it so I ignored it. When I got to EclipseCon, I realized just how many developers were absolutely jazzed about this tool because it made their jobs so much easier. That was when I decided I had to get off my duff and get a clue about what it was. I have tried to convey some of what I learned about Mylar here. My goal for this article was to provide enough information for you to decide whether or not Mylar was something worth pursuing, installing, and playing with. I appreciate your reading and hope to hear your impressions if you get a chance to play with Mylar.

You can discuss this article and Mylar in general here, so drop on in and let's talk.