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
Feb 03

After installing Ubuntu 9.10, eclipse became naughty. I tried to create a Java Project. However, mouse-click on Next/Finish buttons didn’t work. The buttons got focused, but no response. So you have to press ENTER or SPACE to actually press the buttons.

A quick fix here: create a shell script. For example, eclipse.sh:

export GDK_NATIVE_WINDOWS=1
/home/frankdu/Developer/eclipse/eclipse

Then add executable permission to the file: chmod +x ./eclipse.sh

Every time you run eclipse.sh to launch eclipse. At least we can be happy for a while. Please see http://www.eclipse.org/forums/index.php?t=msg&goto=498640& for more information.

  • Share/Bookmark
Dec 21

The source code can be checked out with CVS or subversion. I assume that you are running eclipse. We will use the CVS tool.

1. Open the CVS view: Window -> Show View -> Other -> CVS -> CVS Repositories

2. Add a new repository location, using the settings below:
Host: dev.eclipse.org
Repository path: /cvsroot/eclipse
User: anonymous
Connection Type: pserver
Port: use default. If it doesn’t work or you are behind firewall, use 80.

And, that’s it! It should works now.

  • Share/Bookmark
Dec 21

Since eclipse 3.5, you will find 3 versions for Mac OS X users: carbon, cocoa, and cocoa-64.

A simple note here: Install carbon version for Leopard and earlier versions. Try Cocoa 64-bit for Snow Leopard.

It took me a couple of minutes. Therefore, a quick note here.

  • 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 25

Let’s say you need to dynamically adjust a widget size, and then update scroll bar information. Things are pretty simple, if we understand how eclipse layout works.

I have a PageBook widget, and wish to resize the form page as selection changes. Here is the important part:

  1.  
  2. // other code
  3. pageBook.showPage(parent);
  4. Point computeSize = pageBook.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  5.  
  6. // the following two statements are very important, because they will tell swt/jface how to layout.
  7. GridDataFactory.defaultsFor(pageBook).align(SWT.FILL, SWT.TOP).span(2, 1).hint(SWT.DEFAULT, computeSize.y + 20).applyTo(pageBook);
  8.  
  9. pageBook.layout(true, true);
  10.  
  11. // reflow the form
  12. form.reflow(true);
  13.  
  • 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