July 2010

Jul 26, 2010

Eclipse 3.6, aka Helios, was released about a month ago. It has become a tradition: this is the time I highlight some of my favorite hidden features in the new release. I focus my article on features which are less obvious, off the beaten path. Features you might not be familiar with if you didn't take the time to read the "new and noteworthy" for this release.

If you haven't done so already, you are invited to read my posts for Eclipse 3.4 (Ganymede) and Eclipse 3.5 (Galileo) (which won the Galileo Blogathon). You can probably pick up some new tricks there as well. I also took the time to reiterate on some of my favorite shortcuts, which made this article a tad longer.

As always, if you are familiar with more features which are hidden and worthy, please let me know in the comments.

The Eclipse Platform

Resource Filters

Projects in Eclipse are associated with a root folder. All the file hierarchy of this folder is included in the project. This hierarchy is visible in the Navigator view. In Helios, you may selectively filter out files and folders from your project. For example, if your operating system creates extra files (like those pesky .DS_Store files in OS X or thumbs.db in Windows) you don't need in your project, filter them out. Right click on a project or folder, select Properties and look under Resource → Resource Filters.

Opening a File from the Command Line

Eclipse is a powerful IDE. It is a perfect companion when working on a large projects. However, for most people, it does not replace the conventional text editor for more casual work like composing HTMLs, tweaking CSSs or going over XMLs. I'm guessing that the reasons for that are rooted in the original Eclipse concept: working only on files within your projects. In older versions it was very difficult to open just any file from the file system in Eclipse for editing.

The situation today is very different. You can drop a file directly into Eclipse, but that was possible in Galileo. In Helios, there's a new addition which enables opening a file directly from the command line. This opens the door to associating files with Eclipse. For example, you can double click an HTML file in your operating system and open it in Eclipse for editing. It will require a bit of hacking, but it is worth it. To get started, visit this page.

Learn Keyboard Shortcuts with Quick Access

The Quick Access feature is one of my favorite features in Eclipse. It acts like a universal launcher: hit Ctrl+3 (or Cmd+3) and start typing the name of a command, view, perspective or any other UI element that can be invoked. It's a very quick way for launching commands without ever leaving your keyboard.

This very handy feature just became even more useful: it now shows keyboard shortcuts within the view. This makes it a perfect tool for learning and memorizing keyboard shortcuts. For example, what is the keyboard shortcut for switching to the next editor? You could look it up in the menu or preferences, but that takes too much time. Besides, if you reach for the mouse you'll probably end up just selecting the next editor. Instead, hit Ctrl+3, type "next editor" and you will learn that the shortcut is Ctrl+F6.

Workspace Names

Many Eclipse users use more than one workspace. I often find myself switching and even working with multiple instances of Eclipse running different workspaces. Helios introduces a handy little feature which lets you assign a name to your workspace. This name will appear first in the window title, before the perspective name and current file name. The options is available in the Preferences, under General → Workspace.

Java

The JDT (Java Development Tools) is one of the oldest projects of Eclipse. No doubt, it is getting better, not older. I do wish there was a bit more innovation. Well, that opens the door to innovative tools like nWire for Java.

Package name abbreviations

Here's a common scenario: you are using the package or project explorer, and view the packages in a flat view. That's probably the most convenient way to look at your source tree. With one major drawback: the package names are usually too long which leads to either excessive horizontal scrolling or a wider side bar that takes too much screen real-estate.

Helios solves this problem: you can assign abbreviations and shorten the list. In the Preferences, under Java → Appearance. For example, org.eclipse.ui can be shown as [ui]. This applies to the project sources and included JARs as well.

More preferences import/export

Copying preferences between workspaces is a challenge in Eclipse. One of the critically overlooked feature is Eclipse is the ability to export and import preferences. You start with File → Export and select General → Preferences. Now, you get a list of preferences sets that can be selected to export. Import works quite similar.

