Extending the Eclipse Assistance and specification development process

Source: Internet
Author: User
Tags extend functions interface sql net query range version
Specification if the development tools on the market do not meet your needs and you are not realistic about developing your own IDE, this article is what you need, and it describes how to extend Eclipse JDT to assist in standardizing your project development process and helping to constrain your code specifications.

   I. Preface

Do your team's personnel not develop according to the development process and code specifications you have developed? Members of your team often change, and often tell novices what Struts is and what MVC is. The functionality of an existing development tool does not meet your needs?

If you encounter the above problem, please look at this article, although it does not necessarily solve your problem, but at least it gives you some inspiration. This article from the actual case triggers, in simple terms, illustrated to you how to use the Eclipse platform to standardize your team's development process, and help beginners quickly into the development. Read this article, preferably with Java EE Development, Eclipse platform and plug-in development, Eclipse platform JDT plug-in extensions and Struts related knowledge.

   Two. Implementation of the overall description

Eclipse is an open source platform, but today its functionality is no longer lost to any development tool, and Eclipse has become one of the most popular development tools with the help of Eclipse's JDT and a variety of third-party plug-ins.


Eclipse already has the capabilities of software development, testing, documentation, collaboration, etc., and it has been integrated into the entire process of software development.

Let's start with a practical example and see how we extend Eclipse to help and standardize our development efforts. This is a power company Sales Analysis System, which has a wide range of analysis topics, such as to analyze the sales of a power company, users can choose a time range to analyze the company's sales, as shown in the following figure:


Our team's process of developing a subject is roughly like this:


   to write an extended JDT plug-in-assisted development process

Our development process is essentially the same as above, but since we use wizards and extended JDT to help us complete our work, the actual developer process will be simplified as follows:


The core is the expansion of the JDT plug-in, the development of the process to focus on a Wizard complete.

First, let's look at the actual effect and then explain it in depth.

1. In the Eclipse platform, click Start-> New->J2EE development Package-> Develop a new analysis theme menu.

As shown in the following illustration:


2. The first display is to generate the Action class interface, which extends the functionality of the JDT plug-in to allow the programmer to enter the customer's allowable query conditions, and it has set the parent class in order to see the parent class org.apache.struts.action.Action, this is struts Requirements. This is then used to automatically generate Formbean, and the JSP table alone.


3. Click Next, enter SQL here, and you can test directly. The parameters are replaced with the. Team members can directly write directly here, test the SQL, and finally automatically generate Java code.


4. If there are no errors, click the Finish button. The jsp,action skeleton and basic functionality code is automatically generated. Automatically generated JSP forms, automatically generated Action and automatically generated JSP for realistic query results. Because each project here is completely different, the build uses the template engine so that modifying the template at any time will not need to be modified to Java code.

The general structure is as follows, there are two JSP, a anction:


5. Modify the skeleton according to the actual situation, run, and test the effect.

  Three. How to develop

1. The first is how to develop the Wizard in Eclipse.

Here I don't start from scratch on how to develop Wizard, if you have no idea how to develop Wizard, please refer to the eclipse.org from Doina Klinger article: http://www.eclipse.org/articles/ Article-jface%20wizards/wizardarticle.html, this step by Stey describes how to create Eclipse wizard, and a variety of detail knowledge.

First, take a look at our plugin's Plugin.xml file:

>


Point= "Org.eclipse.ui.newWizards" >

Name= "Beijing can Bo decoding Java development package"
Id= "NET.SF.YANGTZE.PDPF"/>
Class= "Net.sf.yangtze.pdpf.wizards.NewSubjectWizard"
icon= "Icons/sample.gif"
category= "NET.SF.YANGTZE.PDPF"
Name= "Developing a new analysis theme"
Id= "Net.sf.yangtze.pdpf.wizards.NewSubjectWizard"/>



The class Net.sf.yangtze.pdpf.wizards.NewSubjectWizard that implements it inherits from the Org.eclipse.jface.wizard.Wizard class, and it has several important methods:

AddPage-Adding pages to Wizard is the page that can be browsed through next>,<back.

Finishpage-When the user clicks Finish, the program completes the work. In our plug-in is to complete the automatic generation of jsp,action work, put the code in the Finishpage method can be.

We have two Page one to enter and test the SQL statement, one to customize the Action and the parameters that can be entered.

2. Then how to expand from the JDT.

This part of the ready-made information is not much, so we have to explore a little bit. Programmers who often use eclipse to develop Java should be very familiar with JDT, and in fact the Eclipse platform can be used to develop any language, it is not a Java Ide,java IDE's functionality is done through the JDT plug-in, and in the Eclipse world everything is Plug - ins.

In Java development, there are many Wizard to help us complete the coding work, such as the new class, interface, the following figure:


And it has a lot of ancillary work, such as when you click on the superclass, there is a help you enter the superclass name of the window will bounce out, in which you do not need to enter the full name of the class, it will automatically prompt. Both the interface and the package have similar auxiliary input functions.


I use these features as a convenience and a habit, so I want my plugin to have a similar function when creating the Action, and I don't want to reinvent the wheel myself (and it's not easy to do), so I have to extend it from the JDT without using the standard Org.eclipse.jface.wizard.Wizard class.

In the traditional wizard we use Org.eclipse.jface.wizard.Wizard and Org.eclipse.jface.wizard.WizardPage classes, but if you want to inherit the JDT function must correspond to use Org.eclipse.jdt.internal.ui.wizards.NewElementWizard and Org.eclipse.jdt.ui.wizards.NewTypeWizardPage classes.

Newelementwizard is also inherited from Wizard, it just does some checking is not a Java project, and so on, the new class in Eclipse, and interface Wizard are from this kind of foundation development. Rich in content is the Org.eclipse.jdt.ui.wizards.NewTypeWizardPage class, it contains browsing items, browsing the superclass, interface and other functions, but also provides a rich way to build your Java type, such as adding methods, add import and so on , you can refer to your own API doc file for more information.

Take a look at the example in my plugin above:

public void CreateControl (composite parent) {
Initializedialogunits (parent);
Composite composite = new Composite (parent, 0);
int ncolumns = 4;
GridLayout layout = new GridLayout ();
Layout.numcolumns = ncolumns;
Composite.setlayout (layout);
The source folder control in the previous illustration
Createcontainercontrols (composite, ncolumns);
Package
Createpackagecontrols (composite, ncolumns);
A split Line
Createseparator (composite, ncolumns);

Createtypenamecontrols (composite, ncolumns);
Createmodifiercontrols (composite, ncolumns);
The selection control of the parent class
Createsuperclasscontrols (composite, ncolumns);
Interface Selection Control
Createsuperinterfacescontrols (composite, ncolumns);
//
Createseparator (composite, ncolumns);
The controls we extend
Creatstrutscontrols (composite, ncolumns);
Setsuperclass ("Org.apache.struts.action.Action", true);
Setcontrol (composite);
}


   Summary

The power of Eclipse is that it allows Plug-ins to extend other plug-ins, using JDT you can fully develop a fast development tool that meets your requirements without much code. Interested readers can refer to the Lomboz project, a plug-in that develops Java EE for Eclipse, which is powerful but does not actually have much code.

Extending Eclipse can build your own rapid development tool that can significantly improve productivity. And any novice can be quick to start, your knowledge is shared by the entire project team members, which reduces the complexity of Java is criticized. As far as my example is concerned, in my project team, new employees only need basic Java and SQL knowledge, they don't have to learn struts,mvc from scratch, they can have more time to develop more features for their users without having to worry about tools and frameworks. Hope this article can play a role, more domestic developers can integrate into the Eclipse world.

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.