Getting Started with Eclipse platform: Development Environment and Examples

xiaoxiao2021-03-06  19

Test a Java development environment, we will create and run a "Hello, World" application. Use the Java perspective, right-click "Hello" item, select New => Class, as shown in Figure 2. In the subsequent dialog box, type "Hello" as class name. In "Which Method Stubs Would You Like To Create?", Select "Public Static Void Main (String [] args" check box, then press Finish.

Figure 2. Creating a new class in the Java perspective

This will create a .java file that contains the Hello class and empty main () method in the editor area, as shown in Figure 3. The following code is then added to the method (note that the declaration of I is intended to be omitted):

Figure 3. Hello class in the Java editor

You will notice some of the features of the Eclipse editor when typing, including syntax checks and code auto-completion. In version 2.1 (I have downloaded M2 editions), when you type a knot or double quotation, Eclipse automatically provides paired symbols and places the cursor within the symbol. In other cases, you can call the code automatic completion by pressing Ctrl-Space. The code automatically completes the list of suggested suggestions, you can choose from the list via the keyboard or mouse. These recommendations can be a list of methods for a particular object, or a code snippet that is expanded based on different keywords (such as for or while). Grammatical check reliance on incremental compilation. Whenever you save the code, it accepts compilation and syntax check in the background. By default, syntax errors will be displayed in red underline, and a red dot with white "X" will appear on the left. Other errors indicate along the left side of the editor; these are the editor perhaps the problem that you can fix - the so-called Quick Fix feature.

The above code example has a bulb-like icon behind the for statement because the declaration of i is omitted. Double-click the icon to call up the recommended fix list. In this example, it will provide recommendations for creating a class field I, a local variable I or a method parameter i; one of the suggestions that click it will display the code to be generated. Figure 4 shows the recommended list and the code generated after a local variable is recommended.

Figure 4. Quick FIX suggestion

Double-click the suggestion to insert the suggestion code into the appropriate location in your code. Once the code is not erroneously compiled, you can select RUN from the Eclipse menu (note that there is no separate compilation step because compile is done when you save the code. If the code does not have a syntax error, it Can run). A Launch Configurations dialog with an appropriate default setting will appear; please press the Run button in the upper right corner. A new tab pane will appear in the following pane (console), which shows the output of the program, as shown in Figure 5.

Figure 5. Output of the program

You can also run the program in the Java debugger. First double-click the gray edge of the left end of the editor view to set a breakpoint in the main () system.out.println () after calling System.out.Println (). A blue point will appear there. Then select Debug from the RUN menu. As described above, a Launch Configurations dialog appears. Please select RUN. The perspective will automatically switch to the Debug perspective, which has many interesting new views, as shown in Figure 6:

Figure 6. Debug perspective

First, note the DEBUG view in the upper left corner of this perspective. This view displays the stack, and there is a toolbar in the title bar, which allows you to perform execution, including continuing, suspend, or terminating programs, tracking the next statement, single-step execution, or returning from ways. The pane in the upper right corner contains many tabs, including Variables, Breakpoints, Expressions, and Display. Here I click on the Variables view so that we can see the current value of I. You can get more information about these views by context-sensitive help: click on the title, then press F1.

Additional plugins In addition to the plug-ins of JDT for editing, compiling, and debug applications, some available plugins support from modeling, generating automation, unit testing, performance test, and version control to configure management's complete development process. The Eclipse standard comes with a plug-in with CVS, and CVS is an open source code for source code control and a Concurrent Version System. The Team plug-in is connected to the CVS server, allowing a member of the development team to operate a set of source code files, but will not cover each other changes. Here is not intended to further explore how to source source code from Eclipse, as this requires installation of CVS servers, but supports development teams, not just independent development, this is an important essential feature of Eclipse. Some third-party plugins that have been available or have been announced include: version control and configuration management CVS merant PVCS Rational Clearcase UML modeling Omondo Eclipseumlrational xde (instead Rose) TOGETHER WebSphere Studio Edition graphic Batik Svg Macromedia Flash Web Development, HTML, XML Macromedia Dreamweaver XMLBUDDY App Server Integration Sysdeo Tomcat Launcher To view the plugin example, and how to view it with Eclipse, download popular Omondo Eclipseuml, which is free. This plugin relies on GEF, which is Graphical Editor Framework, which is another Eclipse plugin. GEF is part of the Tools subproject. To download the GEF, go to the Eclipse Web site, select Downloads, and then click the "Tools PMC Downloads Page" link. Note that you need to download the GEF version recommended by Omondo (for Omondo 1.0.2 is a GEF version 2.0). After downloading, the plugin installation is usually done by decompressing the download file and copy its content to the Eclipse plugin directory. In this example, the GEF needs to decompress the Eclipse directory (it will automatically enter the plugin directory from the directory). For security, you may want to extract it into a temporary directory, and then copy the relevant directory accordingly. If Eclipse is running, you will need to stop it and then restart it so that it can recognize the newly installed plugin. Once Eclipseuml (and gef) installation is complete, you can create a class diagram like creating a Java class file. In the Java perspective, right-click the "Hello" project in Package Explorer and select New => Other from the pop-up menu. There will be a new option for UML in the left pane of the New dialog. The free version of Eclipseuml only supports a class diagram, so the only option on the right is UML Class Diagram. Please select UML Class Diagram and type a name for this class, such as "Hello": Figure 7. Class Diagram Editor

