Bug 448873 - [Perspectives] [Contributions] View Actions Icons Duplication after Reset Perspectives
Summary: [Perspectives] [Contributions] View Actions Icons Duplication after Reset Per...
Status: CLOSED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4.1   Edit
Hardware: PC Windows 7
: P3 major with 10 votes (vote)
Target Milestone: 4.5 M5   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 448865 (view as bug list)
Depends on:
Blocks: 420956
  Show dependency tree
 
Reported: 2014-10-26 06:22 EDT by Wael Mashal CLA
Modified: 2018-03-19 17:56 EDT (History)
4 users (show)

See Also:


Attachments
duplicated icons Breakpoins view - Debug Perspective (62.31 KB, image/png)
2014-10-26 06:22 EDT, Wael Mashal CLA
no flags Details
Duplication icons test project (15.40 KB, application/octet-stream)
2014-10-27 08:08 EDT, Wael Mashal CLA
no flags Details
ContibutionManager patch (1.02 KB, application/octet-stream)
2014-11-10 04:03 EST, Wael Mashal CLA
no flags Details
ContributionManeger patch (1.02 KB, patch)
2014-11-10 04:05 EST, Wael Mashal CLA
no flags Details | Diff
Commit and Push Message (33.98 KB, image/png)
2014-11-16 03:36 EST, Wael Mashal CLA
no flags Details
Commit and Push Error Message (24.99 KB, image/png)
2014-11-16 03:36 EST, Wael Mashal CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wael Mashal CLA 2014-10-26 06:22:43 EDT
Created attachment 248188 [details]
duplicated icons Breakpoins view - Debug Perspective

The Actions icons duplicated when the view is not the default and focused and then we click on reset perspective menu option 

How to reproduce :

1- Run Eclipse 4.4.1 or 4.4.0
2- Change to debug perspective 
3- Select Breakpoins view (Breakpoins focused)
4- Go to Window -> Reset Perspective...
5- Reopen the Breakpoins view

Expected:
We have the same icons before the reset

Actual :
all the action icons duplicated (see the attached)

Important notes :

  1- this bug not reproduced on 4.3 
  2- this bug reproduced on all perspective with the above steps and when the view not the default on in the perspective 
  3- with my own perspective also reproduced when I build the view using code     also with plugin.xml tags
Comment 1 Wojciech Sudol CLA 2014-10-27 04:28:45 EDT
Menu items in view menu are duplicated as well. Repeating provided steps adds another set of duplicated icons and menu items.
A workaround is to close and reopen the view.
Comment 2 Wael Mashal CLA 2014-10-27 08:07:24 EDT
Hi

I investigate deeply on this issue and I have some finds:

This bug reproduced just when we use org.eclipse.ui.viewActions extension point for the view tool bar actions instead of org.eclipse.ui.menus and org.eclipse.ui.commands , as you see in the attached project "test" plugin.xml I added view "SampleView" under Java Perspective with two actions one using the viewActions "duplecated" and the Other using menuContribution "No duplication" . then when I tried to reproduce the bug , just the viewActions action icon duplicated.

Also from the eclipse docs I noted that the viewActions deprecated

"WARNING: This extension point is DEPRECATED.
Do not use this extension point, it will be removed in future versions of this product. Instead, use the extension 
 point org.eclipse.ui.commands 
You can now use org.eclipse.ui.menus to place commands in menus and toolbars as well.
"

Important questions :
1- what the main difference between  viewActions and menuContribution ?
2- is there any plan to change eclipse views like Project Explorer , Debug breakpoints , Navigator ..etc to use menuContribution instead viewActions ? if this solution the right one?

please advice ?

Thanks
Comment 3 Wael Mashal CLA 2014-10-27 08:08:31 EDT
Created attachment 248201 [details]
Duplication icons test project
Comment 4 Wael Mashal CLA 2014-11-06 02:41:21 EST
Hi

Any updates ? is there any chance to create a patch or mention the root cause for this issue to create our own local patch , unfortunately am still debugging with no results until now , please advice ? 

Thanks
Comment 5 Wojciech Sudol CLA 2014-11-06 05:45:02 EST
This bug has been introduced with commit http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=1c012e53763fb76d851642928fd1ccb7d9844deb which was a fix for bug 425928.
Comment 6 Wael Mashal CLA 2014-11-06 06:39:52 EST
Hi

I don't follow you sorry ,
How this commit related to my reported bug ? 

do you have a chance to take a look to the attached plugin project ?


Thanks
Comment 7 Wael Mashal CLA 2014-11-06 06:40:11 EST
(In reply to Wojciech Sudol from comment #5)
> This bug has been introduced with commit
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=1c012e53763fb76d851642928fd1ccb7d9844deb which was a fix for bug 425928.

Hi

I don't follow you sorry ,
How this commit related to my reported bug ? 

do you have a chance to take a look to the attached plugin project ?


Thanks
Comment 8 Wael Mashal CLA 2014-11-09 06:51:46 EST
(In reply to Wojciech Sudol from comment #5)
> This bug has been introduced with commit
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=1c012e53763fb76d851642928fd1ccb7d9844deb which was a fix for bug 425928.
Hi

I checked out the source code for org.eclipse.e4.ui.workbench.renderers.swt StackRenderer.java and I changed the code as below but icon duplication bug still reproduced , please advice ?

if (needsTB) {
    part.getToolbar().setVisible(true);
    newViewTB = (ToolBar) renderer.createGui(part.getToolbar(),ctf.getTopRight(),     part.getContext());
   if (newViewTB == null) {
        adjusting = false;
	return;
   }
   newViewTB.moveAbove(null);
   newViewTB.pack();
} 



Thanks
Comment 9 Wael Mashal CLA 2014-11-10 04:02:59 EST
Hi

I am trying to resolve this bug by adding a code for ignoring the duplicated items depend on item "id" in ContributionManager class @ itemAdded method 

please find the attached patch,

please advice if this patch accepted or we should solve it in a different way ?

Thanks
Comment 10 Wael Mashal CLA 2014-11-10 04:03:49 EST
Created attachment 248531 [details]
ContibutionManager patch
Comment 11 Wael Mashal CLA 2014-11-10 04:05:21 EST
Created attachment 248533 [details]
ContributionManeger patch
Comment 12 Wojciech Sudol CLA 2014-11-12 11:31:15 EST
(In reply to Wael Mashal from comment #8)
> I checked out the source code for org.eclipse.e4.ui.workbench.renderers.swt
> StackRenderer.java and I changed the code as below but icon duplication bug
> still reproduced , please advice ?

Did you test this change with IDE or with your project? It works fine for me with IDE. Anyway a more complex fix is necessary to avoid reintroducing bug 425928. I will try to take a look at your patch this week.
Comment 13 Wael Mashal CLA 2014-11-13 02:38:03 EST
(In reply to Wojciech Sudol from comment #12)
> (In reply to Wael Mashal from comment #8)
> > I checked out the source code for org.eclipse.e4.ui.workbench.renderers.swt
> > StackRenderer.java and I changed the code as below but icon duplication bug
> > still reproduced , please advice ?
> 
> Did you test this change with IDE or with your project? It works fine for me
> with IDE. Anyway a more complex fix is necessary to avoid reintroducing bug
> 425928. I will try to take a look at your patch this week.

Yes , its work fine , and I have two local patches version now for 4.4.0 and 4.4.1
Comment 14 Wael Mashal CLA 2014-11-13 08:07:32 EST
(In reply to Wael Mashal from comment #13)
> (In reply to Wojciech Sudol from comment #12)
> > (In reply to Wael Mashal from comment #8)
> > > I checked out the source code for org.eclipse.e4.ui.workbench.renderers.swt
> > > StackRenderer.java and I changed the code as below but icon duplication bug
> > > still reproduced , please advice ?
> > 
> > Did you test this change with IDE or with your project? It works fine for me
> > with IDE. Anyway a more complex fix is necessary to avoid reintroducing bug
> > 425928. I will try to take a look at your patch this week.
> 
> Yes , its work fine , and I have two local patches version now for 4.4.0 and
> 4.4.1

I mean my patch works fine , :-)
Comment 15 Wojciech Sudol CLA 2014-11-13 08:46:56 EST
(In reply to Wael Mashal from comment #14)
> I mean my patch works fine , :-)

And I meant the code from comment 8 :) . Anyway, could you push your patch to Gerrit - https://wiki.eclipse.org/Platform_UI/How_to_Contribute#Creating_a_Gerrit_review_or_a_patch ?
Comment 16 Wael Mashal CLA 2014-11-13 09:35:37 EST
(In reply to Wojciech Sudol from comment #15)
> (In reply to Wael Mashal from comment #14)
> > I mean my patch works fine , :-)
> 
> And I meant the code from comment 8 :) . Anyway, could you push your patch
> to Gerrit -
> https://wiki.eclipse.org/Platform_UI/
> How_to_Contribute#Creating_a_Gerrit_review_or_a_patch ?

Yes I commit to master , but I face an issue with pushing

I Got this Message 

 http://wmashalu5i@git.eclipse.org/gitroot/platform/eclipse.platform.ui.git: git-receive-pack not permitted
Comment 17 Wojciech Sudol CLA 2014-11-13 10:54:39 EST
It looks like an URL to Git repository - not Gerrit. Did you follow the article mentioned in the link from comment 15? You can find more information about Gerrit configuration here: https://wiki.eclipse.org/EGit/Contributor_Guide#Using_Gerrit_at_Eclipse .
Comment 18 Michael Rennie CLA 2014-11-13 15:20:35 EST
*** Bug 448865 has been marked as a duplicate of this bug. ***
Comment 19 Wael Mashal CLA 2014-11-16 03:35:28 EST
(In reply to Wojciech Sudol from comment #17)
> It looks like an URL to Git repository - not Gerrit. Did you follow the
> article mentioned in the link from comment 15? You can find more information
> about Gerrit configuration here:
> https://wiki.eclipse.org/EGit/Contributor_Guide#Using_Gerrit_at_Eclipse .

Yes, and I used Gerrit before , the commit Message 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bug 448873 - [Perspectives] [Contributions] View Actions Icons Duplication after Reset Perspectives 

The Actions icons duplicated when the view is not the default and focused and then we click on reset perspective menu option 

Change-Id: I0000000000000000000000000000000000000000
Signed-off-by: wmashalu5i <Wael.mashal@softwareag.com>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


<Changed ID auto generated>

but when I click on Commit and Push button I got the Error <See attached>
Comment 20 Wael Mashal CLA 2014-11-16 03:36:22 EST
Created attachment 248685 [details]
Commit and Push Message
Comment 21 Wael Mashal CLA 2014-11-16 03:36:50 EST
Created attachment 248686 [details]
Commit and Push Error Message
Comment 22 Andrey Loskutov CLA 2015-01-06 15:23:48 EST
I've uploaded the (modified) patch:  https://git.eclipse.org/r/39074
Comment 23 Andrey Loskutov CLA 2015-01-11 05:39:50 EST
(In reply to Andrey Loskutov from comment #22)
> I've uploaded the (modified) patch:  https://git.eclipse.org/r/39074

According to Paul the patch is not OK: "For legacy reasons, it's perfectly valid to have 2 IContributionItems with the same ID in one ContributionManager, as long as they're not the same ICI instance."

I also agree that the problem should be fixed at the root. 
I've played now how this duplication happens.

1) if one creates perspective with a single breakpoints view, the buttons aren't duplicated on reset.
2) if one creates perspective with a the variables and breakpoints views next to each other (not in the same stack), the buttons aren't duplicated on reset.
3) if one creates perspective with a the variables and breakpoints views behind (in the same stack):
3.1) if the breakpoints view is visible the buttons aren't duplicated on reset.
3.2) if the breakpoints view is NOT visible the buttons ARE duplicated on reset.

So the problem can be reproduced only by resetting perspective while the view is hidden behind other views. Visible views aren't affected.

The fixes for  bug 383569 and bug 420956 (https://git.eclipse.org/r/39349) aren't affecting this behavior, so this is most likely not a page/window/toolbar/coolbar issue but the org.eclipse.ui.internal.e4.compatibility.ActionBars problem.

I will try to debug it.
Comment 24 Andrey Loskutov CLA 2015-01-11 11:50:21 EST
(In reply to Wojciech Sudol from comment #5)
> This bug has been introduced with commit
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?id=1c012e53763fb76d851642928fd1ccb7d9844deb which was a fix for bug 425928.

That's true. Reverting this change fixes this issue. 
CompatibilityView.createPartControl() installs IContextFunction on the view to populate the view's toolbar via actionBuilder.readActionExtensions(getView()) and this happens now *twice*.

Details:
###
StackRenderer.adjustTopRight() is called now twice (on StackRenderer.showTab() and on ActionBars.updateActionBars()) and inside the adjustTopRight() renderer is asked to create toolbar's GUI:

if (needsTB && part != null && part.getObject() != null) {
	part.getToolbar().setVisible(true);
	newViewTB = (ToolBar) renderer.createGui(part.getToolbar(),
	ctf.getTopRight(), part.getContext());

ToolBarManagerRenderer.postProcess() checks if there is POST_PROCESSING_FUNCTION installed and finds the IContextFunction from CompatibilityView, which is then called. This function lets ViewActionBuilder to read and contribute extensions to the view toolbar => therefore only "legacy" contributions are affected.
###

One can fix it in the CompatibilityView so that IContextFunction computes the toolbar contributions only once, but I'm not sure if this is the right solution because it still not a fix for the root cause, also one of the POST_PROCESSING_DISPOSE callbacks will be then lost (even if they aren't used yet at all).

Anyway, next try: https://git.eclipse.org/r/39352
Comment 25 Andrey Loskutov CLA 2015-02-07 18:46:27 EST
Fixed in 4.5 M5 via https://git.eclipse.org/r/39352.