Bug 461579 - "Pin Editor" button initially not enabled under specific conditions
Summary: "Pin Editor" button initially not enabled under specific conditions
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-06 07:25 EST by Andrey Loskutov CLA
Modified: 2021-06-09 05:45 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2015-03-06 07:25:32 EST
Follow up after https://git.eclipse.org/r/40449 / bug 445538

"Pin Editor" button initially not enabled after "Apply" used in the preferences and CPD was opened before.

AS IS:

1) Start with new workspace
2) Create new general project, new file C1, open editor on C1. 
3) Open Customize Perspective dialog (CPD)
4) Do not change anything, just click OK on CPD. 
5) Go to Window->Preferences->General->Editors
6) Enable "Close editors automatically".
7) Important! Now use "Apply" button. "Pin Editor" button appears on the main toolbar behind the dialog.
8) Now use "OK" to close the dialog and check the "Pin Editor" button state => it is *disabled* (unexpected), though focus is on the editor.
9) Switch focus to any view and then back to the C1 editor => now "Pin Editor" button is enabled (expected).

TO BE:

In the step 8 the "Pin Editor" button must be enabled and step 9 should not be needed.


Unclear is: why both step 3 and step 7 are required to reproduce.

On debugging we saw that in HandlerServiceHandler.isEnabled(), HandlerServiceImpl.lookUpHandler(..) returns null for "executionContext" - PartImpl(org.eclipse.e4.ui.compatibility.editor)Context and "commandId" - org.eclipse.ui.window.pinEditor. As a result, the tool item is set as disabled.

How CPD is involved still unclear (I even removed entire dispose() code in CPD and CustomizeActionBars without success), but at least one the workaround is available.

Adding this snippet to the end of the EditorsPreferencePage.performOK() method (where the pin button preference is managed) fixes this issue.

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); commandService.refreshElements(IWorkbenchCommandConstants.WINDOW_PIN_EDITOR, null);
}
});

I will provide patch soon.
Comment 1 Eclipse Genie CLA 2021-06-09 05:45:34 EDT
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.