Packaging and branding an Eclipse RCP application

Our contact list application is up and running, but until now we can only run it from our development environment. In this section, we will see how we can transform our application into a self-contained product that can be distributed to users.

In order to achieve this, we need to create a product configuration file that describes how our product will be packaged and what it will contain. Fortunately, just like with the other plugin development configuration files, Eclipse has a wizard and a special editor for the product configuration file. To create the file using the wizard, right-click on your RCP application project in the PackageExplorer view, and navigate to New | Product Configuration. Make sure you are utilizing the Plug-in Development perspective in order to see these options. In the wizard window, type in contactlist.product as the product configuration filename. The wizard allows you to use an existing product or launch a configuration as the base configuration for the product. Because we have already launched the product inside our development environment, we already have a launch configuration that fits our basic needs. Select Use a launch configuration and select the ContactsList configuration. When you click on Finish, the product configuration editor will open, as shown in the following screenshot:

Packaging and branding an Eclipse RCP application

Fill the General Information section with the same values as the ones shown in the previous screenshot. In the Product Definition section, let's create a new product by clicking on the New button. Click on Browse to select ContactList as the defining plugin of the product. Leave Product as the product ID. In Application, select ContactList.application. Click on finish. We haven't used features in our product, so leave plug-ins selected as the product configuration.

Switch to the Dependencies tab of the product configuration editor. The list should already contain a number of plugins; ContactsList among them. This information came from the launch configuration we pointed to the wizard. You can check the list and add/remove plugins if necessary. Let's leave the ones that came from the launch configuration.

This should be enough for us to generate a bundle that contains our contact list application. Save the product configuration editor, right-click on the ContactsList project in the Package Explorer window, and select Export. Under the Plug-in Development category of the Export wizard, select Eclipse product and click on Next.

In the next page, point to the contactlist.product configuration file we just created in the Configuration field. The Root directory field determines the name of the folder that will contain our product. Because we want to generate a single file, select Archive file in the Destination field and point to a valid filename in your system. The .zip extension will be appended to the path you insert here. We don't want to include the source files in our product, so uncheck the Export source box. Your wizard page should look like the following screenshot:

Packaging and branding an Eclipse RCP application

Click on Finish to start generating the product. When done, browse to the location you have pointed to in the wizard. You will find a ContactsList.zip file. Extract it and you will find an Eclipse-executable eclipse.ini configuration file and folders named configuration and plugins. As you can imagine, the plugins folder contains all the plugins added in the product configuration editor, including the ContactsList plugin. Double-click on the eclipse file and you will find our contact list application running outside of the development environment.

Branding an Eclipse RCP application

You have probably found it odd to have an executable named eclipse for an application called ContactList. The lack of icons and splash screens would also be a problem if this was an actual product. Let's fix these issues. Go back to the product configuration editor by double-clicking on the contactlist.product file. In the Launching tab, you will find a Program Launcher section. This is where you personalize your launcher. Select a proper name for our application. If you wish to add a launcher icon, add it to the project folder (the RCP application template generates an Icons folder; you can put the launcher icon there), and point to it in the Icon field. You can also specify launching arguments for both the application and the Java virtual machine in the Launching tab. Note that these configurations are specific to each platform (Linux, Mac OS X, Solaris, and Win32).

The Splash tab allows you to add a splash screen in your application. Splash screens are a useful feature for applications because they let users know that work is actually being done during the application's startup and it hasn't hung. To add a splash screen, one of your application's plugins must contain the image that will be used as the splash screen and as a bitmap file named splash.bmp in the plugin's root folder. Make sure the splash.bmp file is being included in the plugin's build by opening the Plug-in Manifest Editor window, switching to the Build tab, and ensuring the splash.bmp entry in the Binary Build list is checked. Once you have the splash screen file in place and properly included in the Build tab, just refer to the plugin in the Location section of the Splash tab. You can also include a progress bar or messages telling which part of the application is currently being loaded, similar to the ones in Eclipse.

The Branding tab allows selecting application window images. These images will be used in your operating system's toolbars and taskbars to represent your application. You can also customize the About Dialog message and image in this tab. To display the About window, you have to create an entry in the applications menu. because the About window still hasn't been ported to the command framework, we have to create the entry in the ApplicationActionBarAdvisor class. The following code shows an example of how the class can be implemented in order to create a Help menu with an About Contact List entry that displays the message and the image indicated in the contactlist.product file. The imports section is omitted.

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchAction aboutAction;

  public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {
      aboutAction = ActionFactory.ABOUT.create(window);
    }

    protected void fillMenuBar(IMenuManager menuBar) {
      MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
      menuBar.add(helpMenu);
      helpMenu.add(aboutAction);
    }
}

You can also add a welcome page to your application in the Branding tab, similar to the one that appears when you start Eclipse for the first time. By clicking on the New button in front of the Intro ID field, you will be presented with a welcome page wizard window. Select the current plugin as Target, select an ID for Intro, and click on Finish. This will create implementations for the org.eclipse.ui.intro and org.eclipse.ui.intro.config extension points in order to add the welcome page to your application. The welcome page's contents are described in an XML file placed in the plugin's root, named introContent.xml. Unfortunately, there's no specific editor for this file, so you will have to create and edit it manually.

Tip

The introContent.xml format's contents are outside the scope of this book, but you can find plenty of information about it in the Platform Plug-in Developer Guide article by going to User assistance support | Welcome at help.eclipse.org.

Last but not least, the Licensing tab allows you to specify a license text and URL for your application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset