Generate business model editor with GMF

Source: Internet
Author: User

Using GMF to implement the business model editor in the past Graphical Editor framework (GEF) to implement the business model editor is both slow and painful. It takes a long time to understand the complex GEF framework, GEF is a typical MVC Framework. You can customize a model. When the model attributes change, you can notify the model listener. The model listener in GEF is called a controller, it is at the core of the MVC Framework and serves as a bridge connecting models and views. It is responsible for reflecting model changes to views, at the same time, the user's operations on the view are reflected in the model. Some concepts such as commands and policies are also involved in this process. We will not elaborate here, after all, we will not introduce GEF. Of course, we can use eclipse modeling framework (EMF) to implement the model, because the model generated by EMF has already implemented the Message notification mechanism, saving a lot of work in the custom model, if EMF and GEF can be effectively combined, it is estimated that there will be no GMF. Because EMF and GEF use different command stacks, the seamless integration of EMF and GEF brings a great deal of technical problems. At this time, GMF came into being ("heroes of the Times "), it solves the technical problems encountered in the combination of GEF and EMF. Of course, I am not saying that with graphical modeling framework (GMF), GEF and EMF will be useless, a deep understanding of GEF and EMF is of great help in GMF learning. Let's go to the topic! During this time, due to work reasons, I made some research on GMF. Although I only learned a little about it, I want to write it out and share it with you, at the same time, I also ask the prawns in this regard to give some comments. Below, I use GMF to implement a simple business model Editor, which can be expanded later. We know that GMF is based on EMF modeling, so we need an ecore model. here our ecore model is transformed from MDL. We use rose to design an MDL file. In this model, there are ipackage and iclass classes (iattribute and iassociation classes can be added later). They are in an aggregation relationship. Construct an ecore Model 1. Open eclipse, right-click the navigator view, and choose new --> project to create a GMF project, such À Ecore, right-click the navigator view, and choose new --> other to create an EMF model. genmodel on the select model importer Wizard Page, select "Rose class model". On the "Rose Model import" Wizard Page, select the newly created image file. in the MDL file, click Finish to generate the ecore model and genmodel. Generate Model And edit code 1. Open the generated genmodel, right-click the root node, and click Generate model code and generate Model Code (the two generated projects will be referenced by the Business Model editor project ). Create other models GMF has a very practical tool that helps you generate an editor step by step. 1. select from domain model. In the pop-up dialog box, select the source image. ecore; 2. in the domain gen model, select. In the pop-up dialog box, select the source text file. genmodel; 3. select the derive above domain model. The Wizard dialog box is displayed. This wizard dialog box is used to generate a graphical def model. Anyone familiar with GEF knows that these models correspond to the graphic model in the graphic editor. In the First Wizard Page of the wizard dialog box, you can specify the file name and storage path for generating the graphical def model. Here, we accept the default value of the image. gmfgraph, click "Next". On the second Wizard Page, you can specify the corresponding ecore model. Here, we accept the default value. ecore: click "Next". On the third Wizard Page, you only need to specify the di1_element as ipackage, that is, specify the model corresponding to the canvas. If other values accept the default value, click Finish. 4. Select derive under domain model. The Wizard dialog box is displayed. This wizard dialog box is used to generate a graphical tool model. Anyone familiar with GEF will know that these models correspond to the graphic model in the editor palette. In the First Wizard Page of the wizard dialog box, you can specify the file name and storage path for generating the graphical tool model. Here, we accept the default value of the image. gmftool, click "Next". On the second Wizard Page, you can specify the corresponding ecore model. Here, we accept the default value. ecore: click "Next". On the third Wizard Page, you only need to specify the di1_element as ipackage. If you accept the default value for others, click Finish. 5. Select combine on the Right of domain model. The Wizard dialog box is displayed. This wizard dialog box is used to generate the mapping model of EMR. ecore, EZ. gmfgraph, and ez. gmftool. In the First Wizard Page of the wizard dialog box, you can specify the file name and storage path for generating the gmfmap model. Here, we accept the default value of the image. gmfmap: click "Next". On the second Wizard Page, you can specify the corresponding ecore model, gmfgraph model, and gmftool model. Here we accept the default value, and click "Next ", on the third Wizard Page, you only need to specify the dimo-root element as ipackage and click "Next". On the fourth wizard page, you can specify the node and link) the corresponding class. Here we accept the default value and click Finish. Here we must modify the generated. Specify a value for the digoal label attribute of mapping/top node reference/node mapping/label mapping. Here we specify digoal label ielementname, that is, the node name attribute is displayed on the node graph. 6. Select transform on the right of the mapping model. The dialog box is displayed. Here, we accept the default value of *. gmfgen. Click Finish. Then, the dialog box is displayed. Click "yes. 7. Select generator dimo-editor in distmgen model to generate a Graphical Editor. We restart an eclipse workbench, file/New/examples/ez digoal

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.