X

Geertjan's Blog

  • October 26, 2012

Save Actions in NetBeans IDE 7.3

Geertjan Wielenga
Product Manager

Several developers, especially those familiar with equivalent functionality in Eclipse, have been asking for so-called "Save Actions", that is, support for actions that are automatically performed when a file is saved.

Here's the related NetBeans issue: http://netbeans.org/bugzilla/show_bug.cgi?id=140719  

In NetBeans IDE 7.3, the issue is resolved as follows:

  1. A new "On Save" tab is found in the "Editor" tab of the Options window. Defaults for all languages are set via the "All Languages" item in the drop-down. Here, for all languages, you can specify what kind (all, none, or only modified lines) of formatting and space removal will occur automatically when a file is saved:

  2. Via the drop-down, you see all the languages supported by the IDE:

  3. You can pick a language and then override the default On Save settings:

  4. Per language, there may be additional On Save settings. For example, for Java, you can specify that, when saving a Java file, unused import statements should be removed and/or the rules you've set for organizing import statements should be applied:

There's also a set of new NetBeans IDE APIs for adding new On Save functionality via custom plugins. Via MIME type registration of OnSaveTask.Factory, you can register new On Save actions that will be run for files conforming to the relevant MIME type. There's also extensions via the Editor Options API for registering new panels (one per language) to the On Save panel in the Options window. I'll demonstrate some examples of the APIs in upcoming blog entries.

Join the discussion

Comments ( 3 )
  • guest Friday, October 26, 2012

    I'm happy that this feature is integrated into netbeans now.

    But I'm a little bit disappointed, that the "Inspect and Transform" feature of netbeans wasn't integrated with the "On Save" dialog.

    It would be nice to selected some of the options like "@Overwirte" annotation, and they get triggered by the save action.

    I hope the "On Save" dialog will get an enhancement in this direction in the future.


  • Eli McMakin Friday, October 26, 2012

    Nice job, guys.

    Could this remove the "headers already sent" error when you have extra spaces after the PHP closing tag? Or is that something separate?


  • Jan Wednesday, November 7, 2012

    That leaves only a couple of more things before I 'able' to switch to Netbeans

    1. being able to import Eclipse java formatting rules in Netbeans.

    2. having Netbeans organize imports behave exactly the same as Eclipse (is that already possible).

    Thanks for the demo by the way, and nice to meet you (at Vuur/Utrecht)


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.