Eclipse Myeclipse Tips and Tricks en
Eclipse Myeclipse Tips and Tricks en
In this Tutorial we present tips and trick for the development enviroment eclipse and the extension
MyEclipse.
Generals
Author:
Sascha Wolski
Sebastian Hennebrueder
http://www.laliluna.de/tutorial.html – Tutorials for Struts, JSF, EJB, Hibernate, xdoclet, eclipse and
more.
Datum:
January, 25 2005
Development Tools
Eclipse 3.x
MyEclipse plugin 3.8
(A cheap and quite powerful Extension to Eclipse to develop Web Applications and EJB (J2EE)
Applications. I think that there is a test version availalable at MyEclipse.)
Table of Content
Tips and tricks for eclipse and the IDE MyEclipse............................................................................ 1
Generals............................................................................................................................................. 1
Workbench tips and tricks.................................................................................................................. 2
Select working set......................................................................................................................... 2
Navigation History..........................................................................................................................3
Customize key bindings.................................................................................................................4
Key Binding Assistance................................................................................................................. 4
Tiling the editor work area............................................................................................................. 5
Collapse all items...........................................................................................................................5
Show line numbers on the text editor............................................................................................ 5
Show line numbers on java editor................................................................................................. 6
Maximize a view or editor window................................................................................................. 6
Customize the menu bar............................................................................................................... 6
Switch workspaces........................................................................................................................ 7
List of open editors........................................................................................................................ 7
Development tips and tricks............................................................................................................... 7
Content assist (auto completion)................................................................................................... 7
Using content assist to add getter and setter methods................................................................. 8
Using content assist to add constructors.......................................................................................8
Delegate methods......................................................................................................................... 8
Create getter and setter methods..................................................................................................9
Override and implement methods.............................................................................................. 10
Java code templates....................................................................................................................10
Quick fix function (Ctrl + 1).......................................................................................................... 12
Quick fix on imports................................................................................................................ 12
Quick fix to create a new method........................................................................................... 12
Quick fix to change method signatures.................................................................................. 12
Use quick fix to add unimplemented methods........................................................................ 13
Quick fix to surround lines with if / while / for statement.........................................................13
Quick fix to remove a if / while / for statement........................................................................13
The outline window...................................................................................................................... 14
MyEclipse tips and tricks.................................................................................................................. 15
Add capabilities to a project.........................................................................................................15
Show line numbers in MyEclipse editor....................................................................................... 16
Content assist for JSP and XML Files......................................................................................... 16
Design Mode for HTML files........................................................................................................ 17
MyEclipse Database Explorer......................................................................................................17
The package explorer shows the selected working set with the assigned projects.
On the drop down menu you can see which working set is activated. You can deselect the working
set with the option Deselect Working Set.
Navigation History
The workbench editors holds a navigation story. If you open a second editor while you are editing,
you can press Navigate > Back (Alt + Left Arrow) to go back to the last editor. This makes
working with several open editors a whole lot easier.
Delegate methods
Eclipse provide a wizard to add delegate methods. This is useful when you use frequently
composition of classes.
In the editor right click and then Source > Generate delegate Methods or you define a key
binding to call the delegate wizard (Window > Prefrences > Workbench > Keys) .
An example for a delegate method:
String string = new String();
/**
* delegate method
*/
public char charAt(int arg0) {
return string.charAt(arg0);
}
Create getter and setter methods
Eclipse provides the option to generate getter and setter methods for attributes of classes. Right
mouse button in the editor Source > Generate Getters and Setters or you define a key binding to
call the wizard (Window > Prefrences > Workbench > Keys).
Override and implement methods
Eclipse provides an assistant to implement and override methods. For example, when you
implement a interface you do not type the methods of the interface by hand.
In the editor right mouse button > Source > Override/Implement Methods.
After creating the template you can use it with the content assist by typing the first letters and the
shortcut Ctrl + Space.
If you open a class in the editor you will see the content (imports, attributes and methods) of the
class in the outline window.
The outline window can not only be used to illustrate the content of a class or XML file, it can also
be used to work with the content.
If you choose a item of the outline window, the cursor jumps to the item in the editor, so it is an
easy way to navigate through the class.
By pressing the right mouse button on an item, for example a method, you can choose several
actions. The outline window provides multiselection, for example to delete the items.
MyEclipse tips and tricks
Add capabilities to a project
MyEclipse provides a wizard to add capabilities for struts, JavaServer faces and hibernate. Right
click on the project and choose one of the capabilities. You also can add the JSTL Libraries to
your project.
On Window > Preferences > MyEclipse > Project Capabilities you can customize the
capabilities (Libraries und other files).
You can do different actions with a table like Edit table data, Create Table Script etc. A special
action is to create hibernate mappings.