Time for action – creating an E4 application

Eclipse applications use an application ID to launch and start execution. For E4 applications, org.eclipse.e4.ui.workbench.swt.E4Application is used. Since this is specified within a product, to start with a new E4 application will be created.

  1. Go to the File | New | Project... menu and choose Eclipse 4 | Eclipse 4 Application Project from the list.
    Time for action – creating an E4 application

    Note

    If the Eclipse 4 Application Project is not shown here, check that the E4 tools are installed correctly.

  2. Create a project with the name com.packtpub.e4.application, and step through the wizard. Choose the default values for each field.
    Time for action – creating an E4 application
  3. On the last page, ensure that the Create sample contents option is selected. This will ensure that the E4 tools creates standard parts and menus for the default application.
    Time for action – creating an E4 application
  4. Click on Finish and the project will be created.
  5. Right-click on the com.packtpub.e4.application project and choose Run As | Eclipse Application. This launches a new version of the IDE, which isn't what might be expected.
  6. Double-click on the product file (called com.packtpub.e4.application.product) and click on the run icon in the top-right corner:
    Time for action – creating an E4 application

    Note

    If you get a web browser launched when invoking the product, it may be that RAP is installed. If this happens, the product can be launched by going to the Run | Run As... and selecting the Eclipse Application type, followed by Run a product: com.packtpub.e4.application.product. Alternatively, the Overview tab has a Testing section, which includes a link to Launch an Eclipse Application.

  7. When the application runs, an error may be seen:
    !MESSAGE Application error
    !STACK 1
    java.lang.RuntimeException: No application id has been found.

    This indicates that the product was missing one or more dependencies in the product list. Some older versions of the E4 tools did not include required plug-ins such as javax.xml. As a result, the runtime application fails to install, with the cryptic error that it can't find the application.

  8. To resolve the problem, click on the Add Required Plug-ins for the product (the button on the right of the product editor, as seen in the preceding screenshot). Now, when it is run, the default window should be shown:
    Time for action – creating an E4 application

What just happened?

The new E4 wizard created a simple E4 rich client application, including creating some sample content (menus, commands, and so on). After fixing issues with missing dependencies, product launch operation starts the application successfully.

When running any kind of Eclipse application, it is good practice to stop the launch when there are missing dependencies. The launch configuration, visible via the Run | Run Configurations... menu, has an option on the plug-ins tab Validate plug-ins automatically prior to launching:

What just happened?

Now, when launching the product without adding the necessary plug-ins, a warning will be shown. Clicking on the Validate Plug-ins button can run this validation at any time.

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

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