Skip to content
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

File->'Close Editor' menu doesn't work with e4 editors. #2176

Open
eobrienPilz opened this issue Aug 9, 2024 · 1 comment
Open

File->'Close Editor' menu doesn't work with e4 editors. #2176

eobrienPilz opened this issue Aug 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@eobrienPilz
Copy link
Contributor

Steps to reproduce

To reproduce you will need to define an editor part in an e4 fragment.
It should be marked as closable and given the 'Editor' tag.
Run the code and launch the editor
The Close menu option is available as a right click popup on the editor tab and it works.

image

However the File->Close Editor menu option is disabled.

image

From debuging I can see that the handler code (CloseEditorHandler) doesn't consider e4 editors.
It expects IEditorPart and checks that ISources.ACTIVE_EDITOR_NAME is set on the evaluation context.
E4 editors dont use IEditorPart or set ISources.ACTIVE_EDITOR_NAME.

From a quick prototype it seems to work for all editors (e4 and legacy) if the menu handlers are defined using an e4 fragment.

e.g. This seems to work for both E4 and legacy editors.

public class CloseActiveEditorHandlerE4 {
@CanExecute
boolean canExecute(@nAmed(IServiceConstants.ACTIVE_PART) MPart part) {
boolean isEditor = part.getTags().stream().filter(t -> t.equals(Workbench.EDITOR_TAG)).count() > 0;
return isEditor && part.isCloseable();
}

@Execute
void execute(EPartService partService, @Named(IServiceConstants.ACTIVE_PART) MPart part) {
	partService.hidePart(part, false);
}

}

The same issue exists with File->'Close All Editors'.

@feilimb
Copy link

feilimb commented Sep 23, 2024

Pull request created to address this: #2315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants