Graphical Editing Framework
Encyclopedia
Graphical Editing Framework (GEF) is a framework that was developed for the Eclipse
Eclipse (software)
Eclipse is a multi-language software development environment comprising an integrated development environment and an extensible plug-in system...

 platform. It is used to create graphical editors for various diagrams like electrical networks or tree diagrams. Such diagrams offer easy editing capabilities for data in specific domains and are well suited as a graphical representation of that data. GEF editors can be used inside an Eclipse RCP application, the application framework offered by Eclipse. Usually, GEF is used as a part of the Graphical Modeling Framework (GMF)
Graphical Modeling Framework
The Graphical Modeling Framework is a framework within the Eclipse platform. It provides a generative component and runtime infrastructure for developing graphical editors based on the Eclipse Modeling Framework and Graphical Editing Framework...

 which combines the Eclipse Modeling Framework (EMF)
Eclipse Modeling Framework
Eclipse Modeling Framework is an Eclipse-based modeling framework and code generation facility for building tools and other applications based on a structured data model...

 and GEF to create the code for both the data model and the diagram editor.
Editors generated with GEF consist of the following components:
  • The diagram editor including tool palette
  • Figures which graphically represent the underlying data model elements
  • EditParts which match figures and their respective model elements
  • Request objects for user input
  • EditPolicy objects which evaluate the requests and create appropriate command objects
  • Command objects that edit the model and provide undo
    Undo
    Undo is a command in many computer programs. It erases the last change done to the document reverting it to an older state. In some more advanced programs such as graphic processing, undo will negate the last command done to the file being edited....

    -redo

Design Pattern Usage

GEF makes heavy use of Design Patterns
Design Patterns
Design Patterns: Elements of Reusable Object-Oriented Software is a software engineering book describing recurring solutions to common problems in software design. The book's authors are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides with a foreword by Grady Booch. The authors are...

. These patterns are often mandatory under GEF and developers are required to understand them.

Model-View-Controller Pattern in GEF

Model-View-Controller
Model-view-controller
Model–view–controller is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" from the user interface , permitting independent development, testing and maintenance of each .Model View Controller...

 is an architectural design pattern which divides an application into separate parts which communicate which each other in a specific way. The goal is to separate data model (model), graphical user interface (view) and business logic (controller). GEF uses the MVC pattern extensively.
  • Model: The data model can either be generated using EMF, self-implemented by the user or it may already exist in case of a legacy software.
  • Controller: The EditParts act as controllers. Typically, each model element has its matching EditPart. EditParts may contain other EditParts thereby matching model elements containing other model elements. EditParts also have a reference to the figure which graphically represents the model element. Finally, EditParts evaluate requests and create the appropriate command to edit the underlying model.
  • View: For each element within the model, including connections, a figure has to be implemented using the Draw2d framework. Oftentimes the figure is some geometrical drawing.

Other Featured Design Patterns

  • Factory: Creating models from palette, creating EditParts and creating Figures
  • Observer
    Observer pattern
    The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods...

    : Typically a controller (EditPart) listening on Model and View
  • Command
    Command pattern
    In object-oriented programming, the command pattern is a design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time...

    : To implement Undo and Redo functions
  • Strategy
    Strategy pattern
    In computer programming, the strategy pattern is a particular software design pattern, whereby algorithms can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable...

    : EditParts can install and remove EditPolicies dynamically
  • Chain of responsibility
    Chain-of-responsibility pattern
    In Object Oriented Design, the chain-of-responsibility pattern is a design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains a set of logic that describes the types of command objects that it can handle, and how to pass off those...

    : To decide which EditPolicy should handle a Request

Request and Response Mechanism

Any user action with the editor can generate a request. The nature of the request is understood by the context of invocation. The context is determined by the EditPart the user interacts with and the active tool. The tool can be any selected entry in a tool palette. The request is handed over to the selected EditPart, which in turn returns an Command.

This is achieved using the Chain of responsibility
Chain-of-responsibility pattern
In Object Oriented Design, the chain-of-responsibility pattern is a design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains a set of logic that describes the types of command objects that it can handle, and how to pass off those...

mechanism over Editpolicies. The editpolicies determine if they can handle the request, otherwise they pass on to the next editpolicy. The order of declaration of editpolicies determine the order in which the request is passed around. The capable editpolicy creates a command. This command is handed back to the tool which initiated the "Request". Execution of the command causes the model to be modified (Response).

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK