Eclipse插件开发:如何在eclipse插件开发中以编程方式在外部编辑器中打开文件

时间:2021-10-05 06:35:56

I am opening a .xlsx file in eclipse .It opens internally in MS excel which again contain my excel plugin.Which do not work properly when eclipse open excel internally.

我在eclipse中打开一个.xlsx文件。它在MS excel内部打开,它再次包含我的excel插件。当eclipse在内部打开excel时,它无法正常工作。

So how can i set ,eclipse always open .xlsx file externally.

那我怎么设置,eclipse总是在外部打开.xlsx文件。

1 个解决方案

#1


You can define an editor for xlsx in your plugin using the org.eclipse.ui.editors extension point:

您可以使用org.eclipse.ui.editors扩展点在插件中为xlsx定义编辑器:

<extension
     point="org.eclipse.ui.editors">
  <editor
        extensions="xlsx" 
        id="myeditor.id"
        icon="icon path"
        launcher="myeditor.Launcher"
        name="XLSX editor">
  </editor>
 </extension>

This is using the launcher attribute to specify that a class to launch an external editor is to be used.

这是使用launcher属性指定要使用启动外部编辑器的类。

The Launcher class would be something like:

Launcher类将是这样的:

public class Launcher implements IEditorLauncher 
{
  public void open(IPath file)
  {
    File file = file.toFile();

    java.awt.Desktop.getDesktop().open(file);
  }
}

#1


You can define an editor for xlsx in your plugin using the org.eclipse.ui.editors extension point:

您可以使用org.eclipse.ui.editors扩展点在插件中为xlsx定义编辑器:

<extension
     point="org.eclipse.ui.editors">
  <editor
        extensions="xlsx" 
        id="myeditor.id"
        icon="icon path"
        launcher="myeditor.Launcher"
        name="XLSX editor">
  </editor>
 </extension>

This is using the launcher attribute to specify that a class to launch an external editor is to be used.

这是使用launcher属性指定要使用启动外部编辑器的类。

The Launcher class would be something like:

Launcher类将是这样的:

public class Launcher implements IEditorLauncher 
{
  public void open(IPath file)
  {
    File file = file.toFile();

    java.awt.Desktop.getDesktop().open(file);
  }
}