Eclipse - SPLessons

Eclipse Code Navigation

Home > Lesson > Chapter 10
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Eclipse Code Navigation

Eclipse Code Navigation

shape Introduction

This chapter Eclipse Code Navigation demonstrate Navigate menu in detail. There are many ways that a user can navigate around the code in Eclipse. The navigation menu is context aware, so the options will change based on what portion of Eclipse that has the current focus. Following are the concepts covered.
  • Navigate Menu
  • Hovering
  • Editor History and Annotations

shape Description

Navigation has some useful capabilities with the Editor History and can also be done using annotation by customization. The JDT has a breadcrumb feature that lets user to navigate to almost anywhere else in the current project, the main use of Navigate Menu is to quickly locate and navigate to a preferred resource. In order to deal with resources, follow the procedure mentioned below. Click on Navigate menu -> select Go To -> select Resource, the Resource might not always be enabled. So, make sure to enable it by checking the files focused in the Package Explorer. The image below display the Navigate menu location in Eclipse. Now, a popup window appears known as Go To Resource provided with a Filter box, simply type something looking for like Assert file, now a list appears beneath the filter box providing with some list of files that are matched with searched key words as shown in the image below. If user want to do some Contains search, type a Wildcard Character before the key word in the Filter box, now user get provided with all the resources more than Java files as shown in the image below. In order to limit the files to Java, simply type *assert*.java in filter box, now in order to open the preferred file after the search, simply by double clicking on the selected file will open up and highlight the file in Package Explorer as indicated in the image below.

shape More Info

The Open Resource feature in Navigate menu is the most useful feature, in order to deal with Open Resource follow the procedure mentioned. Go to Navigate menu -> select Open Resource as shown in the image below. Now, a popup window appears provided with Filter box for searching the preferred file, type some key word in the box and select the matched file from the list provided beneath the filter box as shown in the image below. Now, double click on the file in order to open the file in Editors tab as shown in the image below. The only difference between Go To and the Open Resource is when user go back to the Navigate menu and Go To option, while the file opened in the editors tab can notice that Resource is dimmed and the Open Resource is not. The image below show the difference between Go To and Open Resource when the editors tab opened.

Hovering

shape Description

Eclipse have some useful and important features, Hovering is the one among them. In order to deal with how hovering Works, simply open a file and hover over a method, if there are any java docs for that method user can view them as shown in the image below. In order to lock the explored window place the cursor inside the window and click on the window. Another thing user can do is to use some of the chrome provided down below the explored window they are Show in Javadoc View The same explored window can be opened in views at the bottom of window as shown in the image below. Open Declaration User can open the declaration to the source code using the option Open Declaration, the image below display the Open Declaration on explored window. Open Attached Javadoc in a Browser User can also open the Javadoc in a browser, the image below display the option on the explored window.

shape More Info

In order to check the Hover General setting and its short cut keys, follow the procedure shown below. Go to Quick Access -> type Hover -> select the Hovers- Java/Editor from Preferences as shown in the image below. Now, a popup window appears known as Preferences providing a navigation menu with some option. Select Java -> click Editor -> click Hovers from the options as indicated and On the left side of the navigation menu User can view some options for setting the Hovers as shown in the image below. After performing all the required changes, simply click Apply or OK button to save the changes as indicated in the image.

Editor History and Annotations

shape Description

The editor history buttons work a lot like the back and forward buttons in a browser, in order to deal with History buttons click on a couple of locations in a file, double-click on some locations like TestRunner, failureSelected, and getRunner. Now, when user hit Navigate Back button, it will take to failure Selected, the constructor, and then back to the top of the file. The image display the Navigate back button in eclipse. Similarly the Navigate Forward button will perform the opposite work of the Navigate Back button, the image below display the Forward button. The Last Edit Location button jumps to the file location which was edited for the last time, The image below display the button location which display the last edited location. Another very important navigation feature available in JDT was Breadcrumb, in order to view Breadcrumb follow the procedure below. Select any method, Right click -> select Show in Breadcrumb as shown in the image below. Now, a navigation bar appears beneath the tab providing with Project details and data like Source folder, Packages, Files as indicated in the image below. The Breadcrumb can be hided and displayed using the Toggle button provided in the Toolbar.

Summary

shape Key Points

  • The main use of Navigate Menu is to quickly locate and navigate to a preferred resource.
  • The Breadcrumb feature allows user to navigate almost everywhere in the current project.
  • Eclipse support Hovering features any Java docs method can be hovered and viewed.
  • The Edit History buttons are similar like back and forward buttons of a browser.