Java 从Eclipse4中的处理程序更新视图

Java 从Eclipse4中的处理程序更新视图,java,eclipse,eclipse-rcp,e4,Java,Eclipse,Eclipse Rcp,E4,我是Eclipse4应用程序的新手。 我有一个菜单项open handler,当我单击它时,会出现文件对话框,我可以选择文件,我应该在视图零件上显示所选文件 有人可以帮助我如何从处理程序更新视图吗?您可以使用EPartService在处理程序中查找您的角色: @Execute void execute(EPartService partService) { MPart part = partService.findPart("part id "); // TODO use FileDi

我是Eclipse4应用程序的新手。 我有一个菜单项open handler,当我单击它时,会出现文件对话框,我可以选择文件,我应该在视图零件上显示所选文件


有人可以帮助我如何从处理程序更新视图吗?

您可以使用
EPartService
在处理程序中查找您的角色:

@Execute
void execute(EPartService partService)
{
  MPart part = partService.findPart("part id ");

  // TODO use FileDialog

  YourClass yourClass = (YourClass)part.getObject();

  // TODO call a method in YourClass to set the table input
}

其中
YourClass
是您为零件定义的类。然后,您只需要向
YourClass
添加一个方法,您可以调用该方法来设置表输入。“part id”是您在应用程序模型中为MPart指定的id。

Pure e4没有视图。这是您制作的看起来像视图的
MPart
,还是您实际使用的是3.x
ViewPart
?我正在使用MPart。在Mpart中,我使用Tableviewer显示在文件对话框中选择的文件名。