Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 361136

Summary: [quick fix] Save actions are disabled after using Java quick fix in Java Editor
Product: [Eclipse Project] Platform Reporter: Vitaliy Yakovchuk <Vitaliy.Yakovchuk>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, deepakazad, jeffreybolle, lukas.glowania, markus.kell.r, nickh186, pwebster, raksha.vasisht, robertkrikke, smikkelsen, stephan.herrmann, tarik.ozkanli, uschkinredsunshine, vkhomyackov
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug

Description Vitaliy Yakovchuk CLA 2011-10-17 09:39:56 EDT
Build Identifier: 20110916-0149

Save, Save As and even Save All actions became not available after using Content Assist for creation a new method in other file (). Hot keys Ctrl+S, Ctrl+Shift+S do not work as well. The only way to save a file is to close Java Editor view and answer Yes in Save Resource dialog.

Bug was present in Eclipse 3.7 and was not fixed in the latest update.

Reproducible: Always

Steps to Reproduce:
1. Create new public class A
2. Create new public class B in another file
3. Create a new method in class A (for example doIt())
4. Create a new call in the doIt method to a some not existing method in class B, for example create method in class A:
    public void doIt(){
        new B().newMethod();
    }

5. Move cursor on not existing "newMethod" in shown Content Assistant's window click on "Create method "newMethod" in type B" or do the same by clicking on error in code icon.
6. When file B.java will be opened/activated, a "newMethod" will be created, but Save, Save As and Save All actions will disabled.
Comment 1 Raksha Vasisht CLA 2011-10-20 06:47:31 EDT
Cannot reproduce on 3.8 with  I20111018-0850 build on Ubuntu 9.10.
I could however reproduce it on ubuntu 11.04 with an earlier build - I20110912.  Seems like it got fixed in 3.8. Pls try the latest build from 3.8 stream. Closing it as WORKSFORME.
Comment 2 Raksha Vasisht CLA 2011-10-20 06:52:00 EDT
(In reply to comment #1)
> Cannot reproduce on 3.8 with  I20111018-0850 build on Ubuntu 9.10.
Nope, sorry. Only worked once. Now I see the problem again. Reopening.
Comment 3 Vitaliy Yakovchuk CLA 2011-10-20 09:31:56 EDT
Today I tried win32 version, everything works fine.
Comment 4 Dani Megert CLA 2011-10-21 04:08:46 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > Cannot reproduce on 3.8 with  I20111018-0850 build on Ubuntu 9.10.
> Nope, sorry. Only worked once. Now I see the problem again. Reopening.

Raksha, can you constantly reproduce it now? And on Windows 7?
Comment 5 Raksha Vasisht CLA 2011-10-21 15:40:01 EDT
(In reply to comment #4)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Cannot reproduce on 3.8 with  I20111018-0850 build on Ubuntu 9.10.
> > Nope, sorry. Only worked once. Now I see the problem again. Reopening.
> 
> Raksha, can you constantly reproduce it now? And on Windows 7?

Yes, it works fine on windows 7, but I see the problem on Linux- ubuntu 9.10 constantly on I20111018-0850. 

Also, the same quick fix works fine inside the same CU.
Comment 6 Raksha Vasisht CLA 2011-10-24 11:45:15 EDT
*** Bug 360660 has been marked as a duplicate of this bug. ***
Comment 7 Dani Megert CLA 2011-10-25 03:43:23 EDT
*** Bug 358358 has been marked as a duplicate of this bug. ***
Comment 8 Deepak Azad CLA 2011-11-08 07:44:18 EST
*** Bug 350371 has been marked as a duplicate of this bug. ***
Comment 9 Deepak Azad CLA 2011-11-11 10:38:55 EST
*** Bug 363591 has been marked as a duplicate of this bug. ***
Comment 10 Stephan Herrmann CLA 2011-11-11 18:21:31 EST
This might be the same as one of the issue I observed while working on the
quickfixes for null annotations. See bug 337977 comment 4.

In may case, however, it sufficed to switch editors back and forth
to be able to save again.

And yes, I'm on ubuntu, too.
Comment 11 Victor Homyakov CLA 2011-12-09 02:48:53 EST
(In reply to comment #10)
> In may case, however, it sufficed to switch editors back and forth
> to be able to save again.

I can confirm that switching to other editor and back again enables save buttons.

> And yes, I'm on ubuntu, too.

Linux Mint 9 (Ubuntu 10.04 clone).
Comment 12 Deepak Azad CLA 2012-01-25 09:25:53 EST
Tried this today on 3 Linux machines but could not reproduce. Looks like I need to find an Ubuntu machine...
Comment 13 Lukas Glowania CLA 2012-01-30 05:13:15 EST
*** Bug 370093 has been marked as a duplicate of this bug. ***
Comment 14 Deepak Azad CLA 2012-02-02 04:12:08 EST
(In reply to comment #12)
> Tried this today on 3 Linux machines but could not reproduce. Looks like I need
> to find an Ubuntu machine...
One of these machines was Ubuntu 11.04. 

Stephan, which Ubuntu version are you using? Does the bug still happen with the latest Eclipse SDK builds?
Comment 15 Lukas Glowania CLA 2012-02-02 04:57:15 EST
On fresh files i can do the quick fix 1 time without this bug coming up. When i delete the generated method and use the reappeared quick fix again, the bug is there.
Comment 16 Stephan Herrmann CLA 2012-02-04 07:00:29 EST
I retried several combinations of Kubuntu 11.04 vs. 11.10 and 
Eclipse SDK 4.2M5 vs. 3.8M5.

Only one combination exhibits the bug: 11.10 & 3.8M5.

Hmm...
Comment 17 Vitaliy Yakovchuk CLA 2012-02-14 06:51:29 EST
As for me, it looks like, It always  happens if all files were saved befor using the quick fix.
Comment 18 Lukas Glowania CLA 2012-02-15 08:40:33 EST
In the vast majority of cases when the bug comes up, a quick fix was used that switches the content of the editor ("generate method", "add exception to").
Today i saw the bug in action by just using the "add cast to" quick fix without switching of editor content.
Comment 19 Markus Keller CLA 2012-02-26 12:23:28 EST
I can reliably reproduce on Ubuntu 11.10 with latest builds, e.g. N20120216-2000.

Important to reproduce:
- B.java is open in an editor and in saved state
- Quick Fix is executed by clicking into the Quick Fix hover or double-clicking the popup list (not applied via Enter key)

The problem is that e.g. org.eclipse.ui.internal.handlers.SaveHandler#evaluate(IEvaluationContext) uses InternalHandlerUtil.getActiveWorkbenchWindow(context), but on this platform, the "activeWorkbenchWindow" variable is still null at this point because the focus is still in the Quick Fix hover or popup list's shell.

WorkbenchSourceProvider#updateActiveShell(Map) should update "activeWorkbenchWindow", but it's too late since the SWT.Activate event is sent later on GTK.

However, I think the check for the activeWorkbenchWindow doesn't make sense anyway and should be removed. I could also imagine other legitimate use cases where an editor could become dirty while the workbench window is not active. In that case the Save action should also be updated.

The fixes in SaveHandler and SaveAsHandler are trivial (remove the call to "InternalHandlerUtil.getActiveWorkbenchWindow(context)"). The SaveAllHandler is harder, since the current workbench window is really used there. Maybe we need a "wokbenchWindow" variable that is not cleared when the shell loses focus?
Comment 20 Eclipse Genie CLA 2020-02-11 01:53:04 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.