I am trying to customize right mouse click in my RCP E4 browser, I created the popup menu in application.e4xmi, and here is my code for triggering the right click event.
for creating the part inside a part stack:
public void showBrowser(Composite parent, EModelService service,
MApplication application, EPartService partservice) {
MPartStack mpartstack = (MPartStack) service.find(
"com.example.e4.rcp.wizard.partstack.confps", application);
MPart navigationpart = partservice
.createPart("com.example.e4.rcp.wizard.partdescriptor.navigate_pd");
navigationpart.setLabel("Visual Navigator");
// for adding the menucontext
//
mpartstack.getChildren().add(navigationpart);
MPartStack metadata_ps = (MPartStack) service.find(
"com.example.e4.rcp.wizard.partstack.metadataPS", application);
metadata_ps.setVisible(true);
MPart metadatapart = partservice
.createPart("com.example.e4.rcp.wizard.partdescriptor.metadatadesc");
metadatapart.setLabel("Metadata");
metadata_ps.getChildren().add(metadatapart);
}
Inside the part descriptor: " com.example.e4.rcp.wizard.partdescriptor.navigate_pd "
@Inject
IEclipseContext context;
EMenuService menuservice;
@PostConstruct
public void createControll(Composite parent, EModelService service,
MApplication application) {
// some other stuffs
menuservice.registerContextMenu(browser, "com.example.e4.rcp.wizard.popupmenu");
}
its showing NullPointerException at runtime, i tried to inject EMenuService in postconstruct method also, but in that case as expected the result is worse (you know why). I am pretty new in RCP E4, so advanced sorry if I am making any basic mistake.
You must use @Inject on each field that you want injected:
Your existing code is only asking for
IEclipseContext
to be injected.