Some handy things to know in Eclipse

Questions and answers regarding the use of eclipse environment as seen in Servoy Developer

Some handy things to know in Eclipse

Postby pbakker » Tue Jul 29, 2008 4:26 pm

Hi All,

Here are some tips how to improve your development speed by utilizing some of the features in Eclipse.

Key combination to use within Eclipse:
- Control-Shift-L: Locates/searches for any servoy resource you have, and opens the editor
- Control-L: shows a popup where you can type the linenumber you want to jump to
- Control-Shift-F: Formats you (selected) code
- Control-/: toggles commenting
- Control-H: shows a search screen to search all the files in your workspace
- Control - Space: Trigger code completion
- Control - O: Quick Outline in the javascript editor to quickly jump to another method/variable

Help->Key Assist: Shows you all the available key combinations

Problems View:
Inside Eclipse there is a View called Problems and it shown you both Warnings and Errors. Errors are off course more serious than warnings. If something isn't working, check if there are any related Errors or Warnings in your workspace and fix them first. Some of the entries support the Quick Fix option in the rightClick contextual menu if you rightClick the entry.

View the same Resource (Form, sourceCode) multiple times:
You can Rightclick editor tabs to open the same resource again in a new editor: RightClick the editor tab and select New Editor. Then you can drag the new tab around, for example to the bottom of the existing Editor, effectively creating a split view. For example handy when refactoring code.

Add task:
Eclipse allows you to add tasks to your code, without placing them as comments withing your code. Just go to the line of code where you want to add the task and select Edit - Add task from the menuBar. All your tasks are accessible through the Tasks view.

Bookmarks:
Eclipse allows you to create bookmarks for yourself in your code. Just go to the line of code you want to bookmark and select Edit - Add bookmark from the menuBar. All your bookmarks are accessible through the Bookmarks view.

Local history:
Eclipse saves all the changes you make in your code (up to a certain configurable limit (Window - Preferences - General - Workspace - Local History)) and you can have a look at them, by rightClicking your sourcecode and select Compare with - Local History. This will activate the history view in Eclipse. there you will see all the local revisions of your source code file. Select 2 of them by control-clicking and then rightclick the selection to open the two revisions in a Compare Editor. Note: the same mechanism is available when you use SVN or CVS for remote history.

Folding
Window - Preferences - JavaScript - Editor - Folding: Gives you the option to enable folding of Comments, possible making it easier to read code.

Templates
Window - Preferences - JavaScript - Editor - Templates: When you find yourself typing or copy-pasting the same block of code or comment everytime, use this option to create a new template for yourself. The template is then accessible through Code Completion (Control-Space).

If you have any Eclipse tips yourself, please post them here!

Regards,

Paul
pbakker
 
Posts: 2820
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Some handy things to know in Eclipse

Postby amcgilly » Thu Dec 18, 2008 3:17 am

Great tips - thanks.

I am finding that often when I hit return in my script, it is putting the cursor somewhere odd on the next line.

If I type

Code: Select all
if (a == b)


then it puts me under the 'a'. If I type
Code: Select all
var a = arguments[0]


it puts me under the 0

I would like it instead to place the cursor under the first character in the line I just ended. I believe that's what the editor in 3.5 did.

I've tried turning off every editor-related option I can find, including 'smart caret position after new line' and 'smart caret position at line start and end' but it's still doing it.

Any ideas?
Adrian McGilly
Servoy Developer

Image
amcgilly
 
Posts: 374
Joined: Fri Dec 09, 2005 12:03 am
Location: San Francisco, CA

Re: Some handy things to know in Eclipse

Postby jcompagner » Tue Jan 06, 2009 12:25 am

if you do:

if (a == b)

