Archive for the ‘How-To's’ Category

GWT UiBinder support

Tuesday, January 26th, 2010

The first IntelliJ IDEA 9.0.2 EAP build will add support for UiBinder, new functionality introduced in GWT 2.0. IntelliJ IDEA will understand tags and attributes in ui.xml files:

Inconsistencies between ui.xml file and associated Java class will be highlighted:

You can jump from field to the corresponding tag by using icon on the gutter:

Also IDE provides actions to quickly create new ui.xml file with associated Java class (in Edit | New | Google Web Toolkit menu) and to generate @UiHandler method (in Code | Generate menu).

Expect new version EAP to be published shortly.

Resize (tool) windows with keyboard

Monday, January 25th, 2010

Since IntelliJ IDEA is so much loved by keyboard addicts, here is a tiny yet helpful feature introduced in version 9.0.2: you can change size of a tool window by means of your keyboard.

Say, you’re doing “find usages”, the tool window is popping up and it’s too small for you to comfortably look at the usages tree. Now you don’t have to grab a mouse to stretch it up, just hit Ctrl-Shift-Up (Meta-Shift-Up for Mac users) and your tool window is getting bigger.

So, if you need to resize a tool window: focus it (by Alt-number or Ctrl-Tab) and then use Ctrl-Shift plus an arrow key that points to the direction you want.

You can also use these arrow shortcuts to resize dialogs and actually any window that IntelliJ IDEA shows. Say, you opened the project structure dialog and it’s too narrow for you. Use Ctrl-Shift-Right and Ctrl-Shift-Down to make it bigger.

Flex SDK Sources and Flexmojos Projects

Monday, January 18th, 2010

If you are working with Flexmojos Maven projects in IntelliJ IDEA 9, and have imported Flexmojos project as described in this post, and are planning to debug your application and browse through Flex SDK sources, this post is a must-read for you. Inside you will find details on how to configure IntelliJ IDEA so that it properly recognizes SDK sources and their ASdocs.

(more…)

JPA 2.0 Typesafe Criteria API and Annotation Processing Howto

Thursday, November 19th, 2009

Maia build subsystem now recognizes Java Annotation Processors. Most of JPA 2.0 implementations are expected to make use of the Pluggable Annotation Processing API to automatically generate static metamodel classes. Here is a list of steps required to generate JPA 2.0 metamodel and keep it up-to-date with Hibernate Static Metamodel Generator. For the simplicity in this sample project the processor jar file is added to the module dependencies.

  • Enable annotation processing
  • Select Obtain processors from project classpath option
  • Add a processor class name to the Processors list
  • Add a module with annotated classes to the list of modules to process
  • To output generated classes to a generated directory under module content root, set Generated Sources Directory Name to generated. Note that this directory will not be set as a source root automatically.

Now, Annotation processors will be run every time you invoke Make or Compile. Besides, there is a special menu item Process Annotations that does exactly what its name says. In this sample project I have added the generated directory to project sources to get completion in JPA 2.0 Typesafe Criteria API calls. Enjoy, Comment.

IntelliJ IDEA PSI Viewer

Thursday, November 19th, 2009

If you’re an IntelliJ IDEA plugin developer, you’re surely going to enjoy IntelliJ IDEA PSI Viewer (Tools -> View PSI Structure), which displays internal structure of various files, as they’re interpreted by IntelliJ IDEA. If you’re implementing a new language support, or trying to add some cool new features to what’s already supported — this viewer is what you’re gonna need a lot.

As you see, PSI Viewer is made up of of tree parts:

  • An editor with file content
  • PSI structure view with parent-child tree of its elements
  • Area that displays references of element selected in PSI structure view.

Note that references marked as red resolve to null.

Available since build 92.35

Surprising Update: IntelliJ IDEA 8.1.4

Friday, November 13th, 2009

While IntelliJ IDEA 9 aka Maia is knocking on the door, our development team just released a fresh update to IntelliJ IDEA 8 — v8.1.4.

Read release notes, download a copy for your platform, and don’t forget — our Free Upgrade Program is still running!

Intelligent Copy&Paste

Friday, October 2nd, 2009

Do you find yourself copying and pasting parts of bodies between different methods and then facing broken code?

Unfortunately, parameter names tend to differ — like in this (very simplified) example:

Nothing is easier than fixing this problem with a few keystrokes in IntelliJ IDEA!

First, move caret on any red reference (highlighted with red color), or simply press F2, and then invoke available Quick-Fixes via Alt+Enter:

Now select Rename Reference (again, you can use arrow keys or just start typing Ren.. + Enter) and… IntelliJ IDEA fixes code for you!

See, sometimes it’s just the small features making it possible to achieve maximum productivity.

PostgreSQL Dialect Support

Thursday, September 24th, 2009

Maia release is closing in, and yet we have not run out of useful features to announce. Next EAP brings you a long-awaited support of PostgreSQL dialect. Just as with all others, you can set it at project, folder, or individual file levels either via Project Settings section of Settings dialog, or by invoking a quick-fix on any error marker inside of an .sql file with Alt+Enter shortcut.

Code Inspections for Web Applications

Thursday, September 17th, 2009

If you ever coded a Web project, you know that all the errors in those HTML / JavaScript files are detected only during run time. Starting next build IntelliJ IDEA 9 (Maia) will help you to spot the problems much earlier. Just invoke Inspect code action from the Analyze menu on the necessary files.
(more…)

Developing Android Applications in Maia

Wednesday, August 26th, 2009

Maia supports development of applications for Android operating system. To begin creating an Android application, open the File menu, click New Project, click Next, and then select Android Module type:

Now you need to create Android SDK — just specify its location folder and build target. IntelliJ IDEA will create a new global library for it (to which you can later attach sources or javadoc for better coding assistance).

For that you can either click View Classpath in the Android Facet configuration (which is automatically added to your module) or edit it just as any other library. Note that Android sources and javadoc are added automatically if they are located in default locations: <sdk dir>/src and <target dir>/src for source code and <sdk dir>/docs/reference and <target dir>/docs/reference for javadoc.

You can create Activities, Services, Broadcast Receivers and Remote Interfaces (AIDL files) from popup menu (Alt+Insert). IntelliJ IDEA automatically registers them in an AndroidManifest.xml file and provides syntax highlighting for AIDL code.

To create a new Android Resource, select the res folder (or any of its specific child folders) and press Alt+Insert:

To launch an Android application you can either use an Android run configuration (created automatically when Create ‘Hello, World!’ project option is selected in Android Facet settings), or just press Ctrl+Shift+F10:

You can use external JARs in your application by just adding dependencies via Project Structure dialog, Ctrl+Shift+Alt+S. Java module dependencies can be added in a similar way.