Favorite Eclipse shortcuts

ที่มา : codeofdoom.com/

Anyone who knows me knows that I hate touching the mouse. I do not like using it one bit. If there is a shortcut on the keyboard, its a pretty big guarantee I am going to do my best to find it. Being a programmer, I spend a massive amount of time using Eclipse. Naturally I have a pretty good understanding of all the shortcuts that make my life easier. Here a list of shortcuts that can help you. Also a brief how to on removing the most annoying shortcut of all, show in breadcrumbs.

Ctrl+space. Autocomplete.
This will recommend a list of classes they will fit what you have typed so far. If there is only one match, it will just print it out for you. After it does print it out for you, it will include the import for you. If something is ever missing the import at the top, I will just go to the Class declaration and just hit Ctrl+space.

Ctrl+Shift+R. Open resource.
I cannot live without this shortcut. It is such a time saver. Whenever you are trying to find a specific class, just start typing it and it will populate which classes match that criteria. Once you found it, select it and there you go! It also works great if you are new to a framework and need to find certain classes or if you partly recall the class name but not 100% sure.

Ctrl+O. Show inherited members.
This is another one that works great when you are working with classes with a massive lump of methods attached to it. You COULD do this within the Package Explorer, but no one likes touching that mouse! You can even type to filter down your methods. If you have methods with the same name and just different parameters, this also works great. Just type in part of the method name and get a few overview and access to each of the methods.

Ctrl+H. Loads search box.
I cant tell you how often this saves me. This isnt just a ‘find’ box, this does a ‘find in files’ within the File Search tab. Within here, you can specify what you are looking for in the files, what you file types you want to search in, etc. There are other types of search you can use, but I have not run into a case where I need them. Have you?

Ctrl+Shift+C. Comments a block of code.
This is perfect for debugging. It is strange because really when you think about it, you are only talking about having something put a /* at the begging of what you selected and a */ at the end of what you selected. However, I use this a lot more often than you would expect.

Ctrl+D. Delete a line.
Self explanatory. Extremely useful. If I didn’t have that, I’d have to waste time with Shift+End, Delete!.

Ctrl+E. Menu for opened files.
This will bring up a list of opened files that you have. Not only that, it will also allow you to type in your class names to narrow down your choices.

F4. Shows class hierarchy.
This is extremely useful when you are new to a with a massive framework and you really want to get a sense of how things are all connect, who extends what, etc. Unfortunately, this never made it into Flex Builder (bummer), but I enjoy life when I get to use it in Java land :) .

F3 and Ctrl+Left Mouse Click. Shows declaration.
I enjoy using this when I am working with larger files or anything with long methods (which always irks me). It can get extremely annoying to see where some variables are declared. All you have to do is high light the variable then hit F3. Sometimes I will hold control and hover over variable names if I am having a problem.

F5, F6, F7, F8. In debug mode.
There three shortcuts are probably used more than anything. I wanted to group them all into one section.
F5 – Step Into. When you are debugging an application and you come across a function call, F5 will step into that function and proceed from there.
F6 – Step. This allow you to debug line by line. However, this will not step into any functions.
F7 – Step out. If you are debugging in a function and you want to step out of it to where the function was called, this is what is used.
F8 – Skip to next breakpoint. If there arent any other break points to high, you will be just running the application until your application hits another breakpoint, taking you back into debug mode.

Alt+leftarrow or Alt+rightarrow. Jump back to a line, Jump forward to a line.
According to eclipse, this is “Next word, Previous word’. I am not sure what that means. All I know if I am stepping into functions, debugging through multiple files and breakpoints, this is a life saver. It allows me to retrace my steps, step by step. If I go back with Alt+leftarrow, I can go right back to where I was with Alt+rightarray.

Ctrl+Shift+L. Displays all shortcuts.
Self explanitory. Dig in and find your favorite!

This last one is not about using a shortcut. It is about what you have to do to turn it of.

Alt+Shift+B. Show in breadcrumb.
This is something that might work great for some people. For me, it annoys the hell out of me. It puts a breadcrumb in your text area and it does not give you an easy way to get rid of it. So here is how you get rid of Show in breadcrumb.