then it is correct that it indents for you when you press enter (if you do have a 1 line if then that is the right place)
If you then type { then that will go back up (under the i of the if)
But this was broken a bit in 4.1 and is already fixed in 4.1.1

about that arguments. I guess this could be improved
the solution for that now is to use ; then the parser knows you really are terminating the line, now it is confused with something else
please make a case for this
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7977
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

TIP: The Progress view

Postby ROCLASI » Sun Nov 22, 2009 1:14 pm

If you are like me and you like to know what Eclipse is actually doing then you might want to use the Progress view.
How to install ? Simple.
Go into the perspective you want this new view to be installed (like the Form Design perspective).
Go into the menubar > Window > Show View > Other...
You get a dialog window where you can do a search for 'progress' (or just the first characters of this).
Select the item and click the OK button.

Now the view is in your perspective but not yet anchored in it (in fact it's floating over your other views).
Drag the tab of this Progress view to the position in your perspective where you want it (like under the properties view for example).
Let go and you are set.

You can do this for all the perspectives where you want to see what Servoy/Eclipse is actually doing.

Enjoy :)
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5209
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Some handy things to know in Eclipse

Postby Hans Nieuwenhuis » Sun Nov 22, 2009 1:39 pm

Thanks Guys,

Great tips !!!

Hans
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: Some handy things to know in Eclipse

Postby mboegem » Sun Nov 22, 2009 2:45 pm

This is a nice thread... a few of my favourites (sorry only windows, the mac ones are almost simular)

alt- arrow up/down > move
ctrl-alt-arrow up/down > copy
ctrl-d > delete

all the above shortcuts work on:
a) the line the cursor is currently on
b) the selected line(s) of code

There's just one downside to these shortcuts: once you are used to them, you end up applying them everywhere else... but it's just eclipse that will work ;-)
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1384
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: Some handy things to know in Eclipse

Postby ROCLASI » Sun Nov 22, 2009 4:51 pm

Some other shortcuts that I use all the time are the following:
(you can substitute CMD with CTRL when you are not on a Mac)

- CMD-SHIFT-A to open a form selected in the tree (or from the method editor of this form!)
- CMD-SHIFT-Z to open the methods of a form selected in the tree (or from the form editor of this form!)

Also handy to retrace your steps is to use the following commands to move to the editor you were in:
-CMD-[ to go back to the last used editor tabs
-CMD-] to go forward

And another great Eclipse feature:
- click on a method name you use in your code to put your cursor in it and hit F3 to jump to that method. (also available under right-click)

And Paul already mentioned this one but since it's such a timesaver I mentioned it again.
Don't browse, but search..use the CMD-SHIFT-L to jump to a form,method, table,etc (any Servoy object).
Use wildcards like *somename when you don't know for sure what it starts with.
You can find any Servoy object this way and open it in an editor. Saves you the trip to the Solution Explorer tree.

And new in Servoy 5:

-ALT-SHIFT-A to launch the debug rich-client
-ALT-SHIFT-B to launch the debug web-client

All are big timesavers for me. Less mousing around.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5209
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Some handy things to know in Eclipse

Postby mboegem » Sun Nov 22, 2009 9:16 pm

Still forgot one...

ctrl-Q, no in Eclipse not the easy way to quit but the easy way to return to the last edit position.

So... editing a global method, having to look up the context of another global method. Then hit ctrl-Q and you will return to the last edit position of the earlier global method.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1384
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: Some handy things to know in Eclipse

Postby david » Mon Nov 23, 2009 6:47 pm

I don't like seeing all the code for all the methods in an editor. Here's how to restrict the code being shown to the selected method in the outline view.

There is an Eclipse command called "Show selected element only" that is not key-bound. Go to Preferences > General > Keys and set a key binding to this command. Have it run "When in windows".

This command will now work when you have a method editor sheet open and the outline view has the focus. Notice in the attached screen shots that I don't show variables in my outline view either to make things easier to navigate.

You can basically keep this on all the time and forget about it. If a method is selected in the outline view, you get filtering. You can go back to unfiltered by not having a method selected (click somewhere empty in the outline view window).

