Bug 499155 - Copy & Paste won't work correctly in dialogs if custom CopyHandler is used
Summary: Copy & Paste won't work correctly in dialogs if custom CopyHandler is used
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows All
: P3 critical with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2016-08-04 08:57 EDT by Corneliud Dirmeier CLA
Modified: 2022-11-11 04:20 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Corneliud Dirmeier CLA 2016-08-04 08:57:03 EDT
As already described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=406651, Copy&Paste does not work in any dialog if you have registered a custom CopyHandler. 

Example: you have a copyHandler that is enabled for a specific type of selections (e.g. adaptable to IProject). You select a project (e.g. in package explorer) -> the copy handler is activated. Then you open a dialog and select any text. Try to copy/pase (using ctrl+c / ctrl+v). This will not work because the custom copy handler (of the project) is still active!

There is a minimal example in https://bugs.eclipse.org/bugs/show_bug.cgi?id=406651.

The bug exists at least since eclipse 4.2 and seems to occure only on windows.
Comment 1 Corneliud Dirmeier CLA 2018-01-09 07:47:53 EST
Is anyone responsible for this bug?
Comment 2 Daniel Schwering CLA 2019-10-29 05:34:13 EDT
This bug still persists in current 2019 releases.
Comment 3 Eclipse Genie CLA 2022-01-29 16:39:24 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Daniel Schwering CLA 2022-02-01 05:54:54 EST
In our case it helped to override isHandled in our Handler 

    @Override
    public boolean isHandled() {
        Display display = Display.getCurrent();
        [...]
        return display != null && display.getFocusControl() instanceof Tree;
    }

works till we use a Tree in a dialog...
Comment 5 Erdal Karaca CLA 2022-11-10 01:19:57 EST
It seems HandlerActivations are not in the same order as in E3: in E4, the custom handler will be registered AFTER the default handler such that when a key binding is executed, it will pick up the custom handler.

Code location to analyze: org.eclipse.ui.internal.handlers.LegacyHandlerService.HandlerSelectionFunction
Comment 6 Erdal Karaca CLA 2022-11-10 01:22:11 EST
Registeration of handlers:
org.eclipse.ui.internal.handlers.LegacyHandlerService.readHandlers()

Anyone aware of the order of configuration elements having impact on handler activation?
Comment 7 Erdal Karaca CLA 2022-11-10 04:54:15 EST
alternative hypothesis: the selection service returns a valid selection when a dialog is open but should not return the selection from the workbench window (induced because of hierarchical IEclipseContext)
without a valid selection, the custom copy handler would not be active/handled and key binding would fallback to the default WidgetMethodHandler
Comment 8 Lars Vogel CLA 2022-11-11 03:06:17 EST
Erdal, please recreate issue at GitHub/Eclipse-Platform in the UI repo