-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify the 'Close Editor' handler and enabled when evaluation to supp… #2315
Modify the 'Close Editor' handler and enabled when evaluation to supp… #2315
Conversation
54e1a4a
to
b556ea3
Compare
Could anyone pick this up? @jukzi ? @iloveeclipse ? |
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); | ||
IEditorPart part = HandlerUtil.getActiveEditorChecked(event); | ||
window.getActivePage().closeEditor(part, true); | ||
public Object execute(ExecutionEvent event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, we should always try to look in the event to ensure we get the right editor. Other strategies can have flaws and return another editor than the one that triggered the event.
Would it be possible to get the e4 element (MPart) from the event context instead?
If not, I think it would be worth keeping usage of HandlerUtil.getActiveEditorChecked(event)
if it's not null, and if null, then failback to an alternative strategy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback - yes that makes sense, I have updated the PR now such that the event context is used to retrieve the active part. If the active part is an IEditorPart I perform the previous logic, else if it is an E4Wrapper such as when we contribute a PartDescriptor via a model fragment it is dealt with via the EPartService.
1c4a9da
to
d619fe7
Compare
…ort for Compatibility parts and new Parts which represent an Editor and are contributed via eg. PartDescriptors in a Model Fragment. Associated with Issue#2176.
d619fe7
to
86bd7be
Compare
Thanks for the change, this looks much better to me. |
Many thanks Mickael, lets see how the CI jobs go this time. |
Also, just a heads up : I may look into a similar approach in a separate PR for handling the 'Close Active Editors' (plural), if I ever get that far I might tag you in that PR if that's OK. |
Modify the 'Close Editor' handler and 'enabledWhen' evaluation to add support for both compatibility-layer editor parts, and new Parts contributions which represent an Editor and are contributed via eg. a PartDescriptors in a Model Fragment addition.
Associated with Issue#2176 (#2176).