In Eclipse, the challenge is all about filtering out the the stuff you don't need to see at any given moment. This is my favorite.
Attachments
key setup.png
Setup the key binding
key setup.png (137.16 KiB) Viewed 5222 times
selection.png
Just showing the selected method. Note no vertical scroll bar in the method editor
selection.png (313.99 KiB) Viewed 5229 times
no selection.png
No method selected. Showing all code in method editor (note the vertical scroll bar)
no selection.png (319.46 KiB) Viewed 5208 times
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1724
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Some handy things to know in Eclipse

Postby Harjo » Mon Nov 23, 2009 11:50 pm

ow guys! keep on going! I love this topic! :D :D
Harjo Kompagnie
Direct ICT / Servoy Hosting / ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
User avatar
Harjo
 
Posts: 4271
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Some handy things to know in Eclipse

Postby pbakker » Tue Nov 24, 2009 10:52 am

Nice one David, emulating Servoy 3.5 behavior in Servoy 4/41/5 :D
pbakker
 
Posts: 2820
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Some handy things to know in Eclipse

Postby jcompagner » Tue Nov 24, 2009 12:02 pm

David,

no need for a keybinding for this (ofcourse it could be handy)
What you configure is a toolbar action/command

right click on the toolbar (empty part) -> customize perspective -> Tab: toolbar visibility -> Editor Presentation -> Select the "show source of selected element only"

That will present you with a toolbar icon in your current perspective
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7977
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Some handy things to know in Eclipse

Postby david » Tue Nov 24, 2009 2:56 pm

jcompagner wrote:David,

no need for a keybinding for this (ofcourse it could be handy)
What you configure is a toolbar action/command

right click on the toolbar (empty part) -> customize perspective -> Tab: toolbar visibility -> Editor Presentation -> Select the "show source of selected element only"

That will present you with a toolbar icon in your current perspective


Ahha, that's how that's done. Servoy 4 had that icon by default. Cool!
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1724
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Some handy things to know in Eclipse

Postby Sjoerd » Tue Nov 24, 2009 10:05 pm

In Servoy 5.0 you can set under Preferences / Javascript / Error/ Warnings a setting: STRICT MODE.
This will give you autochecks on your code.

-----
Briefly, Rhino reports warnings in strict mode for

assignments to undefined variables
references to undefined properties
inconsistent return statements in a function
duplicate parameter names
variables that hide parameters
assignment in a conditional
trailing comma in object initializer
indirect calls to eval
useless expressions
-----

It will save a lot of time with debuging/testing your methods. You can see in PROBLEMS view the errors and warnings.

The reports gave a lot of warnings which I didn't expect. Most of the errors had to do with variables and return values.

Examples:
function x(a,a) {...} //will raise a warning about the duplicate arguments
function x(a) {var a = 10} //will raise a warning about hiding an argument
if (x = 10) //will raise a warning about doing an assignment ("if ((x = 10))" will not!)
var a = 10; var a = 11 //will raise warning about redeclaration of variable
function x() { if (true) { return 1} else {}} //will raise warning about inconsistent returns


I still have some errors "Code has no side effects" DLTK type. It has to do with some find() .... search() methods. Something to do with operators "<" or " >"
Sjoerd
 
Posts: 12
Joined: Wed Feb 14, 2007 10:03 pm
Location: Leeuwarden - Netherlands

Re: Some handy things to know in Eclipse

Postby david » Sun Nov 29, 2009 4:42 am

Our debug perspective setup. Rearranged to make coding and debugging easier (at least to us).

If you haven't tried this already, you can drag views (click and drag any tab) and whole blocks of views (click and drag the section header) and place them wherever you want in the Eclipse window. Then save under "Window > Save perspective as...".
Attachments
debug.png
debug.png (243.11 KiB) Viewed 4923 times
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1724
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Next

Return to Eclipse Environment

Who is online

Users browsing this forum: No registered users and 2 guests