Time for action – creating a product

An Eclipse product is a branding and a reference to an application. The product also has control over what features or plug-ins will be available, and whether those plug-ins will be started or not (and if so, in what order).

Chapter 7, Understanding the Eclipse 4 Model created a product to bootstrap the E4 application (provided by the org.eclipse.e4.ui.workbench.swt.E4Application class) but this section will create a product that binds to the headless application created previously to demonstrate how the linkage works.

  1. Use File | New | Other | Plug-in Development | Product Configuration to bring up the product wizard.
  2. Select the com.packtpub.e4.headless.application project and put headless as the filename.
  3. Leave Create a configuration file with the basic settings selected.
  4. Click on Finish and it will open up headless.product in an editor.
  5. Fill in the details as follows:
    • ID: com.packtpub.e4.headless.application.product
    • Version: 1.0.0
    • Name: Headless Product
  6. Click on New on the right of the product definition section, which will launch a dialog to create a product. Fill in the dialog as follows:
    • Defining plug-in: com.packtpub.e4.headless.application
    • Product ID: product
    • Application: com.packtpub.e4.headless.application.id

    Note

    It may say id1, id2, and so on. This comes from the plugin.xml file in the previous step.

    Time for action – creating a product
  7. Click on Run on the top-right corner of the product to launch the product:
    Time for action – creating a product
  8. There will be an error reported java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter because the runtime can't find the required plug-ins. Switch to the Dependencies tab, and add:
    • com.packtpub.e4.headless.application
    • org.eclipse.core.runtime
    Time for action – creating a product
  9. Click on Add Required Plug-ins and the rest of the dependencies will be added:
    Time for action – creating a product
  10. Run the product and the same Headless Application should be displayed as before.
  11. Export the product, either via File | Export | Plug-in Development | Eclipse Product, or via the Export button at the top of the product editor, to a local directory.
  12. From the directory where the product was exported, run eclipse to see the message being printed. On Windows, run eclipsec.exe to see the output. On OS X, run Eclipse.app/Contents/MacOS/eclipse.

What just happened?

Using and running a product may not seem that different from running an application, but the key difference between the two is that an application is a start point and one which can be installed into an existing Eclipse runtime, whereas a product is a standalone system that can be run independently.

A product defines the look and feel of the application's launch icons, specifies what will be bundled, and how it is launched. The product then hands over control to an application, which executes the runtime code.

The editor is a GUI for the product file, which is an XML file that will look similar to the following:

<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="Headless Product"
   uid="com.packtpub.e4.headless.application.product"
   id="com.packtpub.e4.headless.application.product"
   application="com.packtpub.e4.headless.application.id" version="1.0.0"
   useFeatures="false" includeLaunchers="true">
   <configIni use="default"/>
   <launcherArgs>
      <vmArgsMac>-XstartOnFirstThread
         -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
   </launcherArgs>
   <launcher>
      <solaris/>
      <win useIco="false">
         <bmp/>
      </win>
   </launcher>
   <vm/>
   <plugins>
      <plugin id="com.packtpub.e4.headless.application"/>
      <plugin id="org.eclipse.core.contenttype"/>
      <plugin id="org.eclipse.core.jobs"/>
      <plugin id="org.eclipse.core.runtime"/>
      <plugin id="org.eclipse.core.runtime.compatibility.registry"fragment="true"/>
      <plugin id="org.eclipse.equinox.app"/>
      <plugin id="org.eclipse.equinox.common"/>
      <plugin id="org.eclipse.equinox.preferences"/>
      <plugin id="org.eclipse.equinox.registry"/>
      <plugin id="org.eclipse.osgi"/>
   </plugins>
</product>

Have a go hero – creating a product based on features

The product created previously specified an exact set of plug-ins that are needed to run the code. Many Eclipse applications are based on features, and products can also be defined by features as well.

Move the plug-in dependencies from the product to a feature, and then have the product depend on the feature instead. That way, when the feature is updated, it can be done externally to the product definition.

Pop Quiz – understanding features, applications, and products

Q1. What is the keyword used in the version number that gets replaced by the timestamp?

Q2. What files get generated in an update site build?

Q3. What is the name of the file that allows an update site to be categorized?

Q4. What is the difference between feature "requires" and "includes"?

Q5. What is the difference between an application and a product?

Q6. What is an application's entry point?

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

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