A method based on EMF model to judge the validity of connecting lines in GEF

Source: Internet
Author: User

Introduction: Combining the currently popular EMF (Eclipse modeling framework) and GEF (graphical Editing framework) technology, a common validation method is proposed for creating connectors in graphical development. Finally, an example of dynamic schema verification is given, and the truth table of the connection line is listed according to the definition of the schema. Validation of each item of the truth table ensures that no connection lines can be created between the corresponding graphs of models that do not conform to schema definition rules, which reduces the complexity of Schema validation and modification.

A method based on EMF model to judge the validity of connecting lines in GEF

The traditional way to develop graphical tools in Java is to use either AWT or Swing directly, this method is generally complex in dealing with the details of graphical development (the creation/deletion of graphics, amplification/reduction, drag and drop, and revocation), and the corresponding relationship between graphical design and back-end model needs to be defined by the developer. There is no uniform standard, so it is difficult to maintain; The graphical interface developed by AWT or Swing is inconsistent with the style of the Windows interface, making it difficult for users who are always using Windows to accept it. EMF and GEF technologies are used as part of the ECLIPSE project to develop code generation and graphical tools for the model. GEF simplifies the processing of graphics, developers do not have to focus on graphics processing, providing a graphical development framework based on MVC (MODEL-VIEW-CONTROLLER) structure to effectively maintain the correspondence between graphics and models; based on SWT, The style of the graphic is the same as that of Windows. Therefore, using GEF for graphical development can improve development efficiency while ensuring scalability.

EMF and GEF Introduction

Emf

EMF is a set of Java frameworks that you can use to create tools and other applications that are based on a structured model. For the introduction of object-oriented models, EMF can help you quickly transform your model into efficient, correct, and customizable Java code. The standard format for the model definition used by EMF is XMI (XML Metadata Interchange), and there are four ways to convert the model you created to the XMI format:

Create a XMI document directly using a text or XML editor;

Export the model created using modeling tools such as Rational Rose to generate the XMI document;

Using a Java interface with model feature annotations;

Use an XML Schema to describe the format of the model.

Gef

GEF makes it easy for developers to create a rich graphical editor from a ready-made model, providing a basic framework for building multiple applications, such as state diagrams, GUI editors, Class diagram editors, and state machines. GEF includes two plug-ins: Org.eclipse.draw2d and ORG.ECLIPSE.GEF. The org.eclipse.draw2d provides a set of layouts and descriptions for the displayed graphics, ORG.ECLIPSE.GEF uses the MVC architecture and provides controllers (such as EditPart) to manipulate the models and views.

GEF working principle

GEF uses the MVC architecture, which is shown in Figure 1. GEF is used in conjunction with EMF, which is responsible for generating models. Each part of MVC is a tree structure, and is a one by one correspondence. Where EditPart acts as a controller, where various editpolicy can be used, and editpolicy implementations sometimes need to invoke the Command toolset class, while the graphics drawn by Draw2d act as the role of the view. The specific work flow is:

Editpartfactory creates a corresponding editpart for each model;

A view corresponding to the model is created within each EditPart, that is, the displayed graph;

When the property of the model changes, it notifies EditPart of its property changes;

EditPart updates the display of the view based on the changes in the model's properties;

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.