Eclipse IDE Tips and Tr icks

Eclipse IDE Tips and Tr icks

Eclipse has the ability to integrate with many source control packages using add-ons or plug-ins.This allows Eclipse to manage checking out a file—making it writable—when you first start to edit a file, checking a file in, updating a file, showing a file’s status, and a number of other tasks, depending on the support of the add-on.Generally speaking, not all files are suitable for source control. For Android projects, any file with the bin and gen directories shouldn’t be in source control.To exclude these generically within Eclipse, go to Preferences,Team, Ignored Resources.You can add file suffixes such as *.apk, *.ap_, and *.dex by clicking the Add Pattern button and adding one at a time. Conveniently, this applies to all integrated source control systems.For instance, the Properties tab is usually found on the bottom of a perspective. For code, this works fine because this tab is only a few lines high. But for resource editing in Android, this doesn’t work so well. Luckily, in Eclipse, this is easy to fix: Simply drag the tab by left-clicking and holding on the tab (the title) itself and dragging it to a new loca- tion, such as the vertical section on the right side of the Eclipse window.This provides the much-needed vertical space to see the dozens of properties often found there.

Sometimes, you might find that the editor window is just too small, especially with all the extra little metadata windows and tabs surrounding it.Try this: Double-click the tab of the source file that you want to edit. Boom! It’s now nearly the full Eclipse window size! Just double-click to return it to normal.You can minimize entire sections, too. For instance, if you don’t need the section at the bottom that usually has the console or the one to the left that usually has the file explorer view, you can use the minimize button in each section’s upper-right corner. Use the but- ton that looks like two little windows to restore it.Ever wish you could see two source files at once? Well, you can! Simply grab the tab for a source file and drag it either to the edge of the editor area or to the bottom.You then see a dark outline, showing where the file will be docked—either side-by-side with another file or above or below another file.This creates a parallel editor area where you can drag other file tabs, as well.You can repeat this multiple times to show 3, 4, or more files at once.

Ever wish you could see two places at once in the same source file?You can! Right-clickthe tab for the file in question and choose New Editor.A second editor tab for the samefile comes up.With the previous tip, you can now have two different views of the same file.Eight seems to be a good number to use for the Number of Opened Editors Before Closing option to keep the clutter down but to have enough editors open to still get work done and have reference code open. Note also that if you check Open New Editor under When All Editors Are Dirty or Pinned, more files will be open if you’re actively editing more than the number chosen.Thus, this setting doesn’t affect productivity when you’re editing a large number of files all at once but can keep things clean during most normal tasks.

Creating Custom Log Filters

Every Android log statement includes a tag.You can use these tags with filters defined in LogCat.To add a new filter, click the green plus sign button in the LogCat pane. Name the filter—perhaps using the tag name—and fill in the tag you want to use. Now there is another tab in LogCat that shows messages that contain this tag. In addition, you can cre- ate filters that display items by severity level.Android convention has largely settled on creating tags based on the name of the class. You see this frequently in the code provided with this book. Note that we create a con- stant in each class with the same variable name to simplify each logging call. Here’s an example:Auto-complete is a great feature that speeds up code entry. If this feature hasn’t appeared for you yet or has gone away, you can bring it up by pressing Ctrl+spacebar.Auto-com- plete not only saves time in typing but can be used to jog your memory about methods— or to help you find a new method.You can scroll through all the methods of a class and even see the Javadocs associated with them.You can easily find static methods by using the class name or the instance variable name.You follow the class or variable name with a dot (and maybe Ctrl+spacebar) and then scroll through all the names.Then you can start typ- ing the first part of a name to filter the results.

Cours gratuitTélécharger le document complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *