Over a million developers have joined DZone.

Dynamic JFace XML TableViewer Tutorial

DZone 's Guide to

Dynamic JFace XML TableViewer Tutorial

· Java Zone ·
Free Resource

The following tutorial will show you how to build a dynamic JFace TableViewer driven from an XML file. The beauty of this solution is that your data model is decoupled from view logic so when the XML data changes you don’t need to change the concrete code.

It’s a pretty simple tutorial which should take around 5 – 10 minutes to complete.

Step 1. Create a new project in eclipse 3.4

Open Eclipse -> Click File -> new Plug-in project -> Next

To keep the examples simple type galang.research in the project name and click next. You can type any name you want though you’ll need to factor this into all the code samples I will provide.

Select Yes in the Rich Client Application section, click next.

Select RCP application with a view, click next.

Select Add Branding.

Click finish, then Yes.

Unzip the file located at the URL below and save the test.xml within the zip file as /temp/test.xml to your local pc.


Right click project and configure build path, link source, then click browse and select the src location to where you have unzipped the file above.

Enter srcExt fo folder name

Your package explorer should look like this.

Modfy View.java in the galang.research package with the following code.


* This is a callback that will allow us to create the viewer and initialize

* it.


public void createPartControl(Composite parent) {

viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL


viewer.setContentProvider(new RowContentProvider());

RowLabelProvider labelProvider = new RowLabelProvider();





And add the following imports to View.java

import galang.research.jface.RowContentProvider;

import galang.research.jface.RowLabelProvider;


Double click plugin-xml and click the Lanch eclipse application.

Congratulations, you’ve just completed this tutorial. Have a play around with the /test/temp.xml and see how it dynamically impacts the RCP application after restarting it.

From http://ggalangblog.blogspot.com.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}