2017-05-05 6 views
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を使用するにはどうすればよいですか?

答えて

2

これは決して実装されていないようです。代わりに、org.eclipse.e4.core.services.statusreporter.StatusReporterクラスを注入し、エラーの記録や表示に使用できます。

@Inject 
StatusReporter statusReporter; 

statusReporter.report(status, StatusReporter.SHOW | StatusReporter.LOG); 
+0

私は同様の問題が発生しました。それにもかかわらず、あなたの助言に従えば、私はコンパイラの警告を受け取ります: "落胆したアクセス:タイプ 'StatusReporter'はAPIではありません。私はこれについて心配すべきであり、他の選択肢がありますか? – Pyves

+1

@Pyves通常は問題ですが、e4 APIの場合は問題ありません。多くのe4 APIはまだ完全にはファイナライズされていないので、この警告を出してください。 –

関連する問題