A team project set file for the digraph1 example is here. Download the team project set file and do the following to import the plug-in project into your workspace.
The main objective of the digraph1 example was to provide a simple graphical editor that demonstrates GEF's Model-View-Controller (MVC) architecture. This first directed graph example is as simple as it gets.
The model is a simple graph (Digraph1Graph) with a number of nodes (Digraph1Node). In this simple example the graph has a fixed number of nodes and a fixed location for each node in the graph.
We define the view to display the graph using figures. The figure for the graph is simply a FreeformLayer. Each node figure is a Digraph1NodeFigure.
We bridge the model and view with the controller, or EditPart. We have an EditPart for the graph and each node (Digraph1GraphEditPart and Digraph1NodeEditPart).
The graphical viewer has an edit part factory (Digraph1EditPartFactory) to create new EditParts for the example.
We make use of a XYLayoutEditPolicy to place the nodes on the graph (Digraph1XYLayoutEditPolicy).
Finally, we use an editor with no editing functionality to display the graphical viewer (Digraph1GraphicalEditor).
The graph example editor opens for any file with the digraph1 file extension. So we need a project and file in the workspace to open the editor. First, create a new project resource File > New > Project. Then a new file resource, such as file.digraph1 using File > New > File. After creating the file, the Directed Graph Example Editor will open.
Most frequently, GEF is used to graphically display your model in an Eclipse editor. However, GEF's viewers can also be used in views, dialogs, or just about anywhere you can place a control.
The digraph1 example hosts the same content from the editor in a view. The code in the Digraph1GraphicalView is exactly like the content in the GraphicalEditor.
To open the view, select Window > Show View > Other and select the Directed Graph Example View from the Other category.
The org.eclipse.gef.examples.digraph1.rcp package provides the four classes required to put the graphical editor in a RCP application.
The RCP application can be directly started by running an Eclipse application from Run > Open Run Dialog... A new configuration can be created as below:
Our WorkbenchWindowAdvisor works by creating a dummy file in a project. Since our example loads from a static model, the editor opens when the RCP application starts.
By Anthony Hunter, IBM Rational Software
: /cvsroot/org.eclipse/www/gef/reference/digraph1.php,v 1.10 2007/11/16 04:29:04 ahunter Exp $
Please send comments about this example document to the eclipse.tools.gef newsgroup.
Back to the top