Tag Archives: jdt

Eclipse Tips: Open Implementation

Eclipse Helios has another subtle enhancement to the JDT. It is called as Open Implementation. So what’s that? Before we play around with the feature, let’s create some classes.

interface IProcessor {
	void process();
}
public class Processor1 implements IProcessor {

	@Override
	public void process() {
		// TODO Auto-generated method stub
	}

}
public class Processor2 implements IProcessor {

	@Override
	public void process() {
	}

}
public class Main {

	public static void main(String[] args) {
		new Processor1().process();
	}

	public static void a(IProcessor p) {
		p.process();
	}
}

Before Open Implementation is implemented, we have only Open Declaration with F3 as default keybinding. Try this on Eclipse before Helios. Put your text cursor on method process on statement p.process(); in class Main. Click F3. You’ll be brought to the process method in IProcessor.

But what we need often is not the declaration, we need the implementation of the method. Before Helios, what I do is to go the declaration, click Ctrl+T and pick the implementation I want.

Helios shortens this. Put your text cursor again on the method and click menu Navigate → Open Implementation. Now if you have more than one implementation of the method, you will get choice to pick which implementation to open.

By defining a keybinding on Preferences → General → Keys you can even use the feature easier, but before you do that, see if this shortcut is fast enough for you.

Click Ctrl and hold it. Now move your mouse over the same method. Tadam… you will get choice.

If you pick Open Implementation you’ll get the same choice as before.

So that’s it. Hopefully this tips helps you a lot.

Eclipse Helios: 5 JDT Improvements

Helios has been released. This simultaneous release includes more projects but many people still regard Eclipse as Java IDE. So in this post, I want to share the most important JDT improvements that I think will be loved by most Java developers.

Java Formatter Improvements

I’ve discussed this improvements on my other post.

Package Abbreviation

This is a very nice touch improvement especially if you’re working with a big projects. The abbreviation can be set on Preference → Java → Appearance. Check the Abbreviate package names box and set the rules.

Better Generic Support

The support for Java generic is improved. In the formatter, in the javadoc, in the javadoc hover… Overall. Is better. This is including the fix for my little generic quiz and bugs mentioned in the bug list.

New Icon for Build Problems

It’s always weird seeing a project with error but no resource is marked as error. With this new icon, I hope I will be less confused next time I encounter a build problems.

Debugger detailed view

This is the one I love most. I discussed this feature before on my other post. The problem is, changing the properties via dialog isn’t really comfortable. With this improvement, you can edit all breakpoint properties without opening any dialog.

Eclipse: Copy Qualified Java Name

Eclipse has a nice feature to copy qualified name from a resource and this is very useful to create documentation or working with XML. For example:

Say that I need the full qualified name from class CaseFormat. What I have to do is:

  1. Click on + beside CaseFormat.java.
  2. Right click on CaseFormat (not CaseFormat.java).
  3. Select Copy Qualified Name.
  4. There you go, you can paste the full qualified name of class CaseFormat anywhere you want.

But that’s kind of a lot of steps, isn’t it?

OK… you can create a keyboard shortcut for Copy Qualified Name but still you have to expand CaseFormat.java before you can do that. If you don’t expand the *.java node what you’ll get is: ‘/guava/src/com/google/common/base/CaseFormat.java’ instead of ‘com.google.common.base.CaseFormat’.

This problem is kind of annoying and if you have to do this a lot of time, it will certainly damage your productivity.

So here is a tiny plugin to solve the problem.

com.satukubik.copyqualifiedname_1.0.0

You can download it, save it to your dropins folder, and restart Eclipse. After that a shortcut Ctrl+Shift+C is available for you to copy qualified java name without having to expand the *.java node.

For those who are curious, I’ve put the source code of the plugin here: http://code.google.com/a/eclipselabs.org/p/copyqualifiedjavaname/. Feel free to clone, suggest improvement, or report a bug.

Lambda4JDT: lambda expression on your Java code

This is just another proof how many people are starting to want some functional syntaxes on Java. Some lambda expressions are possible to be implemented using current Java, but there are just too many noise in the result.

Lambda4JDT provides a new plugin for Eclipse that can collapse the noise in the implementation without changing the syntax of Java. I must say that the approach it takes is pretty unique and original.