Wednesday, April 10, 2013

Adding additional composites to Eclipse editor

I've been working on DSL editor that we have in our product. One of the features we wanted to add is a way to examine AST generated based on expression. This AST viewer would allow user to examine parts of language statement and see what's going in the tree so he can of sort of debug each step of the execution.

 On the UI side we needed a way to present the AST tree and synchronize it with the statement that is being entered. One way to do it is add a view that would synchronized with editor, however drawback in this approach is not seeing the view when editor is maximized. What I wanted to achieve is something that Eclipse Compare editor offers - and editor which is split into two parts. I started looking at code. It's pretty involved and had a lot things that I really didn't need. I took a closer look at our DSL editor that extends TextEditor and decided to play with createPartControl(Composite parent) method since this is where UI elements were build. The result was just what I needed.

What I ended up doing is shown here:

public void createPartControl(Composite parent) {
   SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
   sashForm.setLayout(new FillLayout());

   new ASTComposite(sashForm, SWT.BORDER);
As you can see SashForm is used to achieve split pane. Top pane is where editor is added, and bottom is where any Composite goes, in my case it's a specialized Composite that has TreeViewer holding AST of the expression. Pretty simple and effective.

Monday, April 8, 2013

Making location in target definition version agnostic

When adding custom target definition location make version of the software site "0.0.0" in order to pick up latest version. This works just like when defining feature that your feature depends on to pick up latest version.

Blogger Syntax Highliter