Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Documentation

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

Open the Eclipse preferences under Window →  Preferences and enter the search term "formatter", which should show Java →  Code Style →  Formatter under the results in the left pane like shown here:

...

Select "Formatter" click the "Import..." button and navigate and select the tools/src/main/resources/eclipse/OpenMRSFormatter.xml

Import the OpenMRSFormatter.xml into an own profile and call it for example "OpenMRS Formatter".

...

Nothing should be selected under "Code Style".

Nothing should be selected under "Member Accesses".

...

Open the Eclipse preferences using Window → Preferences and enter the search term "templates" which should show Java →  Editor →  Templates under the results in the left pane like shown here:

Image RemovedImage Added

Click on "Import..." and select the tools/src/main/resources/eclipse/templates.xml and click on "Apply and Close".

...

To add a new unit test to a test class, open the test class in the editor. Place the cursor to where you want to add the test and write test and hit Control+Space (for the context menu) which will show you a list of options like shown belowhere:

Image RemovedImage Added

select the "OpenMRS Style JUnit 4 Test" and hit enter to get this:

Image RemovedImage Added

the words you see selected are variables/placeholders, with the darker one being on focus. Enter the method name you want to test and hit TAB to advance to the next variable and type in the should style sentence of what you are testing. Hit TAB again to advance to the method body.

...

If you want to log an event in a class that does not yet have an instance of a Logger open the class and place the cursor to the top and type logger and hit Control+Space (for the context menu) which will show you a list of options like shown below

Image RemovedImage Added

select the logger template and hit enter. This will add the logger with the necessary imports like so

...

If you do not like Eclipse to open the pom.xml files in the GUI style window you can disable that by opening the Eclipse preferences and using Window → Preferences and enter the search term "maven" which should show Maven →  User Interface under the results in the left pane like shown here:

Image RemovedImage Added

Make sure the checkbox is checked as shown.

...

For this to work from within Eclipse you need to enable Maven to download the source code and JavaDocs which you can do by opening the Eclipse preferences using Window → Preferences and entering the search term "maven" as shown here:

Image RemovedImage Added

Ensure you check

...

Tips on How To Use Your IDE

...

Import a Project with an Existing Source

Use Case

  1. You have an existing Eclipse workspace folder.
  2. You no longer have projects in Eclipse for the source code in the workspace folder

Solution

Image Removed

Image Removed

In order to import an existing project into your current workspace begin by navigating to File → Import...

Image Added

You will be greeted with an import window with  a list of import wizards. Next you will want to navigate to General → Existing Projects into Workspace, select it and continue with Next as shown here:

Image Added

Upon selecting Next you will be greeted with a screen similar to the one portrayed here:

Image Added

From here simply browse for your directory, select all of the wanted projects and select Finish


Debug a Web Application with Eclipse

...

Panel

-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5000

Image Removed

Image Removed

After you should launch Debug Configurations... using IRun → Debug Configurations...

Image Added

Once launched you will be greeted with a window. In the left sidebar find the option Remote Java Application and double click to open it as shown here:

Image Added

Start up tomcat and then debug with this new Remote Java Application and breakpoints within the code will open within Eclipse.

...

Open the Eclipse preferences using Window → Preferences and enter the search term "clean up" which should show Java →  Code Style →  Clean up under the results in the left pane like shown here

Image RemovedImage Added

 

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.

Image RemovedImage Added

Make sure you only select what you want to change.

Now to clean up all the files in your project you open the Eclipse project explorer and go to the package view, right click and select 'Source' →  'Clean Up' as shown below

Image RemovedImage Added