With the development of Eclipse, many Java projects will say goodbye to the absence of interfaces and ant attacks, and start to have their own easy-to-use interfaces. (Of course, ant, Which is lightweight and generic, should still be supported .) I think the most typical thing is andromda. It's so tiring to rely on build. xml and a bunch of configuration files to generate so many things.
I did not write Eclipse plug-ins or SWT applications, so I took this opportunity to try it out. The requirements of my code generation plug-in are:
1. The plug-in reads the model. xml file that stores metadata and generates a listview
2. the user selects the domain object of the Code to be generated from listview. The plug-in displays a dialog box for generating options.
3. After you enter the generate option in the dialog box, the plug-in generates the code.
This plug-in is very simple. You almost don't have to chew on any books. Just follow the cookbook.
1. File-> New-> plug-in development-> plug-in Project
2. Select plug-in with a view as the template to generate the default code.
3. Modify the getelements () function of the viewcontentprovider class of xxxview. java. This function returns a string [] to generate objects in the view.
4. In the makeactions function in xxxview. Java, modify the run () function of Action1, which is the main function of work.
5. Take a sample and copy a dialog example. Although there are ve and SWT-designer, my dialog box is relatively simple, and the source code is edited directly.
6. Continue to modify the run function of Action1, open dialog, and generate code based on the returned value of dialog.
Thoughts:
1. Writing the Eclipse plug-in is very simple, and SWT is easier than originally imagined.
2. write a framework with a superb architecture-you only need to write the most important code, and the rest is done by default by the system. When you need to change the default practice, it is so difficult to find an extended interface. Therefore, both VC and eclipse in MS need to generate wizzard to generate a large amount of auxiliary code. However, Microsoft Visual Studio often provides another level of programming interface without directly modifying the source code. Eclipse only generates code based on the template once, and directly changes the source code for others.
3. Based on the callback mechanism of anonymous internal classes, SWT/swing is not as good as the magic macro of MFC in ms.