Bug 211520 - [CommonNavigator] Save disabled when Project Explorer view has focus
Summary: [CommonNavigator] Save disabled when Project Explorer view has focus
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P2 normal with 4 votes (vote)
Target Milestone: 4.13 M1   Edit
Assignee: Lakshminarayana CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted, noteworthy
Depends on:
Blocks: 427897
  Show dependency tree
 
Reported: 2007-11-29 16:46 EST by Tom Lennan CLA
Modified: 2019-06-25 15:20 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Lennan CLA 2007-11-29 16:46:22 EST
This looks like another difference between how Project Explorer works and other viewers (such as Package Explorer or Navigator) work.  If your project is modified and you change focus between the Project Explorer and some one of the other views, you'll see that the save icon (and File > Save menu item) goes from disabled (when the Project Explorer has focus) to enabled (when some other view has focus).

Quick way to re-create this behavior:
Open the Project Explorer view
Create a new project
Create a new file in the project
Open the new file in a text editor and enter some text
Save will be enabled because the text editor has focus
Click on the Project Explorer title to set focus in that view
Note that save is now disabled
Open Navigator or Package Explorer
Note that save is now enabled
Comment 1 Scott Ellis CLA 2010-10-05 18:41:45 EDT
The Save As... menu item is broken in the same way
Comment 2 Mickael Istria CLA 2014-06-26 11:00:09 EDT
I'd like to raise the priority of this issue as this is a really annoying small one.
Comment 3 Mickael Istria CLA 2014-06-27 10:17:25 EDT
In SaveHandler.java, the issue seems to be that getSaveablePart(context) return ProjectExplorer when ProjectExplorer is selected, whereas it's more expected to return the TextEditor (at least, that's what JDT Package Explorer seems to do).
Comment 4 Mickael Istria CLA 2014-06-27 10:30:53 EDT
To be more precide, the root issue is that CommonNavigator does implement ISaveablePart (and ISaveableSource). Just removing the "implements ISaveablePart" in CommonNavigator does the trick and delegates Save command (and enablement) to the active editor.

This change constitutes an API change, but it's really a major bug in Project Explorer. Is it possible to get it as part of Luna RC1?
FYI, JBoss Developer Studio relies on CNF and on the Project Explorer view for an easier navigation, and we wouldn't mind to have this behaviour changing positively in a near future ;)
Comment 5 Paul Webster CLA 2014-06-27 10:39:38 EDT
We can't change the API here.  Also, I'm not convinced change the behaviour here is a good thing in the service release.  IIRC the common navigator allows the content providers to return their own set of saveables (it has its own save infrastructure) which would stop working if we removed that interface.


We can consider a way to fix it for Mars (like have the default content provider plug into the CNF saveable API) but that sounds like a lot of work.

PW
Comment 6 Mickael Istria CLA 2014-06-27 10:47:23 EDT
Ok, thanks for the explanation. Do you have an example of a CNF extension which does provide some specific Saveable parts in its context provider?
Then what would you think about an implementation of the default content provide that would simply return the active editor (ie output of Util.getAdapter(activePart, ISaveablePart.class) when activePart isn't an ISaveablePart) by default?
Comment 7 Paul Webster CLA 2014-06-27 10:49:19 EDT
The default content provider would have to implement saveables to the CNF API.  I don't know what that API requires, though (it would require some research :-)

PW
Comment 8 Mickael Istria CLA 2014-06-30 06:51:15 EDT
CommonNavigator currently contains:

  public boolean isSaveAsAllowed() {
    return false;
  }

I tried to replace the "false" by "isDirty()", and then everything seems to work fine. Would this "isDirty()" be a better implementation?
That would be great since it doesn't require any API change. Is isDirty() a good enough implementation? At least, it seems better than "false"...
Comment 9 Mickael Istria CLA 2014-06-30 07:09:47 EDT
(In reply to Mickael Istria from comment #8)
> CommonNavigator currently contains:
> 
>   public boolean isSaveAsAllowed() {
>     return false;
>   }
> 
> I tried to replace the "false" by "isDirty()", and then everything seems to
> work fine. Would this "isDirty()" be a better implementation?
> That would be great since it doesn't require any API change. Is isDirty() a
> good enough implementation? At least, it seems better than "false"...

Please ignore this comment, which was totally wrong.
Comment 10 Mickael Istria CLA 2014-06-30 08:07:19 EDT
If I understand correctly, the CommonNavigator was designed this way (using a NavigatorSaveableService and implementing the SaveableSource and SaveablePart interfaces) because it was designed in order to be used as an editor too. Am I right?
If so, then the Project Navigator is not meant to be an editor, but a Navigator, so we could think of overriding the right methods to delegate save state to editors.

Would that be an acceptable fix?
Comment 11 Paul Webster CLA 2014-07-02 10:15:14 EDT
I had looked into it, and really the appropriate fix here would be for the default content provider in org.eclipse.ui.navigator.resources to provide the saveables through the CNF API.

PW
Comment 12 Mickael Istria CLA 2014-07-04 07:23:19 EDT
I'm digging in the code of CNF and Saveable and it's not very obvious to me...
In order to fix this bug, it seems like that things to provide are:
* a SaveableProvider instance that would return as Saveable the current active editor. Let's call it "ActiveEditorSaveableProvider"
* Make the ResourceExtensionContentProvider implement IAdaptable and make the adapt() method return my ActiveEditorSaveableProvider.

Would this work? Is that all?
If it is enough, wouldn't it be better to create a DummyContentProvider which would adapt the the ActiveEditorSaveableProvider (since after all, the ActiveEditorSaveableProvider is not related at all with the ResourceExtensionsContentProvider) ?
Comment 13 Mickael Istria CLA 2014-08-20 11:58:33 EDT
The more I look at the NavigatorSaveableService, the more I have the impression that it's just that the Package Explorer should not at all rely on the save mechanism provided by CNF.
With save implementation relying on CNF for Package Explorer, then the save is computed/enabled depending on what's selected inside the Project Navigator. It seems totally counter intuitive as the Package Explorer and all other edition tools in general only take into account the opened editors to decide what to save or not.
Even if implementing the right ContentProvider and SaveableSources, it would just be a terrible hack that would introduce the fact that whatever is the context of the CNF, the NavigationSaveableService returns the current editor as saveable. It's IMO much cleaner to say that Package Explorer doesn't want to rely on the NavigationSaveableService or doesn't want to contribute to the save action enablement.
Comment 14 Paul Webster CLA 2014-08-20 21:13:28 EDT
The Project Explorer needs to respond to pluggable saveables.  Products use the CNF pluggable capabilities but expose it by simply adding the Project Explorer in their perspectives.

The Project Explorer can't just suddenly only track the active editor.

That's why having org.eclipse.core.navigator.resources implement the active editor using the standard CNF mechanism is probably the only way to solve this bug.

PW
Comment 15 Mickael Istria CLA 2014-08-21 03:17:35 EDT
Products that rely on CNF to compute the save state of Project Navigator may be unhappy with that change since it would break there assumptions on Project Navigator behaviour.
Is it acceptable to change so much the default behaviour, in one way or the other?
Comment 16 Eclipse Genie CLA 2019-05-31 02:49:00 EDT
New Gerrit change created: https://git.eclipse.org/r/143097
Comment 17 Mickael Istria CLA 2019-05-31 11:48:36 EDT
(In reply to Eclipse Genie from comment #16)
> New Gerrit change created: https://git.eclipse.org/r/143097

Patch set 3 is promising, we'll most likely manage to polish it and get it fixed early in 4.13.
Comment 19 Mickael Istria CLA 2019-06-16 03:25:08 EDT
Thank you!
Comment 20 Mickael Istria CLA 2019-06-22 17:50:06 EDT
Reopening: With this patch, the "dirty" marker is sometimes shown of Project Explorer. This is not desired.
Comment 21 Eclipse Genie CLA 2019-06-23 13:29:52 EDT
New Gerrit change created: https://git.eclipse.org/r/144681
Comment 22 Lakshminarayana CLA 2019-06-23 13:32:34 EDT
(In reply to Mickael Istria from comment #20)
> Reopening: With this patch, the "dirty" marker is sometimes shown of Project
> Explorer. This is not desired.

Fix https://git.eclipse.org/r/144681
Comment 23 Mickael Istria CLA 2019-06-24 03:29:34 EDT
@Laksminarayana: Can you please also add a note about this noticeable improvement in the N&N => https://git.eclipse.org/c/www.eclipse.org/eclipse/news.git ?
Comment 25 Andrey Loskutov CLA 2019-06-24 04:14:35 EDT
(In reply to Eclipse Genie from comment #24)
> Gerrit change https://git.eclipse.org/r/144681 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=07f05f87e6f140d55afc9bb1a8f4cc9c897b682f

This causes API error:

The superinterfaces set has been expanded for class 
 org.eclipse.ui.navigator.resources.ProjectExplorer

Please fix.
Comment 26 Lakshminarayana CLA 2019-06-24 04:44:34 EDT
(In reply to Andrey Loskutov from comment #25)
>
> This causes API error:
> 
> The superinterfaces set has been expanded for class 
>  org.eclipse.ui.navigator.resources.ProjectExplorer
> 
> Please fix.

I couldn't reproduce it in my workspace. Can you provide more details? Where can I check?
Comment 27 Andrey Loskutov CLA 2019-06-24 04:56:04 EDT
(In reply to Lakshminarayana from comment #26)
> (In reply to Andrey Loskutov from comment #25)
> >
> > This causes API error:
> > 
> > The superinterfaces set has been expanded for class 
> >  org.eclipse.ui.navigator.resources.ProjectExplorer
> > 
> > Please fix.
> 
> I couldn't reproduce it in my workspace. Can you provide more details? Where
> can I check?

You should have API tooling installed, API baseline set to 4.12 and run clean build on org.eclipse.ui.navigator.resources project.
Comment 28 Mickael Istria CLA 2019-06-24 05:01:33 EDT
(In reply to Andrey Loskutov from comment #27)
> You should have API tooling installed, API baseline set to 4.12 and run
> clean build on org.eclipse.ui.navigator.resources project.

I also don't see the problem you're mentioning, while API Baseline is set.
But I do see "The minor version should be incremented in version 3.6.600, since new APIs have been added since version 3.6.500".
I also tried it with the API Tools application used in build and didn't see it. Investigating...
Comment 29 Lakshminarayana CLA 2019-06-24 05:07:39 EDT
(In reply to Mickael Istria from comment #28)
> (In reply to Andrey Loskutov from comment #27)
> > You should have API tooling installed, API baseline set to 4.12 and run
> > clean build on org.eclipse.ui.navigator.resources project.
> 
> I also don't see the problem you're mentioning, while API Baseline is set.
> But I do see "The minor version should be incremented in version 3.6.600,
> since new APIs have been added since version 3.6.500".
> I also tried it with the API Tools application used in build and didn't see
> it. Investigating...

Yes, I also have the same situation.
Comment 30 Andrey Loskutov CLA 2019-06-25 04:14:17 EDT
(In reply to Mickael Istria from comment #28)
> (In reply to Andrey Loskutov from comment #27)
> > You should have API tooling installed, API baseline set to 4.12 and run
> > clean build on org.eclipse.ui.navigator.resources project.
> 
> I also don't see the problem you're mentioning, while API Baseline is set.
> But I do see "The minor version should be incremented in version 3.6.600,
> since new APIs have been added since version 3.6.500".
> I also tried it with the API Tools application used in build and didn't see
> it. Investigating...

This IS what I see, I just made it easier for you to understand where the error is coming from. If you look into the error details (Ctrl+1 on error in manifest), you will see the error.

However PDE API tooling is most likely wrong. The class is final, and addition of a method to a final class is not an API break (no one can extend final class), see notes on https://wiki.eclipse.org/Evolving_Java-based_APIs#Example_4_-_Adding_an_API_method.

I've created PDE bug for that, see bug 548607.

I hate compilation errors in my workspace, but I'm not sure if the fix is trivial or not, let wait for Vikas answer on bug 548607 before updating version.
Comment 31 Mickael Istria CLA 2019-06-25 04:22:27 EDT
(In reply to Andrey Loskutov from comment #30)
> This IS what I see

Ok, good then.

> However PDE API tooling is most likely wrong. The class is final, and
> addition of a method to a final class is not an API break (no one can extend
> final class), see notes on
> https://wiki.eclipse.org/Evolving_Java-based_APIs#Example_4_-
> _Adding_an_API_method.

I've given more thoughts about it this morning, and I think we're in a regular error case that requires a regular *minor* version bump.
What's reported here is actually not an API Breakage, but more an API addition (ie ProjectExplorer can now be dereferenced for usage of ISecondarySaveableSource#isDirtyStateSupported).

I think we should just bump version to 3.7.0.
Comment 32 Andrey Loskutov CLA 2019-06-25 04:25:02 EDT
(In reply to Mickael Istria from comment #31)
> I think we should just bump version to 3.7.0.

Yes, I was on a wrong trip with the API bug. Please bump the version.
Comment 33 Eclipse Genie CLA 2019-06-25 04:28:07 EDT
New Gerrit change created: https://git.eclipse.org/r/144811
Comment 35 Mickael Istria CLA 2019-06-25 05:13:09 EDT
Thanks Laksminarayana and Andrey!
@Laksminarayana Can you please add a note about this in the news and noteworthy document for the 4.13 release?
Comment 36 Lakshminarayana CLA 2019-06-25 06:11:59 EDT
(In reply to Mickael Istria from comment #35)
> Thanks Laksminarayana and Andrey!
> @Laksminarayana Can you please add a note about this in the news and
> noteworthy document for the 4.13 release?

okay, will add in a bit
Comment 37 Eclipse Genie CLA 2019-06-25 14:31:15 EDT
New Gerrit change created: https://git.eclipse.org/r/144870
Comment 39 Mickael Istria CLA 2019-06-25 15:20:49 EDT
Thanks  Lakshminarayana!