1
でたstatusHandlerを使用して、各クラスには、このような状況を扱うことができる:E3でE4
IStatus status = new Status(IStatus.WARNING, TestPlugin.PLUGIN_ID, "Hello World");
StatusManager.getManager().handle(status, StatusManager.SHOW);
今では少しトリッキーと思われます。これは、注射をサポートするクラスのために働く必要がThis documentation推測:
@Inject Provider<StatusHandler> statusHandler;
@Inject Provider<StatusReportingService> statusReportingService;
public void foo() {
try {
// some operation
} catch (SomeException ex) {
statusHandler.get().handle(ex, IStatus.ERROR, "Error Message", statusReportingService.get());
}
}
しかし、それはしていません。例には輸入が(?そしてなぜそこだろう単純なJavaで唯一の4 Provider
のクラスがあります)がなかったので、私は彼らがjavax.inject.Provider
を意味し、org.eclipse.jface.util.StatusHandler
を注入しようとした推測:
org.eclipse.e4.core.di.InjectionException: Unable to instantiate public org.eclipse.jface.util.StatusHandler()
at org.eclipse.e4.core.internal.di.ConstructorRequestor.execute(ConstructorRequestor.java:44)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:373)
at org.eclipse.e4.core.internal.di.InjectorImpl.makeFromProvider(InjectorImpl.java:325)
at org.eclipse.e4.core.internal.di.ProviderImpl.get(ProviderImpl.java:34)
at org.acme.project.Main.createStatusHandler(StatusUtil.java:26)
ので、多分それは右StatusHandler
ではありません? E4でStatusHandler
を使用するにはどうすればよいですか?
私は同様の問題が発生しました。それにもかかわらず、あなたの助言に従えば、私はコンパイラの警告を受け取ります: "落胆したアクセス:タイプ 'StatusReporter'はAPIではありません。私はこれについて心配すべきであり、他の選択肢がありますか? – Pyves
@Pyves通常は問題ですが、e4 APIの場合は問題ありません。多くのe4 APIはまだ完全にはファイナライズされていないので、この警告を出してください。 –