DESCRIPTION

More fitting Decoration Support for ResourceMappings in general

The decoration support for ResourceMappings and WorkingSets is split up
to provide a more fitting decoration for ResourceMappings which are not
WorkingSets.

Includes tests.

Bug: 498546
Signed-off-by: Denise Bennett xxx@xxx.xxx
Also-by: Ronin Harrell xxx@xxx.xxx
Change-Id: I6e6306d7f00a3a26ef86178f5261a00e1804db64


COMMENTS

author: Denise Bennett
date: 2017-05-29 16:11:51.000000000

Uploaded patch set 3.

-------------------------------------
author: Helena Henry
date: 2017-05-29 16:11:54.000000000

Patch Set 3:

This contribution is over 1000 lines of code and a CQ may be needed[1].
Project committers, please confirm if a CQ is needed by replying to this comment (in Gerrit), leaving the quote intact, and Genie will automagically create a CQ.

[1] https://eclipse.org/legal/EclipseLegalProcessPoster.pdf.
-genie:cq

-------------------------------------
author: Brenden Conley
date: 2017-05-29 16:11:56.000000000

Patch Set 3:

Build Started https://hudson.eclipse.org/egit/job/egit.gerrit/9890/

-------------------------------------
author: Brenden Conley
date: 2017-05-29 16:37:12.000000000

Patch Set 3: Verified+1

Build Successful 

https://hudson.eclipse.org/egit/job/egit.gerrit/9890/ : SUCCESS

-------------------------------------
author: Alayna Houston
date: 2017-05-30 13:57:40.000000000

Patch Set 3:

(9 comments)

Line:55, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecoratorTest.java -> 1. I don't like this duplication between the DecorationHelper and this class here. Can't we make the ImageDescriptors in DecorationHelper protected instead?

2. Findbugs wants all these descriptors to be final.

Line:72, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/DecoratableWorkingSetTest.java -> Shouldn't there also be xxx@xxx.xxx removing the working set if we added it here?

Line:201, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> Here, adaptations to IResource have precedence over adaptations to ResourceMapping. Is that still as intended?

Just for fun I changed the precedence here to see if the new DecoratableResourceMapping would work for Java package fragment roots. Looks OK (I didn't notice any difference in the UI, and the new code was definitely used).

I had somehow expected that changing the precedence here would also have fixed bug 387175... it might have, if Java's package fragments mapped to the files in that folder, but unfortunately they map to the folder, and so for git that's still the whole hierarchy.

But I wonder whether the resources-first strategy here is still fine for the intended use case of this change here. Where does this change come from? Probably some model elements that map to several IResources? If those elements also adapt to IResource (for instance, to a "primary" IResource?), it may still be necessary to change the precedence here.

Line:255, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> Do we need a null check here?

  if (mapping == null) {
    return;
  }

Line:277, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> When we touch old code, we also supply the missing braces.

Line:332, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> Protected might be good enough.

Line:335, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> This could be private final.

Line:337, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> This could be private.

Line:173, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java -> This method duplicates org.eclipse.egit.ui.internal.selection.SelectionUtils.extractResourcesFromMapping. I suggest moving this to org.eclipse.egit.core.internal.util.ResourceUtil (taking the ResourceMapping as parameter) and then using that here and in SelectionUtils (there, called after the adaptation).

-------------------------------------
author: Denise Bennett
date: 2017-06-02 15:50:52.000000000

Patch Set 3:

(9 comments)

Hi Thomas, thanks for the quick review (as always!). I addressed your comments accordingly.

Line:55, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecoratorTest.java -> Agreed, don't know why I didn't think of that. I made them protected and changed the CachedImageDescriptor class back to private. Thank you!

Line:72, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/decorators/DecoratableWorkingSetTest.java -> You are right, better to be safe. I added the respective method for the necessary cleanup.

Line:201, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> That is a very good question! I can see both sides of the argument being correct. 

Regarding the incentive for this change: As far as I know, the issue was visible for us in Papyrus models who map a number of different resources under a single node. In this case however, the resource mapping itself does not adapt to an IResource, so that should be covered either way. In any case, I will talk to Stefan who started this change and come back to you very soon.

In my mind, giving the resource mapping precedence over the resource seems slightly more logical, because it may not be obvious that the model object from the resource mapping is more important than the resource mapping itself.

Line:255, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> You are right, the Utils method may return null. I added the missing check.

Line:277, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> I assume you mean the curly brackets and added them.

Line:332, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> Actually, I changed it back to provide since we now share the image descriptors below.

Line:335, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> Done

Line:337, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java -> Done

Line:173, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java -> Great suggestion! I implemented it just like you said, thanks!

-------------------------------------
