Skip to content

Eclipse Setup for iObserve

Reiner Jung edited this page Sep 25, 2016 · 23 revisions

The iObserve project comprises several different repositories used for various artifacts used to realize the iObserve approach. To improve inter interoperability, between different research groups, we defined the following setup instructions for your Eclipse environment.

The present configuration is tested with Eclipse Neon, but should also work with Mars.

Prerequisites

  • Java JDK 8
  • Eclipse Neon
  • Eclipse Gradle support
  • Eclipse support for Checkstyle
  • Eclipse support for Findbugs (optional)
  • Eclipse support for PMD (optional)

Coding Conventions

We know that people might have different coding conventions in different projects, this tutorial instructs how to setup the formatter and the editor in for the iObserve project specific manner. If you want these coding styles to be present in all projects you have to deviate from the given instructions or reproduce the setup for every project.

As iObserve comprises multiple Eclipse projects, it is preferable to use a workspace wide configuration. Therefore, we encourage you to create a separate workspace for iObserve and follow these instructions.

Please note that we use Xtend and Java to implement parts of iObserve. Therefore, several preferences must be configured for both languages.

To start the configuration: Start Eclipse and open the Preferences page (Windows > Preferences)

Setup the Clean Up

Unfold the Java Code Style option and then Clean Up. This will open the clean up form in the dialog.

Clean Up
  • Now click on the Import...-button under Active - Profile. This brings up a file dialog.
  • Select in the file dialog the iobserve-eclipse-cleanup.xml in the iobserve directory.
  • Ensure that the iObserve cleanup Rules are displayed as active entry in the selector below.
  • Finally click on Apply to apply the clean up settings.

Setup the Formatter

Unfold the Java Code Style option and then Formatter. This will open the formatter form in the dialog.

Formatter
  • Now click on the Import...-button under Active - Profile. This brings up a file dialog.
  • Select in the file dialog the iobserve-eclipse-formatter.xml in the iobserve directory.
  • Ensure that the iObserve Code Format is displayed as active entry in the selector below.
  • Finally click on Apply to apply the formatter settings.

Setup the Save Actions

Save actions are applied to the content while saving the file. the are setup in the project properties dialog.

Unfold the Java Editor option and select Save Actions.

Save Actions
  • Check Perform the selection actions on save
  • Check Format source code
  • Check Organize imports
  • Check Additional Actions

The result should look like in the image above.

  • Click on the Configure...*-button right of the list of additional actions. This brings up the save action configuration.
Code Organizing
  • Select the tab Code Organizing
  • Select the options as displayed in the picture (above).
Code Style
  • Select the tab Code Style
  • Select the options as displayed in the picture.

Note that we force the setting of final modifiers everywhere. This has two advantages. First, it indicates to the reader that this property, parameter and variable is not modified, i.e., no new object is assigned to it. This increases code readability. Second, it hinders programmers to modify properties accidentally or in case they should be modifiable, shows that there is some mix up somewhere else in the code. You may also consulte the checkstyle manual on this property.

Member Access
  • Select the tab Member Access
  • Select the options as displayed in the picture.
Missing Code
  • Select the tab Missing Code
  • Select the options as displayed in the picture.
Unnecessary Code
  • Select the tab Unnecessary Code

  • Select the options as displayed in the picture.

  • Now click on Ok to accept the setup.

  • In the Save Actions tab, press Apply to apply these settings.

Setup Templates

The iObserve templates have been extended by a template for the standard file header. It can be applied to the header by moving the cursor to the top left and pressing CTRL-Space for context help. By selecting the header template from the list, the editor adds the header template include the correct year for the code revision.

Unfold the Editor option and select Templates.

Java Templates
  • Select the Import...-button on the right. This brings up a file dialog.
  • Select in the file dialog the iobserve-java-templates.xml in the iobserve directory.
  • In the Templates, press Apply to apply these settings.
  • Press the Ok-button.