Unfortunately, many preferences are missing. In order to support this feature, each plugin need to specifically "ask" for it and not many do. In Helios, JDT adds support for exporting/importing the Java appearance, code style and compiler preferences. This is a neat feature which makes backing up and sharing preferences much easier.

Variable Instance Count in Java 1.6

Now for a little debugger upgrade. The debugging perspective has the very useful Variables View. It is often neglected, but this view has more information to offer. The default columns are Name and Value. The view has a small drop-down menu on the top-right corner. By selecting Layout → Columns → Select Columns... you can choose which columns are shown.

Helios adds a very useful column which shows Instance Count: the number of instances corresponding to the concrete type of each variable. It requires JVM 1.6 or newer. Handy for chasing those pesky memory leaks. This joins the Galileo feature of showing a list of instances of a given type: select the type in the editor or outline view, right click, and from the context menu select All Instances.... The instance count is available from the same menu as well.

Formatter on/off tags

I'm a big fan of Save Actions since the early days of Europa (for more information, read this article). For those not familiar with the option: it enables certain formatting rules and code clean-ups which will be executed after each save. It works really well for me and I'm simply lost without it.

As much as I like it, there are specific cases where I wish it was off. For example, if I put a little ASCII diagram in the comments and don't want the formatter to destroy it by wrapping the lines. Helios adds two formatter tags, added as line comments, that turn the formatter on and off. You need to specifically enable this feature under the formatter settings (Java → Code Style → Formatter), in Off/On Tags.

It is also interesting to note that in Helios you can no longer modify the formatter built-in profiles, you must create your own.

PDE (Plugin Development Environment)

Feature based launch configurations

This could be a big time saver for people who are serious about plugin development. When launching a plugin for testing and debugging using PDE, the default behavior is to load all the plugins of the target platform. This has several drawbacks, mainly, performance. Loading less plugins means quicker launch and smaller memory footprint (read my article about this subject).

There are other scenarios where you might want to start with a partial feature set. For example, for testing, you might want to load JDT but not Mylyn. In previous versions, this required going over a list of literally hundreds or plugins and handpicking them one by one. In Galileo, you can create launch configurations based on features, which is a big time saver in this case. To get started, edit you Launch Configuration, under Plug-ins, in the Launch With field, select Features Selected Below.

OSGi Console

This one is for your inner hacker. The Equinox OSGi implementation, as every plugin developer should now, is the underlying framework of the Eclipse platform. In Helios, you can open a console and tap into your running platform through the OSGi interface. To open an OSGi console, open a Console View, and from the Open Console drop-down menu (top-right button) select OSGi Console.

What can you do with an OSGi Console? Start and stop plugins, Check for plugin dependencies issues, install and uninstall plugins, list OSGi services and much more. Type ? for a list of all possible commands. Let the hacking begin.

API Use Reports

The API use reports have been around for a while, but now they are well integrated and easy to use. These reports describe which APIs and internals are being used by other bundles. There are many options for these reports. For example, look at the report of PDE against the Helios API.

The API Use Reports are tucked away in the External Tools section. To get started, select Run → External Tools → External Tool Configurations... select the API Use Report node and click on New Launch Configuration.

Other Plugins

Quick Outline in XML/HTML/CSS

The Eclipse WebTools project includes useful editors for many web-related file formats like XML, HTML and CSS. This was already a good editor, but it just got even better. The most notable addition is the new Quick Outline option (Cmd+O or Ctrl+O) which works much like in the Java editor, showing a hovering outline of the file with a quick search option. There are more improvements in other areas, including the content assist.

The Quick Outline may not be such a hidden feature, however, many Eclipse users are not familiar with the WebTools editors. I recommend checking them out, they are very good.

Faster PHP Resolution (plus, a tip on how to make it even faster)

Helios includes a new version of PDT (PHP Development Tools): 2.2. Apart from some new features on the surface, there are many enhancements behind the scenes. The module responsible for resolving artifacts was redone to improve performance. This affects features like code completion, Open Type, Type Hierarchy, etc. If you tried PDT before and wasn't very satisfied with the performance, you should give it another go.

