문제

I need to get workspace a location using API in Eclipse 4.x platform. I know that I can use

ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();

but I'm wondering if there is another way to do that without static reference to ResourcesPlugin? For example using Dependency Injection..

Thanks in advance Qinto.

도움이 되었습니까?

해결책

From Eclipse Wiki:

@Inject @Named(E4Workbench.INSTANCE_LOCATION) private Location instanceLocation;

This didn't work for me in my LifeCycleManager, though, throwing an exception that the Location object was not available to be injected. I removed the @Named annotation and a valid Location object was injected:

@Inject private Location instanceLocation;

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top