Eclipse platform entry: development environment and Instances

Source: Internet
Author: User
Tags version control system
Test the Java development environment. We will create and run a "Hello, world" application. Use the Java perspective, right-click the "hello" project, and choose new => class, as shown in figure 2. In the subsequent dialog box, type "hello" as the class name. In "which method stubs wocould you like to create ?" Next, select the "public static void main (string [] ARGs)" check box, and then press finish.

Figure 2. Create a class in the Java perspective

This will create a. Java file in the editor area that contains the Hello class and the empty main () method, as shown in 3. Then add the following code to the method (note that the I declaration is intentionally omitted ):

Figure 3. Hello class in the Java Editor

You will notice some features of the eclipse editor when typing, including syntax check and Automatic completion of code. In version 2.1 (I have downloaded version m2 for trial), eclipse will automatically provide the pair symbol when you type parentheses or double quotation marks and place the cursor within the pair.

In other cases, you can call the code auto-completion function by pressing Ctrl-space. The code automatically provides a list of context-sensitive suggestions. You can select from the list by keyboard or mouse. These suggestions can be a list of methods for a specific object, or code snippets based on different keywords (such as for or while.

Syntax check depends on incremental compilation. Every time you save the code, it receives the compilation and syntax check in the background. By default, syntax errors are displayed with red underscores, and a red dot with white "X" appears on the left side. Other errors are indicated by the lightbulb icon on the left of the editor. These are the problems that the editor may fix for you-the so-called quick fix feature.

The above code example has a lightbulb icon behind the for statement because the I statement is omitted. Double-click the icon to bring up the recommended repair list. In this example, it provides suggestions for creating a class field I, a local variable I, or a method parameter I. Click each suggestion to display the code to be generated. Figure 4 shows the recommended list and code generated after a local variable is created.

Figure 4. Quick Fix suggestions

Double-click the suggestion to insert the suggestion code to the proper position in the code. Once the code compilation is completed without errors, you can select Run from the eclipse menu to execute the program (note that there is no separate compilation step here, because compilation is performed when you save the code. If the Code has no syntax errors, it can run ). In this case, a launch events dialog box with the appropriate default settings appears. Press the run button in the upper right corner. A New Option Pane appears in the following pane (console), showing program output, as shown in Figure 5.

Figure 5. program output

You can also run the program in the Java debugger. Double-click the gray edge on the left of the editor view to set a breakpoint in main () system. Out. println () after system. Out. println () is called. A blue point will appear there. Select debug from the run menu. As described above, a launch events dialog box is displayed. Select Run. The perspective is automatically switched to the debug perspective, with many interesting new views, as shown in Figure 6:

Figure 6. debug perspective

First, pay attention to the debug view in the upper-left corner of the perspective. This view displays the call stack and has a toolbar in the title bar that allows you to control program execution, including continuing, suspending or terminating the program, tracking the next statement, and executing the next statement in one step, or return from the method.

The upper-right pane contains a number of Option-style views, including variables, breakpoints, expressions, and display. Here I click the variables view so that we can see the current value of I.

You can obtain more information about these views through context-sensitive help: Click the view title, and then press F1.

Additional plug-ins

Except for plug-ins like jdt used to edit, compile, and debug applications, some available plug-ins support the complete development process from modeling, automatic generation, unit testing, performance testing, Version Control to configuration management.

Eclipse is a standard plug-in that works with CVS. CVS is an open source code Concurrent Version System (Concurrent Versions System) for source code control ). The team plug-in connects to the CVS server, allowing developers to operate on a group of source code files without overwriting others' changes. It is not intended to further explore how to implement source code control from within eclipse, because it requires the installation of the CVS server. However, supporting the development team is not just independent development, which is an important essential feature of Eclipse.

Some third-party plug-ins available or announced to be launched include:

Version Control and configuration management

CVS
Merant PVCs
Rational clearcase

UML modeling

Omondo eclipseuml
Rational xde (instead of Rose)
Together WebSphere Studio Edition

Graphics

Batik SVG
Macromedia Flash

Web development, HTML, XML

Macromedia Dreamweaver
Xmlbuddy

Application Server Integration

Sysdeo Tomcat Launcher

To view the example of a plug-in and how it is integrated with Eclipse, download the popular omondo eclipseuml plug-in, which is free of charge. This plug-in depends on GEF, that is, Graphical Editor framework, which is another Eclipse plug-in. GEF is part of the tool subitem. To download GEF, go to the eclipse web site, select "downloads", and click the "Tools PMC Downloads page" link. Note that you need to download the GEF version recommended by omondo (GEF 2.0 for omondo 1.0.2 ).

After downloading the plug-in, you can usually decompress the downloaded file and copy its content to the Eclipse plug-in directory. In this example, GEF needs to be decompressed to the eclipse directory (it will automatically enter the plug-in directory from this directory ). To ensure security, you may want to extract it to a temporary directory and then copy the relevant directory from it. If eclipse is running, you need to stop it and restart it so that it can identify the newly installed plug-in.

