Save Actions in NetBeans IDE 7.3

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.

Comments:

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.

Posted by guest on October 26, 2012 at 09:20 AM PDT #

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?

Posted by Eli McMakin on October 26, 2012 at 04:22 PM PDT #

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)

Posted by Jan on November 07, 2012 at 11:42 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
24
25
26
27
28
29
30
   
       
Today