The JDT plug-in builds on the Eclipse platform by adding robust Java-related capabilities to Eclipse. The JDT is such a core part of the Eclipse SDK that it is bundled with it. The Eclipse platform combined with the JDT plug-in provides so many features that it would fill up an entire book. Hence, for the sake of conciseness, I will list the numerous features provided by plug-ins next, with a brief description of each. The online help bundled with Eclipse provides more detail on how these features work (the Eclipse help system is covered later in this chapter).
Figure 8.24. TODO comments and Tasks view.As I mentioned earlier, Eclipse provides many types of wizards. The JDT-specific wizards include the capability to create classes, packages, annotations, simple files, and more. Each of these wizards is powerful in their own respect. For example, Figure 8.25 shows the Class Wizard. Notice how we can specify just about everything we need to create a skeleton class belonging to some package, extending another class or implementing various interfaces, containing a main method, inheriting constructors from the super class, and more. Now if Eclipse could only write our business logic, we would all be set. Figure 8.25. New Java Class Wizard.The JDT comes preconfigured with JUnit. The JUnit plug-in provides a wizard and a view to create and test classes. Figure 8.26 shows the JUnit Wizard. We will use the JUnit view later in this chapter. Figure 8.26. New JUnit Test Case Wizard.
As you would guess, Ant is an integral part of Eclipse. Figure 8.27 shows the Ant view for running Ant tasks and the Ant editor for editing Ant build XML files (notice the Ctrl+spacebar-based context help for the XML elements and attributes). Also, the Console view shows the output of the Ant command with clickable filenames that take us directly to the point of the error! Figure 8.27. Ant editor and view.Eclipse's Export feature provides the capability to export many types of files. I like the fact that any exportable files by any plug-ins show up in one place. Also, export is a term used loosely here because we can even create JAR files using this option. Figure 8.28 shows the list of files we can export to (in our setup so far). Figure 8.28. Export options.
The Java Scrapbook feature is a very handy feature to experiment with single lines of Java code, as shown in Figure 8.29. You can create a new Java scrapbook from the File, New, Other wizard (look for Java, Java Run/Debug, Scrapbook Page in the tree) and then execute it by highlighting your line of code and selecting Execute from the context (right-click) menu or the Run menu (or by pressing Ctrl+U on Microsoft Windows, for example). Figure 8.29. Java Scrapbook page.The JDT provides extensive code refactoring options, although I must admit this is my weak area in that I have not used these features extensively. According to the Eclipse online help, "The refactoring tools support a number of transformations described in Martin Fowler's book Refactoring: Improving the Design of Existing Code, Addison Wesley, 1999, such as Extract Method, Inline Local Variable, etc." The point behind refactoring is to improve the code without impacting the functionality it provides. Perhaps it's a personal preference for me to come up with my own refactoring ideas rather than trusting software to do it for me, although many of the refactoring options in Eclipse are simple and harmless to use. Figure 8.30 shows the Refactor menu items. For example, we can extract (create) an interface class using the concrete methods of a concrete class. Other options provide the capability to pull up a method to a parent class, rename a package, class, or method, inline variables, add exceptions, and much more. Figure 8.30. Refactor menu.
We just went through a lot of features provided by the combination of the Eclipse platform and the JDT plug-in, but as they say, you ain't seen nothing yet! There is so much to Eclipse that it would take a few books to cover what's available on the eclipse.org website and elsewhere (and so much more under development, just waiting to surface). Nonetheless, I will cover a lot by the end of this chapter. As I mentioned earlier, what makes Eclipse so powerful are the plug-ins available for this platform. So far, we have discussed only one plug-in, the JDT. I also mentioned earlier that hundreds of plug-ins are available out theresome small and simple, others more complex. Borland is one example; however, there is a very long list of companies developing plug-ins for Eclipse, including the Eclipse Foundation itself, as we will see in the next section. |