This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 240143 - Save/Save All action disabled while a file is modified
Summary: Save/Save All action disabled while a file is modified
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 7.4
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jan Peska
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-09 09:03 UTC by Jan Peska
Modified: 2014-04-08 09:37 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Peska 2014-01-09 09:03:46 UTC
Separate issue for a problem described  in #206513. Original description of the problem from mgoe:

The problem still happens in an application based on the Netbeans platform (version 7.4, all patches applied). I will add the log messages with the requested loggers switched on as well as a screen shot of the editor tab and toolbar after I modified the edited document (TabAndToolbarAfterModification1.png).

In order to workaround the problem I tried to implement my own versions of the Save and SaveAll actions. I wasn't successful for the Save action but for the SaveAll action I was able to implement a replacement which works (see attachment SaveAllAction.java). My SaveAll action is properly enabled while the Save and SaveAll action supplied by the Netbeans platform is not enabled (TabAndToolbarAfterModification2.png).

To get notified about changes I registered my SaveAll action as change listener using: DataObject.getRegistry().addChangeListener(). I found out that the stateChanged() method is not called on the EDT. In order to fix this I implemented a Runnable which moved the update of the enabled state into the EDT. Perhaps are the problems with the Save action EDT violations as well.

Best regards,
Martin
Comment 1 Jan Peska 2014-01-09 09:06:02 UTC
Martin, 
can you please specify a reproduction scenario. It is not obvious to me from your original comment. It would be very helpful to be able to debug it.

Thanks
Comment 2 mgoe 2014-01-13 13:35:23 UTC
Unfortunately I have not yet found a scenario which allows to reproduce the problem.

In order to analyze the problem I would suggest that you overwrite DataObject.setModified(boolean modif) and DataObject.isModified() to check in which thread these methods are called. When I tried to debug the problem I found that setModified() was always called with the correct argument but not from the EDT. Since setModified() also informs the change listeners I think that this causes the problem. In my implementation of the SaveAll action (see attachment of bug #206513) which always was enabled correctly (even when the Netbeans version wasn't) I was able to fix the problem by making sure that changing the enabled state of the Action was done on the EDT. Perhaps the Save action could be fixed in the same way.

Best regards,
Martin
Comment 3 nilsmsa 2014-04-08 09:37:43 UTC
Hi, I just noticed something regarding this bug:

While running "Clean and Build" on a maven project (Scala) I got some compilation errors. I clicked on the error in the "Output - Build" windows. This opened the faulty source file as expected, but when I fixed the error the save button remained grayed out (same goes for save under "File"). I then switched to an other source tab and then back again. Save was still grayed out, but as soon as I modified the file again save became available. Having a hard time reproducing the bug, but the fact that switching tabs seems to work around the issue might help to narrow down the problem. Anyone else able to confirm that tab switching helps?


(Running NB 7.4 with all updates installed, ArchLinux OpenJDK 7.u51_2.4.6-1-x86_64)