Java:IEventBroker空点异常
我想在按下JButton时在我的RCP项目中发布一个事件。为此,我尝试使用IEventBroker 我遵循了vogella.com上的教程 不幸的是,这会生成一个空点异常Java:IEventBroker空点异常,java,eclipse,events,eclipse-rcp,e4,Java,Eclipse,Events,Eclipse Rcp,E4,我想在按下JButton时在我的RCP项目中发布一个事件。为此,我尝试使用IEventBroker 我遵循了vogella.com上的教程 不幸的是,这会生成一个空点异常 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at chipcoach.tableviewerDMA.GanttFrame.actionPerformed(GanttFrame.java:522) at javax.swing.Abs
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at chipcoach.tableviewerDMA.GanttFrame.actionPerformed(GanttFrame.java:522)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
在本教程的后面部分中,它也没有说明@EventTopic和@UIEventTopic注释的定义位置。Christian的绝对出色的事件代理解决了我在RCP项目中如何使用事件代理的问题
需要添加以下依赖项:
org.eclipse.e4.core.services
org.eclipse.osgi.services
很可能注入无法填充
eventBroker
。您是否使用调试器验证了这一点?您是如何创建此类的?Eclipse只对从应用程序模型创建的对象进行注入。如何验证注入是否工作?请原谅我缺乏知识此类用于绘制Gannt图表:公共类GantFrame扩展ApplicationFrame实现MouseWheelListener、ChangeListener、AxisChangeListener、ActionListener{。然后通过AWT frame composite=new composite(scrolledComposite,SWT.EMBEDDED | SWT.NO_BACKGROUND)添加到视图组合中;frame=SWT_AWT.new_frame(composite);本质上只注入Application.e4xmi中直接提到的类。对于其他任何需要使用ContextInjectionFactory
。因此,如果您使用new
创建类,它不会被注入。请参阅我对
org.eclipse.e4.core.services
org.eclipse.osgi.services