Bug 286219 - [Edit][Actions] Can't do any team action from compare editors
Summary: [Edit][Actions] Can't do any team action from compare editors
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Team (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Pawel Pogorzelski CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2009-08-11 06:54 EDT by Dani Megert CLA
Modified: 2010-04-09 09:16 EDT (History)
3 users (show)

See Also:


Attachments
Fix v01 (4.33 KB, patch)
2009-12-21 08:39 EST, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (39.85 KB, application/octet-stream)
2009-12-21 08:40 EST, Tomasz Zarna CLA
no flags Details
Patch_v02 (4.63 KB, patch)
2010-04-09 09:04 EDT, Pawel Pogorzelski CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2009-08-11 06:54:01 EDT
R3.5.

The compare editor does not offer team actions (via context menu) which makes my life harder than it should be: each time a change is reviewed I have to manually search (due to bug 219570) that file in the Synchronize view in order to commit or update that file.

Simplest fix would be to offer the Team menu like it's available in the normal editors.
Comment 1 Tomasz Zarna CLA 2009-12-14 07:55:28 EST
First some general facts:
- all context menu actions in the compare editor are added programmatically (see org.eclipse.compare.internal.MergeSourceViewer.menuAboutToShow(IMenuManager) in o.e.compare)
- Team menu is defined in o.e.team.ui
- a few Team actions are contributed in o.e.team.ui/plugin.xml
- majority of actions we're interested in are defined using org.eclipse.ui.popupMenus and objectContributions in o.e.team.cvs.ui/plugin.xml

I wonder what are my options...
a) can I programmatically add objectContributions to the editor's context menu?
b) can I programmatically add Team actions to the editor using IMenuService?
c) would fixing bug 173457 or bug 175693 help here?

Paul could you please shed light on this? I'm not sure where should I start.
Comment 2 Paul Webster CLA 2009-12-16 08:46:18 EST
(In reply to comment #1)
> I wonder what are my options...
> a) can I programmatically add objectContributions to the editor's context menu?
> b) can I programmatically add Team actions to the editor using IMenuService?
> c) would fixing bug 173457 or bug 175693 help here?

A little background.  We get the behaviour we want for for this because most editors include their editor input when they call registerContextMenu(menu, provider, true);  Every time a context menu shows, the FileEditorInput (the most common) adapts to ResourceMapping (or is transformed) in the bowels of the ObjectActionContributionManager, and you get your Team menu and actions.

Right now the compare editor returns a subclass of CompareEditorInput.  I think that makes it hard to provide a general solution.

Converting the popupMenus stuff to proper commands would give you more flexibility to try and solve this but then you are dealing with the variables available (activePart, activeMenuIds, activeEditor, activeEditorInput) and property testers.  It's not obvious to me right now how you could define a team menu expression that would be valid for the compare editor (since team doesn't need to know about compare, right?).

What if the CVSCompareEditorInput adapted to an IFile (for the case where there was one local file) or ResourceMapping (I'm a little less sure about this one) and your CompareEditor said it *would* include its input?  it's not a general solution (what if the CompareEditorInput was to IFiles?) but would it allow the Team menu to show up in Dani's case?

PW
Comment 3 Tomasz Zarna CLA 2009-12-17 11:46:56 EST
Thanks for the comment Paul, at least I know now where to begin. I'll start with adopting CompareEditorInput to something useful as you suggested and see what happens.
Comment 4 Tomasz Zarna CLA 2009-12-21 08:39:40 EST
Created attachment 154873 [details]
Fix v01

Adapting to IContributorResourceAdapter.class and changing the flag[1] to consider compare editor input when adding object contributions looks promising. I'll install it into my Eclipse to play with it and see is it worth anything.

[1] org.eclipse.ui.IEditorSite.registerContextMenu(MenuManager, ISelectionProvider, boolean)
Comment 5 Tomasz Zarna CLA 2009-12-21 08:40:01 EST
Created attachment 154874 [details]
mylyn/context/zip
Comment 6 Tomasz Zarna CLA 2010-01-11 05:34:03 EST
Found one case (so far) which needs to be fixed before releasing the patch:
1. Synchronize a project, having at least one outgoing change.
2. Do "Open" and "Open in Compare Editor" for that file.
3. While in Compare Editor, right click in the left pane and do "Replace With > Latest from HEAD".
4. A warning about uncommitted changes to be overwritten shows up. This is expected. Select "OK".
5. Compare editor closes since there are no more changes to display.
=> "File not accessible" dialog pops out when focus gets back to the regular editor for the file.
Workaround: Select "Close".

After quick research, this seems to happen for all file types except plugin.xml...
Comment 7 Tomasz Zarna CLA 2010-01-21 07:06:32 EST
It looks that we're pretty close to fixing it but I won't make it in 3.6M5. I'm too busy with blockers of bug 236169. Moving to 3.6M6.
Comment 8 Tomasz Zarna CLA 2010-02-19 06:00:54 EST
Pawel, could please investigate why the dialog from comment 6 shows up. The patch is good imo, but I'm afraid I missed something and as we all know the Devil is in the details ;)
Comment 9 Pawel Pogorzelski CLA 2010-04-09 08:52:56 EDT
I can't reproduce the problem from comment 6. In step 5 I get a dialog saying "The file X has been changed on the files system. Do you want to replace the editor contents with these changes?" This dialog can be reproduced without a patch, one has to simply invoke Replace With > Latest from the other editor and switch to compare editor before the action ends (I did having both editors visible).
Comment 10 Pawel Pogorzelski CLA 2010-04-09 09:04:47 EDT
Created attachment 164367 [details]
Patch_v02

Patch from comment 4 adjusted to HEAD.
Comment 11 Pawel Pogorzelski CLA 2010-04-09 09:16:40 EDT
Patch_v02 in HEAD. Tomasz, your concerns from comment 6 has been forked to bug 308637 as it's not something introduced by the patch. Marking as FIXED.