eclipse

Toggle view

Register ActiveMQ Spring namespace with eclipse 3.6

In a earlier post I described how to setup the eclipse XML editor to validate a Spring context file containing the AMQ namespace.

Looks like with eclipse 3.6 that does not work anymore, I was not able to actually use a JAR file as location like I used to set this up with eclipse 3.4.
So I’m directly associating the AMQ namespace with the XML schema available from the AMQ project.

Read more

Getting started with eclipse RCP development

Lars Vogel is maintaining a really helpful set of up-to-date articles about eclipse RCP programming.

My eclipse 3.5 blog entry has been promoted to be published by the German "eclipse magazin"

A while ago I had written this blog entry about the upcoming eclipse 3.5 release. The german “eclipse magazin” asked my if I would share this blog for being published in their next issue. Today I received a printed copy of this issue. They actually allocated almost a page for this ;)

eclipse 3.5

Since eclipse 1.0 has been released back in November 2001 it has evolved into a pretty popular and feature rich IDE. I remember using eclipse 2.0.1 first time, it was pretty much only a Java development IDE with little support for application containers.
Soon eclipse 3.5 (galileo) arrives supporting a wide palette of programming languages, programming models and execution environments, application containers, etc. The past 3 months I had been testing galileo from early milestone releases and been happy with it – also with my favourite eclipse plugins that I use in my daily business.

Here I briefly show some of the many features that I like:

Install New Software

I believe with eclipse 3.4 the user interface for updating/installing plugins has been pretty much messed up. Seems the eclipse engineers have done a good job to fix it up again. It has never been so easy and intuitive (with drag & drop support for update-site URLs) to install and update an eclipse plugin. But even more important, now it is possible to export bookmarks of your favourite plugins (you can select them plugin by plugin) and import them into another eclipse installation (e.g. for switching to a new eclipse release).

Available Software Export

Type Filter (eclipse 3.4)

With a large number of libraries in the classpath it gets pretty overloaded in the type search dialogs. Mostly you find lots of classes that you never want to deal with directly. E.g. classes from the com.sun.* packages. Still you have to skip over them while searching for some other classes.
By defining a type filter you can suppress any package you are not interested in.

type-filter

toString() Method

I usually would use the ToStringBuilder from the Apache commons-lang package to implement any toString() method.
As of eclipse 3.5 the Source->generate toString()… feature can be customized to support the commons-lang ToStringBuilder pattern.

tostring

Format edited lines only (eclipse 3.4)

In a team environment it is important that everybody is using the same formatting rules for auto-formatting the source code. Otherwise code comparison / mergeing can get pretty nasty. However sometimes this is not the case. Still eclipse can help to minimize the impact of autoformatting. You can choose the option to format only the code portion that has been actually changed.

format-edited-lines

Breadcrumbs (eclipse 3.4)

Eclipse has always had a perspective called Java Browsing (some heritage from good old Visual Age). I never really liked it, as it consumes quite a lot of space of the workbench.
With eclipse 3.4 the eclipse team introduced the so called breadcrumbs (Alt-Shift-B) which is showing almost they same information but much is more compact. It allows you to quickly jump between packages, classes, members, etc.

breadcrumbs

Block selection

Alt-Shift-A activates a special editing mode where it is possible to select any rectangular text area and copy / paste it.

block-selection

Flex Builder plugin installation

A few days ago I had installed the Flex Builder Plugins on a staging eclipse ganymede installation where I typically would test plugins. The installer created a link /links/com.adobe.flexbuilder.feature.core.link with the content

d:/Java/Flex Builder 3 Plug-in

To activate this plugins in my productive eclipse installation I just copied this link file and restarted eclipse but the flex plugins didn’t get activated. After a while I found a discussion in some Adobe forum.

So I changed the contents of the link file to:

path=d:/Java/Flex Builder 3 Plug-in

Now it works!
Unfortunately the eclipse documentation on this also didn’t clarify that.

Register XML schema in eclipse XML catalog

Sometimes XML schemas don’t get published to public sites but are provided as part of of a jar etc. Under these circumstances it’s impossible for a XML editor to perform proper validation of a XML document against its XML schema.
eclipse allows registering schemas in its internal XML catalog in various ways. Open the XML Catalog property sheet in the preferences dialog and add the schema location.

An example for registering a schema in a jar:

