Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Spelling and grammar in some parts of the document

...

For testing and development purposes, it is highly recommended that you setup the OpenMRS SDK. Instructions for setting up the OpenMRS SDK can be found  here and here.

How To Configure Your IDE

...

In order for Eclipse to format the code, you will need to import the OpenMRSFormatter.xml. This is file is located in the OpenMRS core, which you should clone if you haven't already.

...

Also check the two settings of "Number of (static) imports needed for *" and make sure the number is high enough for Eclipse not to replace your imports with the so called "star imports" using * because we do not want these. 99 is the default value for Eclipse and is usually high enough. 

...

From now on when you change a class and save it, Eclipse will format the code for you according to your formatter settings and organize the imports according to the import settings.

Show Print Margin

If you want to see whether your lines are longer than what you configured in the formatter you can let Eclipse show you a "Print Margin".

...

Anchor
add-templates
add-templates
Add OpenMRS C
ode Templates

To save you some typing and so that you can focus on solving problems we put together a few code snippets/templates. Once you imported import them you can type short keywords and Eclipse context menu will suggest the appropriate template and once you select it, fill in the code with some variables for you to adjust the snippet to your use case.

...

See all templates available

We are not posting there their names here since the templates.xml should remain the single source of truth.

You can either use the Eclipse settings to see the templates you have or if you want to know the exact names of all snippets that you got from adding the OpenMRS templates execute

...

If your class already has a Logger instance just place the cursor to where you want to log and type logd (for debug), logi (for info), ... hit Control+Space (for the context menu) select the template and hit enter. Depending on what template you are using you might need to only enter your log message or also add a parameter after the message like for example for logpe (for logging an error and passing it an exception) or logpi (to log an info message using the slf4j parametrized message style like log.info("the temperatur was {}", temperatureObject) ).

...

You might find yourself taking over the development of an existing module that others wrote and could use a little clean up. Lets Let us say it misses for example the @Override annotation in a lot of places. In such cases Eclipse can help automate this repetitive tasks.

Eclipse provides you with a "Clean Up" feature where you can configure it to format the code according to your formatter settings or take another action like remove white spaces, fix indentation, add a missing override annotation, ...

...

Click 'New...' to create a new profile, in our case we call it 'add override annotations' and you select just what you want to clean up. The options are just like in the save actions settings dialog.

Make sure you only select what you want to change.

...