By: Michelle Kempner
Page 1 of 3
This is the second article in our series on Eclipse, an IDE useful for any programming language that a plug-in has been written for. In the first article, we covered installing Eclipse and wrote and debugged a Hello World Java program. In this article, we will install some plug-ins for ColdFusion, PHP and Flash. While there are IDEs specifically created for each of these languages, one benefit of using Eclipse is that you can write programs in different languages without learning different software. Eclipse is cross-platform and portable so it is good for a group of developers working on different platforms and, an important factor, Eclipse is free.
The recommended way to install CFEclipse is from the Eclipse IDE. Simply select Help > Software Updates > Find and install:
- Select Search for new features to install and click Next.
- Click New Remote Site.
- Enter CFEclipse in the Name text box and http://cfeclipse.tigris.org as the URL.
- Check the box next to CFEclipse and click Next. Eclipse returns a list of available plug-ins from that site.
- Select the highest stable version of CFEclipse and follow the screen directions.
At this point, you may be prompted to restart the Workspace to complete installation of CFEclipse. You can also restart Eclipse manually at a later time.
Before we begin using CFEclipse, let's go over the concept of perspectives in Eclipse. A perspective defines a set of views and editors. By default, Eclipse comes with these perspectives pre-installed: Resource, Java, Debug, Java Browsing, Java Type Hierarchy, Plug-in Development, CVS Repository and Team Synchronization. In Part one, we only worked in the Java and Debug perspectives. If you move some windows around while working in a perspective, Eclipse saves those settings. After you install CFEclipse, it will be added to the list of perspectives. In order to start using it, go to Window > Open Perspective or click on the perspective icon on the upper right and select CFEclipse. The CFEclipse perspective opens and we can begin exploring it. Every time you open a perspective it remains open until you close it. To close a perspective, right-click on the perspective icon and select Close or Close All.
To begin working with CFEclipse, you must first create a ColdFusion project. If you right click in the Navigator window and select New, there is a generic menu. To customize the menu, open Window > Customize Perspective with only the CFEclipse perspective open. The submenus pull down on the right indicates what menu you are customizing. Keep it on New and select CFEclipse. Click OK and then right click in the Navigator window again and the menu options should now be CFEclipse specific. Select New > CFML Project. Enter CFTest in the Project Name text box and click Finish.
Figure 1 You can customize your perspectives by choosing Window > Customize Perspective
Next, create a CFC by choosing New > CFC to open the CFC Component wizard. You can leave everything blank (except for Component Name) and make changes later or you can use the wizard to set up inheritance, display name, hint, and properties. You can always right click on the CFC later and rename it, but you will have to remember to manually rename the component name as well.
After completing the wizard, the new CFC opens in Eclipse. Insert your cursor after the opening tag and begin typing <cfproperty>. As you type, CFEclipse displays all the ColdFusion tags that begin with the letter that you have typed. Place your cursor in the cfproperty tag and hit Ctrl + space bar for code hinting. All of the possible attributes and definitions appear on the screen. Highlight an attribute by selecting it and a brief description appears next to it. Double-click the attribute to insert it into your code. Next, hit Ctrl + space bar again to see a list of valid values for the attribute.
CFEclipse can help with code completion and point out errors as well. As you type, you will notice that closing tags and quotation marks appear automatically. When you type a closing bracket or brace, CFEclipse turns the previous opening bracket or brace red. It is still up to you to make sure that the red brace actually correctly matches. CFEclipse indicates errors with a red X in the left margin. To cause an error, type a closing </cfif> tag without an opening tag. Place your cursor over the error icon and you will see the appropriate error message.
Overall, CFEclipse seems to be a viable and free alternative to developing in Dreamweaver, HomeSite or PrimalScript. The code hinting feature is my favorite part of using CFEclipse. There is an annoying bug where CFEclipse always closes a quotation mark even if it is already a closing mark. This will hopefully be addressed in an update. A great time to use CFEclipse is when you are working on an application that combines technologies, like a Flash project with Remoting and a Java backend. With Eclipse plus plug-ins, you can do all of the development in one application just by switching perspectives.
Find more tips and examples at Dopefly.