Kategorie: Programmieren

EMF: Object is not contained in a resource

I had a small problem saving my EMF model to XML. I got the error message “The object … is not contained in a resource”. The solution is simple. In the EMF editor just set containment to true for the reference: Done! After that, the object was saved correctly in the XML file.

weiterlesen »

setAccelerator(SWT.CTRL | ‚O‘); //not working!

In my current RCP application I had a problem that the menu key shortcuts did not work correctly: When I started the application and pressed the shortcut, nothing happened. After I opened the menu once, suddenly everything worked! I created the menu item in the “ApplicationActionBarAdvisor”: actionOpen.setAccelerator(SWT.CTRL | ‚O‘); So what is the problem? It …

weiterlesen »

org.eclipse.swt.SWTError: No more handles

In our current project we came across the following error, when we opened multiple of our editors in a RCP application: Never seen this one before. Most sources in the internet mentioned something about “not disposing SWT resources”. However this happened when we opened the editor. So a “not disposed” problem was very unlikely. Strange …

weiterlesen »

Color Themes for Eclipse

When it comes to programming I like dark backgrounds in the editor. Setting the colors in Eclipse is a lot of work and the settings only apply for a certain workspace. If you create another workspace, all is set to default colors. But there is a simple solution: Eclipse color theme After installing the plugin …

weiterlesen »

Save and load an EMF model to an XML file

Here are two code snippets which give you an example how to save and load an EMF model to an XML file. Note that "Data" is my EMF model object. Save EMF to XML file: public void saveData(String fileName, Data data) throws IOException { Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; Map<String, Object> m = reg.getExtensionToFactoryMap(); m.put("daform", new …

weiterlesen »

Eclipse RCP: Forms Section not expanded

Sometimes strange things happen in Eclipse. Like this one in WindowBuilder, the best tool for designing GUIs in Eclipse (via). I created a Forms API section in the program, but when I executed the program, the section was not expanded, not content was shown: In the properties editor, expanded was set to true. What to …

weiterlesen »

Java: Handle Exceptions from Threads

In this post I want to describe handling exceptions from threads with the ThreadGroup class and the uncaughtExceptionHandler. First we create a Thread which does useful stuff and throws an exception at some time: public class PfostenThread implements Runnable { @Override public void run() { for (int i = 0; i < 1000000; i++) { …

weiterlesen »

Dynamically create QR codes using PHP

Today I wrote a blog entry about QR codes in our eKiwi.de blog. There we where using an online tool to create the QR code. If you want to create QR codes dynamically on your website, you can use the class from http://phpqrcode.sourceforge.net/ The usage is pretty simple. In this example I created an image …

weiterlesen »

Java/RCP – okPressed in JFace dialog

Sometimes JFace and RCP are not straightforward. At least not for me. For example the JFace dialog: It features an OK and Cancel button by default. If you want to do something when the user clicks the OK button, for example save the values from control elements to variables, you can overwrite the "okPressed" method: …

weiterlesen »

C#–Read STDOUT from a console application

Recently I needed to start a console application from C#, wait until the execution has finished and read the output back. Here is a simple way this can be done. The first thing is to run the process and attach an EventHandler for the finish of the process: Process process = new Process(); process.StartInfo.FileName = …

weiterlesen »