2012-04-05 18 views
-1

エディタビューを作成するためにTextEditorを拡張するクラスがあります。私はplugin.xmlのように、必要なすべての入力をしました。私はエディタ入力null以外の名前を持つ必要がありますEclipseプラグインエディタを開く

:null引数:今私は...

org.eclipse.core.runtime.AssertionFailedExceptionをエディタを開くに次のエラーを取得していますエディタを開くために次のコードを使用しています。

IWorkbenchPage page = 
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); 
page.openEditor(input, xyz.ID); 
+0

エラーメッセージが示すように、 'input'オブジェクトを検査する必要があります。あなたは 'FileEditorInput'などを使っていますか?あなたの入力は実際のデータを含んでいますか? –

答えて

-1

次のコードは、この問題に対する正しい解決方法です。

if (fileToOpen.exists() && fileToOpen.isFile()) { 
    Stirng path = // file path that to be input.; 
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); 
    URI fromString = org.eclipse.core.runtime.URIUtil.fromString("file://" + path); 
    try { 
     IEditorPart openEditor = IDE.openEditor(page, fromString, XYZEditor.ID, true); 
     IEditorInput editorInput = openEditor.getEditorInput(); 
     //editorInput. 
    } catch (PartInitException e) { 
     //Put your exception handler here if you wish to 
    } 
} 
関連する問題