5 handy eclipse tips you must know
It is imperative to be able to quickly navigate through your code as in commercial projects there will be thousands of artifacts. You will find more debugging tips using eclipse and other tools. The following tips are must know, and if you don't know any of this already, apply these tips and see how productive you become. Especially the control clicking shown here will help you fly through your code.
Tip #1 : Navigating between web resource files and Java classes
<div> <s:link rendered="#{!myAccounts.viewAccounts}" reRender="myAccounts" styleClass="link-excel" view="/view/accounts/myaccounts.excel.xhtml" > Export </s:link> ...... </div>you will often want to navigate from one xhtml or JSP page to another. In the above example to navigate to myaccounts.excel.xhtml page from your current page, highlight the text "myaccounts.excel.xhtml" in the above code and then press "ctrl+shift+r" short-cut to select the file and go to that file directly. In the above code, "myAccounts" within #{!myAccounts.viewAccounts} is an annotation attribute in the Java based backing bean. To get quickly to the backing Java bean, you will need to highlight the text "myAccounts" in the above code and the press "ctr+h" short-cut to bring up the search dialog to search for that text. The Java snippet will look like this
@In(value = "myAccounts") private MyAccounts myAccountsController;Once you have found the Java source file that has the text "myAccounts" annotated attribute, you can go directly to the method with the context helper short cut "ctrl+o" and then typing the first few charaters of the method "viewAccounts" to go to that method. This tip can be applied for other Web frameworks as well if you want to navigate between Web resources and Java source files.
The "highlighting + ctrl+h" is also handy for navigating to relevant Java or web resource file from a spring config file or any other configuration file like web.xml.
Tip #2: If you are navigating between Java source files then the code snippet below
public void init(Long accountId) { logger.debug("Initialising accounts .... "); this.selectedAccount = this.serviceFacade.getAccount(accountId, user); this.authoriser.checkPermission(new AccountsPermission(this.user, this.selectedAccount)); ... }
may require you to navigate to "AccountsPermission" class. Highlight the "AccountsPermission" and press "F3" function key to go to that class. If you want to see the type hirarchy (i.e. its interfaces, super class, sub class, etc) press "F4". You can also highlight a varible like "selectedAccount" or a method like "checkPermission" and then press "F3" to go to that variable or method declaration.
What is even more efficient is "ctrl + clicking". All you have to do is press the ctrl key and then click on a variable or class to name to navigate to it. If a particular method has both interface and implementation, you will get a contextual option list to choose either the interface or the implementation with this control clicking.
So, both "ctrl + clicking" and "highlight + (ctrl+shift+r or ctrl+h) are very handy commands for navigating around.
Tip 3#: If eclipse is slow in opening your files or starting up, etc it is likely that some plugins might be making it slow.
Recently I had this issue, and after removing a number of plugins, for example Atlasian Maven/Bamboo build plugins and some JBoss plugins for JSF and Seam UI development, my eclipse is much faster and responsive.
Tip #4: If you are working on a large project with lots of modules or projects
it is worth creating "working sets" to group relevant projects together. This will also enable you to open and close projects or modules based on "working sets". You can also search for resources based on a "working set". Google for "How to create a working set in eclipse".
Tip #5:Code assist to type less
No body wants to type a lot of code. While working on your code, you can use "ctrl + space" to auto complete some variable names, methods, class names, etc.
The above short-cut keys will help you navigate quickly through your code. Feel free to comment with other useful tips. There are more tips on
- Debugging tips on eclipse tutorial style
- Other debugging tools and tips to be more productive
- Eclipse beginner tutorials
Labels: Eclipse Tutorial
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home