Eclipse tips: Better Java navigation + more!

Everyone I have ever seen use Eclipse has package explorer open and they are constantly scrolling up and down, left and right, to open classes in different packages and projects. I hate package explorer. I don’t think a tree is the right way to represent classes, there is too much scrolling up and down and the indentation causes left and right scrolling. Also, I don’t want my IDE to try to replace my filesystem. There is a better way!

Years ago I found three views that can replace package explorer: projects, packages, and types. With these three views I can open any class in the same package in one click, and class in the same project in two clicks, and any class in any other project in three clicks. It is godly! :slight_smile: Go ahead, try it out, it rocks!

In the projects view, I use the filter settings (click the little arrow) to filter out resource directories and JARs. This way the view only contains projects and source folders.

The three views don’t need as much horizontal space. The package view can, but to fix that click the little arrow in the view and make sure it is set to “package presentation -> flat”. Also, go to Window -> Preferences -> Java -> Appearance and set the “compression pattern” to “5…” without the quotes. You can change 5 higher or lower. This shortens all package names except the last one to 5 characters.

I usually keep a fourth view, members, in a tab in the same group as types, for the rare occasion I want to browse a class’ methods (usually to get an overview of the public API).

Another tip for navigation is a plugin called Easy Explore. This lets you right click anywhere in Eclipse and open the operating system’s filesystem browser at that resource location. This lets me use the filesystem as I wish and I don’t have to try to do inside the IDE. The plugin is here:
http://osdn.dl.sourceforge.net/sourceforge/easystruts/org.easyexplore_1.0.1.zip
Just put it in the Eclipse/plugins directory and restart Eclipse.

I like to put my 3 views on the right. This way I can hit ctrl+m to see more code and the position of the code doesn’t shift. For a while now I have been using a 24", 1920x1200 monitor rotated 90 degrees. The 1920 pixels high gives me 126 lines of code visible at once! The 1200 pixels across is enough for 130 columns and the 3 views stacked on top of each other. I usually have the debug and problems view under those. Across the bottom I have the console, with tabs for seldom used views.

If you are using a single, not so large monitor, you can drag the console view to the toolbar at the bottom left of the Eclipse window. Right click its icon and check orientation -> horizontal. Now your console will pop over your code when stuff is written to it. Hit escape or click away to make the console go back to the toolbar. This maximizes the code you can see on screen, and also gives you a larger console window when you need to look at the console. Be careful though, if you close the console view by clicking its X button you have to go to Window -> Show View to get it back.

Another tip, word completion. I highly recommend binding ctrl+shift+space to “Word Completion”. When pressed, it looks backwards from your caret and inserts the first word it finds with the same prefix as what you have typed. Hit it again to get the next match, etc. When it hits the beginning of the file, it looks in the bottom of the file. Then it looks in every other file you have open. The reason it is so amazing is because it just does the insert, no popup. The first or second match is almost always the right match. People watching me program are amazed that the words just pop into view without me typing them!

To see all keyboard shortcuts, hit ctrl+shift+L in Eclipse.

I’ve used the 4-panels view since I started with Eclipse. I can’t fathom why people use the tree view it’s a totally inappropriate way to navigate round a project, let alone multiple projects. Blame Eclipse maybe, because the default view it gives Java developers is the tree view. Some developers I know don’t even know that the browsing view exists.

Nothing beats having two monitors though :slight_smile:

Cas :slight_smile:

Sweet! It is good to know someone else out there is using the 4 views. i have shown people the light, then later I catch them still using package explorer. I don’t get it.

I used to be big into multiple monitors. For the past 3 years though, I changed to thinking one big ass monitor is better than two smaller ones, especially if you rotate the big one to maximize vertical space. With two monitors I put my console and tools on one and use the other one for coding. This is nice, but not as good as a single monitor where you get a larger space for code if needed (ctrl+m in Eclipse). The single monitor approach is also better when doing tasks that don’t need two monitors (web browsing).

Of course, the only thing better than THAT, is one big ass monitor and a second monitor. :wink: I do wish Eclipse’s floating views would snap together though.

[quote=“Nate,post:3,topic:34403”]
For the couple of hundred £ it takes, I do wonder why every programmer doesn’t have two, three or even four 1920x1080 displays =]
They can be had for as little as ~£110 ea. atm

This arrangement of views sounds intriguing; will check it out next time I fire up Eclipse.

I changed from package explorer to this after reading this post and it will take some getting used to. I agree though that once I’m used to it it’ll save me some mouse clicks and give me better overview :slight_smile:

Thanks a lot!

Sure, but how much is a graphics card which has 4 outputs? I can’t even find any on newegg (one which claims to have 4 DVI outputs, but the photo clearly shows that it only has 2).

I just quickly tested the Projects / Packages / Types views and I can’t say I’m impressed. It’s six clicks, not three, to open a type in another project (three clicks on view tabs). In addition, I prefer to keep the number of views open as low as possible. Package Explorer and Outline contains everything I need.

Two dual DVI outputs?

I’ve got SIX outputs on my computer at home. ;D

If you copy/paste a type in the Types-view, it will create an inner class in the class that you copied, with the same name. Compile error!

Further, if you work in a lot of packages at the same time, it’s so much easier to have the Package Explorer view with multiple open packages. Otherwise you keep clicking in the Packages-view. In Vista the Package Explorer view scrolls horizontally automatically.

Best of both worlds, is to have both the Package Explorer and Projects+Packages+Types open, but that clutters the UI.

So how does a dual DVI output work? Is there a special splitter cable?

Not sure what you’re asking?

3 graphics cards, each with 2 outputs -> upto 6 monitors possible.

They don’t have to be anything particularly special either; even an old pci gfx card will suffice.

Rob, if you assume that Markus’ post was a reply to mine then Wildern’s question makes sense.

Markus, I am as puzzled as Wildern.

Yep, splitter cable for dual link dvi ports. Looks thisly: http://www.pacificgeek.com/productimages/xl/H9361.jpg

Also, at home, I’ve got some double ATi card with a total of four single link dvi outputs, and a separate NVidia card with two outputs. I normally only use two of the ATI ports, though, unless I disable some hardware acceleration.
I used to have three monitors (two in the ATi, one in the NVidia), but my main one broke so I’m down to two now.

You are putting all three views in one group as tabs? Stack the three views vertically so all three are visible at once, then it is three clicks. It shouldn’t take up any more room than package explorer.

Yeah, this happens when you have a type selected. Either paste into the package view or select no type and paste into the type view.

[quote]Further, if you work in a lot of packages at the same time, it’s so much easier to have the Package Explorer view with multiple open packages. Otherwise you keep clicking in the Packages-view.
[/quote]
Doesn’t seem like a huge problem. Once I have the classes open, I am ctrl+tabbing between them, not using the views anymore.

[quote]Best of both worlds, is to have both the Package Explorer and Projects+Packages+Types open, but that clutters the UI.
[/quote]
I keep the package explorer as a quick view in the bottom left toolbar. I need it occasionally, like to find a jardesc file so I can right click it and have Eclipse generate a JAR.

Do these cards have DMS-59 outputs? The splitter doesn’t work on normal dual-link DVI-D outputs right?

I wonder why ATI didn’t put those on the 5870s, I just got mine and found out that I need either a DisplayPort monitor or a 100$ DP-DVI active adapter to go triple-head…

@Quad monitor setup:
Besides the extra GFX card there are also splitters available (f.i. from Matrox) but they are more expensive then just adding in another card.

IIRC isn’t ATI comming out with a quad-head card?

I’ve got an ATi quad head at home…