Eclipse 插件开发问题: Could not create action delegate for id: org.xvision.junitx.runtest.action

时间:2021-10-16 23:31:16
我尝试为Eclipse的View中右键菜单增加一个新的项目.

我的插件项目叫 org.xvision.junitx

插件的plug.xml 为
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin
   id="org.xvision.junitx"
   name="Junitx Plug-in"
   version="1.0.0"
   provider-name="xvision"
   class="org.xvision.junitx.runtest.JUnitXPlugin">

   <runtime>
      <library name="org.xvision.junitx.jar">
         <export name="*"/>
      </library>
   </runtime>
   <requires>
      <import plugin="org.eclipse.ui"/>
      <import plugin="org.eclipse.core.resources"/>
      <import plugin="org.eclipse.jdt.core"/>
      <import plugin="org.eclipse.core.runtime"/>
   </requires>
   
   <extension point="org.eclipse.ui.popupMenus">
      <objectContribution
         id="org.xvision.junitx.runtest"
         objectClass="org.eclipse.jdt.core.IType">
 <action
    id="org.xvision.junitx.runtest.action"
    class="org.xvision.junitx.runtest.RunTestAction"
    label="Run Test For Me"
    style="radio"
    enablesFor="1">
    </action>
      </objectContribution>
   </extension>
</plugin>

RunTestAction 类代码如下:

package org.xvision.junitx.runtest;

import org.eclipse.jdt.core.IType;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.*;
import org.eclipse.ui.*;

public class RunTestAction
implements
IObjectActionDelegate
{
ISelection selection;

public void setActivePart(IAction action, IWorkbenchPart targetPart)
{
}
public void selectionChanged(IAction action, ISelection selection)
{
this.selection = selection;
}
public void run(IAction action)
{
if (!(selection instanceof IStructuredSelection)) return;
IStructuredSelection structured = (IStructuredSelection) selection;
IType type = (IType) structured.getFirstElement();
// TODO need a run(type) method
}
}


插件类代码如下:
package org.xvision.junitx.runtest;

import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.IType;

public class JUnitXPlugin extends Plugin
{
private static JUnitXPlugin instance;

public JUnitXPlugin(IPluginDescriptor descriptor)
{
super(descriptor);
instance = this;
}
public static JUnitXPlugin getPlugin()
{
return instance;
}
public void run(IType type)
{
//TODO run the tests in the given type
}

}

运行后,在某一个Class上右击键菜单出现的"Run Test For Me"项目.控制台报错误:
Could not create action delegate for id: org.xvision.junitx.runtest.action
Reason:
Plug-in org.xvision.junitx was unable to load class org.xvision.junitx.runtest.RunTestAction.

我就傻了,看了半天文档也搞不定,特地问问各位大侠.高分求解,跪求ing.....

1 个解决方案

#1


是要做report么?

#1


是要做report么?