Eclipse Auto Complete Templates for ATG

Eclipse has an often under-utilized feature called Templates. You’ve probably used the built in templates when Eclipse auto-completes for loops or try-catch blocks, etc… However, you can create your own templates for commonly used chunks of code. This can save you a lot of time, and more importantly can facilitate you writing better quality code.

ATG Eclipse Templates

ATG Eclipse Templates

By making commonly used code blocks available with a couple of keystrokes it is much easier to write best practices code, that otherwise you might shortcut around.

You can view, import, and create new templates by going to Eclipse’s Preferences, then opening Java->Editor->Templates. Each Template has a Name, this is what triggers it for auto-complete so making this simple and unique is good, a Description, a Context, a checkbox to Automatically insert, and then the Pattern which is the code that will get inserted for you. Within the Pattern you have access to a substantial number of variables, such as the current class or method name, variables, method arguments, dates, etc… which allow you do some very useful things.

For ATG coding I’ve created nine Templates for common code blocks.

My templates isBlank and isNotBlank create if blocks based on ATG’s StringUtils.isBlank method, which checks for null, empty, or blank Strings. Checking Strings is something that I do all the time (validating user input, query params, etc…) so being able to do it in a few keystrokes is very useful.

ls.isBlank(${cursor})) {

}

I have three templates for ATG Performance Monitor operations. Adding in ATG Performance Monitor hooks when you’re coding can make diagnosing performance problems later much easier. Using templates means you don’t have to remember the syntax or even type in the class and method names:

PerformanceMonitor.startOperation("${enclosing_type}", "${enclosing_method}");

I also have four templates for the primary ATG logging methods with the respective if blocks needed to prevent unnecessary String concatenations.

if(isLoggingDebug()) {
	logDebug("${enclosing_type}.${enclosing_method}:" + "${cursor}");
}

I’ve exported these nine ATG templates so you can easily import and start to use them.
Eclipse ATG Coding Templates.

What templates have you created?

“No repository found containing” Error when update Eclipse

A couple of days ago I started having issues updating my Eclipse plugins. I’d get a “No repository found containing” error for several of the repositories that it was trying to update from. Here is a quick fix:

  1. Go to Help->Software Updates, then select the Available Software tab and click the Manage Sites button
  2. Use the Export button to export the sites to a bookmarks.xml file
  3. Open the bookmarks.xml file in your favorite text editor, and add a trailing “/” to any of the site urls which are missing the “/” on the end. Save the changes.
  4. Back in the Manage Sites window within Eclipse, select all of the sites and click the Remove button
  5. Now, click Import and load in the edited bookmarks.xml file

Now try your import again, and it should work.

Why I Love Having 8 Gigs of RAM

I recently upgraded my primary computer from a 15″ MacBookPro with 4 GB of RAM to a 17″ MacBookPro with 8 GB of RAM. That probably sounds gratuitous. Here’s why it’s not:

picture-3

I’m currently running:

  • Mac OS 10.5.6
  • Adium (IM chat client)
  • Mail.app (e-mail client)
  • iCal (calendar application)
  • iTunes (music)
  • OmniFocus (GTD todo list)
  • TextMate (text editor)
  • Preview (image viewer – for looking at screenshots, scanned requirements docs)
  • PostgreSQL (CouponEngine database)
  • pgAdmin (postgreSQL client and admin app)
  • Terminal
  • Safari 4 (primary browser)
  • Firefox 3 (for testing look and feel)
  • Eclipse (development environment)
  • Windows XP (running in Parallels-for testing and Oracle)
  • Oracle 10G (ATG database)
  • JBoss 4.0 + ATG 2006.3 with full Commerce stack
  • JBoss 4.2 + Seam application
  • ANT JVMs for running builds

This is what I need to run to do my job, and it takes more than 4 GB of RAM.

Now that I have 8 GB, I’m not longer running into swapping and paging delays, and I’m much more productive.

Having close to twice the screen real estate (~70% more I think), a faster CPU, and 8 hours of battery life don’t hurt either. This is the perfect machine for me.

Eclipse, Subversion, and SSH_OPEN_ADMINISTRATIVELY_PROHIBITED

If you use the Subclipse plugin to access subversion repositories from Eclipse using the ssh+svn protocol, you may see errors like this:

SSH_OPEN_ADMINISTRATIVELY_PROHIBITED

when you try to do too many things at once.

When I tried switching to JavaHL instead of SVNKit, I got different errors, so that was out.

Adding this line to my eclipse.ini file fixed it though:

-Dsvnkit.ssh2.persistent=false

It prevents the SVNKit adapter from issuing multiple sessions through a persistent SSH connection, which seems to trigger the error on some SSH servers at least.

Eclipse StartOnFirstThread Error (and fix!)

This appears to be an issue with the JVM under Leopard (Mac OS X 10.5), but I started getting the following error within Eclipse when using the ResourceBundleEditor plugin:

StartOnFirstThread Error Message

It also apparently happens with other plugins/apps and is an issue with the AWT kit in the new JVM. After pouring through all of my Eclipse config files and determining that I definitely was NOT specifying StartOnFirstThread anywhere, I found this fix:

Within the Eclipse application bundle, in the file Contents/MacOS/eclipse.ini, add this line:

-Djava.awt.headless=true

Save the file, and restart Eclipse. Problem solved.