简体   繁体   中英

Eclipse : Open perl file in default editor

How to open a perl script file in text editor ?

As if now i'm using the below code to open files in text editor

IWorkbenchPage page = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));
        try {
            IDE.openEditorOnFileStore(page, fileStore);
        } catch (PartInitException e1) {
            e1.printStackTrace();
        }

Text files are opened properly but perl script files are executed. I think it uses the default file association to open the file. How can I change it so that my perl script be opened in text editor ?

Try something like this. It bypasses the lookup for default editor in getEditorId() (called by openEditorOnFileStore() ) and directly opens an editor by your choice.

String editorId = "some.editor.ID";
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));
page.openEditor(new FileStoreEditorInput(fileStore), editorId);

(wild guess code, but hopefully should work)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM