Eclipse Yoxos Services Downloads Blogs About
Home > Blogs >

Archive for February, 2009

on Feb 5th, 2009Migrating your p2 application to Eclipse 3.5

Anybody building plugins / products / tools based on Eclipse, Milestone 5 is a pretty important time.  The API should be stable, most of the features should be spelt out, and the new splash screen is here icon smile Migrating your p2 application to Eclipse 3.5 .

If you haven’t been keeping up-to-date with the milestone builds, you should really consider getting M5 and setting it as your target. There may be a few changes needed.  I discovered these changes while helping a few friends port their code based on p2, to Eclipse 3.5.  I thought I would document some of the hurdles we had to go through.

  1. Version is now called Version. To be more specific org.osgi.framework.Version is now called org.eclipse.equinox.internal.provisional.p2.core.Version.   p2 uses the new Version class everywhere, so if you use p2, you will likely have to update your import statements, and in some cases, your plug-in dependencies.
  2. Because of the changes to Version, VersionRange has also changed. Update org.eclipse.osgi.service.resolver.VersionRange to point to org.eclipse.equinox.internal.provisional.p2.core.VersionRange.
  3. URL are now URIs.  Next to version, this is probably the  biggested change.  This is a little easier as you should not need to touch your dependencies for this one.
  4. Metadata interfaces.   If you used ProvideCapabilities, RequiredCapabilities, TouchpointData, License, Copyright, or anything else in the metadata bundle, you will likely need to put an I on the front.  That is: IProvidedCapabilities, IRequiredCapabilities, etc…
  5. Changes to the Query API.  The Query API has a little more structure to it.  The most common use of Query was to Extend Query and override isMatch.  IsMatch would then be used as a filter to select / reject elements.  However, this was not the only use. You could also extend Query and override perform to build a query that requires more context.  To make this more explicit, two types of queries were created.  MatchQueries and ContextQueries.  How does this affect you?  Likely you just have to extend MatchQuery (instead of Query).  However, if you created a custom perform, then extend ContextQuery.
  6. There were a few other small changes (method name changes, etc..).  

I think all these changes are positive, and they should make for a more stable base moving forward.

on Feb 5th, 2009Not running. Not Board.

As you may have seen, Mike posted the nominees for the 2009 elected board members race the other day. The observant reader may also have noticed that my name is not on the list for re-election.  I’ve been on the Foundation Board of Directors for some time now. It is great fun and an awesome learning experience.

There are a few factors in my decision to not run.

  • It’s time to make some room for others.
  • EclipseSource, our new company, will take over the Innoopract Strategic Membership and I will act as the alternate to Jochen Krause our formal representative.
  • Participating in the Board requires considerable time and effort.  It is extremely rewarding but nonetheless hard to manage while creating a new company and participating heavily in the Eclipse community.

Being on the board is a fantastic experience and a privilege.  I’ve learned vast amounts from some of the community’s and industry’s best. From time to time I may even have had an impact and helped to improve things.

The board discussions are always, uhhh, lively with a wide range of opinions and perspectives.  It is a large but functional board and Mike is doing a great job of balancing giving people their say and avoiding (well, minimizing) rat-holes.

As Mike points out, there is an impressive roster of nominees. Should be an excellent race.  Best of luck to all the candidates.

on Feb 3rd, 2009Databinding: A Custom Observable for a Widget

The introduction of the databinding framework in Eclipse 3.3 is with no doubt one of the most useful tools in the hands of the form developer. The ability to transform and validate user input in such a flexible and reusable way is a great enhancement. But where there is light, there is shadow. Sometimes there is just no IObservable available for your target or model object. This blog entry will demonstrate how easy it can be to create a custom IObservable for a DateTime widget.

The DateTime widget represents one value: a java.util.Date. This Date object is the one we want to get and set on the target (target being the UI widget). Therefore we wrap the DateTime in an IObservableValue by extending the AbstractObservableValue class. Essentially an IObservable* offers methods to get and set data, to determine the type of data and to register listeners to be notified of changes. The following code demonstrates a skeleton implementation of an IObservableValue.

public class DateTimeObservableValue extends AbstractObservableValue {

  private final DateTime dateTime;
  Listener listener = new Listener() { ... };

  public DateTimeObservableValue(final DateTime dateTime) {
    this.dateTime = dateTime;
    this.dateTime.addSelectionListener(this.listener);
  }

  @Override
  protected Object doGetValue() {
    // the utility method creates a Date from the DateTime
    return dateTimeToDate();
  }

  @Override
    protected void doSetValue(final Object value) {
      if (value instanceof Date) {
        // the utility method sets the date on the DateTime
        dateToDateTime((Date) value);
      }
  }