Go to Window then customize perspective. In there, go to the Commands tab. For me, I used the Java Editor Presentation. But on the Toolbars details, you should see Toggle Breadcrumb with an icon of a C and an arrow. Click on that then click okay. On your toolbar (if it wasnt already there), you should now see that icon. Click that to turn it off.

Just like any other trade, the better you know your tools, the better you will be. I am not saying this makes you a good programmer, but it does make you more efficient. If you feel I left out any shortcuts that find essential, feel free to comment!

Adding a library/JAR to an Eclipse Android project

Instead, follow the (widely available) instructions for importing the third-party library, then adding it using Build Path (which makes it known to Eclipse for compilation purposes). Here is the step-by-step:

  1. Download the library to your host development system.
  2. Create a new folder, libs, in your Eclipse/Android project.
  3. Right-click libs and choose Import -> General -> File System, then Next, Browse in the filesystem to find the library’s parent directory (i.e.: where you downloaded it to).
  4. Click OK, then click the directory name (not the checkbox) in the left pane, then check the relevant JAR in the right pane. This puts the library into your project (physically).
  5. Right-click on your project, choose Build Path -> Configure Build Path, then click the Libraries tab, then Add JARs…, navigate to your new JAR in the libsdirectory and add it. (This, incidentally, is the moment at which your new JAR is converted for use on Android.)

Ref: http://stackoverflow.com/questions/3642928/adding-a-library-jar-to-an-eclipse-android-project

เตรียมตัวเขียน Android app บน Ubuntu 12.04

1. ติดตั้งแบบง่ายด้วย ADT Bundle

  1. เปิดหน้าดาวน์โหลด Android SDK
  2. ดาวน์โหลด ADT Bundle จะได้ไฟล์ adt-bundle-linux-x86_64-20130514.zip
  3. แตกไฟล์จะได้ไดเร็กทอรี่ adt-bundle-linux-x86_64-20130514
  4. สร้างไดเร็กทอรี่ชื่อ Development ไว้ใต้ /home/jack/ (สร้างชื่ออื่นก็ได้)
  5. คัดลอก adt-bundle-linux-x86_64-20130514 มาไว้ใต้ /home/jack/Development เป็นอันเสร็จสิ้นการติดตั้ง

2. ติดตั้ง SDK บน Eclipse เอง

$ sudo apt-get install eclipse

หลังจากที่ติดตั้ง eclipse เสร็จให้ติดตั้ง ADT Plugin ดังนี้

Continue reading

ติดตั้ง CDT ให้กับ Eclipse เพื่อพัฒนาภาษา C ด้วย Eclipse

ทำกาติดตั้ง CDT ให้กับ Eclipse โดยไปที่เมนู Help > Software Updates > Find and Install
จากนั้นตรง Name ให้ใส่คำว่า CDT
ส่วนตรง URL ให้ใส่ url ของ CDT ให้ตรงกับ เวอร์ชั่นของ Eclipse ที่เราใช้อยู่ โดยดู url นี้ได้จากhttp://www.eclipse.org/cdt/downloads.php

ที่มา: CDT DownloadsC++ Development using eclipse IDE

ภาษาไทยกับ Eclipse

เมื่อทำการติดตั้ง Eclipse เรียบร้อยแล้ว จะสามารถใช้งานภาษาไทยใน Eclipse ได้ทันที แต่ถ้ามีปัญหาไม่สามารถใช้ได้ ให้ไปกำหนด Default Encoding ของ Eclipse ซะใหม่

โดยไปที่ Window > Preferences > General > Workspace แล้วทำการเปลี่ยน Text file encoding ดังรูป


ที่มา: Setting the default text encoding for Eclipse

ติดตั้ง Android SDK บน Eclipse ด้วย Android Development Tools (ADT) Plugin

ก่อนอื่น ทำการดาวน์โหลดและติดตั้ง Eclipse เวอร์ชั่น 3.4 หรือใหม่กว่า


ดาวน์โหลด SDK (SDK download page)

เซ็ต path ของ Windows ไปที่ tools/ directory

ติดตั้ง ADT Plugin

เปิด Eclipse แล้วเลือกเมนู Help > Install New Software.

ที่ Available Software dialog แลือก Add….


Continue reading