簡體   English   中英

從文件系統以編程方式打開Eclipse Custom Editor文件

[英]Open Eclipse Custom Editor file programmatically from file system

我正在使用自定義文本編輯器開發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();
    }

謝謝

嘗試使用IDE.openEditor(...)

這個Eclipse wiki有關於此的更多信息:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM