public class ActionAddLucene implements IObjectActionDelegate
{
private static final String FILESEPARATOR =
System
private static final String LUCENESRCJAR =
private static final String LUCENEJAR =
private static final String LIB =
private static final String RESOUCELIB =
private IStructuredSelection structSelection;
public ActionAddLucene()
{
super();
}
public void setActivePart(IAction action
{
}
public void run(IAction action)
{
Object selectObj = structSelection
if (selectObj instanceof IProject)
{
IProject project = (IProject) selectObj;
IJavaProject javaProject = JavaCore
IClasspathEntry[] oldPaths = javaProject
IClasspathEntry luceneLibEntry =
JavaCore
LUCENESRCJAR)
false);
if(classPathExists(oldPaths
{
return;
}
URL luceneLib = Activator
RESOUCELIB + FILESEPARATOR + LUCENEJAR);
URL luceneSrc = Activator
RESOUCELIB + FILESEPARATOR + LUCENESRCJAR);
IClasspathEntry[] newPaths =
new IClasspathEntry[oldPaths
System
IFolder libFolder = project
if (!libFolder
{
try
{
libFolder
} catch (CoreException e)
{
handleException(e);
}
}
copyURLToFile(luceneLib
LIB + FILESEPARATOR + LUCENEJAR);
copyURLToFile(luceneSrc
LIB + FILESEPARATOR + LUCENESRCJAR);
right
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28988.html