Once eclipseuml (and GEF) is installed, you can create a class diagram just like creating a Java class file. In the Java perspective, right-click the "hello" project in package explorer and choose new => other from the pop-up menu. The left pane of the new dialog box contains a new option for UML. The free version of eclipseuml only supports class diagrams. Therefore, the only option on the right is UML class digoal. Select UML class digoal and enter a name for the class diagram, such as "hello ":

Figure 7. Class digoal Editor

The editor area displays a graphic editor with a canvas for drawing class diagrams. You can create a class diagram in two ways: drag and drop a Java file from package explorer to the class diagram to reverse engineer the existing code; alternatively, you can use the painting tools available in the toolbar above the blank class diagram. To test the first method, create a new class named "person" (using file => New => class) and assign it two private attributes listed below:


      /** Person.java * @author david */public class Person {private String name;private Address address;/** * Returns the address. * @return Address */public Address getAddress() {         return address;}/** * Returns the name. * @return String */public String getName() {        return name;}/** * Sets the address. * @param address The address to set */public void setAddress(Address address) {        this.address = address;}/** * Sets the name. * @param name The name to set */public void setName(String name) {       this.name = name;}}

(It should be admitted that I only typed rows for name and address. The getter and setter methods are automatically generated through eclipse, that is, right-click the source code and select Source => Generate getter and setter from the pop-up menu .)

Save and disable person. Java hello. UCD.

Figure 8. Person class diagram

To create a Java class from UML, click the "New Class" button on the toolbar at the top of the class diagram window, that is, the third button from the left, and then click the class diagram. When the New Class Wizard is opened, enter adress as the class name and press finish.

You can right-click the class name and choose new => attribute to add attributes to the class. In the new properties dialog box, enter the property name, type, and visibility. Right-click the class name and choose new => method to add the method. When you change a class chart, the source editor window below the chart will reflect the changes. Finally, you can click the association button (the fifth one from the left) to draw a line segment from the person class to the address class to draw the relationship between the two classes. This will bring up another dialog box, where you can enter the association attributes (refer to eclipseuml help for more information about the required information ). The figure after completion should be similar to the following:

Figure 9. Join

This UML plug-in shows several typical features of the Eclipse plug-in. First, it shows close integration between tools. On the surface, it is absolutely impossible to see that multiple components are working. Integration with the eclipse platform and jdt is seamless. For example, when the person class is created, it displays a syntax error because its attribute address is not defined. Once the Address class is created in the UML diagram, these components are displayed separately.

Another feature is that eclipseuml leverages the capabilities provided by other plug-ins-in this example, the GEF plug-in provides tools for developing visual editors.

Another feature is that eclipseuml plug-in uses multi-level functions for distribution. The basic plug-ins that support class diagrams are free of charge, but more mature versions are charged for use.

Eclipse Platform Architecture

The eclipse platform is a framework with a strong set of services that support plug-ins, such as jdt and plug-in development environments (PDE ). It consists of several major components: Platform Runtime Library, work zone, workbench, team support and help.

Figure 10. architecture of the eclipse Platform

Platform

The Platform Runtime Library is the kernel. It checks which plug-ins are installed at startup and creates registry information about them. To reduce the startup time and resource usage, the plug-in is loaded only when any plug-in is actually required. Everything except the kernel is implemented as a plug-in.

Work Zone

The workspace is a plug-in for managing user resources. This includes projects created by users, files in those projects, file changes and other resources. The workspace also notifies other plug-ins about resource changes, such as file creation, deletion, or modification. Workbench

The Workbench provides a user interface for eclipse. It is built using the standard Window Toolkit (SWT) and a more advanced API (jface); SWT is a non-standard replacement of Java's swing/awt gui api, jface provides user interface components based on SWT.

SWT has proved to be the most controversial part of Eclipse. SWT maps to the local graphics function of the underlying operating system more closely than swing or SWT. This not only makes SWT faster, but also makes Java programs look more like local applications. Using this New Gui API may limit the portability of the eclipse workbench, but SWT porting versions for most popular operating systems are available.

Eclipse's use of SWT only affects the portability of eclipse itself-No Java applications built using eclipse will be affected unless they use SWT instead of Swing/AWT.

Team support

The team support component provides support for version control and configuration management. It adds views as needed to allow users to interact with any version control system (if any) in use. Most plug-ins do not need to interact with the team's support components unless they provide version control services.

Help

The help component has the same scalability as the eclipse platform itself. Similar to adding a plug-in to eclipse, the plug-in provides an additional navigation structure that allows tools to add documents as HTML files.

Prospect of eclipse

Development around eclipse is in a critical stage. Major software and tool providers are involved, and the number of open-source Eclipse plug-in projects is growing.

The portable, extensible, and open-source framework is not a new idea (You may think of Emacs), but eclipse brings new impetus due to its mature, robust, and elegant design. The release of world-class software worth $40 million in IBM in the open source code field has brought a long-lasting shock to the industry.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.