IntelliJ FAQ
Back to current version Restore this version

This is a blog like article with a FAQ for d3web developers transitioning from Eclipse to IntelliJ IDEA:

Import current code styles#

Download the attached code_styles.jar(info) and import them with File -> Import settings.

Adding new files and classes to version control automatically:#

Go to File -> Settings -> Version control -> Confirmation -> When files are created. You're probably looking for "Add silently".

Save actions like in eclipse#

Edit -> Macros -> Start macro recording

Now we record the actual macro simulating our Save actions:

  1. Code -> Reformat Code (formats the code according to the code style/template, also allows to optimize inputs)
  2. File -> Save all
  3. Build -> Compile (compiles the changes which also causes them to be hot swapped when in debug)

Edit -> Marcros -> Stop macro recording

After that, I bound the macro to "Cmd + Alt + S". This way I still have the normal save, but also the macro which does more...

Show Javadoc#

Use View -> Quick Documentation or the corresponding keyboard shortcut (depends on OS and Keymap).
On Mac OSX with Eclipse keymap, F2 Works.

It's also possible to enable automatic JavaDoc popup on code completion in Preferences -> Editor -> Code completion (Autopopup documentation).
At the beginning this worked for me (somewhat clitching), but now it no longer works :(

Running Headless-App-Tests in JUnit#

To run the Headless-App-Tests in JUnit (e.g. for debugging), create/add a new JUnit Configuration. In the configuration, it is important to select "class" at the dropdown for the "Form mode" (upper right). I also recommend to use "Single instance only".

If "Fork mode: class" is not selected, JUnit seems to use different JVMs to execute test and parameter method, which causes the ArticleManager in the test method to be empty.

Sorting of import statements#

By default IntelliJ has different order of import statements as Eclipse. To avoid having these change every time a class is edited in the different IDEs, we should adjust the order in IntelliJ. This can be done under Code Style -> Java - > Imports. The order should be:
  1. import java.*
  2. <blank line>
  3. import javax.*
  4. <blank line>
  5. import all other imports
  6. <blank line>
  7. import cc.denkbar.*
  8. import com.denkbares.*
  9. import de.*
  10. <blank line>
  11. import static all other imports

The above order will not quite avoid all changes, since Eclipse seems to additionally add blank lines between all all imports with different first path elements, but its close enough. I think since it is a code style, this should also be part of the code style settings, which are also attached to this site.