CabSetupCreator

Lately on current project we needed a tool, that will take our implemented classes, files and libraries, pack them all into one .cab file, which could be then installed on the remote WinCE/WM device. Well, there is such tool. It is called QuickCab. It has newest version 2.0. But the problem is, this is free for non-commercial use. So my customer had to buy this. Okey, price was not so high at all, so we decided to test this. And it didn’t help us a lot, because there were some bugs in it, like for example when you copied whole directory, the files in that directory went to first directory, that was nested in copied directory…well in summary we were not decided to use it. And it’s okey. We said, we don’t have such a lot files at all, we can for our first tests simply copy the files on the device and it will also work. But this was annoying me all the time (so the last week). This “copy thing”, it just don’t look good. I mean, okey we can do it during development, especially when someone changes 1 .jar file, so we have to override 1 .jar file on the device, and that’s it. But finally we will need such tool, that will create .cab files thought. So I’ve started to explore internet on the last weekend to find out, what are our options. Well….there aren’t so large. When someone offers .cab file creator, then it appears that this is free-trial-version for personal use, or something like this…So, I thought, okey…We need a tool, which will take those files we need (mostly jars and JNI libraries) and create from them an inf-file, which can be then used to create .cab-file with Microsoft’s cabwizard. It didn’t sound so bad on saturday morning (about 9:00). I went at hotels restaurant, eat my breakfast, went back to my room, and tought…ok…we are developing in java, using eclipse…hmmm…I thought this is not a bad idea to create a tool integrated with our environment…so the right answer was of course eclipse RCP.

So, the effect of this 2 days work at weekend is below. This is the first version of the tool, so be gentle with your comments and opinions. First of all it takes what was good in quickcab – GUI organisation, but it is whole new project, and everything was designed from nothing. So, I didn’t re-engineered quickcab (quickcab works on .NET), cabsetupcreator works on eclipse RCP :) Those are whole different stories.

Cabsetupcreator in version 1.0 has 4 main views :

DeviceFilesView – where you simply organise your devices directory/files structure, by creating directories or simply “adding” files from your local PC to devices directories/files structure :

New added files are shown in red foreground color.

ShortcutsView – this is where you organise your shortcuts, name it and so on. You can create shortcuts from the files you copied into devices directory/files tree structure in DeviceFilesView :

New added shortcuts are shown in red foreground color.

RegisterView – here you organise your register entry. You can add new keys, values to keys and so on.

New register entries are shown in red foreground.

CreateView – here you simply choose application name (it’s needed for cabwizard, so don’t forget about it), provider (this is also a must), then you choose where your cab file should be created, and you give the path to the cabwizard. If you don’t have cabwizard then don’t worry. Only inf-file will be created. You can borrow cabwizard from your buddy in front of you (who have MS Visual Studio), and generate your .cab file.

Okey, I think that’s all…

Ah, yes…installation notes and links… :)

REQUIREMENTS:

1. you have to have eclipse RCP running version (I’ve used eclipse indigo 3.7 for RCP and RAP developers), so you can download it from eclipse page

2. you have to have jdk(jre) 1.5 at least , but if you are java developer you know, what I mean

INSTALATION :

1. Download eclipse .jar plugin from CabSetupCreator_1.0.0.201112132306.jar

2. Copy this file to eclipse’s plugin directory

3. start/restart eclipse

4. choose perspective -> CabSetupCreator

YOU CAN CREATE .CAB FILES (or at least inf-files, if you don’t have cabwizard) AUTOMATICALLY.

CabSetupCreator is free for use (personal/business or both :) ). Thanx in advance for any comments about it (if you successfuly launch it).

myBatis, derby and eclipse RCP

Lately I was working on an eclipse RCP application that uses myBatis for ORM. And I decided to write a small tutorial on how to bind myBatis + derby + eclipse RCP together. This is small tutorial for beginners. You can read it from here :

binding mybatis and eclipse RCP

Source code for this is under following link :

Source code for the tutorial

Cool eclipse RCP layout

By default eclipse comes with an old-fashioned layout design. What does it means? Well, perspective bar is not layed down on the right side in relation to cool bars. Views and editors parts have title in a rectangle (not nice-rounded), perspective bar is not resizable, take a look at this picture :

And it is okey, if you like the old-fashioned eclipse. But I don’t like it. Especially, when I have this opportunity, when I can do it look much better, with this cool resizable perspective bar, or rounded title tabs for views and editors. So, here is what you have to do, to make such layout :

  1. Right click on your main project
  2. From the context menu choose : New -> File
  3. In the opened dialogbox write in the File name field a name of the customization file (for example mine is serda_customization.ini) – here be sure, that this file will be located in the root folder of the main project. And then click Finish button.

Now edit this file and add following lines :


org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight

First line tells eclipse workbench to NOT use traditional style. This is were the titles of the view windows will be nice-rounded (not traditional = not rectangled).

Second line tells where to put perspective bar.

Of course, to use perspective bar, you have to activate it in the workbench window. So, open the class ApplicationWorkbenchWindowAdvisor and here in the method called preWindowOpen check if you have following lines of code :


configurer.setShowCoolBar(true);
configurer.setShowStatusLine(true);
configurer.setShowPerspectiveBar(true);

And now there is only one thing to do. You have to adjust your plugin.xml configuration file. So let’s open it. Click it twice in the Package Explorer view and go to the tab plugin.xml (this will edit the code of the file). Here, you have to locate the tag <extension id=product point="org.eclipse.core.runtime.products" … And in this extension you have to add new extension called "preferenceCustomization". See the code listing below. It shows only the extracted extension with id "product" (THIS IS NOT THE WHOLE plugin.xml source, JUST the extension) :


<extension
         id="product"
         point="org.eclipse.core.runtime.products">
      <product
            application="Serda.application"
            name="Simple Eclipse RCP Dictionary Application">
         <property
               name="windowImages"
               value="icons/alt_window_16.gif,icons/alt_window_32.gif">
         </property>
         <property
               name="preferenceCustomization"
               value="serda_customization.ini">
         </property>
      </product>
   </extension>

And now just run the application. See the picture below for reference :

Centering eclipse RCP application window

When you start your eclipse RCP it is usually located in the top left corner of your screen. And it’s quite okey, if you like it so. I for example don’t like this kind of behaviour. I wanted, that this application window will be located in the center of the screen. So, here is what we will do.

  1. Open the class ApplicationWorkbenchWindowAdvisor
  2. Add a method postWindowCreate
  3. Modify this method appropriate like in the listing code below


@Override
public void postWindowCreate() {
    super.postWindowCreate();
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    Shell shell = configurer.getWindow().getShell();
    Rectangle rectangle = configurer.getWindow().getWorkbench().getDisplay().getPrimaryMonitor().getBounds();
    
    int minWidth = 800;
    int minHeight = 600;
    int x = 400;
    int y = 100;
    
    if(rectangle.width > 0) {
        x = (rectangle.width - minWidth) / 2;
        y = (rectangle.height - minHeight) / 2;
    }
    
    shell.setBounds(x, y, minWidth, minHeight);
}

And that’s it. Shortly speeking the most valuable line is here line :


Rectangle rectangle = configurer.getWindow().getWorkbench().getDisplay().getPrimaryMonitor().getBounds();

This line gets bounds of the primary monitor. You could ask, why primary monitor? Is it not the same as :


configurer.getWindow().getWorkbench().getDisplay().getBounds();

Well, no. It could be the same. If you are sure, you, or someone, who uses your application is not going to use two monitors. If this is true. Then it’s okey. You could get the bounds for your application directly from display object. But, if someone, who likes it, will connect additional monitor to the machine, will get then "interesting" effect, when running this application.

Couple of words about OSGi and Eclipse RCP

Lately I’ve been working a lot on eclipse RCP. Well, in matter a fact in eRCP, but by the way eclipse RCP was also the point of interest. Anyways, I decided to work a little bit harder on eclipse RCP, because it seems to me, that this is a very interesting technology (not mentioning, that eclipse RAP is rising and starting to shine).

