DESCRIPTION

Added context menu to the Commit Editor's header text

Added a context menu with 'Copy' and 'Select
All' to the header the Commit Editor.

Bug 359038
Change-Id: I418fe61db9e6cd9b52d67cefdf14555b5190e5ae
Signed-off-by: Jaelyn Mcpherson xxx@xxx.xxx

COMMENTS

author: Jaylon Avila
date: 2011-11-23 13:02:18.000000000

Patch Set 1:

It seems that the menu item is enabled when nothing is selected. Is this intentional?

-------------------------------------
author: Sebastian Porter
date: 2011-11-23 13:10:01.000000000

Patch Set 1:

> It seems that the menu item is enabled when nothing is
> selected.
That's not what I see (running on 3.8). Only 'Select All' is enabled.

-------------------------------------
author: Douglas Trujillo
date: 2011-11-24 08:25:03.000000000

Patch Set 1:

It seems "Copy" is disabled when there is no selection only on the first try after opening the commit viewer  (tried using Eclipse 3.7.1). When repeating this experiment while keeping the view open "Copy" is always enabled also when there is no selection.

I find this overly complex. I expected an action to just copy the SHA1. So why do we need two menu actions "Select all" and "Copy" instead of simply "Copy SHA1". When using "Select all" I have to click another time to copy the selection which is annoying. Also usually I only need the SHA1 without prefix "Commit " so I would never use "Select all".

If you also want to allow copying an explicit selection we could have an action "Copy" which would copy the selection (if there is an explicit selection) or the SHA1 if there is no explicit selection. Or, if you find this hard to understand, we could have two actions: 
- "Copy SHA1" to copy the SHA1 without selecting it first 
- and "Copy"  to copy an explicit selection

History View also just has "Copy" which copies the SHA1.

-------------------------------------
author: Sebastian Porter
date: 2011-11-24 08:45:38.000000000

Patch Set 1:

> It seems "Copy" is disabled when there is no selection 
> only on the first try after opening the commit viewer 
> (tried using Eclipse 3.7.1). When repeating this
> experiment while keeping the view open "Copy" is always 
> enabled also when there is no selection.
This is really strange. I can't reproduce this. Do you really test the context menu and not the main menu? Can you please provide exact steps how you make the 'Copy' context menu item enabled while the selection is empty? I'm on Windows 7.

> I find this overly complex. I expected an action to just 
> copy the SHA1. So why do we need two menu actions "Select 
> all" and "Copy" instead of simply "Copy SHA1". When using 
> "Select all" I have to click another time to copy the 
> selection which is annoying. Also usually I only need the 
> SHA1 without prefix "Commit " so I would never use 
> "Select all".
I choose 'Copy' because there is already Edit > Copy which does exactly the same: it copies the selected text.

When there's a text selection 'Copy' should not do smart things behind the scenes.

Having said that, I really like your idea of just adding a 'Copy SHA1' context menu item. I can change the patch accordingly if you agree.

-------------------------------------
author: Douglas Trujillo
date: 2011-11-24 22:31:40.000000000

Patch Set 1:

I am on Mac OS X 10.6.8. I used the new context menu:
- open commit viewer
- right click the commit SHA1 without selection -> "Copy" is disabled
- select some part of the SHA1 and right click again -> "Copy" is enabled, copying to clipboard works
- again right click the commit SHA1 without selection -> "Copy" is enabled
- maybe this is a platform dependent bug in SWT ?

Your proposal to provide 2 actions "Copy" to copy selection and "Copy SHA1" to copy the commit ID not regarding if there is a selection sounds good to me.

-------------------------------------
author: Sebastian Porter
date: 2011-11-25 06:20:05.000000000

Patch Set 1:

I don't have a Mac at hand. Could you put a breakpoint on
  copyItem.setEnabled(styledText.getSelectionCount() > 0)
and check whether this is called and that the selection count is? Such code is also used in the TextViewer. I would be surprised if this isn't working on the Mac.

Regarding the menu: I guess if we offer the two copy menu items, we can leave the 'Select All' away, right?

-------------------------------------
author: Douglas Trujillo
date: 2011-11-25 11:38:23.000000000

Patch Set 1:

- on Mac it seems if there is no selection the expected event isn't fired when right-clicking the text area

- yes, I would remove "Select all" action in favor of "Copy SHA1" or "Copy Id"

-------------------------------------
author: Sebastian Porter
date: 2011-11-29 10:25:41.000000000

Patch Set 1:

> on Mac it seems if there is no selection the expected
> event isn't fired when right-clicking the text area

Yes, that would be expected. The event should only be fired whenever the selection changes.

Before attaching the next patch I have to figure out on a Mac what's going on.

-------------------------------------
author: Sebastian Porter
date: 2011-12-05 11:10:10.000000000

Patch Set 1:

Mathias, we looked into it and are still not able to reproduce the problem using your steps. However, if we remove the focus from the commit SHA1 (e.g. by clicking into the message entry field) and then open the context menu, we can see the problem. It comes from calling setSelection(0) in the focus listener. Can you confirm that your given steps are missing a step that causes the focuseLost event?

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