2009-05-28 7 views
2

のEclipse RCPの質問IEDitorPart(エクリプス)からITextViewerを取得</p> <p>は、私は、ファイルを開く

IDocument doc = ((ITextEditor)editorPart).getDocumentProvider().getDocument(editorPart.getEditorInput()); 

私はのテキストビューアを取得する必要がありますそのドキュメント(LinkedModeUIを作成するため)は、これを行う方法はありますか?

答えて

1

1)複数のエディタで1つのドキュメントを開くことができます。すべてのエディタを繰り返して、ファイルのエディタを探す必要があります。 2)ビューアはエディタにカプセル化されています。唯一の方法は、ゲッターを追加するエディタクラスを拡張することだと私は思う。または、継承者から視聴者がアクセスできない場合は、再定義します。

6

以下は、私の仕事:

IEditorPart editorPart = getSite().getPage().getActiveEditor(); 
if (editorPart != null) { 
    ITextOperationTarget target = 
      (ITextOperationTarget)editorPart.getAdapter(ITextOperationTarget.class); 
    if (target instanceof ITextViewer) { 
     ITextViewer textViewer = (ITextViewer)target; 
     // ... 
    } 
} 
関連する問題