So what is Eclipse RCP anyway?

Eclipse is a huge programing environment. It was a "gift" from IBM for community. With Eclipse IDE you can build applications in many languages, from Java, through Python and C++ (by installing appropriate plugins, or simply downloading correct distribution). And eclipse RCP is a kind of framework, which is based on OSGi idea (Eclipse’s implementation of OSGi is called Equinox). This gives to the Java programmer a major tool for creating desktop applications.

  • OSGi - Open Services Gateway initiative – this is a technology based on an idea of modularity. Applications made with this idea are build with modules, which in case of Eclipse are called bundles. Those modules are working one with another, they are living in runnable soup. The very best of it is, you can shut down / start / disable / install / uninstall separate plugins. When the whole application is well-designed, then shutting down one plugin/bundle does not harm another ones. That’s the whole point of modularity.
  • Equinox – this is simply an implementation of OSGi made by Eclipse team.

Controling eclipse RCP application from within OSGi console

First of all you have to enable OSGi console. So, click with right mouse project you are currently developing and from the context menu choose Debug As -> Debug Configurations, here you have to change some settings. See picture below for reference :

Next, in the opened dialogbox you have to choose Arguments tab, and in the Program arguments field add the "-console" string at the end of the entry in this field (see picture below for reference) :

Then, after starting our application in debug mode in view Console you will see appropriate OSGi console mark : "osgi>" :

And here the fun with OSGi console begins. Write there command ss. This will list whole bundles currently running in application environment (I call it personally "bundle soup"). See picture below for reference :

Our sample application (Serda – [S]imple [E]clipse [R]cp [D]ictionary [A]pplication) has already three plugins – itself, main menu plugin and commands plugin. Now, let’s imagine that you have to change some menu (reorganize items) without shutting down the application. In the world of standard desktop applications it is simply impossible. In the world of bundles it is common behaviour. Let’s write in the console :

disableBundle SerdaMainMenu

or simply :

disableBundle 4

That is how we disable main menu plugin.

Now refresh the state of main menu plugin, by writing following :

refresh 4

or

refresh SerdaMainMenu

personally, I prefer shorter commands (those with numbers :) ).

And now, let’s list our bundle soup (remember? by writting ss command in the console). Main menu bundle has state DISABLED :

Check the application now – it’s really disabled. There is no main menu in the application :

Okey, suppose we have changed the main menu. Now, turn it on. In OSGi console write :

enableBundle 4

refresh 4

Check the application again. Hey, main menu is back there :

Below some useful OSGi console commands :

  • help – lists OSGi help
  • install – installs bundle from the given URL
  • uninstall – uninstalls bundle
  • disableBundle – disables bundle
  • enableBundle – enables bundle
  • refresh – refreshes the state of a bundle‘a
  • ss – lists all bundles in the running application bundle soup

Useful links :

  1. http://www.eclipse.org/rap/
  2. http://www.eclipse.org/home/categories/rcp.php
  3. http://www.osgi.org/Main/HomePage
  4. http://www.eclipse.org/equinox/

Examples, where Eclipse RCP is used :

  1. http://www.bioclipse.net/
  2. http://jcommander.sourceforge.net/
  3. http://mytourbook.sourceforge.net/mytourbook/
  4. http://www.xmind.net/
  5. http://zdt.sourceforge.net/
  6. http://www.birt-exchange.com/be/home/
  7. http://www.atante.pl/
  8. http://www.baybreezesoft.com/index.php
  9. http://www.bsiag.com/en/home.html
  10. http://www.deltopia.com/compare-merge-sync/linux/

There are many others. Some are commercial, some not. Some companies don’t even tell, that they use eclipse RCP. So, about them we don’t know. For example my current customer is using this technology, and is not listed in the official eclipse RCP companies list.

The major plus of eclipse RCP is that, it can be started on multiple platforms. Usually code running on Linux is well ported on Windows. You can use also delta pack on Linux, so, you can build windows distributions of your application on Linux machines.

Follow

Get every new post delivered to your Inbox.