Yearly Archives: 2013

5 posts

Registering EMF models in plain java

Using Eclipse EMF/Ecore models inside the Eclipse Platform is quite easy. Loading an XML/XMI serialized model file is only a matter of some lines of code. The most interesting thing about this is that the whole Eclipse platform can handle the registration of models and model factories for you. So instead of knowing what model type you are loading, it will be detected and the right model factory will be used for loading and creating your model instance. Even better is the fact that also derived model objects can be loaded that way.

Just image you are writing a model A and extend object in the model B. So you can create a model instance which contains objects from model A and B and just serialize it to XML. Loading it back will of course give you model objects of type A and B. Although initially only model A existed and B was an extension using derivation. For this to work the resource mechanism of EMF must need to know which namespace is handled by which resource package and factory. If you are running inside an Eclipse Platform this is easily done using the extension mechanism. And the “genmodel” file and generator will automatically create the correct code and “plugin.xml” for this setup.

The problems start when you are outside the Eclipse Platform and running in a plain Java application. The default way to go is by registering all EMF models somewhere before loading the serialized models:

public void setup () {
  MyModelPackage.eINSTANCE.eClass();
}

Continue reading

Fixing the theming issue with Eclipse RCP applications in E4

It seems that migrating from Eclipse RCP 3.x to E4 (Eclipse 4.x) is not a quick win. If you already have an RCP based application the switch to E4 turns out to be a real problem. As is the E4 way if you want some sort of “custom” application that features some IDE components (like a perspective switcher or about dialog). It seems a bit strange that the migration from 3 to 4 is such a bumpy ride. Although there a are lots of tutorials, they mostly only scratch the surface of the task to convert a full blown RCP application. But this should be a rant on E4, I hope that the next releases improve that situation a lot.

When I migrated our RCP Application (OSTC from openSCADA) to E4 using the RCP bundle of E4. This seems not to be a real E4 application, but allows one to run a legacy, 3.x, application inside the new E4 environment. A quick it-just-works migration, still you miss all the E4 fun. But at the first start the user interface looked up bit garbled up. Some black line drawing artifacts. The tabs where a bit “dull” compared to the facy new tabs in E4.

The solution was pretty simple, the final RCP application was missing the bundle “org.eclipse.platform” which contained the themes and the necessary resources.

Fixing the Mint-X theme for Eclipse/SWT

If you are running Mint, Eclipse and you like the Mint-X theme, you might be a bit frustrated every time you open up Eclipse. Especially with Eclipse 4.2 the design of the toolbars is pretty messed up. See the launchpad bug entry: https://bugs.launchpad.net/linuxmint/+bug/1168281

eclipse1

Gladly this is only a minor glitch which can be fixed easily. Hopefully the change of the github pull request will find its way into Mint.

Issues with Eclipse Acceleo and sub-packages in the meta model

Today I stumbled over an issue that was unsolved in my workspace for some days now. Finally I got the time to fix it. I have a ECore meta-model which consists of three sub-packages and has no class in the main package. Generating model, edit and editor for this I had a nice start for my task. Then I wanted to generate code from this meta model and ran into a strange problem. On the console I simply got the following message when I tried to launch the Acceleo UI generator action:

The type of the first parameter of the main template named 'generateElement' is a proxy.

Due to some strange behaviour Acceleo was not able to read the meta-model definition when loading its templates, although the model itself was loaded fine. Trying to re-produce the issue with a new meta-model, everything seemed to work fine until I noticed the difference between my test model and the real model. The test model did have a class in the main package of the meta-model, while the real model did not. So the real model was like:

model
   -> sub1
       -> class1
       -> class2
    -> sub2
       -> class1
       -> class2

while the test model was:

model
   -> class1
   -> sub1
      -> class1

Adding a dummy class to my main package and re-generating all files (including new plugin.xml files) solved the issue with Acceleo. Although I am still not sure where the problem actually lies. It is not in the Eclipse Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=401075

Build your own SIP trunk with Asterisk and mISDN

The mission: “save some bucks by using a free PBX using a cheap isdn card”. Don’t try! Buy something working in the first place. But if you have to, here is one example how it can be done. There are, for sure, many others!

The idea was to replace trixbox using an AVM Fritz!PCI card with something more up to date and not that buggy. FreePBX Distro kicked itself out because of the issues with mISDN. Elastix brought in mISDN support but still failed in configuring it. Since the setup was for only 3 users for now and the idea was to later buy something more professional (I really hope it comes to this point), I used Starface free. It has 4 users and 10 extensions for free. Yet the free version only allows using SIP providers. Also it was not possible to buy a Patton SmartNode 4120 at the moment, which I still hope to get somewhere in the future. So I needed to build our own SIP trunk since the provider used (M-NET) does not provide SIP trunks as a product.

Continue reading