A graphic editor will appear in the editor area, which has a canvas for drawing a class diagram. You can create class diagrams in two ways: Drag and drop the Java file from the package Explorer to the existing code reverse engineering; or use a blank class map to draw a drawing tool in the toolbar. To test the first method, create a new class named Person (using file => new => class), then give it the two private properties 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 acknowledged, I only type lines for Name and Address. Getter and setter methods are automatically generated by Eclipse, that is, right-click source code, then select Source => generate getter and setter from the pop-up menu.) Please save And close the Person.java Hello.ucd.

Figure 8. Person class diagram

To create a Java class from UML, click the "New Class" button on the top toolbar on the Class Cap window, you click on the third button, and then click the chart. When the New class wizard is opened, type adress as class name and press Finish.

You can first click on the class name and select New => Attribute to add attributes to the class. In the New Properties dialog box, enter the property name, type, and visibility. Then right-click the class name and select New => Method to add a method. When you change the class map, the Source Editor window below will reflect the changes made. Finally, you can click on the Association button (fifth from left) to draw a line segment from the Person class to the Address class to draw the relationship diagram between the two classes. This will call another dialog that you can enter the associated property (see Eclipseuml Help for more content about the required information). The chart after completion should be similar to:

Figure 9. Association

This UML plugin demonstrates several typical features of the Eclipse plugin. First, it shows the tight integration between the tools. The surface is absolutely unasight to see multiple components at work; integration with the Eclipse platform and JDT is seamless. For example, when the Person class is created, it shows a syntax error because it is not defined by ADDRESS. Once the Address class is created in the UML diagram, these components are displayed separately. Another feature is the ability of Eclipseuml to utilize other plug-ins. - In this example, it is a GEF plugin that provides tools for developing visual editing editors. Another feature involves the way the Eclipseuml plugin uses multi-level features. The basic plugins that support the class diagrams are free, but more mature versions will be available. The Eclipse platform architecture Eclipse platform is a framework with a strong service that supports plugins, such as JDT and Plug-in Development Environment (PDE). It consists of several major parts: platform runners, workspaces, workbenches, team support and help. Figure 10. Eclipse platform architecture

The platform platform runtime is the kernel. It checks which plugins have been installed when starting, and create registry information about their registry. To reduce startup time and resource, then load the plugin when there is any plug-in. In addition to the kernel, other everything is implemented as a plugin. Workspace Workspace is a plug-in that manages user resources. This includes items created by users, files in those projects, and file changes and other resources. The work area is also responsible for notifying other plugins about resource changes, such as file creation, deletion, or changes. The workbench workbench provides the user interface for Eclipse. It is built using a standard window toolkit (SWT) and a higher API (JFACE); SWT is a non-standard alternative for Java Swing / AWT GUI API. JFACE is based on SWT, providing user interface components. . SWT has proven to be the most controversial part of Eclipse. SWT is more closely mapped to the native graphics function of the base operating system than Swing or SWT, which not only makes SWT faster, but also makes the Java program have more appearance and feel like this appliance. Using this new GUI API may limit portability of the Eclipse table, but the SWT transplanarized version of most popular operating systems is available. Eclipse's use of SWT will only affect Eclipse itself - any Java applications built using Eclipse will not be affected unless they use SWT instead of using Swing / AWT. Team Support Team Support Components are responsible for providing version control and configuration management support. It adds views as needed to allow users to interact with any version control system (if any) used. Most plugins do not need to interact with team support, unless they provide version control services. Help the help component has the ability to scalable with the Eclipse platform itself. The same is the same as the plug-in to add features to help provide an additional navigation structure that allows the tool to add documents in the form of an HTML file. The prospect of Eclipse is in a critical stage around Eclipse. The main software tool providers are involved, and the number of open source Eclipse plug-in projects is growing. Portable, expandable, open source frames are not new ideas (you will think of emacs), but because of its mature, robust and elegant design, Eclipse brings new power. The world-class software worth $ 40 million in the open source area has brought long-lost shock to the industry.

转载请注明原文地址:https://www.9cbs.com/read-39910.html

New Post(0)