Monthly Archives: March 2009

Eclise Modeling Framework (EMF) and its magic

I am trying to understand Eclipse Modeling Framework (EMF). It is so important, because it’s the foudation of other modeling technologies. To name a few, TMF/Xtext and GMF.

So, what’s the relationship among EMF, Rational Rose, Annotated Java, and XML documents? Is one superior to another? Can EMF replace other stuff?

So far I can answer the questions partially. Let’s draw three circles on a whiteboard, and label them Rational Rose, Annotated Java, and XML Schema. As we can see, all three can have model definitions. If we describe a model by all 3 formats, there will definitely be some duplication.

This is partially where EMF fits in. It lands among the 3 modeling methods, and can works as bridges for the models.

One models his/her domain problems once, and transform the modeling to other forms as needed. For example, developers would like to see Java code, and managers prefer to looking at Rose class diagrams, and clients would love documentations.

Transformation is helpful. Like the animated TV Transformers. The robots gain speed performance in vehicle form, and gain fighting/fire performance in soldier form. You model gains different performance in different forms.

So, one of the benefits is lying in its magic transformation. I think mostly it is very straightforward for data model. We know that there are 2 elements in a class definition: data and operation. I am wondering if it helps in modeling the operations. Still a lot to dig out. Will keep walking on it.

Eclipse: How to add a closable editor page in MultiPageEditorpart

By default, the MultiPageEditorPage doesn’t allow to create closable editor pages. What is closable editor page? It means you can dynamically load and close editor pages, like what you have in EditorPlus, UltraEdit, and Notepad++.

To enable closable editor page, there are a few works to do:

1. Create your subclass of MultiPageEditorPart

2. Add your own addPage method. It will call the existing addPage(…) method, and get a pageIndex of newly added editor page:

Eclipse: How to add actions for marker clicking

Let’s say that your XML code is invalid in certain line. There is a relative problem marker placed on the vertical ruler. Like the picture below. Now you wish to make the red problem marker click-able, to invoke certain actions, such as pop up quick-fix suggestions. How to do it?

problem_marker_action

Last week I talked about it in the blog post http://www.frankdu.com/weblog/archives/44. However, there are two issues with the method:

  1. It takes 3 steps.
  2. It doesn’t work with a MultiPageEditorPart. This is a huge problem.

Well, now let’s do it in a better way. It takes two steps, and works with MultiPageEditorPart. Here we go:

  1. Subclass SelectMarkerRulerAction to invoke your desired action. Please refer to the example class PDESelectAnnotationRulerAction.
  2. In your text editor, override the method createActions, to set the RulerClick action. The example class is PDESourcePage, and the code snipet: