DESCRIPTION

Show 'Add to Index' and related team menu entries only when applicable

Change the menu configurations for 'Add to Index', 'Remove from Index',
and 'Ignore' from deprecated action to command/handler and a
menuContribution. Provide visibleWhen and activeWhen specifications
using the new properties isStaged, isIgnored, and hasUnstagedChanges.

Bug: 355809
Change-Id: I35176f8ee77264c334d2c7d9b4333f4dd67fb458
Signed-off-by: Alayna Houston xxx@xxx.xxx

COMMENTS

author: Jayvion Booth
date: 2015-11-26 18:27:10.000000000

Patch Set 4: Code-Review+2

-------------------------------------
author: Brenden Conley
date: 2015-11-26 19:12:33.000000000

Patch Set 4:

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

-------------------------------------
author: Brenden Conley
date: 2015-11-26 19:36:15.000000000

Patch Set 4: Verified+1

Build Successful 

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

-------------------------------------
author: Douglas Trujillo
date: 2015-11-26 21:11:17.000000000

Patch Set 4: Code-Review-2

with this change the following menu actions are no longer shown e.g. on projects, packages, resources in the package explorer

* Team > Add to Index
* Team > Remove from Index
* Team > Ignore

-------------------------------------
author: Jayvion Booth
date: 2015-11-26 21:42:25.000000000

Patch Set 4: -Code-Review

> with this change the following menu actions are no longer shown
 > e.g. on projects, packages, resources in the package explorer
 > 
 > * Team > Add to Index
 > * Team > Remove from Index
 > * Team > Ignore

This menu entries are now context sensitive. So if there is nothing to do for them they aren't shown. Do you mean they should be shown but as "disabled"? I will check the code again tomorrow...

-------------------------------------
author: Douglas Trujillo
date: 2015-11-26 23:02:05.000000000

Patch Set 4:

> This menu entries are now context sensitive. So if there is nothing
 > to do for them they aren't shown. Do you mean they should be shown
 > but as "disabled"? I will check the code again tomorrow...

This doesn't work, I tried with a dirty file, the "Add to Index" is neither shown on team menu in package explorer nor in team menu in the Java editor opened for the modified class. Same for "Remove from Index" on a file with staged modifications and for a new class with "Ignore" action.

If this works reliably I am fine to only show the commands which make sense on the selected resource, though this may be tricky or expensive to compute on packages, folders and projects, we should avoid a performance penalty here

-------------------------------------
author: Alayna Houston
date: 2015-11-27 06:57:01.000000000

Patch Set 4:

I had tested with a general project, and that worked. But indeed, this doesn't work with a Java project, or with any other contributed items that don't implement IResource (the type that ResourcePropertyTester tester is registered to).

Looks like I'll have to move the new property tests either into a separate tester registered on java.util.Collection (iterating inside the tester), or possibly move it to the SelectionPropertyTester.

That change has to happen in the parent commit of this one. The real problem is not this change here, but that the parent commit is wrong.  Looks like property testers don't play well with the adapter pattern: the core support for finding applicable testers only looks at the type hierarchy of the selected elements, not at their adaptations.

Back to the drawing board...

-------------------------------------
author: Alayna Houston
date: 2015-11-27 07:07:32.000000000

Patch Set 4:

As for performance: this resource state is computed for the decorators. If it's fast enough for that, it should also be fast enough for a visibility computation on a context menu, shouldn't it?

-------------------------------------
author: Douglas Trujillo
date: 2015-11-27 08:01:39.000000000

Patch Set 4:

> I had tested with a general project, and that worked. But indeed,
 > this doesn't work with a Java project, or with any other
 > contributed items that don't implement IResource (the type that
 > ResourcePropertyTester tester is registered to).
 > 
 > Looks like I'll have to move the new property tests either into a
 > separate tester registered on java.util.Collection (iterating
 > inside the tester), or possibly move it to the SelectionPropertyTester.
 > 
 > That change has to happen in the parent commit of this one. The
 > real problem is not this change here, but that the parent commit is
 > wrong.  Looks like property testers don't play well with the
 > adapter pattern: the core support for finding applicable testers
 > only looks at the type hierarchy of the selected elements, not at
 > their adaptations.
 > 
 > Back to the drawing board...

yeah, Eclipse is a complex beast

-------------------------------------
author: Douglas Trujillo
date: 2015-11-27 08:02:06.000000000

Patch Set 4:

> As for performance: this resource state is computed for the
 > decorators. If it's fast enough for that, it should also be fast
 > enough for a visibility computation on a context menu, shouldn't
 > it?

I think you are right

-------------------------------------
author: Gerrit Johnathan Pham
date: 2015-12-01 06:31:11.000000000

Change has been successfully merged into the git repository by Alayna Houston

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