Feb 05

This should be a good tutorial. I need to look into it:

http://www.ibm.com/developerworks/edu/os-dw-os-ecl-commplgin1.html

I know there is an excellent tutorial in Chinese. It demos how to craft a source code editor using Eclipse JFace Text Framework and a bit ANTLR. The link is here.

  • Share/Bookmark
Feb 05

Here are some tutorial links for learning antlr v3:

  1. The Getting Started Tutorial from Official Site is Damn Good!
  2. ANTLR Works is a damn good tool!
  3. The Definitive Antlr Reference is a good book
  4. ANTLR 3.X Tutorials are good video course and introduced a damn good eclipse tool: ANTLR IDE.
  • Share/Bookmark
Jan 08

If you are doing antlr v3 for Java, you can be very interested in this series of video tutorials. It demos how to develop with antlr3 IDE, and also the process of a small language. It credits to Marcel for the recommendation. Check it out at:

ANTLR 3.x Tutorials:
http://vimeo.com/groups/29150/videos

  • Share/Bookmark
Nov 02

GEF involves many concepts as it establishes its MVC convention. You may find tutorials from eclipse official site spend most paragraphs in concept explanation.

Here is a very nice tutorial focusing on step-by-step application. It’s not long, around 80 pages in PDF version:

http://www.psykokwak.com/blog/index.php/tag/gef

  • Share/Bookmark
Sep 24

Below is very straightforward code snippet to use PageBook. It is used together with eclipse form. Therefore you will see widgets are created via the FormToolkit class.

  1.  
  2. toolkit = new FormToolkit(container.getDisplay());
  3. form = toolkit.createScrolledForm(container);
  4.  
  5. Composite parent = form.getBody();
  6. GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
  7.  
  8. // create a table as selection provider
  9. final Table table = toolkit.createTable(parent, SWT.BORDER | SWT.VIRTUAL);
  10. table.setHeaderVisible(true);
  11. table.setLinesVisible(true);
  12. for(int i=1; i<=12; i++){
  13.         TableItem item = new TableItem(table, 0);
  14.         item.setText("Item " + i);
  15. }                              
  16.  
  17. toolkit.createLabel(parent, "Selected pagebook:");
  18.  
  19. // create a PageBook
  20. final ScrolledPageBook pageBook = toolkit.createPageBook(parent, SWT.NONE);
  21. GridDataFactory.defaultsFor(pageBook).grab(true, true).applyTo(pageBook);
  22.  
  23. // create PageBook controls
  24. for(int i=0; i<table.getItemCount(); i++){
  25.         TableItem item = table.getItem(i);
  26.         Composite pageContainer = pageBook.createPage(item.getText());
  27.         GridLayoutFactory.fillDefaults().numColumns(1).applyTo(pageContainer);
  28.        
  29.         toolkit.createLabel(pageContainer, item.getText());
  30.         toolkit.createText(pageContainer, "to be edited");
  31.        
  32.         pageBook.showPage(item.getText());
  33. }
  34.  
  35. pageBook.showEmptyPage();
  36.  
  37. // add selection listener, and show relative PageBook on selection
  38. table.addSelectionListener(new SelectionAdapter(){
  39.         public void widgetSelected(SelectionEvent e) {
  40.                 TableItem item = (TableItem) e.item;
  41.                 pageBook.showPage(item.getText());
  42.         }                      
  43. });
  44.  
  • Share/Bookmark
Jun 02

Today I finally went through the CNF tutorials by Michael. It’s a famous online one, located at

http://scribbledideas.blogspot.com/2006/07/pdf-versions-now-available.html

My task is to customize all menu items in our customized navigator. There are generally 2 ways to contribute menus in Common Navigator Framework:

1. Contribute via platform popup menu extensions (viewerContribution and objectContribution).

2. Via ActionProvider inside CNF.

I wish to remove all contributions in the additions section (mainly by objectContribution) and Import/Export actions (via ActionProvider).

To achieve the first aim, set the navigator viewer subnode <popupMnu allowsPlatformContributions=”false” >…</popupMenu>.

To achieve the second goal, remove the following insertionPoint from <popupMenu />:

  1.  
  2. <insertionPoint
  3. name="group.port"
  4. separator="true">
  5. </insertionPoint>
  6.  
  • Share/Bookmark
Apr 30

When setting up headless build in eclipse, you may encountered an error like:

C:\plugin-build\build-target-3.4.1\eclipse\plugins\org.eclipse.pde.build_3.4.1.R34x_v20080805\templates\headless-build\customTargets.xml:18: java.net.MalformedURLException: no protocol: ${eclipseBaseURL}

According to my solution, this is caused by a relative path when you invoke antRunner. For exmaple, if you use a relative path to set the builder:

-Dbuilder=pnstool
or
-Dbuilder=../pnstool

Then the error will appears. If you use an absolute path, the error will be fixed. An example is below:

java -jar %ECLIPSE_HOME%/startup.jar -application org.eclipse.ant.core.antRunner -buildfile %ECLIPSE_HOME%/plugins/org.eclipse.pde.build_3.4.1.R34x_v20080805/scripts/build.xml -Dbuilder=c:/plugin-build/pnstool

  • Share/Bookmark
Mar 15

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.

  • Share/Bookmark
Mar 10

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:

  1.  
  2. //……
  3. int pageIndex = addPage(editor, new MyEditorInput(stepInfo));
  4. setPageText(pageIndex, stepInfo.getName());
  5. setActivePage(pageIndex);
  6.  
  7. // start to set closable property
  8. Composite container = super.getContainer();
  9. if(container instanceof CTabFolder){
  10.         CTabItem tabItem = ((CTabFolder)container).getItem(pageIndex);
  11.         tabItem.setShowClose(true);
  12. }
  13. // voila! done!
  14.  
  • Share/Bookmark
Mar 03

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:
    1.  
    2. protected void createActions() {
    3.         super.createActions();
    4.         PDESelectAnnotationRulerAction action = new PDESelectAnnotationRulerAction(getBundleForConstructedKeys(), "PDESelectAnnotationRulerAction.", this, getVerticalRuler()); //$NON-NLS-1$
    5.         setAction(ITextEditorActionConstants.RULER_CLICK, action);
    6. }
    7.  
  • Share/Bookmark