The Eclipse Graphical Editing Framework Gef Pdf Creator
Chapter 11 GEF View 185 11.1 Setup 185 11.1.1 Installation 185 11.1.2 Plug-in Dependencies 185 11.2 GEF Viewer 186 11.2.1 Standalone GEF View 187 11.2.2 Viewer setContents 187 11.3 EditPartFactory 188 11.3.1 GenealogyGraphEditPart 188 11.3.2 PersonEditPart 189 11.4 Connections 193 11.5 Summary 200. (Eclipse Modeling Framework) or GMF (Graphical Modeling Framework), to be able to gain abstraction levels in application. Now, let's create a new class in the package which inherits from org.eclipse.gef.ui.parts.GraphicalEditor. This class will define our Graphical Editor. It is a sort of starting point of our.
Version 4.1.6 3.2+ The is a set of Eclipse plugins for creating editors that support visual editing of arbitrary models. This framework is very popular and QF-Test has supported recording and playback of GEF items for a long time (since about version 2.2). It is also a good example for the power of the ItemResolver concept (see ), because the gef Jython module contains an implementation of just that interface. The gef module can deal with GEF editors at a generic level and even support several editors at once. Though reasonable item names are provided out of the box also for GMF applications, there are limits to what can be determined automatically. Depending on the underlying model classes, there might still remain some work for you: Implementing custom resolvers to provide useful names and values for your items. The actual GEF component is the FigureCanvas.
This control displays Figures which represent EditParts. When recording a mouse click on such an element, QF-Test does not register a pure 'Mouse event' node for the canvas component with the corresponding (x,y) position but tries to recognize the object under the mouse cursor. For example, the recorded 'QF-Test component ID' may look like canvas@/Diagram/My ship/ShipLargeCargo (wine) canvas@Connection-2 canvas@/Diagram/Rectangle 16329001 where 'canvas' is the 'QF-Test ID' of the FigureCanvas component, followed by the item index of the recognized EditPart (see ). EditParts reside in a tree like hierarchy which is reflected in the index by a path separator '/'. The names of the individual items are generated as follows:. The item name is getModel.toString unless it contains a hash value (e.g. QF-Test tries to extract a name for the item from the model ('My ship' in the above examples).
The class name along with a description gets recorded, e.g. 'ShipLargeCargo (wine)'. If there's no description, an index is appended to the class name when there's more than one item of that class, e.g. 'Connection-2' for the third connection. The root EditPart always reads 'Diagram'.
Myers-Briggs Type Indicator
As one can imagine, those generated item names may not always be useful. For example, items might be deleted so that the recorded index is not longer valid. Or the generated item name is unstable as 'Rectangle 16329001' in the GEF Shapes example: The number is random and when restarting the application a different one will be created. Three options exist to overcome the problem:. Instead of working with a textual index, you can try to go with a numerical one. To this end, open the recording options and set the 'Sub-Item format' to 'Number' (see ). This is probably not satisfying because a numerical index like /0/1 tells nothing about an item.
Get in touch with your developers and convince them to provide a useful implementation of the toString method of the item's model. It would make live easy for you, but only if the developers are cooperative. Write an ItemNameResolver2. This is the tough course but unfortunately the most likely scenario. It is covered in the next section. As stated in, an ItemNameResolver2 is the hook to change or provide names for items.
To get started, insert a new Jython in the node with the following code: def getItemName(canvas, item, name): print 'name:%s'%name print 'item:%s'%(item.class) model = item.getModel print 'model:%s'%(model.class) resolvers.addItemNameResolver2('myGefItemNames', getItemName, 'org.eclipse.draw2d.FigureCanvas') Example 41.28: Get started with a GEF ItemNameResolver2 To ease the installation of the resolver we use the resolvers module described in. The resolver gets registered for the FigureCanvas class where the items reside. The default item name provided by QF-Test is supplied as the last argument to our function getItemName.
Now run the script, press the record button and then simply move the mouse over your figures on the canvas - supposing you have created some of them previously. Note that this first resolver implementation does nothing but print out out some information into the terminal, something like name: Rectangle 16329001 item: org.eclipse.gef.examples.shapes.parts.ShapeEditPart model: org.eclipse.gef.examples.shapes.model.RectangularShape The question is now: Does the model of the GEF EditPart provide any property that might be used as name for the item? The answer in the case of the GEF Shapes example is 'No', and hopefully you are in a better situation with your application. To find out insert a line print dir(model) in the getItemName function and run the script again. Now you will also see the methods of the model when moving the mouse over the items in record mode.
The Eclipse Graphical Editing Framework Gef Pdf Creator Mac
With a bit of luck you will find methods like getId or getLabel and can create a resolver like this: def getItemName(canvas, item, name): model = item.getModel return model.getId resolvers.addItemNameResolver2('myGefItemNames', getItemName, 'org.eclipse.draw2d.FigureCanvas') Example 41.29: A simple ItemNameResolver2 Let's go back to the GEF Shapes example where we don't have such useful methods. Only geometry information is available for the shapes and that is not really helpful. At least we can distinguish between rectangles and ellipses.