简体   繁体   English

如何在Eclipse e4中设置UI部分的输入?

[英]How to set the input for the UI part in eclipse e4?

I am using eclipse e4 application. 我正在使用eclipse e4应用程序。 I am using the eventBroker to pass values from one part to another part. 我正在使用eventBroker将值从一个部分传递到另一部分。 If many parts(Kind of tabs) are open , how to pass values to the part(tab) that is currently selected. 如果打开了许多零件(选项卡种类),如何将值传递给当前选定的零件(选项卡)。 ? I am using the @UIEventTopic to get the values for the part. 我正在使用@UIEventTopic获取该部件的值。 But the problem is ,the values are replicated to all the tabs. 但是问题是,值被复制到所有选项卡。 In other words , I am trying to show different JFreechart in different tabs, but the charts are replicated to the previous tabs. 换句话说,我试图在不同的选项卡中显示不同的JFreechart,但是图表已复制到先前的选项卡。

Can anyone please suggest me some ideas? 谁能建议我一些想法?

Thanks in advance 提前致谢

The event broker always broadcasts to anything that is dealing with the event, you can't use it to send to one specific thing. 事件代理总是广播到处理该事件的任何事物,您不能使用它来发送特定事件。

If you are in a Handler you can get the current part in the @Execute method and set a value directly in your class - something like: 如果您在Handler中,则可以在@Execute方法中获取当前部分,并直接在您的类中设置一个值-类似于:

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart)
{
  Object part = activePart.getObject();

  if (part instanceof MyClass)
   {
     ((MyClass)part).setValue(xxxx);
   }
}

Update: 更新:

If you are in another part use the EPartService to get the active part: 如果您在另一个零件中,请使用EPartService获取活动零件:

@Inject
EPartService partService;

...

MPart activePart = partService.getActivePart();

Object part = activePart.getObject();

if (part instanceof MyClass)
 {
    ((MyClass)part).setValue(xxxx);
 }

You can also use EPartService.findPart("part id") to find a part with a given id. 您也可以使用EPartService.findPart("part id")查找具有给定id的零件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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