3

カスタム テキスト エディタを使用して Eclipse プラグインを開発しています。

このカスタム エディター内でプログラムによってファイルを開く必要があります。Eclipse の DefaultTextEditor を使用して開くと、ファイルが開き、テキストなどを編集できます。

しかし、エディターを使用してファイルを開こうとすると、エディターが空白になり、編集できなくなります。使用しているソースはこちら。

    File file = new File(filename);
    IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(file.toURI());
    FileStoreEditorInput editorInput = new FileStoreEditorInput(fileOnLocalDisk);

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = window.getActivePage();

    try {
          // this works fine    
          page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor");         

          // this is where the issue is
          page.openEditor(editorInput, "MyEditor.editor");          

    } catch (PartInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

ありがとう

4

1 に答える 1

4

使ってみてくださいIDE.openEditor(...)

この Eclipse wiki には、これに関する詳細情報があります。

http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_programmatically%3F

于 2013-08-08T21:18:47.743 に答える