[英]Java: Eclipse Plugin create issue
以下是我嘗試從舊代碼重用的插件代碼。 該插件將無法正常運行。 我已經復制了代碼的插件部分。
請幫助我解決問題。
嘗試在此處實現的想法是在用戶嘗試調用插件時獲取<項目文件夾位置> 。 並將其作為參數傳遞給獨立代碼。
Activator.java
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "PluginName";
// The shared instance
private static Activator plugin;
public Activator() {
plugin = this;
}
public void start(BundleContext context) throws Exception {
System.out.println("Loading the PluginName");
super.start(context);
}
public void stop(BundleContext context) throws Exception {
plugin = null;
System.out.println("Exiting the PluginName");
super.stop(context);
}
public static Activator getDefault() {
return plugin;
}
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
FindUnwantedJarAction.java
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
public class FindUnwantedJarAction implements IObjectActionDelegate {
private IStructuredSelection selection;
public void setActivePart(IAction arg0, IWorkbenchPart arg1) {
// TODO Auto-generated method stub
}
public void run(IAction arg0) {
IProject project = (IProject) selection.getFirstElement();
String projName = project.getName();
String projectLocation = project.getLocation().toString();
//call another class with this parameter
}
public void selectionChanged(IAction arg0, ISelection paramSelection) {
this.selection = (IStructuredSelection) paramSelection;
}
}
Plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IProject"
adaptable="true"
id="core.UnwantedJar">
<menu
label="Find Unwanted Jars"
path="additions"
id="FindUnJar.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="Find!!!"
class="core.marksman.action.FindUnwantedJarAction"
menubarPath="FindUnJar.menu1/group1"
enablesFor="1"
id="CVSLocal.newAction">
</action>
</objectContribution>
</extension>
</plugin>
您還應該對MANIFEST.MF進行全面診斷,但是最可能的原因是,您使用與開發Eclipse實例所運行的JDK不同的JDK運行RAD(並且比捆綁目標環境更早)。在您的MANIFEST.MF中設置為JavaSE-1.6)。
這可能是您可以在“調試”模式下成功運行RAD的原因,但不能作為獨立的應用程序運行。 請查看您的RAD實例的日志,並查看“ java.version =“值。 應該是1.6 ...或更高版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.