eclipse
Eclipse Galileo vs. SVN
Still no “built-in” SVN support. Same song as ever? Almost. SVN Team Provider is now available via the Galileo update site, but:
Subversive SVN Connectors distributed from external location. Such scheme of distribution caused by licensing requirements.
Gnah!!! Source
Ok, so this time I picked “latest release” (there is no Galileo release available yet) and chose the SVNKit Connector with the highest version available. Seems to work. Still foobar though…
Eclipse 3.4 (Ganymede) vs. SVN
If you’d like to freak out a little, try getting Ganymede to be SVN-capable. I can only say this much: choose Subversive (what else) and the latest SVNKit implementation and you will be likely to have few problems. Finding out which connector to pick (3 alternatives, 2 versions each) can be a pain, though. Many people have blogged about this, for example my workmate Nick. For more, try Google.
3.5 Steps to heaven (the first doesn’t count because the instructions posted there didn’t really work for me):
- Go to eclipse.org and be confused
- Go to Polarion and add the Ganymede update sites to your Eclipse
- In Eclipse, go to Help -> Software Updates and pick at least “Subversive SVN Team Provider” from “Ganymede” -> “Collaboration Tools”, then from the Polarion update site, category “Subversive SVN Connectors”, pick “Subversive SVN Connectors” (didn’t do much for me, I still installed it though) and “SVNKit 1.2.0 Implementation”
- Install, restart Eclipse, be happy.
Eclipse and SVN is by far the worst Hide and Seek game I’ve ever played in 2 years of working with Eclipse :-)
Eclipse building blocks
In the Eclipse world, there are two issues that might become real suckers when it comes to developing in teams:
- People who use Eclipse for development usually have their very individual preferences about plugins, tools and so on
- Every time you upgrade to a new Eclipse version, you have to reinstall all the plugins.
If you intend to give the same Eclipse configuration to the entire team, you need to get a bare bone Eclipse, install all plugins, and then pack a bundle and pass it to the team members.
As an alternative, you can use yoxos on demand in order to create an Eclipse configuration profile, enabling multiple people to download exactly identical Eclipse packages.
The interface is quite easy to use. Components are selected from a tree view. For every component selected, dependencies are checked automatically, the necessary components can then be added to the package.
If you have an account there, you can save the profile(s) you created, in order to reuse them. Try it! :-)
Eclipse Shortcuts – Source and Refactoring
Eclipse offers a whole entire lot of functions to speed up coding and to simplify refactoring. The two most prominent context menu shortcuts are probably:
Alt + Shift + S - opens the "Source" menu Alt + Shift + T - opens the "Refactor" menu
About the Source menu
The “Source” menu offers a variety of options. From there, you can add and remove comments, re-do indentation or formatting in general, add or organize imports, re-order members and so on. The function I use most often is “Generate Getters and Setters”, which is invoked directly by pressing
Alt + Shift + S, R - Generate Getters and Setters
This is really the killer feature deluxe – imagine a business model class with 10 attributes, each needing a getter and a setter – pressing just a few keys is “a little” easier than typing 10 getters and 10 setters manually. You can even extend the key combo like
Alt + Shift + S, R, Alt + A
and so on – unfortunately, in Eclipse 3.2 there is no key combo for the “Ok” button. Maybe this has changed in newer versions of Eclipse.
About the “Refactor” menu
The “Refactor” menu offers a range of options for refactoring code, including but not limited to attribute/variable renaming, moving methods through the type hierarchy, changing method signatures, and so on. The two functions I use most often from the “Refactoring” menu are “Rename” and “Extract Constant”:
Alt + Shift + T, A - Extract Constant Alt + Shift + R - Rename
“Extract Constant” is very nice if you want to avoid the Magic Number Antipattern, e.g. usage of hard-coded String or Number literals, “optimally” used in multiple places like:
/* ... */ public void magicNumber() { System.out.println("I am a debug message delimiter"); System.out.println("This is the real debug message"); System.out.println("I am a debug message delimiter"); } /* ... */
This should be refactored to something like
/* ... */ public static final String DEBUG_DELIMITER = "I am a debug message delimiter"; public void lessMagicNumber() { System.out.println(DEBUG_DELIMITER); System.out.println("This is the real debug message"); System.out.println(DEBUG_DELIMITER); } /* ... */
The advantage: you can change the delimiter message in ONE single place, and you will not end up trashing the VM’s memory with Strings.
Of course, you can do much more with those menus. Explore them if you have the time :-)
Eclipse Shortcuts – Formatting II
I forgot two nice formatting shortcuts in the last post:
Ctrl + I - Correct Indentation Ctrl + Shift + F - Format code
These work on marked text as well as on the entire file. If no text is selected, the entire file will be formatted.
Qt Jambi + Eclipse
Several years ago, I wrote a couple of articles about GUI development with C++ using Trolltech Qt as the GUI framework. Some months ago, Trolltech released Qt Jambi, the Java version of Qt. Today, I decided to give it a try using Eclipse and Qt Jambi as my tools.
Some notes on the installation process:
- If you don’t already have one, get a current JDK, at least version 1.5
- Get a current Eclipse, Ganymede for example, pick a Java-optimized bundle
- Get Qt Jambi here
- Get the Qt Jambi Eclipse plugin for Java – note: scroll down to the bottom of the page, or you will end up like me downloading the C/C++ Eclipse plugin which will not be of much use :-)
- Unzip all packages
- Put the jar files from the Qt Jambi Eclipse integration package into eclipse/plugins
- Start Eclipse, go to Window -> Preferences -> QtJambi preferences and define the location where you put Qt Jambi
- Go downtown for brunch and continue the article later
To be continued!
Eclipse Shortcuts – Formatting
I’m learning more or less sensible Eclipse shortcuts at the moment, of which I will publish the useful ones here. The first collection is about text formatting:
Ctrl + Shift + L - Show "Key Assist" Ctrl + Alt + K - Convert camel case to underscores and vice versa Ctrl + Alt + E - Chars to HTML entities Ctrl + Alt + W - HTML entities to chars Ctrl + Shift + Y - To lower case Ctrl + Shift + X - To upper case
The next shortcut collection will be about context menus and their most useful elements.
Eclipse refactoring voodoo
Assuming you have a class that handles page navigation, and you need to introduce some extended behaviour in order to have a second type of navigation on the same page, you have two choices:
- Add code to the existing class, add hooks for the distinction of the navigation type in every place you need them, or
- Add a second class that represents the new kind of navigation.
Assuming additionally that you would like to keep the JSP tags for your view layer as they are, and only add a minimal amount of code there, what would you do?
There are, once again, at least to ways to do this:
- Put all code for the first kind of navigation inside an if statement, put all code for the second type of navigation into the else block, duplicate lots of code, just because the types are not the same
- Use interfaces.
Option (2) enables you to write code like this:
I_Navigation nav; if(navType == NavType.ONE) { nav = FirstTypeOfNavigation.getInstance(); } else if(navType == NavType.TWO) { nav = SecondTypeOfNavigation.getInstance(); }
And then, later on, to continue using almost exactly the existing code without changing it much.
So, how would you go ahead at creating the interface I_Navigation?
In Eclipse, it’s easy to generate the interface from the existing navigation class using refactoring. Simply select the class, right-click, select Refactor -> Extract Interface, choose your options, and be happy. Nice, isn’t it? This refactoring saves you something like an hour of typing. I love Eclipse. :)
Eclipse 3.3 (Europa) vs. Tomcat
By default, if you add a Tomcat instance to the servers in Eclipse 3.3, the config and deployment paths will be redirected to workspace specific locations by default. This means that if you start Tomcat from within Eclipse and go to http://localhost:8080/, you will get an error 404 instead of the Tomcat welcome page. To change this, double click the Tomcat entry in the Servers tab, then switch from “Use workspace metadata” to “Use Tomcat installation” and set the server and deployment path correctly, if necessary.
Leaving the Tomcat installation untouched (the default setting in Eclipse 3.3) is certainly not a bad idea, yet I prefer to make direct use of the Tomcat directories.
Have fun using Tomcat :-)
Aptana – RadRails – Eclipse
Reading this article:
JRuby on Rails in Eclipse IDE with WebTools Platform and RadRails
I stumbled over the fact that I couldn’t install RadRails into my freshly downloaded Eclipse 3.3 (Europa) without satisfying an Aptana-related dependency. This made me angry at first, then on second thought I figured out how to get the entire thing running. Here’s what you have to do:
- Go to Help -> Software Updates -> Find and Install … new features … add 2 update sites there: Aptana (http://update.aptana.com/update/studio/3.2/site.xml), RadRails (http://update.aptana.com/install/rails/3.2/)
- Install Aptana RadRails and the Aptana Eclipse Integration
Simple, right? But the existence of Aptana Eclipse Integration is not documented anywhere, hence I had to search a little.
Have fun using RadRails in Eclipse :-)
