I want to take active parts by using EPartService. Can I use EPartService for this?
Asked
Active
Viewed 37 times
0
-
Sorry, what do you mean by 'take active parts'? – greg-449 Oct 02 '15 at 07:01
-
I want to learn which parts are active. Then I will close these active parts. – eponymous Oct 02 '15 at 07:03
1 Answers
0
If you want to get the active part in something like a command handler you can inject it as a parameter:
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart)
{
... handler code
}
If you want a list of all currently displayed parts you can use the EPartService
. Something like:
@Inject
MApplication app;
@Inject
EPartService partService;
// Find all the `MPart` objects in the current presentation
Collection<MPart> parts = partService.getParts();
// Filter the list to include just the parts that are current being displayed (rendered)
parts = parts.stream().filter(MPart::isToBeRendered).collect(Collectors.toList());
Note: This code requires Java 8

greg-449
- 109,219
- 232
- 102
- 145
-
I want to learn all closable and opened parts in window. I think this "activePart" represent only a activePart. Is the code part provide this? – eponymous Oct 02 '15 at 07:36
-
Well those are not 'active'. I have added code to find all the currently displayed (rendered) parts – greg-449 Oct 02 '15 at 07:48