Bug 23862 - [PropertiesView] Properties view doesn't update when switching between editors
Summary: [PropertiesView] Properties view doesn't update when switching between editors
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.13 M1   Edit
Assignee: Rolf Theunissen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 43085 73552 190355 (view as bug list)
Depends on:
Blocks: 57901
  Show dependency tree
 
Reported: 2002-09-19 12:23 EDT by Jeff Kobal CLA
Modified: 2021-06-23 08:11 EDT (History)
11 users (show)

See Also:


Attachments
NullPointerException trace in TabbedPropertySheetPage.createTabComposite. (4.12 KB, text/plain)
2020-01-13 04:57 EST, Georgiana Ecobici CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Kobal CLA 2002-09-19 12:23:32 EDT
Open up two files from the Navigator, and enable the "Properties" view.  Notice 
that as you click on each file in the Navigator, the Properties view is updated 
with the properties for that file, and the editor for that file comes to the 
front, as expected.  However, if you click on the editor tabs for each of those 
files, the Properties view does NOT update (though the highlighted file DOES 
change in the Navigator window as expected); instead, the last file clicked in 
the Navigator is still shown in the Properties view.
Comment 1 Nick Edgar CLA 2003-05-22 14:17:31 EDT
Investigating as candidate for 2.1.1, in conjunction with another bug: bug 
36501.
Comment 2 Lynne Kues CLA 2003-05-22 16:57:31 EDT
The Properties View  adds itself as a selection listener for the workbench 
page.  However, the Properties View will only update itself when the Resource 
Navigator is active (i.e., has focus).  When selecting editor tabs, the 
ResourceNavigator is not active, so no updates for the Properties View occur.  
This is how the selection service for the Workbench Page is set up to work.  
Should defer this until after 2.1.1 because any fix would not be simple.
Comment 3 Nick Edgar CLA 2003-05-23 09:51:48 EDT
Since this is not a regression from 2.0.3, we have decided to defer this.

Should address for R3.0 by tracking editor inputs, not just selection.
(This must be done in a generic way, not tied to IResource.)
Comment 4 Jeff Kobal CLA 2003-05-23 10:19:51 EDT
I'm not sure I understand the difficulty here.  The Navigator window updates the
"selected" resource when you switch editor tabs, so can't the properties view
update based on the IResource selected in the Navigator, even when it isn't in
focus?
Comment 5 Michael Van Meekeren CLA 2004-05-21 13:15:41 EDT
Marking as LATER please respond if you think this is critical for 3.0
Comment 6 Denis Roy CLA 2009-08-30 02:15:13 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.
Comment 7 Dani Megert CLA 2009-09-17 11:55:44 EDT
This is something we should simply fix. For editors we could use the editor input as fallback if there's not structured selection.
Comment 8 Jeff Kobal CLA 2009-09-17 12:55:49 EDT
I didn't understand as much about the Workbench back in 2002/2003 when I opened this bug, but I think I get the difficulty now.  The Properties View is populated by the active View in the workbench.  For example, if you open up two Java source files, and switch between those resources in the Navigator or Package Explorer, you will see the Properties update for the selected Resource.  If you then click on the different Java methods listed in the Outline View, you will see the Properties update for the selected method.  If you then click on either of the Java Source Editors, the Properties View doesn't update at all (it keeps the previous contents).  This is because the ViewPart (EditorPart) that corresponds to each of the editors isn't updating the Properties View by default.