Location: jar:file:D:/workspace/mvn-repositories/local/org/apache/activemq/activemq-core/5.1.0/activemq-core-5.1.0.jar!/activemq.xsd
Key Type: Schema Location
Key: http://activemq.apache.org/schema/core/activemq-core.xsd

eclipse and corrupt WTP metadata

Yesterday night I had spent an hour or so tracking down a bug that has been bothering me for a while.
The effect of this bug is that projects created with the m2eclipse plugin seem to be missing some important metadata required by the WTP plugins. As a result references to other projects (in workspace) do not show up as JavaEE (J2EE) module dependencies or sometimes even the project properties dialog for JavaEE module dependencies only shows an error.
I had analysed this bug a while ago already but never documented this, some more investigation is still required to figure out what causes this missing metadata and report it to the m2eclipse developers.

Anyway here is how to fix it. Let’s say we have a web project A and a utility project B. You face the situation that project B does not show up as JavaEE module dependency. Open B in the navigator view (so you can see all the metadata files .project, .settings/… etc.).
Look for a file .settings/org.eclipse.wst.common.component! Does it exist? If no just create it, its contents should be like



    
        
        
    

Next check the .project file



	PROJECTNAME
	

	
	
		
			org.eclipse.wst.common.project.facet.core.builder
			
			
		
		
			org.eclipse.jdt.core.javabuilder
			
			
		
		
			org.maven.ide.eclipse.maven2Builder
			
			
		
		
			org.eclipse.wst.validation.validationbuilder
			
			
		
	
	
		org.eclipse.jdt.core.javanature
		org.maven.ide.eclipse.maven2Nature
		org.eclipse.jem.workbench.JavaEMFNature
		org.eclipse.wst.common.project.facet.core.nature
		org.eclipse.wst.common.modulecore.ModuleCoreNature
	

In my case the file was missing some builders (should not be relevant for the bug)

  • org.maven.ide.eclipse.maven2Builder
  • org.eclipse.wst.validation.validationbuilder

and some natures (these really hurt)

  • org.eclipse.wst.common.modulecore.ModuleCoreNature
  • org.eclipse.jem.workbench.JavaEMFNature

eclipse ganymede – New Save Action Option

Save Action Format Modified Line Only

I am absolutely convinced that source code must be formatted according to rules a team agrees on. Therefore I have my Save Actions setup for auto-formatting my code (by the way I just rely on the eclipse built-in rules, I would only adjust the line length to 120) every time it is saved.
For those whow often need to fix/change unformatted code (code that is not auto formatted at all) are going nuts. Once you start comparing with older revisions you can’t actually tell anymore what exactly you have modified, the auto-formatter has done a damn good job!
So now you can set an option that only formats actually modified lines code.

Sun compiler silently accepts annotation syntax error

Today I experienced another strange thig with the eclipse compiler. I coded some annotations that contain some syntax error which I wasn’t aware of since the IDE didn’t highlight it. The @@ManagedOperationParameters( { @ManagedOperationParameter(name = "category", description = "Logger category"), }) annotation is not correct, trying to compile it with the Sun compiler fails (can you spot it?).

	@ManagedOperation(description = "Get the logging level for a category")
	@ManagedOperationParameters( { @ManagedOperationParameter(name = "category", description = "Logger category"), })
	public String getLoggerLevel(String category) {
		return LogManager.getLogger(category).getLevel().toString();
	}

After reporting this a a eclipse JDT bug I was pointed at that this is allowed syntax (see JLS) but the sun compiler does not properly implement syntax checking! So I should rather see to report this against the Sun compiler. Still it is strange that this syntax is allowed at all!!!

eclipse 3.3 and WAR file imports

eclipse 3.3.1.1 has an annoying bug. Try to import a WAR file that contains class files in WEB-INF/classes. Thes class files are not imported into the right folder in the imported project structure.

Importing a WAR file gets you a special folder ImportedClasses which is supposed to contain the package/folder structure for imported classes. Due to a bug in the eclipse WAR importer they are copied to ImportedClasses/WEB-INF/classes. As a result, starting a deployed web application presents plenty of ClassNotFoundExceptions and the like.

ImportedClasses folder

Today I tried this again with eclipse 3.4-M4 and was glad to see this bug fixed, I was already preparing to file a bug. Until 3.4 is released the classes must be moved manually to the right folder!

green red blue grey