  @Override
    public Object getValueType() {
    return Date.class;
  }

  @Override
    public synchronized void dispose() {
    this.dateTime.removeSelectionListener(this.listener);
    super.dispose();
  }
}

The implementation details are not very special. The getValueType() method has to return the type represented by this IObservableValue (which is the type Date). The do methods set and get the Date value. Since the observable has to propagate changes in the DateTime widget as soon as they ocurre, we attach a listener on the DateTime widget to inform any registered IValueChangeListener of the event. The listener implementation looks like the following:

Listener listener = new Listener() {

  @Override
  public void handleEvent(final Event event) {
    Date newValue = dateTimeToDate();

    if (!newValue.equals(DateTimeObservableValue.this.oldValue)) {
      fireValueChange(Diffs.createValueDiff(DateTimeObservableValue.this.oldValue, newValue));
      DateTimeObservableValue.this.oldValue = newValue;
    }
  }
};

In the DateTime listener we inform any interested IValueChangeListener of our DateTimeObservableValue. In order to avoid unnecessary propagation of update events in the databinding context, we compare the last set Date in the IObservableValue with the new value. Next we create a ValueDiff from our new date value and fire the the value change event. The advantage of listening to the changes in the DateTime widget, is that we are able to fire events which are either invoked by the user changing the DateTime widget or by programmatic changes of the IObservableValues wrapped Date.

You can download the full listing of the observable class here: DateTimeObservableValue.zip

As we can see, it is quite easy to write a custom observable for any kind of widget or datastructure, represented by a single value…  So, how do you embed your data in custom observables? Any obstacles you had to overcome? Problems you faced? Share them with us. icon smile Databinding: A Custom Observable for a Widget

on Feb 2nd, 2009Very basic dependencies

We recently moved our continuous integration builds to a new server. The builds are set up self-contained or have only little dependencies to files outside their workspace. So it shouldn’t be a big deal: Just set up the new projects in your CI server and copy over the settings from the old projects, right?

And if you then get an error that even Google knows only 2 pages of useless results about, you start scratching your head. At least I did after I got this one:

java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3346 or swt-pi-gtk in swt.library.path, java.library.path or the jar file

It gets a bit more mysterious when you start looking for the swt-pi-gtk libraries, locate them in one of the SWT fragments, and you make sure that all your “-os” “-ws” and “-arch” options are set correctly.

To make the long story short, the solution was to install GTK on the new server…

on Feb 1st, 2009Programming Competition in Eclipse

On Saturday, I volunteered a few hours of my time at the University of Victoria to help organize a Programming Competition.   The office mate I had throughout my PhD, Sean, did the real work, but I put together a few problems, helped with the judging, and debugged a few technical problems.

If you haven’t seen (or heard of) a programming competition, it’s pretty interesting. Students are given word problems and some sample input / output files. The have to code solutions to the problems and pass the automated tests. (The real tests are run on a server so the students can’t see the test cases). Many readers of this blog may think the problems are easy (shortest path between cities with constraints such as gas station locations, intersecting shapes, and sub-string matching, are a few examples), but in the atmosphere of a competition, these can be quite challenging. Especially since:

  1. Output must match exactly. There is no room for misspelled words, capitalization inconsistencies or even extra white space.   In fact, the server just runs a diff, and you are either right or wrong.
  2. The students don’t have Internet access.  You either know how to code Dijkstra’s  algorithm, or you don’t.
  3. Once you submit your solution, the server either returns Correct or Wrong Answer.  No stack trace, no explanation of what went wrong, no bugzilla with steps to reproduce.

Overall I thought the competition was a success.  Everyone (even those that have only been coding for a few months) solved a problem, and one student (a second year) solved all 7 problems in the 5 hour time limit.

But something caught my eye during the competition.  Nobody uses the Eclipse IDE.  In fact, most students just us VI and the command line. Aside from the obvious reason (real programmers don’t use IDEs icon smile Programming Competition in Eclipse ), Eclipse actually gets in the way during these competitions. Students are constantly checking their problems by re-directing input and output through their programs, and then running diffs on the results.  Doing this in the Eclipse IDE is not simple, and simplicity is key.

Of course, it would be pretty easy to write a plug-in that would do this. You could even bring up the synchronize view if the output is not correct. As well, we could probably integrate the server software (A Java application that runs the test cases) with Eclipse, so students could submit their programs right from the IDE.  Maybe these plug-ins already exist, I don’t know. These might be good candidates for the Eclipse SOC project (an Eclipse project intended to bring students together).

As for those of you who believe that ‘editing is still the way to code’, there is always the VI plugin for Eclipse. I wouldn’t last 10 minutes in Eclipse without this tool.

© EclipseSource 2008 - 2011