nWire for PHP, which is based on PDT, also benefits from this performance boost. The new PDT uses the H2 database engine (running locally) to keep all the resolution details, a concept borrowed from nWire. If there's something we learned, is that it is imperative to turn off virus scanning on the DB files to keep the performance smooth.

Our suggestion is to disable scanning of the entire workspace folder. If you are worried about viruses, the database files are in <workspace root>/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/. Alternatively, if you can disable scanning by file suffix, disable the files ending with .db.

Conclusion

Eclipse Helios is a worthy release, filled with hidden gems. If you haven't upgraded yet, now is a perfect time to do so. You can head over to the Eclipse downloads page and get Helios today.

Alternatively, nWire is now offering free downloads of the standard Eclipse packages over a highly optimized CDN based on Limelight globally available infrastructure. It is a mirror of the Eclipse main site, so you get the same packages, only faster. Much faster. Go get Helios today.

Jul 07, 2010

It's relatively easy to see that when looking at the modern mobile platforms: iOS and Android. There are so many native apps and developers even develop native apps for both platform. In most cases, this could be solved with one good web app. But people prefer the native apps. Facebook is a good example. They have a good mobile site, but people still install and use the native client.

Why? I don't have anything substantiated, but here's my guess:

It is faster - the performance of HTML rendering and JavaScript execution on mobile devices is still sub-optimal.

Unified experience - it fits better within the OS: it looks the same, uses the same widgets, etc.

It works offline.

Does this applies to the larger devices? I believe so. On the face of it, there's a rise in web apps and decline is desktop apps. But, the desktop is not dead yet. Office apps are a good example: even Microsoft thought it would be wise to create a web-based office apps, but it still kept the Office 2010 on track (with 9M beta downloads...) and we would probably see Office 2012...

I believe most of the reasons above still apply in the desktop world. Speed is less of an issue with the current browsers arms races. That leaves us with offline capabilities and unified experience.

Now, let's look at Eclipse. IMHO, it is the best open source framework for cross platform desktop app development. Mainly because it blends into the operating system. It feels more natural than any other solution. It blends so well, some people will never know it is Java behind the scenes.

Eclipse Helios (aka Eclipse 3.6), which was released a couple of weeks ago takes this even further with cool new ways of assimilating your application into the operating system. I chose two new features that may look minor, but make a lot of difference to end users.

Open File Feature

This features enables Eclipse to open files directly from the OS. This means files may be associated with Eclipse or Eclipse-based applications. For example, you can associate Java files with Eclipse and have them open for Editing within Eclipse with a simple double click. If you've always wanted to use Eclipse as a text editor, now is your chance.

The new feature enables launching Eclipse and opening a file from the command line as well as opening a file in an existing Eclipse instance, although I found that works better on a Mac and not as well on Windows. The original Eclipse distro does not include an installer, so it does not set any file associations in the operating system. You can do it yourself, more details can be found in the Eclipse wiki. Nevertheless, it opens the door for other distributions and Eclipse-RCP based applications to provide such features with minimal effort.

Well done.

Taskbar/Dock Icon API

The TaskItem API enables some very cool tricks that can be applied to the application icon in the Taskbar on Windows or Dock in OS X. It includes:

Overlaying an image or text over the icon.

Displaying progress.

Adding custom right-click actions to the icon.

While this works really well with Windows 7 Taskbar and the OS X Dock, other operating systems may not support all these features. Still, I think it's a worthy addition to the Eclipse API arsenal and I hope to see more application that support it.

The images were taken from the Eclipse Helios New and Noteworthy pages. Developers who wish to utilize those new features should look at this snippet as an example.

Looking Forward

IMHO, these features, along with many more additions, makes Helios an even more compelling choice for cross platform desktop development. Once you do decide to make the leap and turn your app into a web app, check out Eclipse RAP as a possible solution (but that's a topic for a different article).