Category Archives: eclipse

State of Scala IDE on Eclipse

Even thought Scala is now among the trendy programming languages, it still misses a lot before it is considered as one of the major players.

Most Scala programmers are they who are not satisfied with Java, so it’s natural that most of them were before programming with Java. One of the things Java programmers miss from Scala is a robust and functional IDE. Since I’m a big fans of Eclipse, this means Scala IDE for Eclipse. While surely the improvements have introduced to the plugin, there are many things left out.

So what are still missing? This is my list based on several months experience with Scala IDE. If some missing features are missing (duh…), just comment and I’ll try to update the post.

  • No refactoring. I miss refactoring a lot. I still remember the day I find refactoring features on RefactorIT for JBuilder. It’s like the day you saw sun for the first time. And not long after that, I found Eclipse with its build-in refactoring features. Call me lazy programmer, but programmer should be lazy, isn’t it?
  • The content assist takes (almost) forever. Yesterday I found myself restarting Eclipse about five times just because I’m programming with Scala. And I’ve increase the timeout of content assist ten folds.
  • Content Assist doesn’t show (not nearly) all posibilities. When it works, it doesn’t even show nearly all possibilities I want to have. On some cases, it even can’t show a pretty simple completion for a field. As small example: if I write ‘va’, I hope I can get ‘var’ and ‘val’ as the first entries of the completion suggestion.
  • Limited formatting options. Eclipse’s Java Formatter is the best configurable formatter I’ve ever saw. This Scala formatter doesn’t even come near it.
  • No suggestion, not even correction suggestion. I often use Ctrl+1 in Java editor to assign the statement to a variable. Not possible. If you got errors, you got no correction suggestion.
  • No integration to scala documentation. Weird, but the Scala editor can show Javadoc but no Scala documentation is accessible.
  • No auto import. I ended up importing the whole package everytime I need a class.

But yes, I still put a lot of hope woth Scala IDE. It shouldn’t take a lot of time, because the code is in Scala and Scala means productivity, right?

Fresh look for your Eclipse editor

The default theme of Eclipse is good, but I must admit that with some configuration, Vim can show code better. And this is pretty easy, just go to Google and search for ‘vim color’.

I know from a long time ago that Eclipse allows us to change the color preference of our editor. Hence I never change the default since it is just too much hassle to do that. Not counting that when I reinstall Eclipse, I might have to reconfigure all that stuffs.

So when I found this plugin Eclipse Color Theme, I know I will like the plugin. But God, how I’m still surprised to see the result.

Do you like it? There are even more themes you can download here.

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's Quick Diff: See What Changes You've Made Since Last Checkout

A new morning. You’ve checked out the last code from SVN. Stand up and prepare a coffee and when you were back to the computer, Eclipse had loaded the newest code. You ready to code. And you code. Until afternoon and you need to check-in the changes you’ve made. Now you wonder, what have you changed? You know the file you’ve changed, it’s decorated by Eclipse after all. But which lines?

This question is always arisen to most of us. Unfortunately, as default, Eclipse didn’t easily show which lines have you added since last check out. Before I know this feature, I usually compare my code with the latest code in repository. How annoying is that?

It turns out that Eclipse actually already have functionality for that. See this picture.

This feature is called Quick Diff. It is turned on as default but the reference source is the last saved version. If your project use SVN (or CVS, Mercurial, Git as long as you use the Eclipse plugin for that SCM), you can change the Quick Diff behavior to compare the code on your machine with the latest code in the SCM. How nice is that? If you delete lines, you’ll get something like this.

How to do that? As you can guess, go to Preferences and select General → Editors → Text Editors → Quick Diff. Then change the last combo box to SCM you used. That’s it. Now close the main screen and close all opened files. You’ll get the information about which lines have you changed once you open any files.

There is another option in the preference to ‘Show differences in overview ruler’. If you activate this, you’ll get something like in on the right side of the editor.

Now there is still problem with this quick diff functionality. If you have several projects that come from different SCMs, you can’t set the source project based. It’s so not nice and I have filed a enhancement request for that. Vote it up if you also want that functionality!

Eclipse's Team Project Set: Easier Collaboration

Eclipse has this feature Team Project Set which is rarely used. Really rarely I must say.

The point of Team Project Set is when you have many projects on your workspace that build the entire application. People often ask new developers to just check out each project from CVS/SVN. While this works, it is certainly not efficient. With Team Project Set, you will get the same result just by several mouse clicks.

To use Team Project Set, first you have to have a workspace fully configured for your application. Now, click anywhere the Package View and select Export. Select Team Project Set from the list. You should get this dialog window.

Now select the projects you want to include in the Team Project Set and click Next. Select the target file and click finish. Your job is done. Now you can share the project set file to the new developers.

In the new workspace, you can do the reversed step that you do before. Do Import and select Team Project Set.

The next step is self-explanatory, select the project set file you’ve created before and click finish. Depends on the size of your projects, the process will take time anywhere from couple of seconds until several hours. And there you go, the complete projects of your application configured with the SCM.

Limit Your Access to Java API for More Productivity

Simplify your work environment to get more jobs done. One example here is to limit your access to the Java API so you won’t be distracted by proposals that you don’t need.

RCP/SWT developers are facing this all the time. Point is a class in org.eclipse.swt.graphics, but it is also a class in java.awt. When you start to autocomplete, you will get at least two proposals of Point and alas, the Point from java.awt is usually put in the first place. The same with MouseListener. You will get at least one from java.awt.event and one from org.eclipse.swt.events.

You can solve the problem by limiting your access to Java API. To do this, you need to open the Build Path properties of your project.

Here you can double click the Access rules to get the Type Access Rules dialog.

Click Add… to add a rule. For the example I gave before, you may need to set rule to access type java/awt/** as forbidden. You can set many rules as you like and after that close the dialog.

Now if you try to get proposal for Point, you’ll get only the class from SWT and nothing from AWT. This will surely help you choose the right class that you intended.

Helios: How to Prepare Your Eclipse for RCP/Plugin Development

Some RCP-newbies are having difficulties to correctly setup their environment for RCP/Plugin development. Most of them are familiar with Eclipse but not using the Eclipse for RCP/RAP developers package. The problem is sneaky because everything is working except that you don’t get proposals when adding child to the extension. See the following video.

How to fix that? You have to install Eclipse RCP Plug-in Developer Resources from Helios repository and this video shows you how.

Now you can develop the RCP application as you like.