So what Daniel says makes sense -- if the editor doesn't have a StructuredSelection to provide to the Properties View, the default behavior for the EditorPart would be to query the EditorInput for the IResource being edited (if one exists), and provide that resource's properties to the Properties View, instead of continuing to show outdated information.
Comment 9 Eric Moffatt CLA 2009-09-18 13:23:31 EDT
Sounds good to me. If we make the text editor a property source that would get us most of the cases (many of the non-text editors like GEF are already providing properties so they wouldn't have any issues).
Comment 10 Dani Megert CLA 2009-09-18 13:51:47 EDT
>If we make the text editor a property source
What would that mean? Would it help if text editors provide
Comment 11 Dani Megert CLA 2009-09-18 13:58:47 EDT
>>If we make the text editor a property source
>What would that mean? Would it help if text editors provide
I love bugzilla (do I?).

Does the framework query IPropertySourceProvider on selection changed - I'm not positive on this? One remaining issue is that the properties view does not nicely deal with post selection changed events (see bug 162079).
Comment 12 Dani Megert CLA 2014-07-29 07:04:38 EDT
*** Bug 73552 has been marked as a duplicate of this bug. ***
Comment 13 Dani Megert CLA 2014-07-29 07:04:45 EDT
*** Bug 43085 has been marked as a duplicate of this bug. ***
Comment 14 Dani Megert CLA 2017-12-18 11:08:14 EST
Still an issue.
Comment 15 Dani Megert CLA 2017-12-18 11:08:17 EST
*** Bug 190355 has been marked as a duplicate of this bug. ***
Comment 16 Rolf Theunissen CLA 2017-12-19 07:46:50 EST
In fact, as the editor has focus and the Java editor does not provide properties, the properties view should show the default (empty) properties page and not follow the selection in the navigator. This behavior can be observed when using the project explorer (when the package explorer is closed).

This bug seems to be caused by the package explorer.
Comment 17 Dani Megert CLA 2017-12-19 09:11:29 EST
(In reply to Rolf Theunissen from comment #16)
> This bug seems to be caused by the package explorer.

I'd say this is 99% wrong. If you disagree, please provide sound proof of your accusations.
Comment 18 Rolf Theunissen CLA 2017-12-19 14:51:55 EST
(In reply to Dani Megert from comment #17)
> (In reply to Rolf Theunissen from comment #16)
> > This bug seems to be caused by the package explorer.
> 
> I'd say this is 99% wrong. If you disagree, please provide sound proof of
> your accusations.

Sorry, my conclusion was per-mature. In fact, after a closer look, the problem might result from the PropertiesView only handling IStructeredSelection, in its default page. And this page is shared by all parts that do not provide a custom PropertiesViewPaga.

See, PropertySheetPage line 554:
if (selection instanceof IStructuredSelection) { ... }

If it is not a IStructuredSelection, the selection is ignored, the previous selection is still being displayed. As a result, the default properties page shows the last selected IStructuredSelection.

Doing something sane (instead of ignoring) like the snippet below, does update the default properties page selection.


// change the viewer input since the workbench selection has changed.
if (selection instanceof IStructuredSelection) {
    sourcePart = part;
    viewer.setInput(((IStructuredSelection) selection).toArray());
} else {
    sourcePart = part;
    viewer.setInput(new Object[] { selection });
}

However, I have no clue what the side effects of this code might be, or if this behavior makes any sense.
Comment 19 Eclipse Genie CLA 2018-11-24 09:48:22 EST
New Gerrit change created: https://git.eclipse.org/r/133028
Comment 20 Rolf Theunissen CLA 2018-11-24 09:54:08 EST
(In reply to Eclipse Genie from comment #19)
> New Gerrit change created: https://git.eclipse.org/r/133028

With this patch, the behavior as described in option 1 of Bug 57901 comment 4 is implemented:
> 1. It shows properties for the last active part, if any (excluding the
> Properties view itself).  Optionally, check the active editor if the active view
> provides no properties.

Also, the default properties view will show the properties for the current file that is edited in the active editor, if no other structural selection is provided.
Comment 22 Rolf Theunissen CLA 2019-06-15 12:14:16 EDT
(In reply to Eclipse Genie from comment #21)
> Gerrit change https://git.eclipse.org/r/133028 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=3f86f44d634a9b9c56a3904b041673b498e1e948

I found one regression with this, multiple property views are not correctly ignored when selected. This results in a stackoverflow error.

I will push a fix as after git is accessible over https again.
Comment 23 Eclipse Genie CLA 2019-06-15 15:55:10 EDT
New Gerrit change created: https://git.eclipse.org/r/144122
Comment 25 Rolf Theunissen CLA 2019-06-16 08:17:17 EDT
I think this one is fixed now. The properties view will change for any important part change.
If any issues occur as a result of this new behavior, I suggest to open new bugs to solve them.
Comment 26 Lars Vogel CLA 2019-06-30 06:45:04 EDT
Thanks, Rolf for working on this ancient issue.
Comment 27 Georgiana Ecobici CLA 2020-01-13 04:57:33 EST
Created attachment 281461 [details]
NullPointerException  trace in TabbedPropertySheetPage.createTabComposite.

After applying the patch for this fix, I still have NullPointerException in TabbedPropertySheetPage.createTabComposite.
Comment 28 Rolf Theunissen CLA 2020-01-13 06:00:25 EST
(In reply to Georgiana Ecobici from comment #27)
> Created attachment 281461 [details]
> NullPointerException  trace in TabbedPropertySheetPage.createTabComposite.
> 
> After applying the patch for this fix, I still have NullPointerException in
> TabbedPropertySheetPage.createTabComposite.

This Bug and fix are unrelated to the TabbedPropertySheetPage, please create a new bug report for this issue. Include the precise version of Eclipse you are using. And how to reproduce it, that is which editors are you using when the NPE occurs.