Archive for December, 2009

Creating live templates from… templates

Tuesday, December 22nd, 2009

Sometimes I find myself writing repetitive code constructs without being able to extract common code due to Java syntax hmm… let’s call them peculiarities. ‘Sounds like a job for a live template’, I think, and I simply create it. Here’s how. The documentation has it too, but a good example never hurts.

Let’s suppose you have read/write synchronization in your project, and from time to time you need to wrap a bunch of statements in, say, a read action. This involves putting them into a Runnable and giving the latter to some runReadAction method. Do you still do this manually? You don’t need to, IntelliJ IDEA will help you!

First, find an existing code which already invokes the read action and select it:

Go to Tools menu and choose Save as Live Template there:

You’ll see a typical Edit Live Template dialog with the text you’ve selected. Note that all the class references are qualified there and Shorten FQ names checkbox is on, so the mentioned classes will remain the same no matter where you choose to insert it.

What we want to keep is the external syntax: the method call and the runnable. So remove everything inside the run() method braces and replace it with a $SELECTION$ on a single line. It means that you may select something and it’ll be wrapped in this particular construct.

Enter some abbreviation to easily invoke it each time, and some description (optional, but useful). Finally, the formatting looks not quite pretty, so turn on the Reformat according to style checkbox.

That’s all! Click OK and start using it. Find a fragment you want to wrap into a read-action, select it and invoke Surround With… action (Ctrl+Alt+T). You’ll see the read action template in the list:

Select it and the read action is in there:

ActionScript/Flex UML Class Diagrams in IntelliJ IDEA 9

Friday, December 11th, 2009

If you read our recent posts on ActionScript/Flex refactorings, you might have noticed that UML diagramming in freshly released IntelliJ IDEA 9 works not only for Java. That’s right, you can use it to analyze your ActionScript and Flex classes.

(more…)

IntelliJ IDEA 9 Released, Includes Free Edition

Tuesday, December 8th, 2009

IntelliJ IDEA 9 is finally out, bringing you lots of goodies across the board!

If you haven’t followed the EAP (Early Access Program) or missed the Beta release, here is a quick summary of the key new features and improvements in this release:

  • Two editions: Community Edition, free and open-source, and Ultimate Edition, encompassing 100% of the famous IntelliJ IDEA functionality
  • Much faster environment, with background indexing on startup
  • Extensive Java EE 6 support
  • Many productivity features in core Java functionality
  • Best-of-breed PHP support, with dedicated debugger, PHPUnit, etc.
  • Visual editor for defining the structure of project deliverables (.war, .ear archives, etc.)
  • AIR support, ActionScript refactorings, and other Flex support improvements
  • And lots more!

Read more about what’s new and download a free 30-day trial today.

Buy or upgrade to IntelliJ IDEA 9 right now.

Oh, and did you happen to buy your IntelliJ IDEA 8 license on or after October 1, 2009? If so, download v9 and upgrade right now — for free!

Start enjoying this latest and greatest IntelliJ IDEA every day — like we do!

— IntelliJ IDEA Team

Editing HTML Inside of JS Literals

Thursday, December 3rd, 2009

It often happens that we need to edit HTML code inside JavaScript literals. With Maia this is at last possible, and even with pleasure!

Completion, quick documentation, and navigation for HTML, CSS and even JavaScript inside JavaScript literals is at your service :)

Flex CSS Support in Maia

Wednesday, December 2nd, 2009

Editing CSS files in Flex applications becomes easier with the help of some new Maia features.

First, completion for CSS selectors, properties, and property values. For example, if you press Ctrl+Space in this context, you get all class names from
a default namespace http://www.adobe.com/2006/mxml + global selector:

If a CSS property has a color format, IntelliJ IDEA helps you to select a color:

You can look up documentation for default Flex CSS selectors and properties. Just press Ctrl+Q in editor or completion pop-up window:

You may easily navigate from CSS properties and selectors to their declarations in ActionScript. All you need is to press Ctrl+B. Note that if there are several declarations to navigate, you will see a pop-up list.

Also, IntelliJ IDEA provides validation of CSS selectors and properties:

Note that these features are available only in CSS and MXML files under a Flex module, or module with a Flex facet.