Getting Started with Eclipse platform: Development Environment and Examples

xiaoxiao2021-03-05  28

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 I is intended to be omitted): Figure 3. Hello classes in the Java Editor You will notice some of the features of the Eclipse editor, including syntax check and code automatic carry out. 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 recommends Double-click the suggestion to insert the suggested code into the appropriate location in the 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. The output of the program can also be run 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 of 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.

Select UML Class Diagram, then type a name for this class, such as "Hello": Figure 7. A graphic editor will appear in the Class Diagram Editor Editor area, with canvas for drawing class diagrams. 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 the 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 Class. 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 completed figure should be similar as follows: Figure 9. Associated 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. The Eclipse platform architecture platform platform running library 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.

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

New Post(0)