Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!

Bug 156460

Summary: Bind "action" to be "pre-save"
Product: editor Reporter: Lukas Hasik <lhasik>
Component: Key bindingsAssignee: David Strupl <dstrupl>
Status: RESOLVED DUPLICATE QA Contact: issues <issues.netbeans.org>
Priority: P3    
Version: 6.x   
Target Milestone: 6.x   
Hardware: All   
OS: All   
Whiteboard:
Issue Type: ENHANCEMENT Exception Report:

Description Lukas Hasik 2009-01-08 09:16:33 UTC
http://www.nabble.com/Proposal%3A-address-carpel-tunnel-syndrome-in-Netbeans-to21342949.html

it might be useful to provide users a way to bind an action to be run before save. This "pre-save" state could be set up
in the new Keymap table of 7.0
Comment 1 Vitezslav Stejskal 2009-01-08 10:06:16 UTC
Yeah, that sounds cool, but can potentially have zillions of side effects. Are you (QA) going to test that all and each
action when marked as 'pre-save' works and causes no other harm? And their combinations?

Obviously for many actions marking them as 'pre-save' makes absolutely no sense. Why would somebody want to 'Open
Project' when saving files? So this feature should not be allowed just for any action. Maybe we could pick a few that
are suitable for running on save, which would greatly limit the test matrix. Just random thoughts.
Comment 2 Lukas Hasik 2009-01-08 10:10:46 UTC
>Are you (QA) going to test that all and each action when marked as 'pre-save' works and causes no other harm? And their
combination?
-definitely not

>Obviously for many actions marking them as 'pre-save' makes absolutely no sense. Why would somebody want to 'Open
>Project' when saving files? So this feature should not be allowed just for any action. Maybe we could pick a few that
>are suitable for running on save, which would greatly limit the test matrix. Just random thoughts.
-I completely agree. 
Comment 3 Petr Dvorak 2009-01-08 12:38:45 UTC
I would be more in favor of explicitly stating which actions can be pre/post-save. I don't think it is a good idea we
allow user to do anything in the Keymap dialog - imagine the defects saying (roughly): "IDE freezes if I make Save
action a post-save"... Formatting, fixing imports/ commit, ... these all make sense to me...

But probably not in the Keymap dialog that we have now (I don't know how to fit it there - maybe tabs in the Keymap
section?).
Comment 4 Petr Dvorak 2009-01-08 12:40:14 UTC
See also issue 140817 - maybe this is sufficient in the beginning (format+fix imports on Save for Java files)...
Comment 5 tkellerer 2009-01-08 16:57:49 UTC
I brought this up in the NetBeans forum. Thanks to Lukas for logging this

I don't think we need to be able to bind /any/ action to the pre-save "event". From my point of view, only actions that
"modify" the source code are of interest. 

I definitely would like to see "remove trailing spaces" there :)
Comment 6 Vitezslav Stejskal 2009-01-12 10:30:12 UTC
> I definitely would like to see "remove trailing spaces" there :)

6.5 does that automatically for lines that were modified by a user (in order not to interfere with VCS too much).
Comment 7 tkellerer 2009-03-06 17:43:47 UTC
> 6.5 does that automatically for lines that were modified by a user 
No it doesn't :( 

When you e.g. hit enter to create empy lines, NB will indent according to the previous line (which is fine), but those
lines will have "trailing" spaces. 

The same is true when using Copy & Paste. That can also leave trailing spaces in lines that I edited. 

So I still need "remove trailing spaces" as a pre-save action ;)
Comment 8 fan_42 2010-11-04 21:19:11 UTC
If we go with the action that I would like to see there:

- Format
- Organize imports
- add final to private fields which can be final
- remove trailing space
- add @Override to methods which override a method
- add {} at if, for etc.
- remove unnecessary casts. 

I guess we could find some more :)
Comment 9 David Strupl 2011-04-21 13:29:50 UTC

*** This bug has been marked as a duplicate of bug 140719 ***
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo