EMF - 设置eClass的结构特征

时间:2015-08-24 12:30:04

标签: java eclipse emf

我有一个包含多个EStructuralFeatures的eClass。尝试为其中一个功能设置值时,会抛出NullPointer。 这是以下功能:

org.eclipse.emf.ecore.impl.EAttributeImpl@bcabcf (name: active) (ordered: true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: true, unsettable: false, derived: false) (iD: false)

我试图设置一个布尔值

  public void setValue( EStructuralFeature feature, Object value )
  {
    value = validate( feature, value );
    if ( value != null )
    {
      this.eClass.eSet( feature, value );
    }
  }

这个堆栈跟踪是结果:

ENTRY org.eclipse.ui 4 0 2015-08-24 14:06:36.288
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicUnset(BasicEObjectImpl.java:1204)
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicUnset(BasicEObjectImpl.java:1193)
    at org.eclipse.emf.ecore.impl.EClassImpl.eUnset(EClassImpl.java:1098)
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eUnset(BasicEObjectImpl.java:1153)
    at com.example.ppm.repository.wizard.custom.model.MyModel.setValue(MyModel.java:65)
    at com.example.ppm.repository.wizard.custom.ui.pages.MyPage$2.widgetSelected(MyPage.java:82)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at com.example.ppm.repository.wizard.custom.ui.handler.StartWizardHandler.execute(StartWizardHandler.java:35)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
    at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
    at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
    at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
    at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829)
    at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815)
    at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at com.example.ppm.repository.presentation.RepositoryEditorAdvisor$Application.start(RepositoryEditorAdvisor.java:132)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

0 个答案:

没有答案