Search code examples
handlerrcpe4

Hide and show Parts in Handler


I'm trying to hide and show a part in the execute Method of my Handler. But I just can't seem to get it to work as I intended. When accesssing the PartService I get an "Application does not have an active window" exception.

Here's my code for hiding the part

@Execute
@Inject
public void execute(final EPartService partService) {
    final MPart part = partService.findPart("mypart");
    partService.hidePart(part);
}                             

Thanks in advance


Solution

  • Don't specify @Inject on your methods you only need @Execute.

    Using @Inject is causing the code to run when the handler is first created before the application window exists.

    So just:

    @Execute
    public void execute(final EPartService partService) {