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 and RCP Applications, 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 file name.
  3. Leave the Create a configuration file with the basic settings selected.
  4. Click on Finish and it will open up the headless.product file in an editor.
  5. Fill in the details as follows:
    1. ID: com.packtpub.e4.headless.application.product
    2. Version: 1.0.0
    3. Name: Headless Product
  6. Click on New on the right of the product definition section, which will bring up a dialog to create a product. Fill in the dialog as follows:
    1. Defining plug-in: com.packtpub.e4.headless.application
    2. Product ID: product
    3. Application: com.packtpub.e4.headless.application.id
    Time for action – creating a product
  7. Click on the run icon at the top-right 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 Contents tab, and add the following bundles:
    1. com.packtpub.e4.headless.application
    2. 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 macOS, 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 that 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 looks like:

<?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="javax.xml"/>
      <plugin id="org.eclipse.core.contenttype"/>
      <plugin id="org.eclipse.core.jobs"/>
      <plugin id="org.eclipse.core.runtime"/>
      <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 is needed to run the code. Many Eclipse applications are based on features, and products can also be defined by features.

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.

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

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